TFormulaInfo - The solver specific type.public abstract class AbstractFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> extends Object implements FormulaManager
| Modifier and Type | Field and Description |
|---|---|
static ImmutableSet<String> |
BASIC_OPERATORS
Avoid using basic mathematical or logical operators of SMT-LIB2 as names for symbols.
|
static ImmutableBiMap<Character,String> |
DISALLOWED_CHARACTER_REPLACEMENT
Mapping of disallowed char to their escaped counterparts.
|
static ImmutableSet<String> |
SMTLIB2_KEYWORDS
Avoid using basic keywords of SMT-LIB2 as names for symbols.
|
| Modifier | Constructor and Description |
|---|---|
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)
Builds a solver from the given theory implementations.
|
| Modifier and Type | Method and Description |
|---|---|
protected BooleanFormula |
applyCNFImpl(BooleanFormula pF) |
protected BooleanFormula |
applyNNFImpl(BooleanFormula input) |
protected BooleanFormula |
applyQELightImpl(BooleanFormula pF) |
BooleanFormula |
applyTactic(BooleanFormula f,
Tactic tactic)
Apply a tactic which performs formula transformation.
|
protected BooleanFormula |
applyUFEImpl(BooleanFormula pF) |
static void |
checkVariableName(String variableName)
This method is similar to
isValidName(java.lang.String) and throws an exception for invalid symbol
names. |
Appender |
dumpFormula(BooleanFormula t)
Serialize an input formula to an SMT-LIB format.
|
abstract Appender |
dumpFormula(TFormulaInfo t) |
String |
escape(String pVar)
Get an escaped symbol/name for variables or undefined functions, if necessary.
|
TFormulaInfo |
extractInfo(Formula f) |
Map<String,Formula> |
extractVariables(Formula f)
Extract names of all free variables in a formula.
|
Map<String,Formula> |
extractVariablesAndUFs(Formula f)
Extract the names of all free variables and UFs in a formula.
|
ArrayFormulaManager |
getArrayFormulaManager()
Returns the Array-Theory.
|
AbstractBitvectorFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> |
getBitvectorFormulaManager()
Returns the Bitvector-Theory.
|
AbstractBooleanFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> |
getBooleanFormulaManager()
Returns the Boolean-Theory.
|
TEnv |
getEnvironment() |
FloatingPointFormulaManager |
getFloatingPointFormulaManager()
Returns the Floating-Point-Theory.
|
FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> |
getFormulaCreator() |
<T extends Formula> |
getFormulaType(T formula)
Returns the type of the given Formula.
|
IntegerFormulaManager |
getIntegerFormulaManager()
Returns the Integer-Theory.
|
AbstractQuantifiedFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> |
getQuantifiedFormulaManager()
Returns the interface for handling quantifiers.
|
RationalFormulaManager |
getRationalFormulaManager()
Returns the Rational-Theory.
|
AbstractUFManager<TFormulaInfo,?,TType,TEnv> |
getUFManager()
Returns the function for dealing with uninterpreted functions (UFs).
|
boolean |
isValidName(String pVar)
Check whether the given String can be used as symbol/name for variables or undefined functions.
|
<T extends Formula> |
makeApplication(FunctionDeclaration<T> declaration,
Formula... args)
Create a function application to the given list of arguments.
|
<T extends Formula> |
makeApplication(FunctionDeclaration<T> declaration,
List<? extends Formula> args)
Create a function application to the given list of arguments.
|
<T extends Formula> |
makeVariable(FormulaType<T> formulaType,
String name)
Create variable of the type equal to
formulaType. |
<T extends Formula> |
simplify(T f)
Simplify an input formula, while ensuring equivalence.
|
protected TFormulaInfo |
simplify(TFormulaInfo f) |
<T extends Formula> |
substitute(T pF,
Map<? extends Formula,? extends Formula> pFromToMapping)
Substitute every occurrence of any item from
changeFrom in formula f to the
corresponding occurrence from changeTo. |
<T extends Formula> |
transformRecursively(T f,
FormulaTransformationVisitor pFormulaVisitor)
Visit the formula recursively with a given
FormulaVisitor. |
BooleanFormula |
translateFrom(BooleanFormula other,
FormulaManager otherContext)
Translates the formula from another context into the context represented by
this. |
String |
unescape(String pVar)
Unescape the symbol/name for variables or undefined functions, if necessary.
|
<R> R |
visit(Formula input,
FormulaVisitor<R> visitor)
Visit the formula with a given visitor.
|
void |
visitRecursively(Formula pF,
FormulaVisitor<TraversalProcess> pFormulaVisitor)
Visit the formula recursively with a given
FormulaVisitor. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitparsepublic static final ImmutableSet<String> BASIC_OPERATORS
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.
public static final ImmutableSet<String> SMTLIB2_KEYWORDS
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.
public static final ImmutableBiMap<Character,String> DISALLOWED_CHARACTER_REPLACEMENT
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)
public final FormulaCreator<TFormulaInfo,TType,TEnv,TFuncDecl> getFormulaCreator()
public IntegerFormulaManager getIntegerFormulaManager()
FormulaManagergetIntegerFormulaManager in interface FormulaManagerpublic RationalFormulaManager getRationalFormulaManager()
FormulaManagergetRationalFormulaManager in interface FormulaManagerpublic AbstractBooleanFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> getBooleanFormulaManager()
FormulaManagergetBooleanFormulaManager in interface FormulaManagerpublic AbstractBitvectorFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> getBitvectorFormulaManager()
FormulaManagergetBitvectorFormulaManager in interface FormulaManagerpublic FloatingPointFormulaManager getFloatingPointFormulaManager()
FormulaManagergetFloatingPointFormulaManager in interface FormulaManagerpublic AbstractUFManager<TFormulaInfo,?,TType,TEnv> getUFManager()
FormulaManagergetUFManager in interface FormulaManagerpublic AbstractQuantifiedFormulaManager<TFormulaInfo,TType,TEnv,TFuncDecl> getQuantifiedFormulaManager()
FormulaManagergetQuantifiedFormulaManager in interface FormulaManagerpublic ArrayFormulaManager getArrayFormulaManager()
FormulaManagergetArrayFormulaManager in interface FormulaManagerpublic abstract Appender dumpFormula(TFormulaInfo t)
public Appender dumpFormula(BooleanFormula t)
FormulaManagerTo 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.
dumpFormula in interface FormulaManagerpublic final <T extends Formula> FormulaType<T> getFormulaType(T formula)
FormulaManagergetFormulaType in interface FormulaManagerpublic final TEnv getEnvironment()
public final TFormulaInfo extractInfo(Formula f)
public BooleanFormula applyTactic(BooleanFormula f, Tactic tactic) throws InterruptedException
FormulaManagerapplyTactic in interface FormulaManagerInterruptedExceptionprotected BooleanFormula applyUFEImpl(BooleanFormula pF) throws InterruptedException
pF - Input to apply the UFE transformation to.InterruptedException - Can be thrown by the native code.protected BooleanFormula applyQELightImpl(BooleanFormula pF) throws InterruptedException
InterruptedException - Can be thrown by the native code.protected BooleanFormula applyCNFImpl(BooleanFormula pF) throws InterruptedException
pF - Input to apply the CNF transformation to.InterruptedException - Can be thrown by the native code.protected BooleanFormula applyNNFImpl(BooleanFormula input) throws InterruptedException
InterruptedException - Can be thrown by the native code.public <T extends Formula> T simplify(T f) throws InterruptedException
FormulaManagerFor solvers that do not provide a simplification API, an original formula is returned.
simplify in interface FormulaManagerf - The input formulaInterruptedExceptionprotected TFormulaInfo simplify(TFormulaInfo f) throws InterruptedException
InterruptedException - Can be thrown by the native code.public <R> R visit(Formula input, FormulaVisitor<R> visitor)
FormulaManagervisit in interface FormulaManagerpublic void visitRecursively(Formula pF, FormulaVisitor<TraversalProcess> pFormulaVisitor)
FormulaManagerFormulaVisitor.
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.
visitRecursively in interface FormulaManagerpublic <T extends Formula> T transformRecursively(T f, FormulaTransformationVisitor pFormulaVisitor)
FormulaManagerFormulaVisitor.
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.
transformRecursively in interface FormulaManagerpFormulaVisitor - Transformation described by the user.public Map<String,Formula> extractVariables(Formula f)
extractVariables in interface FormulaManagerf - The input formulapublic Map<String,Formula> extractVariablesAndUFs(Formula f)
extractVariablesAndUFs in interface FormulaManagerf - The input formulapublic BooleanFormula translateFrom(BooleanFormula other, FormulaManager otherContext)
FormulaManagerthis.
Default implementation relies on string serialization (FormulaManager.dumpFormula(BooleanFormula) and
FormulaManager.parse(String)), but each solver may implement more efficient translation between its
own contexts.translateFrom in interface FormulaManagerother - Formula belonging to otherContext.otherContext - Formula manager belonging to the other context.this context.public <T extends Formula> T makeVariable(FormulaType<T> formulaType, String name)
FormulaManagerformulaType.makeVariable in interface FormulaManagerformulaType - the type of the variable.name - the name of the variable.public <T extends Formula> T makeApplication(FunctionDeclaration<T> declaration, List<? extends Formula> args)
FormulaManagermakeApplication in interface FormulaManagerdeclaration - Function declarationargs - List of argumentspublic <T extends Formula> T makeApplication(FunctionDeclaration<T> declaration, Formula... args)
FormulaManagermakeApplication in interface FormulaManagerdeclaration - Function declarationargs - List of argumentspublic <T extends Formula> T substitute(T pF, Map<? extends Formula,? extends Formula> pFromToMapping)
FormulaManagerchangeFrom in formula f to the
corresponding occurrence from changeTo.
E.g. if changeFrom contains a variable a and changeTo contains a
variable b all occurrences of a will be changed to b in the returned
formula.
substitute in interface FormulaManagerpF - Formula to change.pFromToMapping - Mapping of old and new formula parts.public final boolean isValidName(String pVar)
This method must be kept in sync with checkVariableName(java.lang.String).
isValidName in interface FormulaManagerpublic static void checkVariableName(String variableName)
isValidName(java.lang.String) and throws an exception for invalid symbol
names. While isValidName(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).
public final String escape(String pVar)
FormulaManagerSee FormulaManager.isValidName(String) for further details.
escape in interface FormulaManagerpublic final String unescape(String pVar)
FormulaManagerThe result is undefined for Strings that are not properly escaped.
See FormulaManager.isValidName(String) for further details.
unescape in interface FormulaManager