Package org.sosy_lab.java_smt.basicimpl
Class FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl>
java.lang.Object
org.sosy_lab.java_smt.basicimpl.FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl>
- Type Parameters:
TFormulaInfo- the solver specific type for formulas.TType- the solver specific type for formula types.TEnv- the solver specific type for the environment/context.
This is a helper class with several methods that are commonly used throughout the basicimpl
package and may have solver-specific implementations. Each solver package is expected to provide
an instance of this class, with the appropriate methods overwritten. Depending on the solver,
some or all non-final methods in this class may need to be overwritten.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends Formula>
TcallFunction(FunctionDeclaration<T> declaration, List<? extends Formula> args) abstract TFormulaInfocallFunctionImpl(TFuncDecl declaration, List<TFormulaInfo> args) Convert the formula into a Java object as far as possible, i.e., try to match a primitive or simple type like Boolean, BigInteger, Rational, or String.convertValue(TFormulaInfo pAdditionalF, TFormulaInfo pF) Convert the formula into a Java object as far as possible, i.e., try to match a primitive or simple type.abstract TFuncDecldeclareUFImpl(String pName, TType pReturnType, List<TType> pArgTypes) protected static StringVariable names (symbols) can be wrapped with "|".<T extends Formula>
Tencapsulate(FormulaType<T> pType, TFormulaInfo pTerm) protected <TI extends Formula,TE extends Formula>
ArrayFormula<TI,TE> encapsulateArray(TFormulaInfo pTerm, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) protected BitvectorFormulaencapsulateBitvector(TFormulaInfo pTerm) encapsulateBoolean(TFormulaInfo pTerm) protected EnumerationFormulaprotected FloatingPointFormulaprotected RegexFormulaencapsulateRegex(TFormulaInfo pTerm) protected StringFormulaencapsulateString(TFormulaInfo pTerm) protected List<TFormulaInfo>extractInfo(List<? extends Formula> input) protected TFormulaInfoextractInfo(Formula pT) voidextractVariablesAndUFs(Formula pFormula, boolean extractUF, BiConsumer<String, Formula> pConsumer) Extract all free variables from the formula, optionally including UFs.extractVariablesAndUFs(TFormulaInfo pFormula, boolean extractUFs) Wrapper forextractVariablesAndUFs(Formula, boolean, BiConsumer)which unwraps both input and output.voidextractVariablesAndUFs(TFormulaInfo pFormula, boolean extractUFs, BiConsumer<String, TFormulaInfo> pConsumer) Wrapper forextractVariablesAndUFs(Formula, boolean, BiConsumer)which unwraps both input and output.protected <TI extends Formula,TE extends Formula>
FormulaType<TE>getArrayFormulaElementType(ArrayFormula<TI, TE> pArray) protected <TI extends Formula,TE extends Formula>
FormulaType<TI>getArrayFormulaIndexType(ArrayFormula<TI, TE> pArray) abstract TTypegetArrayType(TType indexType, TType elementType) abstract TTypegetBitvectorType(int bitwidth) protected abstract TFuncDeclgetBooleanVarDeclarationImpl(TFormulaInfo pTFormulaInfo) final TTypefinal TEnvgetEnv()abstract TTypeprotected <T extends Formula>
FormulaType<T>getFormulaType(T formula) Returns the type of the given Formula.abstract FormulaType<?>getFormulaType(TFormulaInfo formula) final TTypefinal TTypefinal TTypefinal TTypeprotected booleanisCompatible(FormulaType<?> usedType, FormulaType<?> declaredType) This function checks whether the used type of the function argument is compatible with the declared type in the function declaration.abstract TFormulaInfomakeVariable(TType type, String varName) <T extends Formula>
TtransformRecursively(FormulaVisitor<? extends Formula> pFormulaVisitor, T pF) <T extends Formula>
TtransformRecursively(FormulaVisitor<? extends Formula> pFormulaVisitor, T pF, Predicate<Object> shouldProcess) <R> Rvisit(Formula input, FormulaVisitor<R> visitor) abstract <R> Rvisit(FormulaVisitor<R> visitor, Formula formula, TFormulaInfo f) voidvisitRecursively(FormulaVisitor<TraversalProcess> pFormulaVisitor, Formula pF) voidvisitRecursively(FormulaVisitor<TraversalProcess> pFormulaVisitor, Formula pF, Predicate<Formula> shouldProcess)
-
Field Details
-
environment
-
-
Constructor Details
-
FormulaCreator
-
-
Method Details
-
getEnv
-
getBoolType
-
getIntegerType
-
getRationalType
-
getBitvectorType
-
getFloatingPointType
-
getArrayType
-
getStringType
-
getRegexType
-
makeVariable
-
encapsulateBoolean
-
encapsulateBitvector
-
encapsulateFloatingPoint
-
encapsulateArray
protected <TI extends Formula,TE extends Formula> ArrayFormula<TI,TE> encapsulateArray(TFormulaInfo pTerm, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) -
encapsulateString
-
encapsulateRegex
-
encapsulateEnumeration
-
encapsulateWithTypeOf
-
encapsulate
-
extractInfo
-
getArrayFormulaElementType
protected <TI extends Formula,TE extends Formula> FormulaType<TE> getArrayFormulaElementType(ArrayFormula<TI, TE> pArray) -
getArrayFormulaIndexType
protected <TI extends Formula,TE extends Formula> FormulaType<TI> getArrayFormulaIndexType(ArrayFormula<TI, TE> pArray) -
getFormulaType
Returns the type of the given Formula. -
getFormulaType
-
visit
-
visit
-
extractInfo
-
visitRecursively
-
visitRecursively
public void visitRecursively(FormulaVisitor<TraversalProcess> pFormulaVisitor, Formula pF, Predicate<Formula> shouldProcess) -
transformRecursively
public <T extends Formula> T transformRecursively(FormulaVisitor<? extends Formula> pFormulaVisitor, T pF) -
transformRecursively
public <T extends Formula> T transformRecursively(FormulaVisitor<? extends Formula> pFormulaVisitor, T pF, Predicate<Object> shouldProcess) -
extractVariablesAndUFs
Wrapper forextractVariablesAndUFs(Formula, boolean, BiConsumer)which unwraps both input and output. -
extractVariablesAndUFs
public void extractVariablesAndUFs(TFormulaInfo pFormula, boolean extractUFs, BiConsumer<String, TFormulaInfo> pConsumer) Wrapper forextractVariablesAndUFs(Formula, boolean, BiConsumer)which unwraps both input and output. -
extractVariablesAndUFs
public void extractVariablesAndUFs(Formula pFormula, boolean extractUF, BiConsumer<String, Formula> pConsumer) Extract all free variables from the formula, optionally including UFs. -
callFunction
public final <T extends Formula> T callFunction(FunctionDeclaration<T> declaration, List<? extends Formula> args) -
isCompatible
This function checks whether the used type of the function argument is compatible with the declared type in the function declaration.Identical types are always compatible, a subtype like INT to supertype RATIONAL is also compatible. A solver-specific wrapper can override this method if it does an explicit transformation between (some) types, e.g., from BV to BOOLEAN or from BOOLEAN to INT.
-
callFunctionImpl
-
declareUFImpl
-
getBooleanVarDeclaration
-
getBooleanVarDeclarationImpl
-
convertValue
Convert the formula into a Java object as far as possible, i.e., try to match a primitive or simple type like Boolean, BigInteger, Rational, or String.If the formula is not a simple constant expression, we simply return
null.- Parameters:
pF- the formula to be converted.
-
convertValue
Convert the formula into a Java object as far as possible, i.e., try to match a primitive or simple type.- Parameters:
pAdditionalF- an additional formula where the type can be received from.pF- the formula to be converted.
-
dequote
Variable names (symbols) can be wrapped with "|". This function removes those chars.
-