class StridedInterval(BackendObject): (source)
Known subclasses: claripy.vsa.discrete_strided_interval_set.DiscreteStridedIntervalSet
A Strided Interval is represented in the following form:: <bits> stride[lower_bound, upper_bound] For more details, please refer to relevant papers like TIE and WYSINWYE. This implementation is signedness-agostic, please refer to [1] *Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code* by Jorge A. Navas, etc. for more details. Note that this implementation only takes hint from [1]. Such a work has been improved to be more precise (and still sound) when dealing with strided intervals. DO NOT expect to see a 1-to-1 reproduction of [1]. Thanks all corresponding authors for their outstanding works.
Static Method | diop |
It finds the fist natural solution of the diophantine equation a*x + b*y = c. Some lines of this code are taken from the project sympy. |
Static Method | empty |
Undocumented |
Static Method | extended |
It calculates the GCD of a and b, and two values x and y such that: a*x + b*y = GCD(a,b). This code has been taken from the project sympy. |
Static Method | gcd |
Get the greatest common divisor. |
Static Method | highbit |
Undocumented |
Static Method | igcd |
:param a: First integer :param b: Second integer :return: the integer GCD between a and b |
Static Method | lcm |
Get the least common multiple. |
Static Method | least |
Pseudo least upper bound. Join the given set of intervals into a big interval. The resulting strided interval is the one which in all the possible joins of the presented SI, presented the least number of values. |
Static Method | lower |
:return: |
Static Method | max |
Undocumented |
Static Method | min |
Undocumented |
Static Method | min |
Undocumented |
Static Method | pseudo |
It two intervals in a way that the resulting SI is the one that has the least SI cardinality (i.e., which represents the least number of elements) possible if the smart_join flag is enabled, otherwise it just joins the SI according the order they are passed to the function. |
Static Method | sign |
Undocumented |
Static Method | signed |
Undocumented |
Static Method | signed |
Undocumented |
Static Method | top |
Get a TOP StridedInterval. |
Static Method | upper |
:return: |
Method | __add__ |
Undocumented |
Method | __and__ |
Undocumented |
Method | __eq__ |
Undocumented |
Method | __floordiv__ |
Unsigned division |
Method | __ge__ |
Unsigned greater than or equal to |
Method | __gt__ |
Unsigned greater than |
Method | __hash__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __invert__ |
Undocumented |
Method | __le__ |
Unsigned less than or equal to |
Method | __len__ |
Get the length in bits of this variable. :return: |
Method | __lshift__ |
Undocumented |
Method | __lt__ |
Unsigned less than |
Method | __mod__ |
Undocumented |
Method | __mul__ |
Undocumented |
Method | __ne__ |
Undocumented |
Method | __neg__ |
Undocumented |
Method | __or__ |
Undocumented |
Method | __radd__ |
Undocumented |
Method | __rand__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __rshift__ |
Arithmetic shift right. |
Method | __rsub__ |
Undocumented |
Method | __rxor__ |
Undocumented |
Method | __sub__ |
Undocumented |
Method | __truediv__ |
Undocumented |
Method | __xor__ |
Undocumented |
Method | add |
Binary operation: add |
Method | agnostic |
Unary operation: SignExtend |
Method | bitwise |
Binary operation: logical and |
Method | bitwise |
Unary operation: bitwise not |
Method | bitwise |
Binary operation: logical or |
Method | bitwise |
Operation xor |
Method | cast |
Undocumented |
Method | concat |
Undocumented |
Method | copy |
Undocumented |
Method | eq |
Equal |
Method | eval |
Evaluate this StridedInterval to obtain a list of concrete integers. |
Method | extract |
Undocumented |
Method | identical |
Used to make exact comparisons between two StridedIntervals. Usually it is only used in test cases. |
Method | intersection |
Undocumented |
Method | lower |
Undocumented |
Method | lshift |
Undocumented |
Method |
|
Logical shift right. :param StridedInterval shift_amount: The amount of shifting :return: The shifted StridedInterval object :rtype: StridedInterval |
Method | mul |
Binary operation: multiplication |
Method | nameless |
Undocumented |
Method | neg |
Unary operation: neg |
Method | normalize |
Undocumented |
Method | reverse |
This is a delayed reversing function. All it really does is to invert the _reversed property of this StridedInterval object. |
Method | rshift |
Arithmetic shift right. |
Method | rshift |
Logical shift right. |
Method | sdiv |
Binary operation: signed division |
Method | SGE |
Signed greater than or equal to. |
Method | SGT |
Signed greater than. |
Method | sign |
Unary operation: SignExtend |
Method | SLE |
Signed less than or equal to. |
Method | SLT |
Signed less than |
Method | solution |
Checks whether an integer is solution of the current strided Interval :param b: integer to check :return: True if b belongs to the current Strided Interval, False otherwhise |
Method | stride |
Undocumented |
Method | sub |
Binary operation: sub |
Method | udiv |
Binary operation: unsigned division |
Method | UGE |
Unsigned greater than or equal to. |
Method | UGT |
Signed greater than. |
Method | ULE |
Unsigned less than or equal to. |
Method | ULT |
Unsigned less than. |
Method | union |
The union operation. It might return a DiscreteStridedIntervalSet to allow for better precision in analysis. |
Method | upper |
Undocumented |
Method | widen |
Undocumented |
Method | zero |
Unary operation: ZeroExtend |
Instance Variable | uninitialized |
Undocumented |
Property | bits |
Undocumented |
Property | cardinality |
Undocumented |
Property | complement |
Return the complement of the interval Refer section 3.1 augmented for managing strides |
Property | is |
Whether this StridedInterval is a BOTTOM, in other words, describes an empty set of integers. |
Property | is |
The same as is_bottom :return: True/False |
Property | is |
If this is an integer, i.e. self.lower_bound == self.upper_bound. |
Property | is |
Undocumented |
Property | is |
If this is a TOP value. |
Property | lower |
Undocumented |
Property | max |
Treat this StridedInterval as a set of unsigned numbers, and return the greatest one |
Property | min |
Treat this StridedInterval as a set of unsigned numbers, and return the smallest one |
Property | n |
Undocumented |
Property | name |
Undocumented |
Property | reversed |
Undocumented |
Property | size |
Undocumented |
Property | stride |
Undocumented |
Property | unique |
Undocumented |
Property | upper |
Undocumented |
Static Method | _bigger |
Return interval with bigger cardinality Refer Section 3.1 |
Static Method | _gap |
Refer section 3.1; gap function. |
Static Method | _get |
Get the MSB (most significant bit). |
Static Method | _is |
Checks if the most significant bit is one (i.e. is the integer negative under signed arithmetic). |
Static Method | _is |
Checks if the most significant bit is zero (i.e. is the integer positive under signed arithmetic). |
Static Method | _lex |
Lexicographical LT comparison |
Static Method | _lex |
Lexicographical LTE comparison |
Static Method | _minimal |
Calculates the minimal integer that appears in both StridedIntervals. As a wrapper method of _minimal_common_integer_splitted(), this method takes arbitrary StridedIntervals. For more information, please refer to the comment of _minimal_common_integer_splitted(). |
Static Method | _minimal |
Calculates the minimal integer that appears in both StridedIntervals. It's equivalent to finding an integral solution for equation `ax + b = cy + d` that makes `ax + b` minimal si_0.stride, si_1.stride being a and c, and si_0... |
Static Method | _modular |
Undocumented |
Static Method | _modular |
Undocumented |
Static Method | _modular |
Undocumented |
Static Method | _ntz |
Get the number of consecutive zeros :param x: :return: |
Static Method | _to |
Undocumented |
Static Method | _unsigned |
Convert an unsigned integer to a signed integer. |
Static Method | _wrapped |
Return the cardinality for a set of number (| x, y |) on the wrapped-interval domain. |
Static Method | _wrapped |
Determines if an overflow happens during the addition of `a` and `b`. |
Static Method | _wrapped |
Determines if an overflow happens during the subtraction of `a` and `b`. |
Static Method | _wrapped |
Perform wrapped unsigned division on two StridedIntervals. |
Static Method | _wrapped |
Perform wrapped signed multiplication on two StridedIntervals. |
Static Method | _wrapped |
Perform wrapped unsigned division on two StridedIntervals. |
Static Method | _wrapped |
Perform wrapped unsigned multiplication on two StridedIntervals. |
Method | _involuted |
This method reverses the StridedInterval object for real. Do expect loss of precision for most cases! |
Method | _is |
Perform a wrapped LTE comparison only considering the SI bounds |
Method | _min |
Undocumented |
Method | _multi |
Undocumented |
Method | _normalize |
Undocumented |
Method | _nsplit |
Split `self` at the north pole, which is the same as in signed arithmetic. |
Method | _pre |
Undocumented |
Method | _psplit |
Split `self` at both north and south poles. |
Method | _reverse |
This method reverses the StridedInterval object for real. Do expect loss of precision for most cases! |
Method | _rshift |
Arithmetic shift right with a concrete shift amount |
Method | _rshift |
Logical shift right with a concrete shift amount |
Method | _signed |
Get lower bound and upper bound for `self` in signed arithmetic. |
Method | _ssplit |
Split `self` at the south pole, which is the same as in unsigned arithmetic. When returning two StridedIntervals (which means a splitting occurred), it is guaranteed that the first StridedInterval is on the right side of the south pole. |
Method | _surrounds |
Undocumented |
Method | _union |
Undocumented |
Method | _unrev |
Undocumented |
Method | _unrev |
Undocumented |
Method | _unrev |
Logical shift right. |
Method | _unsigned |
Get lower bound and upper bound for `self` in unsigned arithmetic. |
Instance Variable | _bits |
Undocumented |
Instance Variable | _is |
Undocumented |
Instance Variable | _lower |
Undocumented |
Instance Variable | _name |
Undocumented |
Instance Variable | _reversed |
Undocumented |
Instance Variable | _stride |
Undocumented |
Instance Variable | _upper |
Undocumented |
Inherited from BackendObject
:
Method | to |
Claripy calls this to retrieve something that it can directly reason about. |
Class Variable | __slots__ |
Undocumented |
It finds the fist natural solution of the diophantine equation a*x + b*y = c. Some lines of this code are taken from the project sympy. :param c: constant :param a: quotient of x :param b: quotient of y :return: the first natural solution of the diophatine equation
It calculates the GCD of a and b, and two values x and y such that: a*x + b*y = GCD(a,b). This code has been taken from the project sympy. :param a: first integer :param b: second integer :return: x,y and the GCD of a and b
Get the greatest common divisor. :param a: The first operand (integer) :param b: The second operand (integer) :return: Their GCD
Get the least common multiple. :param a: The first operand (integer) :param b: The second operand (integer) :return: Their LCM
Pseudo least upper bound. Join the given set of intervals into a big interval. The resulting strided interval is the one which in all the possible joins of the presented SI, presented the least number of values. The number of joins to compute is linear with the number of intervals to join. Draft of proof: Considering three generic SI (a,b, and c) ordered from their lower bounds, such that a.lower_bund <= b.lower_bound <= c.lower_bound, where <= is the lexicographic less or equal. The only joins which have sense to compute are: * a U b U c * b U c U a * c U a U b All the other combinations fall in either one of these cases. For example: b U a U c does not make make sense to be calculated. In fact, if one draws this union, the result is exactly either (b U c U a) or (a U b U c) or (c U a U b). :param intervals_to_join: Intervals to join :return: Interval that contains all intervals
It two intervals in a way that the resulting SI is the one that has the least SI cardinality (i.e., which represents the least number of elements) possible if the smart_join flag is enabled, otherwise it just joins the SI according the order they are passed to the function. The pseudo-join operation is not associative in wrapping intervals (please refer to section 3.1 paper 'Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code'), Therefore the join of three WI may give us different results according on the order we join them. All of the results will be sound, though. Please use the function least_upper_bound as a stub. :param s: The first SI :param b: The other SI. :param smart_join: Enable the smart join behavior. If this flag is set, this function joins the two SI in a way that the resulting Si has least number of elements (more precise). If it is unset, this function will join the two SI according on the order they are passed to the function. :return: A new StridedInterval
Unsigned greater than or equal to :param other: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Unsigned greater than :param other: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Undocumented
Unsigned less than or equal to :param other: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Unsigned less than :param other: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Arithmetic shift right. :param StridedInterval shift_amount: Number of bits to shift right. :return: The shifted StridedInterval object :rtype: StridedInterval
Unary operation: SignExtend :param new_length: New length after sign-extension :return: A new StridedInterval
Evaluate this StridedInterval to obtain a list of concrete integers. :param n: Upper bound for the number of concrete integers :param signed: Treat this StridedInterval as signed or unsigned :return: A list of at most `n` concrete integers
Used to make exact comparisons between two StridedIntervals. Usually it is only used in test cases. :param o: The other StridedInterval to compare with. :return: True if they are exactly same, False otherwise.
Logical shift right. :param StridedInterval shift_amount: The amount of shifting :return: The shifted StridedInterval object :rtype: StridedInterval
This is a delayed reversing function. All it really does is to invert the _reversed property of this StridedInterval object. :return: None
Arithmetic shift right. :param StridedInterval shift_amount: The amount of shifting :return: The shifted StridedInterval :rtype: StridedInterval
Logical shift right. :param StridedInterval shift_amount: The amount of shifting :return: The shifted StridedInterval :rtype: StridedInterval
Signed greater than or equal to. :param o: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Signed greater than. :param o: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Unary operation: SignExtend :param new_length: New length after sign-extension :return: A new StridedInterval
Signed less than or equal to. :param o: The other operand. :return: TrueResult(), FalseResult(), or MaybeResult()
Checks whether an integer is solution of the current strided Interval :param b: integer to check :return: True if b belongs to the current Strided Interval, False otherwhise
Binary operation: unsigned division :param o: The divisor :return: (self / o) in unsigned arithmetic
Unsigned greater than or equal to. :param o: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Signed greater than. :param o: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Unsigned less than or equal to. :param o: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
Unsigned less than. :param o: The other operand :return: TrueResult(), FalseResult(), or MaybeResult()
The union operation. It might return a DiscreteStridedIntervalSet to allow for better precision in analysis. :param b: Operand :return: A new DiscreteStridedIntervalSet, or a new StridedInterval.
Unary operation: ZeroExtend :param new_length: New length after zero-extension :return: A new StridedInterval
Whether this StridedInterval is a BOTTOM, in other words, describes an empty set of integers. :return: True/False
If this is an integer, i.e. self.lower_bound == self.upper_bound. :return: True if this is an integer, False otherwise
Treat this StridedInterval as a set of unsigned numbers, and return the greatest one :return: the greatest number in this StridedInterval when evaluated as unsigned, or None if empty
Treat this StridedInterval as a set of unsigned numbers, and return the smallest one :return: the smallest number in this StridedInterval when evaluated as unsigned, or None if empty
Return interval with bigger cardinality Refer Section 3.1 :param interval1: first interval :param interval2: second interval :return: Interval or interval2 whichever has greater cardinality
Refer section 3.1; gap function. :param src_interval: first argument or interval 1 :param tar_interval: second argument or interval 2 :return: Interval representing gap between two intervals
Get the MSB (most significant bit). :param v: The integer :param bits: Bits of the integer :return: the MSB
Checks if the most significant bit is one (i.e. is the integer negative under signed arithmetic). :param v: The integer to check with :param bits: Bits of the integer :return: True or False
Checks if the most significant bit is zero (i.e. is the integer positive under signed arithmetic). :param v: The integer to check with :param bits: Bits of the integer :return: True or False
Lexicographical LT comparison :param x: The first operand (integer) :param y: The second operand (integer) :param bits: bit-width of the operands :return: True or False
Lexicographical LTE comparison :param x: The first operand (integer) :param y: The second operand (integer) :param bits: bit-width of the operands :return: True or False
Calculates the minimal integer that appears in both StridedIntervals. As a wrapper method of _minimal_common_integer_splitted(), this method takes arbitrary StridedIntervals. For more information, please refer to the comment of _minimal_common_integer_splitted(). :param si_0: the first StridedInterval :type si_0: StridedInterval :param si_1: the second StridedInterval :type si_1: StridedInterval :return: the minimal common integer, or None if there is no common integer
Calculates the minimal integer that appears in both StridedIntervals. It's equivalent to finding an integral solution for equation `ax + b = cy + d` that makes `ax + b` minimal si_0.stride, si_1.stride being a and c, and si_0.lower_bound, si_1.lower_bound being b and d, respectively. Upper bounds are used to check whether the minimal common integer exceeds the bound or not. None is returned if no minimal common integers can be found within the range. Some assumptions: # - None of the StridedIntervals straddles the south pole. Consequently, we have x <= max_int(si.bits) and y <= # max_int(si.bits) # - a, b, c, d are all positive integers # - x >= 0, y >= 0 :param StridedInterval si_0: the first StridedInterval :param StridedInterval si_1: the second StrideInterval :return: the minimal common integer, or None if there is no common integer
Convert an unsigned integer to a signed integer. :param v: The unsigned integer :param bits: How many bits this integer should be :return: The converted signed integer
Return the cardinality for a set of number (| x, y |) on the wrapped-interval domain. :param x: The first operand (an integer) :param y: The second operand (an integer) :return: The cardinality
Determines if an overflow happens during the addition of `a` and `b`. :param a: The first operand (StridedInterval) :param b: The other operand (StridedInterval) :return: True if overflows, False otherwise
Determines if an overflow happens during the subtraction of `a` and `b`. :param a: The first operand (StridedInterval) :param b: The other operand (StridedInterval) :return: True if overflows, False otherwise
Perform wrapped unsigned division on two StridedIntervals. :param a: The dividend (StridedInterval) :param b: The divisor (StridedInterval) :return: The quotient
Perform wrapped signed multiplication on two StridedIntervals. :param a: The first operand (StridedInterval) :param b: The second operand (StridedInterval) :return: The product
Perform wrapped unsigned division on two StridedIntervals. :param a: The dividend (StridedInterval) :param b: The divisor (StridedInterval) :return: The quotient
Perform wrapped unsigned multiplication on two StridedIntervals. :param a: The first operand (StridedInterval) :param b: The second operand (StridedInterval) :return: The multiplication result
This method reverses the StridedInterval object for real. Do expect loss of precision for most cases! :return: A new reversed StridedInterval instance
Perform a wrapped LTE comparison only considering the SI bounds :param a: The first operand :param b: The second operand :return: True if a <= b, False otherwise
Split `self` at the north pole, which is the same as in signed arithmetic. :return: A list of split StridedIntervals
This method reverses the StridedInterval object for real. Do expect loss of precision for most cases! :return: A new reversed StridedInterval instance
Arithmetic shift right with a concrete shift amount :param int shift_amount: Number of bits to shift right. :return: The new StridedInterval after right shifting :rtype: StridedInterval
Logical shift right with a concrete shift amount :param int shift_amount: Number of bits to shift right. :return: The new StridedInterval after right shifting :rtype: StridedInterval
Get lower bound and upper bound for `self` in signed arithmetic. :return: a list of (lower_bound, upper_bound) tuples
Split `self` at the south pole, which is the same as in unsigned arithmetic. When returning two StridedIntervals (which means a splitting occurred), it is guaranteed that the first StridedInterval is on the right side of the south pole. :return: a list of split StridedIntervals, that contains either one or two StridedIntervals
Logical shift right. :param StridedInterval shift_amount: The amount of shifting :return: The shifted StridedInterval :rtype: StridedInterval
Get lower bound and upper bound for `self` in unsigned arithmetic. :return: a list of (lower_bound, upper_bound) tuples.