Package org.sosy_lab.java_smt.basicimpl
Class AbstractNumeralFormulaManager<TFormulaInfo,TType,TEnv,ParamFormulaType extends NumeralFormula,ResultFormulaType extends NumeralFormula,TFuncDecl>
- java.lang.Object
-
- org.sosy_lab.java_smt.basicimpl.AbstractNumeralFormulaManager<TFormulaInfo,TType,TEnv,ParamFormulaType,ResultFormulaType,TFuncDecl>
-
- All Implemented Interfaces:
NumeralFormulaManager<ParamFormulaType,ResultFormulaType>
public abstract class AbstractNumeralFormulaManager<TFormulaInfo,TType,TEnv,ParamFormulaType extends NumeralFormula,ResultFormulaType extends NumeralFormula,TFuncDecl> extends Object implements NumeralFormulaManager<ParamFormulaType,ResultFormulaType>
Similar to the other Abstract*FormulaManager classes in this package, this class serves as a helper for implementingNumeralFormulaManager. It handles all the unwrapping and wrapping fromFormulainstances to solver-specific formula representations, such that the concrete class needs to handle only its own internal types.- Implementation Requirements:
- The method
NumeralFormulaManager.getFormulaType()must be safe to be called from the constructor (the default implementations ofIntegerFormulaManagerandRationalFormulaManagersatisfy this).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractNumeralFormulaManager.NonLinearArithmetic
-
Field Summary
Fields Modifier and Type Field Description protected FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl>formulaCreator
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNumeralFormulaManager(FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> pCreator, AbstractNumeralFormulaManager.NonLinearArithmetic pNonLinearArithmetic)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.sosy_lab.java_smt.api.NumeralFormulaManager
getFormulaType
-
-
-
-
Field Detail
-
formulaCreator
protected final FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> formulaCreator
-
-
Constructor Detail
-
AbstractNumeralFormulaManager
protected AbstractNumeralFormulaManager(FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> pCreator, AbstractNumeralFormulaManager.NonLinearArithmetic pNonLinearArithmetic)
-
-
Method Detail
-
wrap
protected ResultFormulaType wrap(TFormulaInfo pTerm)
-
isNumeral
protected abstract boolean isNumeral(TFormulaInfo val)
Check whether the argument is a numeric constant (including negated constants).
-
makeNumber
public ResultFormulaType makeNumber(long i)
- Specified by:
makeNumberin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
makeNumberImpl
protected abstract TFormulaInfo makeNumberImpl(long i)
-
makeNumber
public ResultFormulaType makeNumber(BigInteger i)
- Specified by:
makeNumberin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
makeNumberImpl
protected abstract TFormulaInfo makeNumberImpl(BigInteger i)
-
makeNumber
public ResultFormulaType makeNumber(String i)
- Specified by:
makeNumberin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
makeNumberImpl
protected abstract TFormulaInfo makeNumberImpl(String i)
-
makeNumber
public ResultFormulaType makeNumber(Rational pRational)
- Specified by:
makeNumberin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
makeNumberImpl
protected TFormulaInfo makeNumberImpl(Rational pRational)
-
makeNumber
public ResultFormulaType makeNumber(double pNumber)
Description copied from interface:NumeralFormulaManagerCreate a numeric literal with a given value. Note: if the theory represented by this instance cannot handle rational numbers, the value may get rounded or otherwise represented imprecisely.- Specified by:
makeNumberin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
makeNumberImpl
protected abstract TFormulaInfo makeNumberImpl(double pNumber)
-
makeNumber
public ResultFormulaType makeNumber(BigDecimal pNumber)
Description copied from interface:NumeralFormulaManagerCreate a numeric literal with a given value. Note: if the theory represented by this instance cannot handle rational numbers, the value may get rounded or otherwise represented imprecisely.- Specified by:
makeNumberin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
makeNumberImpl
protected abstract TFormulaInfo makeNumberImpl(BigDecimal pNumber)
-
decimalAsInteger
protected final TFormulaInfo decimalAsInteger(BigDecimal val)
This method tries to represent a BigDecimal using only BigInteger. It can be used for implementingmakeNumber(BigDecimal)when the current theory supports only integers and division by constants.
-
makeVariable
public ResultFormulaType makeVariable(String pVar)
Description copied from interface:NumeralFormulaManagerCreates 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 interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
makeVariableImpl
protected abstract TFormulaInfo makeVariableImpl(String i)
-
negate
public ResultFormulaType negate(ParamFormulaType pNumber)
- Specified by:
negatein interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
negate
protected abstract TFormulaInfo negate(TFormulaInfo pParam1)
-
add
public ResultFormulaType add(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
addin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
add
protected abstract TFormulaInfo add(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
sum
public ResultFormulaType sum(List<ParamFormulaType> operands)
- Specified by:
sumin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
sumImpl
protected TFormulaInfo sumImpl(List<TFormulaInfo> operands)
-
subtract
public ResultFormulaType subtract(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
subtractin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
subtract
protected abstract TFormulaInfo subtract(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
divide
public ResultFormulaType divide(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
dividein interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
divide
protected TFormulaInfo divide(TFormulaInfo pParam1, TFormulaInfo pParam2)
If a solver does not support this operation, e.g. because of missing support for non-linear arithmetics, we throw UnsupportedOperationException.- Parameters:
pParam1- the dividendpParam2- the divisor
-
modulo
public ResultFormulaType modulo(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
-
modulo
protected TFormulaInfo modulo(TFormulaInfo pParam1, TFormulaInfo pParam2)
If a solver does not support this operation, e.g. because of missing support for non-linear arithmetics, we throw UnsupportedOperationException.- Parameters:
pParam1- the dividendpParam2- the divisor
-
modularCongruence
public BooleanFormula modularCongruence(ParamFormulaType pNumber1, ParamFormulaType pNumber2, long pModulo)
-
modularCongruence
public BooleanFormula modularCongruence(ParamFormulaType pNumber1, ParamFormulaType pNumber2, BigInteger pModulo)
-
modularCongruence
protected TFormulaInfo modularCongruence(TFormulaInfo a, TFormulaInfo b, BigInteger m)
- Parameters:
a- first operandb- second operandm- the modulus- Returns:
- the formula representing
a = b (mod m)
-
modularCongruence
protected TFormulaInfo modularCongruence(TFormulaInfo a, TFormulaInfo b, long m)
- Parameters:
a- first operandb- second operandm- the modulus- Returns:
- the formula representing
a = b (mod m)
-
multiply
public ResultFormulaType multiply(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
multiplyin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
multiply
protected TFormulaInfo multiply(TFormulaInfo pParam1, TFormulaInfo pParam2)
If a solver does not support this operation, e.g. because of missing support for non-linear arithmetics, we throw UnsupportedOperationException.- Parameters:
pParam1- first factorpParam2- second factor
-
equal
public BooleanFormula equal(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
equalin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
equal
protected abstract TFormulaInfo equal(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
distinct
public BooleanFormula distinct(List<ParamFormulaType> pNumbers)
Description copied from interface:NumeralFormulaManagerall given numbers are pairwise unequal.- Specified by:
distinctin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
distinctImpl
protected abstract TFormulaInfo distinctImpl(List<TFormulaInfo> pNumbers)
-
greaterThan
public BooleanFormula greaterThan(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
greaterThanin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
greaterThan
protected abstract TFormulaInfo greaterThan(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
greaterOrEquals
public BooleanFormula greaterOrEquals(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
greaterOrEqualsin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
greaterOrEquals
protected abstract TFormulaInfo greaterOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
lessThan
public BooleanFormula lessThan(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
lessThanin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
lessThan
protected abstract TFormulaInfo lessThan(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
lessOrEquals
public BooleanFormula lessOrEquals(ParamFormulaType pNumber1, ParamFormulaType pNumber2)
- Specified by:
lessOrEqualsin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
lessOrEquals
protected abstract TFormulaInfo lessOrEquals(TFormulaInfo pParam1, TFormulaInfo pParam2)
-
floor
public NumeralFormula.IntegerFormula floor(ParamFormulaType number)
Description copied from interface:NumeralFormulaManagerTheflooroperation returns the nearest integer formula that is less or equal to the given argument formula.For rational formulae, SMTlib2 denotes this operation as
to_int.- Specified by:
floorin interfaceNumeralFormulaManager<TFormulaInfo,TType>
-
floor
protected TFormulaInfo floor(TFormulaInfo number)
-
getFormulaCreator
protected final FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> getFormulaCreator()
-
toSolverType
protected final TType toSolverType(FormulaType<?> formulaType)
-
-