Interface BitvectorFormulaManager
-
- All Known Implementing Classes:
AbstractBitvectorFormulaManager
public interface BitvectorFormulaManagerManager for dealing with formulas of the bitvector sort.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BitvectorFormulaadd(BitvectorFormula number1, BitvectorFormula number2)This method returns the addition of the given bitvectors.BitvectorFormulaand(BitvectorFormula bits1, BitvectorFormula bits2)This method returns the bit-wise AND of the given bitvectors.BitvectorFormulaconcat(BitvectorFormula prefix, BitvectorFormula suffix)Concatenate two bitvectors.BooleanFormuladistinct(List<BitvectorFormula> pBits)All given bitvectors are pairwise unequal.BitvectorFormuladivide(BitvectorFormula numerator, BitvectorFormula denumerator, boolean signed)This method returns the division for two bitvector formulas.BooleanFormulaequal(BitvectorFormula number1, BitvectorFormula number2)This method returns the bit-wise equality of the given bitvectors.BitvectorFormulaextend(BitvectorFormula number, int extensionBits, boolean signed)Extend a bitvector to the left (add most significant bits).BitvectorFormulaextract(BitvectorFormula number, int msb, int lsb)Extract a range of bits from a bitvector.intgetLength(BitvectorFormula number)This method returns the length of a bitvector, also denoted as bit-size.BooleanFormulagreaterOrEquals(BitvectorFormula number1, BitvectorFormula number2, boolean signed)Compare the given bitvectors.BooleanFormulagreaterThan(BitvectorFormula number1, BitvectorFormula number2, boolean signed)Compare the given bitvectors.BooleanFormulalessOrEquals(BitvectorFormula number1, BitvectorFormula number2, boolean signed)Compare the given bitvectors.BooleanFormulalessThan(BitvectorFormula number1, BitvectorFormula number2, boolean signed)Compare the given bitvectors.BitvectorFormulamakeBitvector(int length, long pI)Convert a number into a bitvector with given size.BitvectorFormulamakeBitvector(int length, BigInteger pI)Convert a number into a bitvector with given size.BitvectorFormulamakeBitvector(int length, NumeralFormula.IntegerFormula pI)Convert/Cast/Interpret a numeral formula into a bitvector with given size.BitvectorFormulamakeVariable(int length, String pVar)Creates a variable with exactly the given name and bitwidth.BitvectorFormulamakeVariable(FormulaType.BitvectorType type, String pVar)BitvectorFormulamodulo(BitvectorFormula numerator, BitvectorFormula denumerator, boolean signed)This method returns the remainder (modulo) for two bitvector formulas.BitvectorFormulamultiply(BitvectorFormula number1, BitvectorFormula number2)This method returns the multiplication of the given bitvectors.BitvectorFormulanegate(BitvectorFormula number)This method returns the negated number, i.e., it is multiplied by "-1".BitvectorFormulanot(BitvectorFormula bits)This method returns the bit-wise complement of the given bitvector.BitvectorFormulaor(BitvectorFormula bits1, BitvectorFormula bits2)This method returns the bit-wise OR of the given bitvectors.BitvectorFormulashiftLeft(BitvectorFormula number, BitvectorFormula toShift)This method returns a term representing the left shift of number by toShift.BitvectorFormulashiftRight(BitvectorFormula number, BitvectorFormula toShift, boolean signed)This method returns a term representing the right shift of number by toShift.BitvectorFormulasubtract(BitvectorFormula number1, BitvectorFormula number2)This method returns the subtraction of the given bitvectors.NumeralFormula.IntegerFormulatoIntegerFormula(BitvectorFormula pI, boolean signed)Convert/Cast/Interpret a signed/unsigned bitvector formula as an integer formula.BitvectorFormulaxor(BitvectorFormula bits1, BitvectorFormula bits2)This method returns the bit-wise XOR of the given bitvectors.
-
-
-
Method Detail
-
makeBitvector
BitvectorFormula makeBitvector(int length, long pI)
Convert a number into a bitvector with given size.- Throws:
IllegalArgumentException- if the number is out of range for the given length.
-
makeBitvector
BitvectorFormula makeBitvector(int length, BigInteger pI)
Convert a number into a bitvector with given size.- Throws:
IllegalArgumentException- if the number is out of range for the given length.
-
makeBitvector
BitvectorFormula makeBitvector(int length, NumeralFormula.IntegerFormula pI)
Convert/Cast/Interpret a numeral formula into a bitvector with given size.If the numeral formula is too large for the given length, we cut off the largest bits and only use the lest significant bits.
-
toIntegerFormula
NumeralFormula.IntegerFormula toIntegerFormula(BitvectorFormula pI, boolean signed)
Convert/Cast/Interpret a signed/unsigned bitvector formula as an integer formula.
-
makeVariable
BitvectorFormula makeVariable(int length, String pVar)
Creates a variable with exactly the given name and bitwidth.Please make sure that the given name is valid in SMT-LIB2. Take a look at
FormulaManager.isValidName(java.lang.String)for further information.This method does not quote or unquote the given name, but uses the plain name "AS IS".
Formula.toString()can return a different String than the given one.
-
makeVariable
BitvectorFormula makeVariable(FormulaType.BitvectorType type, String pVar)
- See Also:
makeVariable(int, String)
-
getLength
int getLength(BitvectorFormula number)
This method returns the length of a bitvector, also denoted as bit-size.
-
negate
BitvectorFormula negate(BitvectorFormula number)
This method returns the negated number, i.e., it is multiplied by "-1". The given number is interpreted as signed bitvector and corresponds to "2^BITSIZE - number". The result has the same length as the given number.
-
add
BitvectorFormula add(BitvectorFormula number1, BitvectorFormula number2)
This method returns the addition of the given bitvectors. The result has the same length as the given parameters. There can be an overflow, i.e., as one would expect from bitvector logic. There is no difference in signed and unsigned numbers.- Parameters:
number1- a Formulanumber2- a Formula- Returns:
number1 + number2
-
subtract
BitvectorFormula subtract(BitvectorFormula number1, BitvectorFormula number2)
This method returns the subtraction of the given bitvectors. The result has the same length as the given parameters. There can be an overflow, i.e., as one would expect from bitvector logic. There is no difference in signed and unsigned numbers.- Parameters:
number1- a Formulanumber2- a Formula- Returns:
number1 - number2
-
divide
BitvectorFormula divide(BitvectorFormula numerator, BitvectorFormula denumerator, boolean signed)
This method returns the division for two bitvector formulas.For signed bitvectors, the result is rounded towards zero (also called "truncated integer division", similar to the division in the C99 standard), e.g., a user can assume the following equations:
- 10 / 5 = 2
- 10 / 3 = 3
- 10 / (-3) = -3
- -10 / 5 = -2
- -10 / 3 = -3
- -10 / (-3) = 3
If the denumerator evaluates to zero (division-by-zero), either directly as value or indirectly via an additional constraint, then the result of the division is defined as:
- "-1" interpreted as bitvector (i.e., all bits set to "1"), if the numerator is non-negative, and
- "1" interpreted as bitvector (i.e., all bits set to "0", except the last bit), if the numerator is negative.
We refer to the SMTLIB standard for the division and modulo operators in BV theory.
- Parameters:
numerator- dividenddenumerator- divisorsigned- whether to interpret all operands as signed or as unsigned numbers.
-
modulo
BitvectorFormula modulo(BitvectorFormula numerator, BitvectorFormula denumerator, boolean signed)
This method returns the remainder (modulo) for two bitvector formulas.For signed bitvectors, the sign of the result follows the sign of the numerator, e.g., a user can assume the following equations:
- 10 % 5 = 0
- 10 % 3 = 1
- 10 % (-3) = 1
- -10 % 5 = 0
- -10 % 3 = -1
- -10 % (-3) = -1
If the denumerator evaluates to zero (modulo-by-zero), either directly as value or indirectly via an additional constraint, then the result of the modulo operation is defined as the numerator itself. We refer to the SMTLIB standard for the division and modulo operators in BV theory.
- Parameters:
numerator- dividenddenumerator- divisorsigned- whether to interpret all operands as signed or as unsigned numbers.
-
multiply
BitvectorFormula multiply(BitvectorFormula number1, BitvectorFormula number2)
This method returns the multiplication of the given bitvectors. The result has the same length as the given parameters. There can be an overflow, i.e., as one would expect from bitvector logic. There is no difference in signed and unsigned numbers.- Parameters:
number1- a Formulanumber2- a Formula- Returns:
number1 - number2
-
equal
BooleanFormula equal(BitvectorFormula number1, BitvectorFormula number2)
This method returns the bit-wise equality of the given bitvectors.- Parameters:
number1- a Formulanumber2- a Formula- Returns:
number1 == number2
-
greaterThan
BooleanFormula greaterThan(BitvectorFormula number1, BitvectorFormula number2, boolean signed)
Compare the given bitvectors.- Parameters:
number1- a Formulanumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 > number2
-
greaterOrEquals
BooleanFormula greaterOrEquals(BitvectorFormula number1, BitvectorFormula number2, boolean signed)
Compare the given bitvectors.- Parameters:
number1- a Formulanumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 >= number2
-
lessThan
BooleanFormula lessThan(BitvectorFormula number1, BitvectorFormula number2, boolean signed)
Compare the given bitvectors.- Parameters:
number1- a Formulanumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 < number2
-
lessOrEquals
BooleanFormula lessOrEquals(BitvectorFormula number1, BitvectorFormula number2, boolean signed)
Compare the given bitvectors.- Parameters:
number1- a Formulanumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 <= number2
-
not
BitvectorFormula not(BitvectorFormula bits)
This method returns the bit-wise complement of the given bitvector.- Parameters:
bits- Formula- Returns:
~bits
-
and
BitvectorFormula and(BitvectorFormula bits1, BitvectorFormula bits2)
This method returns the bit-wise AND of the given bitvectors.- Parameters:
bits1- a Formulabits2- a Formula- Returns:
bits1 & bits2
-
or
BitvectorFormula or(BitvectorFormula bits1, BitvectorFormula bits2)
This method returns the bit-wise OR of the given bitvectors.- Parameters:
bits1- a Formulabits2- a Formula- Returns:
bits1 | bits2
-
xor
BitvectorFormula xor(BitvectorFormula bits1, BitvectorFormula bits2)
This method returns the bit-wise XOR of the given bitvectors.- Parameters:
bits1- a Formulabits2- a Formula- Returns:
bits1 ^ bits2
-
shiftRight
BitvectorFormula shiftRight(BitvectorFormula number, BitvectorFormula toShift, boolean signed)
This method returns a term representing the right shift of number by toShift. The result has the same length as the given number. On the left side, we fill up the most significant bits with ones (i.e., arithmetic shift), if the number is signed and negative, else we fill up with zeroes.
-
shiftLeft
BitvectorFormula shiftLeft(BitvectorFormula number, BitvectorFormula toShift)
This method returns a term representing the left shift of number by toShift. The result has the same length as the given number. On the right side, we fill up the least significant bits with zeroes.
-
concat
BitvectorFormula concat(BitvectorFormula prefix, BitvectorFormula suffix)
Concatenate two bitvectors.
-
extract
BitvectorFormula extract(BitvectorFormula number, int msb, int lsb)
Extract a range of bits from a bitvector. We require0 <= lsb <= msb < bitsize.If msb equals lsb, then a single bit will be returned, i.e., the bit from the given position. If lsb equals 0 and msb equals bitsize-1, then the complete bitvector will be returned.
- Parameters:
number- from where the bits are extracted.msb- Upper index for the most significant bit. Must be in interval from lsb to bitsize-1.lsb- Lower index for the least significant bit. Must be in interval from 0 to msb.
-
extend
BitvectorFormula extend(BitvectorFormula number, int extensionBits, boolean signed)
Extend a bitvector to the left (add most significant bits). If signed is set and the given number is negative, then the bit "1" will be added several times, else "0".- Parameters:
number- The bitvector to extend.extensionBits- How many bits to add.signed- Whether the extension should depend on the sign bit.
-
distinct
BooleanFormula distinct(List<BitvectorFormula> pBits)
All given bitvectors are pairwise unequal.
-
-