Class SMTInterpol
java.lang.Object
de.uni_freiburg.informatik.ultimate.logic.NoopScript
de.uni_freiburg.informatik.ultimate.smtinterpol.smtlib2.SMTInterpol
- All Implemented Interfaces:
Script
public class SMTInterpol extends NoopScript
Implementation of the
Script interface to
interact with SMTInterpol.
Users should however stick to the
Script interface which
provides most of the methods provided in this class.- Author:
- Juergen Christ
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSMTInterpol.CheckTypestatic classSMTInterpol.ProofModeNested classes/interfaces inherited from interface de.uni_freiburg.informatik.ultimate.logic.Script
Script.LBool -
Field Summary
Fields inherited from class de.uni_freiburg.informatik.ultimate.logic.NoopScript
mSolverSetup, mStackLevelFields inherited from interface de.uni_freiburg.informatik.ultimate.logic.Script
EMPTY_SORT_ARRAY, EMPTY_TERM_ARRAY, EXISTS, FORALL -
Constructor Summary
Constructors Constructor Description SMTInterpol()Default constructor using a default logger and no user termination request.SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger)Construct SMTInterpol with a user-owned logger but without user termination request.SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger, boolean ignored)Deprecated.Use a constructor version without the boolean parameter!SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger, boolean ignored, TerminationRequest cancel)Deprecated.Use a constructor version without the boolean parameter.SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger, TerminationRequest cancel)Construct SMTInterpol with a logger and a user termination request.SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.option.OptionMap options)Construct SMTInterpol with an option map.SMTInterpol(SMTInterpol other, java.util.Map<java.lang.String,java.lang.Object> options, de.uni_freiburg.informatik.ultimate.smtinterpol.option.OptionMap.CopyMode mode)Copy the current context and modify some pre-theory options.SMTInterpol(TerminationRequest cancel)Default constructor using a default logger and a given user termination request.SMTInterpol(TerminationRequest cancel, de.uni_freiburg.informatik.ultimate.smtinterpol.option.OptionMap options)Construct SMTInterpol with a user termination request and a user created option map. -
Method Summary
Modifier and Type Method Description Script.LBoolassertTerm(Term term)Assert a Boolean term into the solver.java.lang.Iterable<Term[]>checkAllsat(Term[] input)Perform an AllSAT computation over some important predicates.Script.LBoolcheckSat()Check for satisfiability of the current context.Script.LBoolcheckSatAssuming(Term... assumptions)Check for satisfiability of the current context under additional assumptions.voiddeclareFun(java.lang.String fun, Sort[] paramSorts, Sort resultSort)Declare a function symbol.Term[]findImpliedEquality(Term[] x, Term[] y)Try to find an equality betweenxandythat is implied in the current satisfiable context.voidflipDecisions()Perform a restart and switch the decisions of all undecided literals.voidflipNamedLiteral(java.lang.String name)Flip the truth value decision for a name literal.Term[]getAssertions()Get all assertions contained in the assertion stack.AssignmentsgetAssignment()Get values for all named boolean terms in the model.de.uni_freiburg.informatik.ultimate.smtinterpol.convert.ClausifiergetClausifier()Access to the internal CNF transformer.de.uni_freiburg.informatik.ultimate.smtinterpol.dpll.DPLLEnginegetEngine()Access to the internal DPLL engine.java.lang.ObjectgetInfo(java.lang.String info)Get information from the solver.Term[]getInterpolants(Term[] partition, int[] startOfSubtree)Compute a sequence of interpolants.Term[]getInterpolants(Term[] partition, int[] startOfSubtree, Term proofTree)Compute a sequence of interpolants.de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxygetLogger()Access to the logger used by SMTInterpol.ModelgetModel()Retrieve a complete model from the solver.java.lang.ObjectgetOption(java.lang.String opt)Get the value of an option.TermgetProof()Trigger a call to a proof processor.TermgetProof(SMTInterpol.ProofMode proofMode)Term[]getSatisfiedLiterals()Get all literals currently set to true.TerminationRequestgetTerminationRequest()Use with caution.Term[]getUnsatAssumptions()Get the unsatisfiable assumptions.Term[]getUnsatCore()Get the unsat core.java.util.Map<Term,Term>getValue(Term[] terms)Get values for some terms in the model.booleanisTerminationRequested()voidpop(int n)Pop some levels from the assertion stack.voidpush(int n)Push some levels onto the assertion stack.voidreset()Unset the logic and clear the assertion stack.voidresetAssertions()Resets the assertion stack.de.uni_freiburg.informatik.ultimate.smtinterpol.dpll.ClauseretrieveProof()Retrieve the proof in its internal format.protected voidsetClausifier(de.uni_freiburg.informatik.ultimate.smtinterpol.convert.Clausifier clausifier)protected voidsetEngine(de.uni_freiburg.informatik.ultimate.smtinterpol.dpll.DPLLEngine engine)voidsetErrorCallback(de.uni_freiburg.informatik.ultimate.smtinterpol.smtlib2.ErrorCallback callback)Set an error callback that will be notified about internal problems in the solving process: failed model checks, proof checks, interrnal errors, etc.voidsetInfo(java.lang.String info, java.lang.Object value)Set some information for the solver.voidsetLogic(Logics logic)Set the logic for the solver.voidsetLogic(java.lang.String logic)Set the logic for the solver.voidsetOption(java.lang.String opt, java.lang.Object value)Set an option for the solver.voidsetTerminationRequest(TerminationRequest request)Use with caution.Termsimplify(Term term)Simplify a term.Methods inherited from class de.uni_freiburg.informatik.ultimate.logic.NoopScript
annotate, binary, constructor, datatype, decimal, decimal, declareDatatype, declareDatatypes, declareSort, defineFun, defineSort, echo, exit, getFunctionSymbol, getInterpolants, getTheory, hexadecimal, let, match, numeral, numeral, quantifier, sort, sort, sortVariables, string, term, term, variable
-
Constructor Details
-
SMTInterpol
public SMTInterpol()Default constructor using a default logger and no user termination request. If this constructor is used, SMTInterpol assumes ownership of the logger. -
SMTInterpol
public SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger)Construct SMTInterpol with a user-owned logger but without user termination request.- Parameters:
logger- The logger owned by the caller.
-
SMTInterpol
@Deprecated public SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger, boolean ignored)Deprecated.Use a constructor version without the boolean parameter!Construct SMTInterpol with a logger but without user termination request. The logger is assumed to be configured by the user.- Parameters:
logger- The logger owned by the caller.ignored- This parameter is ignored!
-
SMTInterpol
Default constructor using a default logger and a given user termination request.- Parameters:
cancel- User termination request to poll during checks.
-
SMTInterpol
public SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger, TerminationRequest cancel)Construct SMTInterpol with a logger and a user termination request. This is the main constructor of SMTInterpol.- Parameters:
logger- The logger owned by the caller.cancel- User termination request to poll during checks.
-
SMTInterpol
public SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.option.OptionMap options)Construct SMTInterpol with an option map. SMTInterpol will use the logger used to initialize the option map.- Parameters:
options- The option map used to handle all options.
-
SMTInterpol
public SMTInterpol(TerminationRequest cancel, de.uni_freiburg.informatik.ultimate.smtinterpol.option.OptionMap options)Construct SMTInterpol with a user termination request and a user created option map. This constructor is mainly used by the front ends to set an option map including front end options.- Parameters:
cancel- User termination request to poll during checks.options- Option map to handle options.
-
SMTInterpol
@Deprecated public SMTInterpol(de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy logger, boolean ignored, TerminationRequest cancel)Deprecated.Use a constructor version without the boolean parameter.Construct SMTInterpol with a user-owned logger but without user termination request. Note that the logger is assumed to be correctly set up.- Parameters:
logger- The logger owned by the caller.ignored- This option is ignored!cancel- User termination request to poll during checks.
-
SMTInterpol
public SMTInterpol(SMTInterpol other, java.util.Map<java.lang.String,java.lang.Object> options, de.uni_freiburg.informatik.ultimate.smtinterpol.option.OptionMap.CopyMode mode)Copy the current context and modify some pre-theory options. The copy shares the push/pop stack on the symbols but not on the assertions. Users should be careful not to mess up the push/pop stack, i.e., not to push on one context and pop on another one. Note that this cloning does not clone the assertion stack and should not be used in multi-threaded contexts since users cannot guarantee correct push/pop-stack treatment.- Parameters:
other- The context to clone.options- The options to set before setting the logic.mode- What to do when copying existing options.
-
-
Method Details
-
setErrorCallback
public void setErrorCallback(de.uni_freiburg.informatik.ultimate.smtinterpol.smtlib2.ErrorCallback callback)Set an error callback that will be notified about internal problems in the solving process: failed model checks, proof checks, interrnal errors, etc.- Parameters:
callback- The error callback.
-
reset
public final void reset()Unset the logic and clear the assertion stack. This does not reset online modifiable options.- Specified by:
resetin interfaceScript- Overrides:
resetin classNoopScript
-
resetAssertions
public final void resetAssertions()Description copied from interface:ScriptResets the assertion stack. This option will keep the logic and all globally defined symbols.- Specified by:
resetAssertionsin interfaceScript- Overrides:
resetAssertionsin classNoopScript
-
push
Description copied from interface:ScriptPush some levels onto the assertion stack.- Specified by:
pushin interfaceScript- Overrides:
pushin classNoopScript- Parameters:
n- The number of levels to push.- Throws:
SMTLIBException- If logic is not set.
-
pop
Description copied from interface:ScriptPop some levels from the assertion stack.- Specified by:
popin interfaceScript- Overrides:
popin classNoopScript- Parameters:
n- The number of levels to pop.- Throws:
SMTLIBException- If not enough stack levels are available.
-
checkSat
Description copied from interface:ScriptCheck for satisfiability of the current context. Note that this function should returnScript.LBool.UNKNOWNin case of errors.- Specified by:
checkSatin interfaceScript- Overrides:
checkSatin classNoopScript- Returns:
- The result of the check as a lifted Boolean.
- Throws:
SMTLIBException- If the logic is not set.
-
checkSatAssuming
Description copied from interface:ScriptCheck for satisfiability of the current context under additional assumptions. Note that this function should returnScript.LBool.UNKNOWNin case of errors.- Specified by:
checkSatAssumingin interfaceScript- Overrides:
checkSatAssumingin classNoopScript- Parameters:
assumptions- Additional assumptions as Boolean constants (nullary ApplicationTerms of sort Bool or their negations).- Returns:
- The result of the check as a lifted Boolean.
- Throws:
SMTLIBException- If the logic is not set.
-
setLogic
public void setLogic(java.lang.String logic) throws java.lang.UnsupportedOperationException, SMTLIBExceptionDescription copied from interface:ScriptSet the logic for the solver. The logic should be the name of one of the elements in theLogicsenumeration.- Specified by:
setLogicin interfaceScript- Overrides:
setLogicin classNoopScript- Parameters:
logic- Name of the logic to set.- Throws:
java.lang.UnsupportedOperationException- If the logic is not supported by the solver.SMTLIBException- If a logic is already set.
-
setLogic
Description copied from interface:ScriptSet the logic for the solver.- Specified by:
setLogicin interfaceScript- Overrides:
setLogicin classNoopScript- Parameters:
logic- Name of the logic to set.- Throws:
java.lang.UnsupportedOperationException- If the logic is not supported by the solver.SMTLIBException- If a logic is already set.
-
assertTerm
Description copied from interface:ScriptAssert a Boolean term into the solver. The solver might return a change in the state of the logical context. Compliant solvers do not have to do a full check here but returnScript.LBool.UNKNOWN.- Specified by:
assertTermin interfaceScript- Overrides:
assertTermin classNoopScript- Parameters:
term- The Boolean term to assert.- Returns:
- Possibly an unsatisfiability detected by the solver.
- Throws:
SMTLIBException- If the term is not Boolean or a named term matches an already defined function.
-
getAssertions
Description copied from interface:ScriptGet all assertions contained in the assertion stack. Note that this command is only available in interactive mode. To enable interactive mode, callsetOption(":interactive-mode", true).- Specified by:
getAssertionsin interfaceScript- Overrides:
getAssertionsin classNoopScript- Returns:
- An array of all asserted terms.
- Throws:
SMTLIBException- If interactive mode is not enabled.
-
getAssignment
Description copied from interface:ScriptGet values for all named boolean terms in the model. Note that this command is only available if assignment production is enabled and the lastScript.checkSat()did not returnScript.LBool.UNSAT. To enable assignment production, callsetOption(":produce-assignments", true).- Specified by:
getAssignmentin interfaceScript- Overrides:
getAssignmentin classNoopScript- Returns:
- An
Assignments. - Throws:
SMTLIBException- If assignment production is not enabled, or the solver did not detect unsatisfiability.
-
getInfo
public java.lang.Object getInfo(java.lang.String info) throws java.lang.UnsupportedOperationExceptionDescription copied from interface:ScriptGet information from the solver. Note that the solver only has to implement the info values described in the standard.- Specified by:
getInfoin interfaceScript- Overrides:
getInfoin classNoopScript- Parameters:
info- Name of the info. Note that it has to start with a colon (:).- Returns:
- Value of the option.
- Throws:
java.lang.UnsupportedOperationException- If the info is unsupported.
-
getOption
public java.lang.Object getOption(java.lang.String opt) throws java.lang.UnsupportedOperationExceptionDescription copied from interface:ScriptGet the value of an option.- Specified by:
getOptionin interfaceScript- Overrides:
getOptionin classNoopScript- Parameters:
opt- Name of an option.- Returns:
- The value of this option.
- Throws:
java.lang.UnsupportedOperationException- If option is unsupported.
-
getProof
Description copied from interface:ScriptTrigger a call to a proof processor. Note that this command is only available if proof production is enabled and the lastScript.checkSat()returnedScript.LBool.UNSAT. To enable proof production, callsetOption(":produce-proofs", true).- Specified by:
getProofin interfaceScript- Overrides:
getProofin classNoopScript- Returns:
- the proof. This is given as a big smtlib term of the internal type @proof.
- Throws:
SMTLIBException- If proof production is not enabled or the solver did not detect unsatisfiability.java.lang.UnsupportedOperationException- If proof generation is unsupported.
-
getProof
public Term getProof(SMTInterpol.ProofMode proofMode) throws SMTLIBException, java.lang.UnsupportedOperationException- Throws:
SMTLIBExceptionjava.lang.UnsupportedOperationException
-
getInterpolants
Description copied from interface:ScriptCompute a sequence of interpolants. The nesting array describes the start of the subtree for tree interpolants. For inductive sequences of interpolants use a nesting array completely filled with 0.- Specified by:
getInterpolantsin interfaceScript- Overrides:
getInterpolantsin classNoopScript- Parameters:
partition- The array of formulas. This should contain either top-level names or conjunction of top-level names.startOfSubtree- The start of the subtree containing the formula at this index as root.- Returns:
- Tree interpolants respecting the nesting relation.
-
getInterpolants
Description copied from interface:ScriptCompute a sequence of interpolants. The nesting array describes the start of the subtree for tree interpolants. For inductive sequences of interpolants use a nesting array completely filled with 0. This computes the interpolants from the given proof. It can be called at any time, even if the assertion stack has been modified since computing the proof.- Specified by:
getInterpolantsin interfaceScript- Overrides:
getInterpolantsin classNoopScript- Parameters:
partition- The array of formulas. This should contain either top-level names or conjunction of top-level names.startOfSubtree- The start of the subtree containing the formula at this index as root.proofTree- The proof tree that used to compute interpolants.- Returns:
- Tree interpolants respecting the nesting relation.
-
getUnsatCore
Description copied from interface:ScriptGet the unsat core. Note that this command is only available if unsat core production is enabled and the lastScript.checkSat()returnedScript.LBool.UNSAT. To enable unsat core production, callsetOption(":produce-unsat-cores", true).- Specified by:
getUnsatCorein interfaceScript- Overrides:
getUnsatCorein classNoopScript- Returns:
- An array of terms forming an unsat core.
- Throws:
SMTLIBException- If proof production is not enabled or the solver did not detect unsatisfiability.java.lang.UnsupportedOperationException- If unsat core computation is unsupported.
-
getUnsatAssumptions
Description copied from interface:ScriptGet the unsatisfiable assumptions. Note that this command is only available if unsat assumption production is enabled and the lastScript.checkSatAssuming(Term...)returnedScript.LBool.UNSAT. To enable unsat assumption production, callsetOption(":produce-unsat-assumptions", true).- Specified by:
getUnsatAssumptionsin interfaceScript- Overrides:
getUnsatAssumptionsin classNoopScript- Returns:
- An array of terms that correspond to an unsatisfiable subset of last assumptions.
- Throws:
SMTLIBException- If unsat assumption production is not enabled or the solver did not detect unsatisfiability.java.lang.UnsupportedOperationException- If unsat assumption computation is unsupported.
-
getValue
public java.util.Map<Term,Term> getValue(Term[] terms) throws SMTLIBException, java.lang.UnsupportedOperationExceptionDescription copied from interface:ScriptGet values for some terms in the model. Note that this command is only available if model production is enabled and the lastScript.checkSat()did not returnScript.LBool.UNSAT. To enable model production, callsetOption(":produce-models", true).- Specified by:
getValuein interfaceScript- Overrides:
getValuein classNoopScript- Parameters:
terms- an array of terms whose value should be computed.- Returns:
- A valuation (mapping from term to value (which is again represented by a term) where the keys are the given terms.
- Throws:
SMTLIBException- If model production is not enabled or the solver detected unsatisfiability.java.lang.UnsupportedOperationException- If model computation is unsupported
-
getModel
Description copied from interface:ScriptRetrieve a complete model from the solver. This is an optional (non- SMTLIB compliant) operation. This function can only be called when the previousScript.checkSat()returnedScript.LBool.SATor (optionally)Script.LBool.UNKNOWNand no assertion stack command was issued after this check.- Specified by:
getModelin interfaceScript- Overrides:
getModelin classNoopScript- Returns:
- A model for the current formula.
- Throws:
SMTLIBException- Model production was not enabled.java.lang.UnsupportedOperationException- The solver does not support this operation.
-
setInfo
public void setInfo(java.lang.String info, java.lang.Object value)Description copied from interface:ScriptSet some information for the solver. Note that according to the standard a solver has to return success, but ignore the info.- Specified by:
setInfoin interfaceScript- Overrides:
setInfoin classNoopScript- Parameters:
info- Name of the info. Note that it has to start with a colon (:).value- Value for this info.
-
setOption
public void setOption(java.lang.String opt, java.lang.Object value) throws java.lang.UnsupportedOperationException, SMTLIBExceptionDescription copied from interface:ScriptSet an option for the solver. At least the options described in the standard should be valid options.- Specified by:
setOptionin interfaceScript- Overrides:
setOptionin classNoopScript- Parameters:
opt- Name of the option. Note that it has to start with a colon (:).value- Value for this option.- Throws:
java.lang.UnsupportedOperationException- If the option is unsupported.SMTLIBException- In case of type errors.
-
simplify
Description copied from interface:ScriptSimplify a term. This returns a term that is under the current assertions equivalent to the input term.- Specified by:
simplifyin interfaceScript- Overrides:
simplifyin classNoopScript- Parameters:
term- A (usually Boolean) term to simplify.- Returns:
- The simplified term.
- Throws:
SMTLIBException- If an error occurred or unsupported.
-
flipDecisions
public void flipDecisions()Perform a restart and switch the decisions of all undecided literals. This method should efficiently lead the solver to explore another path in the search tree. -
flipNamedLiteral
Flip the truth value decision for a name literal.- Parameters:
name- The name used in the annotation for this literal.- Throws:
SMTLIBException- If name not known.
-
getClausifier
public de.uni_freiburg.informatik.ultimate.smtinterpol.convert.Clausifier getClausifier()Access to the internal CNF transformer. Should not be used by users.- Returns:
- Internal CNF transformer.
-
getEngine
public de.uni_freiburg.informatik.ultimate.smtinterpol.dpll.DPLLEngine getEngine()Access to the internal DPLL engine. Should not be used by users.- Returns:
- Internal DPLL engine.
-
getLogger
public de.uni_freiburg.informatik.ultimate.smtinterpol.LogProxy getLogger()Access to the logger used by SMTInterpol.- Returns:
- The logger used by SMTInterpol.
-
setEngine
protected void setEngine(de.uni_freiburg.informatik.ultimate.smtinterpol.dpll.DPLLEngine engine) -
setClausifier
protected void setClausifier(de.uni_freiburg.informatik.ultimate.smtinterpol.convert.Clausifier clausifier) -
retrieveProof
public de.uni_freiburg.informatik.ultimate.smtinterpol.dpll.Clause retrieveProof() throws SMTLIBExceptionRetrieve the proof in its internal format. Users should usegetProof()to retrieve the proof as a proof term.- Returns:
- Internal proof.
- Throws:
SMTLIBException- If no proof is present or the proof is found to to be incorrect.
-
getSatisfiedLiterals
Get all literals currently set to true. Note that this function might also be called if SMTInterpol is currently in an unsat state. Then, it will simply return an empty array.- Returns:
- All literals currently set to true.
- Throws:
SMTLIBException- If the assertion stack is modified since the last clean state.
-
checkAllsat
Description copied from interface:ScriptPerform an AllSAT computation over some important predicates.- Specified by:
checkAllsatin interfaceScript- Overrides:
checkAllsatin classNoopScript- Parameters:
input- The important predicates. Must be Boolean.- Returns:
- Iterator over minterms found during iteration.
-
findImpliedEquality
public Term[] findImpliedEquality(Term[] x, Term[] y) throws SMTLIBException, java.lang.UnsupportedOperationExceptionDescription copied from interface:ScriptTry to find an equality betweenxandythat is implied in the current satisfiable context. If successful, this method returns an array of parametersa,b,csuch that the equalitya*x = b*y + cis implied by the current context. Note that thexarray and theyarray must be of equal length and of length at least 2.- Specified by:
findImpliedEqualityin interfaceScript- Overrides:
findImpliedEqualityin classNoopScript- Parameters:
x- The different incarnations of the lhs variable.y- The different incarnations of the rhs variable.- Returns:
- Array of length 3 or array of length 0 if no equality is implied.
- Throws:
SMTLIBExceptionjava.lang.UnsupportedOperationException
-
declareFun
public void declareFun(java.lang.String fun, Sort[] paramSorts, Sort resultSort) throws SMTLIBExceptionDescription copied from interface:ScriptDeclare a function symbol.- Specified by:
declareFunin interfaceScript- Overrides:
declareFunin classNoopScript- Parameters:
fun- Name of the function symbol.paramSorts- Sorts of the parameters.resultSort- Sort of the result of an application of this function.- Throws:
SMTLIBException- If the logic is not set, the logic is not an UF logic but the function takes parameters, or a function with this name already exists.
-
isTerminationRequested
public boolean isTerminationRequested() -
setTerminationRequest
Use with caution. -
getTerminationRequest
Use with caution.
-