Class AbstractBitvectorFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl>
- All Implemented Interfaces:
BitvectorFormulaManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FormulaCreator<TFormulaInfo,TType, TEnv, TFuncDecl> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBitvectorFormulaManager(FormulaCreator<TFormulaInfo, TType, TEnv, TFuncDecl> pCreator, AbstractBooleanFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> pBmgr) -
Method Summary
Modifier and TypeMethodDescriptionadd(BitvectorFormula pNumber1, BitvectorFormula pNumber2) This method returns the addition of the given bitvectors.protected abstract TFormulaInfoadd(TFormulaInfo pParam1, TFormulaInfo pParam2) and(BitvectorFormula pBits1, BitvectorFormula pBits2) This method returns the bit-wise AND of the given bitvectors.protected abstract TFormulaInfoand(TFormulaInfo pParam1, TFormulaInfo pParam2) final BitvectorFormulaconcat(BitvectorFormula pNumber, BitvectorFormula pAppend) Concatenate two bitvectors.protected abstract TFormulaInfoconcat(TFormulaInfo number, TFormulaInfo pAppend) final BooleanFormuladistinct(List<BitvectorFormula> pBits) All given bitvectors are pairwise unequal.protected TFormulaInfodistinctImpl(List<TFormulaInfo> pBits) divide(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) This method returns the division for two bitvector formulas.protected abstract TFormulaInfodivide(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) equal(BitvectorFormula pNumber1, BitvectorFormula pNumber2) This method returns the bit-wise equality of the given bitvectors.protected abstract TFormulaInfoequal(TFormulaInfo pParam1, TFormulaInfo pParam2) final BitvectorFormulaextend(BitvectorFormula pNumber, int pExtensionBits, boolean pSigned) Extend a bitvector to the left (add most significant bits).protected abstract TFormulaInfoextend(TFormulaInfo pNumber, int pExtensionBits, boolean pSigned) final BitvectorFormulaextract(BitvectorFormula pNumber, int pMsb, int pLsb) Extract a range of bits from a bitvector.protected abstract TFormulaInfoextract(TFormulaInfo pNumber, int pMsb, int pLsb) protected final FormulaCreator<TFormulaInfo,TType, TEnv, TFuncDecl> intgetLength(BitvectorFormula pNumber) This method returns the length of a bitvector, also denoted as bit-size.greaterOrEquals(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Compare the given bitvectors.protected abstract TFormulaInfogreaterOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) greaterThan(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Compare the given bitvectors.protected abstract TFormulaInfogreaterThan(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) lessOrEquals(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Compare the given bitvectors.protected abstract TFormulaInfolessOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) lessThan(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Compare the given bitvectors.protected abstract TFormulaInfolessThan(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) makeBitvector(int pLength, long i) Convert a number into a bitvector with given size.makeBitvector(int pLength, BigInteger i) Convert a number into a bitvector with given size.makeBitvector(int length, NumeralFormula.IntegerFormula pI) Convert/Cast/Interpret a numeral formula into a bitvector with given size.protected TFormulaInfomakeBitvectorImpl(int pLength, long pI) protected abstract TFormulaInfomakeBitvectorImpl(int pLength, BigInteger pI) protected abstract TFormulaInfomakeBitvectorImpl(int length, TFormulaInfo pParam1) makeVariable(int pLength, String pVar) Creates a variable with exactly the given name and bitwidth.makeVariable(FormulaType.BitvectorType type, String pVar) protected abstract TFormulaInfomakeVariableImpl(int pLength, String pVar) modulo(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) This method returns the remainder (modulo) for two bitvector formulas.protected abstract TFormulaInfomodulo(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) multiply(BitvectorFormula pNumber1, BitvectorFormula pNumber2) This method returns the multiplication of the given bitvectors.protected abstract TFormulaInfomultiply(TFormulaInfo pParam1, TFormulaInfo pParam2) negate(BitvectorFormula pNumber) This method returns the negated number, i.e., it is multiplied by "-1".protected abstract TFormulaInfonegate(TFormulaInfo pParam1) not(BitvectorFormula pBits) This method returns the bit-wise complement of the given bitvector.protected abstract TFormulaInfonot(TFormulaInfo pParam1) or(BitvectorFormula pBits1, BitvectorFormula pBits2) This method returns the bit-wise OR of the given bitvectors.protected abstract TFormulaInfoor(TFormulaInfo pParam1, TFormulaInfo pParam2) shiftLeft(BitvectorFormula pNumber, BitvectorFormula toShift) This method returns a term representing the left shift of number by toShift.protected abstract TFormulaInfoshiftLeft(TFormulaInfo pExtract, TFormulaInfo pExtract2) shiftRight(BitvectorFormula pNumber, BitvectorFormula toShift, boolean signed) Return a term representing the (arithmetic if signed is true) right shift of number by toShift.protected abstract TFormulaInfoshiftRight(TFormulaInfo pNumber, TFormulaInfo toShift, boolean signed) subtract(BitvectorFormula pNumber1, BitvectorFormula pNumber2) This method returns the subtraction of the given bitvectors.protected abstract TFormulaInfosubtract(TFormulaInfo pParam1, TFormulaInfo pParam2) toIntegerFormula(BitvectorFormula pI, boolean signed) Convert/Cast/Interpret a signed/unsigned bitvector formula as an integer formula.protected abstract TFormulaInfotoIntegerFormulaImpl(TFormulaInfo pI, boolean signed) protected final TTypetoSolverType(FormulaType<?> formulaType) protected final BigIntegertransformValueToRange(int pLength, BigInteger pI) transform a negative value into its positive counterpart.xor(BitvectorFormula pBits1, BitvectorFormula pBits2) This method returns the bit-wise XOR of the given bitvectors.protected abstract TFormulaInfoxor(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
Field Details
-
formulaCreator
-
-
Constructor Details
-
AbstractBitvectorFormulaManager
protected AbstractBitvectorFormulaManager(FormulaCreator<TFormulaInfo, TType, TEnv, TFuncDecl> pCreator, AbstractBooleanFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> pBmgr)
-
-
Method Details
-
makeBitvector
Description copied from interface:BitvectorFormulaManagerConvert/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.
- Specified by:
makeBitvectorin interfaceBitvectorFormulaManager
-
makeBitvectorImpl
-
toIntegerFormula
Description copied from interface:BitvectorFormulaManagerConvert/Cast/Interpret a signed/unsigned bitvector formula as an integer formula.- Specified by:
toIntegerFormulain interfaceBitvectorFormulaManager
-
toIntegerFormulaImpl
-
negate
Description copied from interface:BitvectorFormulaManagerThis 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.- Specified by:
negatein interfaceBitvectorFormulaManager
-
negate
-
add
Description copied from interface:BitvectorFormulaManagerThis 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.- Specified by:
addin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formula- Returns:
number1 + number2
-
add
-
subtract
Description copied from interface:BitvectorFormulaManagerThis 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.- Specified by:
subtractin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formula- Returns:
number1 - number2
-
subtract
-
divide
public BitvectorFormula divide(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Description copied from interface:BitvectorFormulaManagerThis 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.
- Specified by:
dividein interfaceBitvectorFormulaManager- Parameters:
pNumber1- dividendpNumber2- divisorsigned- whether to interpret all operands as signed or as unsigned numbers.
-
divide
-
modulo
public BitvectorFormula modulo(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Description copied from interface:BitvectorFormulaManagerThis 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.
- Specified by:
moduloin interfaceBitvectorFormulaManager- Parameters:
pNumber1- dividendpNumber2- divisorsigned- whether to interpret all operands as signed or as unsigned numbers.
-
modulo
-
multiply
Description copied from interface:BitvectorFormulaManagerThis 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.- Specified by:
multiplyin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formula- Returns:
number1 - number2
-
multiply
-
equal
Description copied from interface:BitvectorFormulaManagerThis method returns the bit-wise equality of the given bitvectors.- Specified by:
equalin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formula- Returns:
number1 == number2
-
equal
-
greaterThan
public BooleanFormula greaterThan(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Description copied from interface:BitvectorFormulaManagerCompare the given bitvectors.- Specified by:
greaterThanin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 > number2
-
greaterThan
protected abstract TFormulaInfo greaterThan(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) -
greaterOrEquals
public BooleanFormula greaterOrEquals(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Description copied from interface:BitvectorFormulaManagerCompare the given bitvectors.- Specified by:
greaterOrEqualsin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 >= number2
-
greaterOrEquals
protected abstract TFormulaInfo greaterOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) -
lessThan
public BooleanFormula lessThan(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Description copied from interface:BitvectorFormulaManagerCompare the given bitvectors.- Specified by:
lessThanin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 < number2
-
lessThan
protected abstract TFormulaInfo lessThan(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) -
lessOrEquals
public BooleanFormula lessOrEquals(BitvectorFormula pNumber1, BitvectorFormula pNumber2, boolean signed) Description copied from interface:BitvectorFormulaManagerCompare the given bitvectors.- Specified by:
lessOrEqualsin interfaceBitvectorFormulaManager- Parameters:
pNumber1- a FormulapNumber2- a Formulasigned- interpret the bitvectors as signed numbers instead of unsigned numbers- Returns:
number1 <= number2
-
lessOrEquals
protected abstract TFormulaInfo lessOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2, boolean signed) -
not
Description copied from interface:BitvectorFormulaManagerThis method returns the bit-wise complement of the given bitvector.- Specified by:
notin interfaceBitvectorFormulaManager- Parameters:
pBits- Formula- Returns:
~bits
-
not
-
and
Description copied from interface:BitvectorFormulaManagerThis method returns the bit-wise AND of the given bitvectors.- Specified by:
andin interfaceBitvectorFormulaManager- Parameters:
pBits1- a FormulapBits2- a Formula- Returns:
bits1 & bits2
-
and
-
or
Description copied from interface:BitvectorFormulaManagerThis method returns the bit-wise OR of the given bitvectors.- Specified by:
orin interfaceBitvectorFormulaManager- Parameters:
pBits1- a FormulapBits2- a Formula- Returns:
bits1 | bits2
-
or
-
xor
Description copied from interface:BitvectorFormulaManagerThis method returns the bit-wise XOR of the given bitvectors.- Specified by:
xorin interfaceBitvectorFormulaManager- Parameters:
pBits1- a FormulapBits2- a Formula- Returns:
bits1 ^ bits2
-
xor
-
makeBitvector
Description copied from interface:BitvectorFormulaManagerConvert a number into a bitvector with given size.- Specified by:
makeBitvectorin interfaceBitvectorFormulaManager
-
makeBitvectorImpl
-
makeBitvector
Description copied from interface:BitvectorFormulaManagerConvert a number into a bitvector with given size.- Specified by:
makeBitvectorin interfaceBitvectorFormulaManager
-
makeBitvectorImpl
-
transformValueToRange
transform a negative value into its positive counterpart.- Throws:
IllegalArgumentException- if the value is out of range for the given size.
-
makeVariable
- Specified by:
makeVariablein interfaceBitvectorFormulaManager- See Also:
-
makeVariable
Description copied from interface:BitvectorFormulaManagerCreates 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.- Specified by:
makeVariablein interfaceBitvectorFormulaManager
-
makeVariableImpl
-
shiftRight
public BitvectorFormula shiftRight(BitvectorFormula pNumber, BitvectorFormula toShift, boolean signed) Return a term representing the (arithmetic if signed is true) right shift of number by toShift.- Specified by:
shiftRightin interfaceBitvectorFormulaManager
-
shiftRight
protected abstract TFormulaInfo shiftRight(TFormulaInfo pNumber, TFormulaInfo toShift, boolean signed) -
shiftLeft
Description copied from interface:BitvectorFormulaManagerThis 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.- Specified by:
shiftLeftin interfaceBitvectorFormulaManager
-
shiftLeft
-
concat
Description copied from interface:BitvectorFormulaManagerConcatenate two bitvectors.- Specified by:
concatin interfaceBitvectorFormulaManager
-
concat
-
extract
Description copied from interface:BitvectorFormulaManagerExtract 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.
- Specified by:
extractin interfaceBitvectorFormulaManager- Parameters:
pNumber- from where the bits are extracted.pMsb- Upper index for the most significant bit. Must be in interval from lsb to bitsize-1.pLsb- Lower index for the least significant bit. Must be in interval from 0 to msb.
-
extract
-
extend
Description copied from interface:BitvectorFormulaManagerExtend 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".- Specified by:
extendin interfaceBitvectorFormulaManager- Parameters:
pNumber- The bitvector to extend.pExtensionBits- How many bits to add.pSigned- Whether the extension should depend on the sign bit.
-
extend
-
getLength
Description copied from interface:BitvectorFormulaManagerThis method returns the length of a bitvector, also denoted as bit-size.- Specified by:
getLengthin interfaceBitvectorFormulaManager
-
distinct
Description copied from interface:BitvectorFormulaManagerAll given bitvectors are pairwise unequal.- Specified by:
distinctin interfaceBitvectorFormulaManager
-
distinctImpl
-
getFormulaCreator
-
toSolverType
-