Class AbstractFloatingPointFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl>
- java.lang.Object
-
- org.sosy_lab.java_smt.basicimpl.AbstractFloatingPointFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl>
-
- All Implemented Interfaces:
FloatingPointFormulaManager
public abstract class AbstractFloatingPointFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> extends Object implements FloatingPointFormulaManager
Similar to the other Abstract*FormulaManager classes in this package, this class serves as a helper for implementingFloatingPointFormulaManager. It handles all the unwrapping and wrapping from and to theFormulainstances, such that the concrete class needs to handle only its own internal types.For
multiply(FloatingPointFormula, FloatingPointFormula), anddivide(FloatingPointFormula, FloatingPointFormula)this class even offers an implementation based on UFs. Sub-classes are supposed to override them if they can implement these operations more precisely (for example multiplication with constants should be supported by all solvers and implemented by all sub-classes).
-
-
Field Summary
Fields Modifier and Type Field Description protected FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl>formulaCreator
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFloatingPointFormulaManager(FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> pCreator)
-
Method Summary
-
-
-
Field Detail
-
formulaCreator
protected final FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> formulaCreator
-
-
Constructor Detail
-
AbstractFloatingPointFormulaManager
protected AbstractFloatingPointFormulaManager(FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> pCreator)
-
-
Method Detail
-
getDefaultRoundingMode
protected abstract TFormulaInfo getDefaultRoundingMode()
-
getRoundingModeImpl
protected abstract TFormulaInfo getRoundingModeImpl(FloatingPointRoundingMode pFloatingPointRoundingMode)
-
wrap
protected FloatingPointFormula wrap(TFormulaInfo pTerm)
-
makeNumber
public FloatingPointFormula makeNumber(Rational n, FormulaType.FloatingPointType type)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumber
public FloatingPointFormula makeNumber(Rational n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumber
public FloatingPointFormula makeNumber(double n, FormulaType.FloatingPointType type)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumber
public FloatingPointFormula makeNumber(double n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumberImpl
protected abstract TFormulaInfo makeNumberImpl(double n, FormulaType.FloatingPointType type, TFormulaInfo pFloatingPointRoundingMode)
-
makeNumber
public FloatingPointFormula makeNumber(BigDecimal n, FormulaType.FloatingPointType type)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumber
public FloatingPointFormula makeNumber(BigDecimal n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumberImpl
protected TFormulaInfo makeNumberImpl(BigDecimal n, FormulaType.FloatingPointType type, TFormulaInfo pFloatingPointRoundingMode)
-
makeNumber
public FloatingPointFormula makeNumber(String n, FormulaType.FloatingPointType type)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumber
public FloatingPointFormula makeNumber(String n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
makeNumberin interfaceFloatingPointFormulaManager
-
makeNumberImpl
protected TFormulaInfo makeNumberImpl(String n, FormulaType.FloatingPointType type, TFormulaInfo pFloatingPointRoundingMode)
directly catch the most common special String constants.
-
isNegativeZero
protected static boolean isNegativeZero(Double pN)
-
makeNumberAndRound
protected abstract TFormulaInfo makeNumberAndRound(String pN, FormulaType.FloatingPointType pType, TFormulaInfo pFloatingPointRoundingMode)
-
makeVariable
public FloatingPointFormula makeVariable(String pVar, FormulaType.FloatingPointType pType)
Description copied from interface:FloatingPointFormulaManagerCreates a variable with exactly the given name.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 interfaceFloatingPointFormulaManager
-
makeVariableImpl
protected abstract TFormulaInfo makeVariableImpl(String pVar, FormulaType.FloatingPointType pType)
-
makePlusInfinity
public FloatingPointFormula makePlusInfinity(FormulaType.FloatingPointType pType)
- Specified by:
makePlusInfinityin interfaceFloatingPointFormulaManager
-
makePlusInfinityImpl
protected abstract TFormulaInfo makePlusInfinityImpl(FormulaType.FloatingPointType pType)
-
makeMinusInfinity
public FloatingPointFormula makeMinusInfinity(FormulaType.FloatingPointType pType)
- Specified by:
makeMinusInfinityin interfaceFloatingPointFormulaManager
-
makeMinusInfinityImpl
protected abstract TFormulaInfo makeMinusInfinityImpl(FormulaType.FloatingPointType pType)
-
makeNaN
public FloatingPointFormula makeNaN(FormulaType.FloatingPointType pType)
- Specified by:
makeNaNin interfaceFloatingPointFormulaManager
-
makeNaNImpl
protected abstract TFormulaInfo makeNaNImpl(FormulaType.FloatingPointType pType)
-
castTo
public <T extends Formula> T castTo(FloatingPointFormula pNumber, FormulaType<T> pTargetType)
- Specified by:
castToin interfaceFloatingPointFormulaManager
-
castTo
public <T extends Formula> T castTo(FloatingPointFormula number, FormulaType<T> targetType, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
castToin interfaceFloatingPointFormulaManager
-
castToImpl
protected abstract TFormulaInfo castToImpl(TFormulaInfo pNumber, FormulaType<?> pTargetType, TFormulaInfo pRoundingMode)
-
castFrom
public FloatingPointFormula castFrom(Formula pNumber, boolean pSigned, FormulaType.FloatingPointType pTargetType)
Description copied from interface:FloatingPointFormulaManagerBuild aFloatingPointFormulafrom another compatible formula. This method uses the default rounding mode.Compatible formula types are all numeral types and bitvector types. It is also possible to cast a floating-point number into another floating-point type. We do not support casting from boolean or array types. We try to keep an exact representation, however fall back to rounding if needed.
- Specified by:
castFromin interfaceFloatingPointFormulaManager- Parameters:
pNumber- the source formula of compatible typepSigned- if aBitvectorFormulais given as source, we additionally use this flag. Otherwise, we ignore it.pTargetType- the type of the resulting formula
-
castFrom
public FloatingPointFormula castFrom(Formula number, boolean signed, FormulaType.FloatingPointType targetType, FloatingPointRoundingMode pFloatingPointRoundingMode)
Description copied from interface:FloatingPointFormulaManagerBuild aFloatingPointFormulafrom another compatible formula.Compatible formula types are all numeral types and bitvector types. It is also possible to cast a floating-point number into another floating-point type. We do not support casting from boolean or array types. We try to keep an exact representation, however fall back to rounding if needed.
- Specified by:
castFromin interfaceFloatingPointFormulaManager- Parameters:
number- the source formula of compatible typesigned- if aBitvectorFormulais given as source, we additionally use this flag. Otherwise, we ignore it.targetType- the type of the resulting formulapFloatingPointRoundingMode- if rounding is needed, we apply the rounding mode.
-
castFromImpl
protected abstract TFormulaInfo castFromImpl(TFormulaInfo pNumber, boolean pSigned, FormulaType.FloatingPointType pTargetType, TFormulaInfo pRoundingMode)
-
fromIeeeBitvector
public FloatingPointFormula fromIeeeBitvector(BitvectorFormula pNumber, FormulaType.FloatingPointType pTargetType)
Description copied from interface:FloatingPointFormulaManagerCreate a formula that interprets the given bitvector as a floating-point value in the IEEE format, according to the given type. The sum of the sizes of exponent and mantissa of the target type plus 1 (for the sign bit) needs to be equal to the size of the bitvector.Note: This method will return a value that is (numerically) far away from the original value. This method is completely different from
FloatingPointFormulaManager.castFrom(org.sosy_lab.java_smt.api.Formula, boolean, org.sosy_lab.java_smt.api.FormulaType.FloatingPointType), which will produce a floating-point value close to the numeral value.- Specified by:
fromIeeeBitvectorin interfaceFloatingPointFormulaManager
-
fromIeeeBitvectorImpl
protected abstract TFormulaInfo fromIeeeBitvectorImpl(TFormulaInfo pNumber, FormulaType.FloatingPointType pTargetType)
-
toIeeeBitvector
public BitvectorFormula toIeeeBitvector(FloatingPointFormula pNumber)
Description copied from interface:FloatingPointFormulaManagerCreate a formula that produces a representation of the given floating-point value as a bitvector conforming to the IEEE format. The size of the resulting bitvector is the sum of the sizes of the exponent and mantissa of the input formula plus 1 (for the sign bit).- Specified by:
toIeeeBitvectorin interfaceFloatingPointFormulaManager
-
toIeeeBitvectorImpl
protected abstract TFormulaInfo toIeeeBitvectorImpl(TFormulaInfo pNumber)
-
negate
public FloatingPointFormula negate(FloatingPointFormula pNumber)
- Specified by:
negatein interfaceFloatingPointFormulaManager
-
negate
protected abstract TFormulaInfo negate(TFormulaInfo pParam1)
-
abs
public FloatingPointFormula abs(FloatingPointFormula pNumber)
- Specified by:
absin interfaceFloatingPointFormulaManager
-
abs
protected abstract TFormulaInfo abs(TFormulaInfo pParam1)
-
max
public FloatingPointFormula max(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
maxin interfaceFloatingPointFormulaManager
-
max
protected abstract TFormulaInfo max(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
min
public FloatingPointFormula min(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
minin interfaceFloatingPointFormulaManager
-
min
protected abstract TFormulaInfo min(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
sqrt
public FloatingPointFormula sqrt(FloatingPointFormula pNumber)
- Specified by:
sqrtin interfaceFloatingPointFormulaManager
-
sqrt
public FloatingPointFormula sqrt(FloatingPointFormula number, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
sqrtin interfaceFloatingPointFormulaManager
-
sqrt
protected abstract TFormulaInfo sqrt(TFormulaInfo pNumber, TFormulaInfo pRoundingMode)
-
add
public FloatingPointFormula add(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
addin interfaceFloatingPointFormulaManager
-
add
public FloatingPointFormula add(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
addin interfaceFloatingPointFormulaManager
-
add
protected abstract TFormulaInfo add(TFormulaInfo pParam1, TFormulaInfo pParam2, TFormulaInfo pRoundingMode)
-
subtract
public FloatingPointFormula subtract(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
subtractin interfaceFloatingPointFormulaManager
-
subtract
public FloatingPointFormula subtract(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
subtractin interfaceFloatingPointFormulaManager
-
subtract
protected abstract TFormulaInfo subtract(TFormulaInfo pParam1, TFormulaInfo pParam2, TFormulaInfo pFloatingPointRoundingMode)
-
divide
public FloatingPointFormula divide(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
dividein interfaceFloatingPointFormulaManager
-
divide
public FloatingPointFormula divide(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
dividein interfaceFloatingPointFormulaManager
-
divide
protected abstract TFormulaInfo divide(TFormulaInfo pParam1, TFormulaInfo pParam2, TFormulaInfo pFloatingPointRoundingMode)
-
multiply
public FloatingPointFormula multiply(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
multiplyin interfaceFloatingPointFormulaManager
-
multiply
public FloatingPointFormula multiply(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode)
- Specified by:
multiplyin interfaceFloatingPointFormulaManager
-
multiply
protected abstract TFormulaInfo multiply(TFormulaInfo pParam1, TFormulaInfo pParam2, TFormulaInfo pFloatingPointRoundingMode)
-
assignment
public BooleanFormula assignment(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
Description copied from interface:FloatingPointFormulaManagerCreate a term for assigning one floating-point term to another. This means both terms are considered equal afterwards. This method is the same as the methodequalfor other theories.- Specified by:
assignmentin interfaceFloatingPointFormulaManager
-
assignment
protected abstract TFormulaInfo assignment(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
equalWithFPSemantics
public BooleanFormula equalWithFPSemantics(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
Description copied from interface:FloatingPointFormulaManagerCreate a term for comparing the equality of two floating-point terms, according to standard floating-point semantics (i.e., NaN != NaN). Be careful to not use this method when you really needFloatingPointFormulaManager.assignment(FloatingPointFormula, FloatingPointFormula).- Specified by:
equalWithFPSemanticsin interfaceFloatingPointFormulaManager
-
equalWithFPSemantics
protected abstract TFormulaInfo equalWithFPSemantics(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
greaterThan
public BooleanFormula greaterThan(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
greaterThanin interfaceFloatingPointFormulaManager
-
greaterThan
protected abstract TFormulaInfo greaterThan(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
greaterOrEquals
public BooleanFormula greaterOrEquals(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
greaterOrEqualsin interfaceFloatingPointFormulaManager
-
greaterOrEquals
protected abstract TFormulaInfo greaterOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
lessThan
public BooleanFormula lessThan(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
lessThanin interfaceFloatingPointFormulaManager
-
lessThan
protected abstract TFormulaInfo lessThan(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
lessOrEquals
public BooleanFormula lessOrEquals(FloatingPointFormula pNumber1, FloatingPointFormula pNumber2)
- Specified by:
lessOrEqualsin interfaceFloatingPointFormulaManager
-
lessOrEquals
protected abstract TFormulaInfo lessOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
isNaN
public BooleanFormula isNaN(FloatingPointFormula pNumber)
- Specified by:
isNaNin interfaceFloatingPointFormulaManager
-
isNaN
protected abstract TFormulaInfo isNaN(TFormulaInfo pParam)
-
isInfinity
public BooleanFormula isInfinity(FloatingPointFormula pNumber)
- Specified by:
isInfinityin interfaceFloatingPointFormulaManager
-
isInfinity
protected abstract TFormulaInfo isInfinity(TFormulaInfo pParam)
-
isZero
public BooleanFormula isZero(FloatingPointFormula pNumber)
- Specified by:
isZeroin interfaceFloatingPointFormulaManager
-
isZero
protected abstract TFormulaInfo isZero(TFormulaInfo pParam)
-
isSubnormal
public BooleanFormula isSubnormal(FloatingPointFormula pNumber)
- Specified by:
isSubnormalin interfaceFloatingPointFormulaManager
-
isSubnormal
protected abstract TFormulaInfo isSubnormal(TFormulaInfo pParam)
-
isNormal
public BooleanFormula isNormal(FloatingPointFormula pNumber)
- Specified by:
isNormalin interfaceFloatingPointFormulaManager
-
isNormal
protected abstract TFormulaInfo isNormal(TFormulaInfo pParam)
-
isNegative
public BooleanFormula isNegative(FloatingPointFormula pNumber)
Description copied from interface:FloatingPointFormulaManagerchecks whether a formula is negative, including -0.0.- Specified by:
isNegativein interfaceFloatingPointFormulaManager
-
isNegative
protected abstract TFormulaInfo isNegative(TFormulaInfo pParam)
-
round
public FloatingPointFormula round(FloatingPointFormula pFormula, FloatingPointRoundingMode pRoundingMode)
- Specified by:
roundin interfaceFloatingPointFormulaManager
-
round
protected abstract TFormulaInfo round(TFormulaInfo pFormula, FloatingPointRoundingMode pRoundingMode)
-
getFormulaCreator
protected final FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> getFormulaCreator()
-
toSolverType
protected final TType toSolverType(FormulaType<?> formulaType)
-
-