Class AbstractFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl>
- Type Parameters:
TFormulaInfo- The solver specific type.
- All Implemented Interfaces:
FormulaManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ImmutableSet<String>Avoid using basic mathematical or logical operators of SMT-LIB2 as names for symbols.static final ImmutableBiMap<Character,String> Mapping of disallowed char to their escaped counterparts.static final ImmutableSet<String>Avoid using basic keywords of SMT-LIB2 as names for symbols. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFormulaManager(FormulaCreator<TFormulaInfo, TType, TEnv, TFuncDecl> pFormulaCreator, AbstractUFManager<TFormulaInfo, ?, TType, TEnv> functionManager, AbstractBooleanFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> booleanManager, @Nullable IntegerFormulaManager pIntegerManager, @Nullable RationalFormulaManager pRationalManager, @Nullable AbstractBitvectorFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> bitvectorManager, @Nullable AbstractFloatingPointFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> floatingPointManager, @Nullable AbstractQuantifiedFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> quantifiedManager, @Nullable AbstractArrayFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> arrayManager, @Nullable AbstractSLFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> slManager, @Nullable AbstractStringFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> strManager, @Nullable AbstractEnumerationFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> enumManager) Builds a solver from the given theory implementations. -
Method Summary
Modifier and TypeMethodDescriptionprotected BooleanFormulaApply conjunctive normal form (CNF) transformation to the given input formula.protected BooleanFormulaapplyNNFImpl(BooleanFormula input) Apply negation normal form (NNF) transformation to the given input formula.protected BooleanFormulaEliminate quantifiers from the given input formula.applyTactic(BooleanFormula f, Tactic tactic) Apply a tactic which performs formula transformation.protected BooleanFormulaEliminate UFs from the given input formula.static voidcheckVariableName(String variableName) This method is similar toisValidName(java.lang.String)and throws an exception for invalid symbol names.Serialize an input formula to an SMT-LIB format.abstract Appenderfinal StringGet an escaped symbol/name for variables or undefined functions, if necessary.final TFormulaInfoExtract names of all free variables in a formula.Extract the names of all free variables and UFs in a formula.Returns the Array-Theory.Returns the Bitvector-Theory.Returns the Boolean-Theory.Returns the Enumeration Theory, e.g., also known as 'limited domain'.final TEnvReturns the Floating-Point-Theory.final FormulaCreator<TFormulaInfo,TType, TEnv, TFuncDecl> final <T extends Formula>
FormulaType<T>getFormulaType(T formula) Returns the type of the given Formula.Returns the Integer-Theory.Returns the interface for handling quantifiers.Returns the Rational-Theory.Returns the Seperation-Logic-Theory.Returns the String Theory.Returns the function for dealing with uninterpreted functions (UFs).final booleanisValidName(String pVar) Check whether the given String can be used as symbol/name for variables or undefined functions.<T extends Formula>
TmakeApplication(FunctionDeclaration<T> declaration, List<? extends Formula> args) Create a function application to the given list of arguments.<T extends Formula>
TmakeApplication(FunctionDeclaration<T> declaration, Formula... args) Create a function application to the given list of arguments.<T extends Formula>
TmakeVariable(FormulaType<T> formulaType, String name) Create variable of the type equal toformulaType.<T extends Formula>
Tsimplify(T f) Simplify an input formula, while ensuring equivalence.protected TFormulaInfoApply a simplification procedure for the given formula.<T extends Formula>
Tsubstitute(T pF, Map<? extends Formula, ? extends Formula> pFromToMapping) Substitute every occurrence of any item fromchangeFromin formulafto the corresponding occurrence fromchangeTo.<T extends Formula>
TtransformRecursively(T f, FormulaTransformationVisitor pFormulaVisitor) Visit the formula recursively with a givenFormulaVisitor.translateFrom(BooleanFormula formula, FormulaManager otherManager) Translates the formula from another context into the context represented bythis.final StringUnescape the symbol/name for variables or undefined functions, if necessary.<R> Rvisit(Formula input, FormulaVisitor<R> visitor) Visit the formula with a given visitor.voidvisitRecursively(Formula pF, FormulaVisitor<TraversalProcess> pFormulaVisitor) Visit the formula recursively with a givenFormulaVisitor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.sosy_lab.java_smt.api.FormulaManager
parse
-
Field Details
-
BASIC_OPERATORS
Avoid using basic mathematical or logical operators of SMT-LIB2 as names for symbols.We do not accept some names as identifiers for variables or UFs, because they easily misguide the user. Most solvers even would allow such identifiers directly, currently only SMTInterpol has problems with some of them. For consistency, we disallow those names for all solvers.
-
SMTLIB2_KEYWORDS
Avoid using basic keywords of SMT-LIB2 as names for symbols.We do not accept some names as identifiers for variables or UFs, because they easily misguide the user. Most solvers even would allow such identifiers directly, currently only SMTInterpol has problems with some of them. For consistency, we disallow those names for all solvers.
-
DISALLOWED_CHARACTER_REPLACEMENT
Mapping of disallowed char to their escaped counterparts.
-
-
Constructor Details
-
AbstractFormulaManager
protected AbstractFormulaManager(FormulaCreator<TFormulaInfo, TType, TEnv, TFuncDecl> pFormulaCreator, AbstractUFManager<TFormulaInfo, ?, TType, TEnv> functionManager, AbstractBooleanFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> booleanManager, @Nullable IntegerFormulaManager pIntegerManager, @Nullable RationalFormulaManager pRationalManager, @Nullable AbstractBitvectorFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> bitvectorManager, @Nullable AbstractFloatingPointFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> floatingPointManager, @Nullable AbstractQuantifiedFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> quantifiedManager, @Nullable AbstractArrayFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> arrayManager, @Nullable AbstractSLFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> slManager, @Nullable AbstractStringFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> strManager, @Nullable AbstractEnumerationFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> enumManager) Builds a solver from the given theory implementations.
-
-
Method Details
-
getFormulaCreator
-
getIntegerFormulaManager
Description copied from interface:FormulaManagerReturns the Integer-Theory. Because most SAT-solvers support automatic casting between Integer- and Rational-Theory, the Integer- and the RationalFormulaManager both return the same Formulas for numeric operations like ADD, SUBTRACT, TIMES, LESSTHAN, EQUAL and others.- Specified by:
getIntegerFormulaManagerin interfaceFormulaManager
-
getRationalFormulaManager
Description copied from interface:FormulaManagerReturns the Rational-Theory. Because most SAT-solvers support automatic casting between Integer- and Rational-Theory, the Integer- and the RationalFormulaManager both return the same Formulas for numeric operations like ADD, SUBTRACT, TIMES, LESSTHAN, EQUAL, etc.- Specified by:
getRationalFormulaManagerin interfaceFormulaManager
-
getBooleanFormulaManager
Description copied from interface:FormulaManagerReturns the Boolean-Theory.- Specified by:
getBooleanFormulaManagerin interfaceFormulaManager
-
getBitvectorFormulaManager
public AbstractBitvectorFormulaManager<TFormulaInfo,TType, getBitvectorFormulaManager()TEnv, TFuncDecl> Description copied from interface:FormulaManagerReturns the Bitvector-Theory.- Specified by:
getBitvectorFormulaManagerin interfaceFormulaManager
-
getFloatingPointFormulaManager
Description copied from interface:FormulaManagerReturns the Floating-Point-Theory.- Specified by:
getFloatingPointFormulaManagerin interfaceFormulaManager
-
getUFManager
Description copied from interface:FormulaManagerReturns the function for dealing with uninterpreted functions (UFs).- Specified by:
getUFManagerin interfaceFormulaManager
-
getSLFormulaManager
Description copied from interface:FormulaManagerReturns the Seperation-Logic-Theory.- Specified by:
getSLFormulaManagerin interfaceFormulaManager
-
getQuantifiedFormulaManager
public AbstractQuantifiedFormulaManager<TFormulaInfo,TType, getQuantifiedFormulaManager()TEnv, TFuncDecl> Description copied from interface:FormulaManagerReturns the interface for handling quantifiers.- Specified by:
getQuantifiedFormulaManagerin interfaceFormulaManager
-
getArrayFormulaManager
Description copied from interface:FormulaManagerReturns the Array-Theory.- Specified by:
getArrayFormulaManagerin interfaceFormulaManager
-
getStringFormulaManager
Description copied from interface:FormulaManagerReturns the String Theory.- Specified by:
getStringFormulaManagerin interfaceFormulaManager
-
getEnumerationFormulaManager
Description copied from interface:FormulaManagerReturns the Enumeration Theory, e.g., also known as 'limited domain'.- Specified by:
getEnumerationFormulaManagerin interfaceFormulaManager
-
dumpFormula
-
dumpFormula
Description copied from interface:FormulaManagerSerialize an input formula to an SMT-LIB format. Very useful when passing formulas between different solvers.To get a String, simply call
Object.toString()on the returned object. This method is lazy and does not create an output string until the returned object is actually used.- Specified by:
dumpFormulain interfaceFormulaManager- Returns:
- SMT-LIB formula serialization.
-
getFormulaType
Description copied from interface:FormulaManagerReturns the type of the given Formula.- Specified by:
getFormulaTypein interfaceFormulaManager
-
getEnvironment
-
extractInfo
-
applyTactic
Description copied from interface:FormulaManagerApply a tactic which performs formula transformation. The available tactics depend on the used solver.- Specified by:
applyTacticin interfaceFormulaManager- Throws:
InterruptedException
-
applyUFEImpl
Eliminate UFs from the given input formula.- Throws:
InterruptedException- Can be thrown by the native code.
-
applyQELightImpl
Eliminate quantifiers from the given input formula.This is the light version that does not need to eliminate all quantifiers.
- Throws:
InterruptedException- Can be thrown by the native code.
-
applyCNFImpl
Apply conjunctive normal form (CNF) transformation to the given input formula.- Parameters:
pF- Input to apply the CNF transformation to.- Throws:
InterruptedException- Can be thrown by the native code.
-
applyNNFImpl
Apply negation normal form (NNF) transformation to the given input formula.- Throws:
InterruptedException- Can be thrown by the native code.
-
simplify
Description copied from interface:FormulaManagerSimplify an input formula, while ensuring equivalence.For solvers that do not provide a simplification API, an original formula is returned.
- Specified by:
simplifyin interfaceFormulaManager- Parameters:
f- The input formula- Returns:
- Simplified version of the formula
- Throws:
InterruptedException
-
simplify
Apply a simplification procedure for the given formula.This does not need to change something, but it might simplify the formula.
- Throws:
InterruptedException- Can be thrown by the native code.
-
visit
Description copied from interface:FormulaManagerVisit the formula with a given visitor.This method does not recursively visit sub-components of a formula its own, so the given
FormulaVisitorneeds to call such visitation on its own.Please be aware that calling this method might cause extensive stack usage depending on the nesting of the given formula and the given
FormulaVisitor. Additionally, sub-formulas that are used several times in the formula might be visited several times. For an efficient formula traversing, we also provideFormulaManager.visitRecursively(Formula, FormulaVisitor).- Specified by:
visitin interfaceFormulaManager- Parameters:
input- formula to be visitedvisitor- an implementation that provides steps for each kind of formula.
-
visitRecursively
Description copied from interface:FormulaManagerVisit the formula recursively with a givenFormulaVisitor. This method traverses sub-components of a formula automatically, depending on the return value of theTraversalProcessin the givenFormulaVisitor.This method guarantees that the traversal is done iteratively, without using Java recursion, and thus is not prone to StackOverflowErrors.
Furthermore, this method also guarantees that every equal part of the formula is visited only once. Thus, it can be used to traverse DAG-like formulas efficiently.
The traversal is done in PRE-ORDER manner with regard to caching identical subtrees, i.e., a parent will be visited BEFORE its children. The unmodified child-formulas are passed as argument to the parent's visitation.
- Specified by:
visitRecursivelyin interfaceFormulaManager
-
transformRecursively
public <T extends Formula> T transformRecursively(T f, FormulaTransformationVisitor pFormulaVisitor) Description copied from interface:FormulaManagerVisit the formula recursively with a givenFormulaVisitor.This method guarantees that the traversal is done iteratively, without using Java recursion, and thus is not prone to StackOverflowErrors.
Furthermore, this method also guarantees that every equal part of the formula is visited only once. Thus, it can be used to traverse DAG-like formulas efficiently.
The traversal is done in POST-ORDER manner with regard to caching identical subtrees, i.e., a parent will be visited AFTER its children. The result of the child-visitation is passed as argument to the parent's visitation.
- Specified by:
transformRecursivelyin interfaceFormulaManagerpFormulaVisitor- Transformation described by the user.
-
extractVariables
Extract names of all free variables in a formula.- Specified by:
extractVariablesin interfaceFormulaManager- Parameters:
f- The input formula- Returns:
- Map from variable names to the corresponding formulas.
-
extractVariablesAndUFs
Extract the names of all free variables and UFs in a formula.- Specified by:
extractVariablesAndUFsin interfaceFormulaManager- Parameters:
f- The input formula- Returns:
- Map from variable names to the corresponding formulas. If an UF occurs multiple times in the input formula, an arbitrary instance of an application of this UF is in the map.
-
translateFrom
Description copied from interface:FormulaManagerTranslates the formula from another context into the context represented bythis. Default implementation relies on string serialization (FormulaManager.dumpFormula(BooleanFormula)andFormulaManager.parse(String)), but each solver may implement more efficient translation between its own contexts.- Specified by:
translateFromin interfaceFormulaManager- Parameters:
formula- Formula belonging tootherContext.otherManager- Formula manager belonging to the other context.- Returns:
- Formula belonging to
thiscontext.
-
makeVariable
Description copied from interface:FormulaManagerCreate variable of the type equal toformulaType.- Specified by:
makeVariablein interfaceFormulaManager- Parameters:
formulaType- the type of the variable.name- the name of the variable.- Returns:
- the created variable.
-
makeApplication
public <T extends Formula> T makeApplication(FunctionDeclaration<T> declaration, List<? extends Formula> args) Description copied from interface:FormulaManagerCreate a function application to the given list of arguments.- Specified by:
makeApplicationin interfaceFormulaManager- Parameters:
declaration- Function declarationargs- List of arguments- Returns:
- Constructed formula
-
makeApplication
Description copied from interface:FormulaManagerCreate a function application to the given list of arguments.- Specified by:
makeApplicationin interfaceFormulaManager- Parameters:
declaration- Function declarationargs- List of arguments- Returns:
- Constructed formula
-
substitute
public <T extends Formula> T substitute(T pF, Map<? extends Formula, ? extends Formula> pFromToMapping) Description copied from interface:FormulaManagerSubstitute every occurrence of any item fromchangeFromin formulafto the corresponding occurrence fromchangeTo.E.g. if
changeFromcontains a variableaandchangeTocontains a variableball occurrences ofawill be changed tobin the returned formula.- Specified by:
substitutein interfaceFormulaManager- Parameters:
pF- Formula to change.pFromToMapping- Mapping of old and new formula parts.- Returns:
- Formula with parts replaced.
-
isValidName
Check whether the given String can be used as symbol/name for variables or undefined functions. We disallow some keywords from SMTLib2 and other basic operators to be used as symbols.This method must be kept in sync with
checkVariableName(java.lang.String).- Specified by:
isValidNamein interfaceFormulaManager
-
checkVariableName
This method is similar toisValidName(java.lang.String)and throws an exception for invalid symbol names. WhileisValidName(java.lang.String)can be used from users, this method should be used internally to validate user-given symbol names.This method must be kept in sync with
isValidName(java.lang.String). -
escape
Description copied from interface:FormulaManagerGet an escaped symbol/name for variables or undefined functions, if necessary.See
FormulaManager.isValidName(String)for further details.- Specified by:
escapein interfaceFormulaManager
-
unescape
Description copied from interface:FormulaManagerUnescape the symbol/name for variables or undefined functions, if necessary.The result is undefined for Strings that are not properly escaped.
See
FormulaManager.isValidName(String)for further details.- Specified by:
unescapein interfaceFormulaManager
-