ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
bitwise_bounds.h File Reference
#include <big-int/bigint.hh>
Include dependency graph for bitwise_bounds.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define UINT_X   unsigned
#define INT_X   int
#define UINT_FUNC(FUNC, LHS, RHS)
#define INT_FUNC(FUNC, LHS, RHS)
#define GET_BIT_INTERVALS(NAME, MIN_UFUNC, MAX_UFUNC, MIN_FUNC, MAX_FUNC)

Functions

UINT_X unsigned_max_or (UINT_X a, UINT_X b, UINT_X c, UINT_X d)
 Adaptation of the algorithm in Henry S.
UINT_X unsigned_min_or (UINT_X a, UINT_X b, UINT_X c, UINT_X d)
 Adaptation of the algorithm in Henry S.
UINT_X unsigned_max_and (UINT_X a, UINT_X b, UINT_X c, UINT_X d)
 Implementation of the algorithm in Henry S.
UINT_X unsigned_min_and (UINT_X a, UINT_X b, UINT_X c, UINT_X d)
 Implementation of the algorithm in Henry S.
UINT_X unsigned_max_xor (UINT_X a, UINT_X b, UINT_X c, UINT_X d)
 Implementation of the algorithm in Henry S.
UINT_X unsigned_min_xor (UINT_X a, UINT_X b, UINT_X c, UINT_X d)
 Implementation of the algorithm in Henry S.
UINT_X unsigned_max_not (UINT_X a, UINT_X)
 Implementation of the algorithm in Henry S.
UINT_X unsigned_min_not (UINT_X, UINT_X b)
 Implementation of the algorithm in Henry S.
UINT_X unsigned_max_left_shift (UINT_X, UINT_X b, UINT_X, UINT_X d)
 Upper bound on interval left shift.
UINT_X unsigned_min_left_shift (UINT_X a, UINT_X, UINT_X c, UINT_X)
 Lower bound on interval left shift.
UINT_X unsigned_max_right_shift (UINT_X, UINT_X b, UINT_X c, UINT_X)
 Upper bound on interval right shift.
UINT_X unsigned_min_right_shift (UINT_X a, UINT_X, UINT_X, UINT_X d)
 Lower bound on interval right shift.
UINT_X unsigned_2_unsigned_max_truncate (UINT_X a, UINT_X b, UINT_X n)
 Upper bound on unsigned to unsigned interval truncation.
UINT_X unsigned_2_unsigned_min_truncate (UINT_X a, UINT_X b, UINT_X n)
 Lower bound on unsigned to unsigned interval truncation.
UINT_X signed_2_unsigned_max_truncate (INT_X a, INT_X b, UINT_X n)
 Upper bound on signed to unsigned interval truncation.
UINT_X signed_2_unsigned_min_truncate (INT_X a, INT_X b, UINT_X n)
 Lower bound on signed to unsigned interval truncation.
UINT_X signed_2_unsigned_max_extend (INT_X a, INT_X b, UINT_X n)
 Upper bound on the unsigned extension of an n bit signed interval.
UINT_X signed_2_unsigned_min_extend (INT_X a, INT_X b, UINT_X n)
 Lower bound on the unsigned extension of an n bit signed interval.
INT_X signed_max_or (INT_X a, INT_X b, INT_X c, INT_X d)
 Implementation of the algorithm in Henry S.
INT_X signed_min_or (INT_X a, INT_X b, INT_X c, INT_X d)
 Implementation of the algorithm in Henry S.
INT_X signed_max_and (INT_X a, INT_X b, INT_X c, INT_X d)
 Implementation of the algorithm in Henry S.
INT_X signed_min_and (INT_X a, INT_X b, INT_X c, INT_X d)
 Implementation of the algorithm in Henry S.
INT_X signed_max_xor (INT_X a, INT_X b, INT_X c, INT_X d)
 Original upper bound on signed interval XOR, inspired by the case-based algorithm for signed interval OR in Henry S.
INT_X signed_min_xor (INT_X a, INT_X b, INT_X c, INT_X d)
 Original lower bound on signed interval XOR, inspired by the case-based algorithm for signed interval OR in Henry S.
INT_X signed_max_not (INT_X a, INT_X)
 Implementation of the algorithm in Henry S.
INT_X signed_min_not (INT_X, INT_X b)
 Implementation of the algorithm in Henry S.
INT_X signed_max_left_shift (INT_X, INT_X b, UINT_X c, UINT_X d)
 Upper bound on interval left shift.
INT_X signed_min_left_shift (INT_X a, INT_X, UINT_X c, UINT_X d)
 Lower bound on interval left shift.
INT_X signed_max_right_shift (INT_X, INT_X b, UINT_X c, UINT_X d)
 Upper bound on interval right shift.
INT_X signed_min_right_shift (INT_X a, INT_X, UINT_X c, UINT_X d)
 Lower bound on interval right shift.
INT_X unsigned_2_signed (UINT_X x, UINT_X n)
 Cast a limited-width unsigned integer to signed integer.
INT_X unsigned_2_signed_max_truncate (UINT_X a, UINT_X b, UINT_X n)
 Upper bound on unsigned to signed interval truncation.
INT_X unsigned_2_signed_min_truncate (UINT_X a, UINT_X b, UINT_X n)
 Lower bound on unsigned to signed interval truncation.
INT_X signed_2_signed_max_truncate (INT_X a, INT_X b, UINT_X n)
 Upper bound on signed to signed interval truncation.
INT_X signed_2_signed_min_truncate (INT_X a, INT_X b, UINT_X n)
 Lower bound on signed to signed interval truncation.
INT_X unsigned_2_signed_max_extend (UINT_X a, UINT_X b, UINT_X n)
 Upper bound on the signed extension of an n bit unsigned interval.
INT_X unsigned_2_signed_min_extend (UINT_X a, UINT_X b, UINT_X n)
 Lower bound on the signed extension of an n bit unsigned interval.
 GET_BIT_INTERVALS (interval_bitand, unsigned_min_and, unsigned_max_and, signed_min_and, signed_max_and) GET_BIT_INTERVALS(interval_bitor
signed_max_or GET_BIT_INTERVALS (interval_bitxor, unsigned_min_xor, unsigned_max_xor, signed_min_xor, signed_max_xor) GET_BIT_INTERVALS(interval_logical_right_shift

Variables

 unsigned_min_or
 unsigned_max_or
 signed_min_or
signed_max_or unsigned_min_right_shift
signed_max_or unsigned_max_right_shift
signed_max_or signed_min_right_shift

Macro Definition Documentation

◆ GET_BIT_INTERVALS

#define GET_BIT_INTERVALS ( NAME,
MIN_UFUNC,
MAX_UFUNC,
MIN_FUNC,
MAX_FUNC )
Value:
template <> \
const interval_templatet<BigInt> &rhs) const \
{ \
if (!lhs.lower || !lhs.upper || !rhs.lower || !rhs.upper) \
return result; \
if (is_unsignedbv_type(lhs.type) && is_unsignedbv_type(rhs.type)) \
{ \
result.set_lower(UINT_FUNC(MIN_UFUNC, lhs, rhs)); \
result.set_upper(UINT_FUNC(MAX_UFUNC, lhs, rhs)); \
} \
else if (is_signedbv_type(lhs.type) && is_signedbv_type(rhs.type)) \
{ \
result.set_lower(INT_FUNC(MIN_FUNC, lhs, rhs)); \
result.set_upper(INT_FUNC(MAX_FUNC, lhs, rhs)); \
} \
return result; \
}
#define INT_FUNC(FUNC, LHS, RHS)
Definition bitwise_bounds.h:1040
#define UINT_FUNC(FUNC, LHS, RHS)
Definition bitwise_bounds.h:1033
This class is used to store intervals in the form of lower <= upper.
Definition interval_template.h:20
void set_lower(const T &b)
Definition interval_template.h:75
void set_upper(const T &b)
Definition interval_template.h:71

◆ INT_FUNC

#define INT_FUNC ( FUNC,
LHS,
RHS )
Value:
FUNC( \
LHS.get_lower().to_int64(), \
LHS.get_upper().to_int64(), \
RHS.get_lower().to_int64(), \
RHS.get_upper().to_int64())

◆ INT_X

#define INT_X   int

◆ UINT_FUNC

#define UINT_FUNC ( FUNC,
LHS,
RHS )
Value:
FUNC( \
LHS.get_lower().to_uint64(), \
LHS.get_upper().to_uint64(), \
RHS.get_lower().to_uint64(), \
RHS.get_upper().to_uint64())

◆ UINT_X

#define UINT_X   unsigned

Function Documentation

◆ GET_BIT_INTERVALS() [1/2]

GET_BIT_INTERVALS ( interval_bitand ,
unsigned_min_and ,
unsigned_max_and ,
signed_min_and ,
signed_max_and  )

◆ GET_BIT_INTERVALS() [2/2]

signed_max_or GET_BIT_INTERVALS ( interval_bitxor ,
unsigned_min_xor ,
unsigned_max_xor ,
signed_min_xor ,
signed_max_xor  )

◆ signed_2_signed_max_truncate()

INT_X signed_2_signed_max_truncate ( INT_X a,
INT_X b,
UINT_X n )

Upper bound on signed to signed interval truncation.

Author
Edoardo Manino.

Maximum value of signed truncate(x, n) given n bits and signed x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ signed_2_signed_min_truncate()

INT_X signed_2_signed_min_truncate ( INT_X a,
INT_X b,
UINT_X n )

Lower bound on signed to signed interval truncation.

Author
Edoardo Manino.

Minimum value of signed truncate(x, n) given n bits and signed x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ signed_2_unsigned_max_extend()

UINT_X signed_2_unsigned_max_extend ( INT_X a,
INT_X b,
UINT_X n )

Upper bound on the unsigned extension of an n bit signed interval.

Author
Edoardo Manino.

Maximum value of unsigned extend(x, n) given n bits and signed x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the input

◆ signed_2_unsigned_max_truncate()

UINT_X signed_2_unsigned_max_truncate ( INT_X a,
INT_X b,
UINT_X n )

Upper bound on signed to unsigned interval truncation.

Author
Edoardo Manino.

Maximum value of unsigned truncate(x, n) given n bits and signed x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ signed_2_unsigned_min_extend()

UINT_X signed_2_unsigned_min_extend ( INT_X a,
INT_X b,
UINT_X n )

Lower bound on the unsigned extension of an n bit signed interval.

Author
Edoardo Manino.

Minimum value of unsigned extend(x, n) given n bits and signed x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the input

◆ signed_2_unsigned_min_truncate()

UINT_X signed_2_unsigned_min_truncate ( INT_X a,
INT_X b,
UINT_X n )

Lower bound on signed to unsigned interval truncation.

Author
Edoardo Manino.

Minimum value of unsigned truncate(x, n) given n bits and signed x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ signed_max_and()

INT_X signed_max_and ( INT_X a,
INT_X b,
INT_X c,
INT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Maximum value of x & y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_max_left_shift()

INT_X signed_max_left_shift ( INT_X ,
INT_X b,
UINT_X c,
UINT_X d )

Upper bound on interval left shift.

Author
Edoardo Manino.

Maximum value of x << y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_max_not()

INT_X signed_max_not ( INT_X a,
INT_X  )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Maximum value of ~x given x in [a,b], potentially negative

Parameters
aMin value of variable x
bMax value of variable x

◆ signed_max_or()

INT_X signed_max_or ( INT_X a,
INT_X b,
INT_X c,
INT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Maximum value of x | y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_max_right_shift()

INT_X signed_max_right_shift ( INT_X ,
INT_X b,
UINT_X c,
UINT_X d )

Upper bound on interval right shift.

Author
Edoardo Manino.

Maximum value of x >> y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_max_xor()

INT_X signed_max_xor ( INT_X a,
INT_X b,
INT_X c,
INT_X d )

Original upper bound on signed interval XOR, inspired by the case-based algorithm for signed interval OR in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Maximum value of x ^ y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_min_and()

INT_X signed_min_and ( INT_X a,
INT_X b,
INT_X c,
INT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Minimum value of x & y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_min_left_shift()

INT_X signed_min_left_shift ( INT_X a,
INT_X ,
UINT_X c,
UINT_X d )

Lower bound on interval left shift.

Author
Edoardo Manino.

Minimum value of x << y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_min_not()

INT_X signed_min_not ( INT_X ,
INT_X b )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Minimum value of ~x given x in [a,b], potentially negative

Parameters
aMin value of variable x
bMax value of variable x

◆ signed_min_or()

INT_X signed_min_or ( INT_X a,
INT_X b,
INT_X c,
INT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Minimum value of x | y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_min_right_shift()

INT_X signed_min_right_shift ( INT_X a,
INT_X ,
UINT_X c,
UINT_X d )

Lower bound on interval right shift.

Author
Edoardo Manino.

Minimum value of x >> y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ signed_min_xor()

INT_X signed_min_xor ( INT_X a,
INT_X b,
INT_X c,
INT_X d )

Original lower bound on signed interval XOR, inspired by the case-based algorithm for signed interval OR in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Minimum value of x ^ y given x in [a,b] and y in [c,d], potentially negative

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_2_signed()

INT_X unsigned_2_signed ( UINT_X x,
UINT_X n )

Cast a limited-width unsigned integer to signed integer.

Author
Edoardo Manino.

Compute cas(x, n) given an n-bit unsigned input x

Parameters
xValue to be converted
nNumber of bits of the result

◆ unsigned_2_signed_max_extend()

INT_X unsigned_2_signed_max_extend ( UINT_X a,
UINT_X b,
UINT_X n )

Upper bound on the signed extension of an n bit unsigned interval.

Author
Edoardo Manino.

Maximum value of signed extend(x, n) given n bits and unsigned x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the input

◆ unsigned_2_signed_max_truncate()

INT_X unsigned_2_signed_max_truncate ( UINT_X a,
UINT_X b,
UINT_X n )

Upper bound on unsigned to signed interval truncation.

Author
Edoardo Manino.

Maximum value of signed truncate(x, n) given n bits and unsigned x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ unsigned_2_signed_min_extend()

INT_X unsigned_2_signed_min_extend ( UINT_X a,
UINT_X b,
UINT_X n )

Lower bound on the signed extension of an n bit unsigned interval.

Author
Edoardo Manino.

Minimum value of signed extend(x, n) given n bits and unsigned x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the input

◆ unsigned_2_signed_min_truncate()

INT_X unsigned_2_signed_min_truncate ( UINT_X a,
UINT_X b,
UINT_X n )

Lower bound on unsigned to signed interval truncation.

Author
Edoardo Manino.

Minimum value of signed truncate(x, n) given n bits and unsigned x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ unsigned_2_unsigned_max_truncate()

UINT_X unsigned_2_unsigned_max_truncate ( UINT_X a,
UINT_X b,
UINT_X n )

Upper bound on unsigned to unsigned interval truncation.

Author
Edoardo Manino.

Maximum value of unsigned truncate(x, n) given n bits and unsigned x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ unsigned_2_unsigned_min_truncate()

UINT_X unsigned_2_unsigned_min_truncate ( UINT_X a,
UINT_X b,
UINT_X n )

Lower bound on unsigned to unsigned interval truncation.

Author
Edoardo Manino.

Minimum value of unsigned truncate(x, n) given n bits and unsigned x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x
nNumber of bits of the result

◆ unsigned_max_and()

UINT_X unsigned_max_and ( UINT_X a,
UINT_X b,
UINT_X c,
UINT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Maximum value of x & y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_max_left_shift()

UINT_X unsigned_max_left_shift ( UINT_X ,
UINT_X b,
UINT_X ,
UINT_X d )

Upper bound on interval left shift.

Author
Edoardo Manino.

Maximum value of x << y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_max_not()

UINT_X unsigned_max_not ( UINT_X a,
UINT_X  )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Maximum value of ~x given x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x

◆ unsigned_max_or()

UINT_X unsigned_max_or ( UINT_X a,
UINT_X b,
UINT_X c,
UINT_X d )

Adaptation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003 for unsigned integers of any width, by scanning from the least significant bit.

Author
Edoardo Manino.

Maximum value of x | y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_max_right_shift()

UINT_X unsigned_max_right_shift ( UINT_X ,
UINT_X b,
UINT_X c,
UINT_X  )

Upper bound on interval right shift.

Author
Edoardo Manino.

Maximum value of x >> y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_max_xor()

UINT_X unsigned_max_xor ( UINT_X a,
UINT_X b,
UINT_X c,
UINT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Maximum value of x ^ y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_min_and()

UINT_X unsigned_min_and ( UINT_X a,
UINT_X b,
UINT_X c,
UINT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Minimum value of x & y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_min_left_shift()

UINT_X unsigned_min_left_shift ( UINT_X a,
UINT_X ,
UINT_X c,
UINT_X  )

Lower bound on interval left shift.

Author
Edoardo Manino.

Minimum value of x << y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_min_not()

UINT_X unsigned_min_not ( UINT_X ,
UINT_X b )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Minimum value of ~x given x in [a,b]

Parameters
aMin value of variable x
bMax value of variable x

◆ unsigned_min_or()

UINT_X unsigned_min_or ( UINT_X a,
UINT_X b,
UINT_X c,
UINT_X d )

Adaptation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003 for unsigned integers of any width, by scanning from the least significant bit.

Author
Edoardo Manino.

Minimum value of x | y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_min_right_shift()

UINT_X unsigned_min_right_shift ( UINT_X a,
UINT_X ,
UINT_X ,
UINT_X d )

Lower bound on interval right shift.

Author
Edoardo Manino.

Minimum value of x >> y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

◆ unsigned_min_xor()

UINT_X unsigned_min_xor ( UINT_X a,
UINT_X b,
UINT_X c,
UINT_X d )

Implementation of the algorithm in Henry S.

Warren Jr., "Hacker's Delight", 2003

Author
Edoardo Manino.

Minimum value of x ^ y given x in [a,b] and y in [c,d]

Parameters
aMin value of variable x
bMax value of variable x
cMin value of variable y
dMax value of variable y

Variable Documentation

◆ signed_min_or

signed_min_or

◆ signed_min_right_shift

signed_max_or signed_min_right_shift

◆ unsigned_max_or

unsigned_max_or

◆ unsigned_max_right_shift

signed_max_or unsigned_max_right_shift

◆ unsigned_min_or

unsigned_min_or

◆ unsigned_min_right_shift

signed_max_or unsigned_min_right_shift