public class LoggingScript extends java.lang.Object implements Script
Script
interface that produces an interaction
file in (almost) SMTLIB 2 compliant format. We still have some extra
commands like "simplify", "reset", or "get-interpolants".Script.LBool
EMPTY_SORT_ARRAY, EMPTY_TERM_ARRAY, EXISTS, FORALL
Constructor and Description |
---|
LoggingScript(Script script,
java.lang.String file,
boolean autoFlush)
Create a new script logging the interaction between the user and the
wrapped script into a file.
|
LoggingScript(Script script,
java.lang.String file,
boolean autoFlush,
boolean useCSE)
Create a new script logging the interaction between the user and the
wrapped script into a file.
|
LoggingScript(java.lang.String file,
boolean autoFlush)
Create a new script logging the commands by the user.
|
Modifier and Type | Method and Description |
---|---|
Term |
annotate(Term t,
Annotation... annotations)
Annotate a term.
|
Script.LBool |
assertTerm(Term term)
Assert a Boolean term into the solver.
|
Term |
binary(java.lang.String bin)
Create a binary term.
|
java.lang.Iterable<Term[]> |
checkAllsat(Term[] predicates)
Perform an AllSAT computation over some important predicates.
|
Script.LBool |
checkSat()
Check for satisfiability of the current context.
|
Script.LBool |
checkSatAssuming(Term... assumptions)
Check for satisfiability of the current context under additional
assumptions.
|
void |
comment(java.lang.String comment)
Write a comment to the generated SMTLIB dump file.
|
Term |
decimal(java.math.BigDecimal decimal)
Create a decimal term.
|
Term |
decimal(java.lang.String decimal)
Create a decimal term.
|
void |
declareFun(java.lang.String fun,
Sort[] paramSorts,
Sort resultSort)
Declare a function symbol.
|
void |
declareSort(java.lang.String sort,
int arity)
Declare a user-defined sort.
|
void |
defineFun(java.lang.String fun,
TermVariable[] params,
Sort resultSort,
Term definition)
Define an alias of a function symbol.
|
void |
defineSort(java.lang.String sort,
Sort[] sortParams,
Sort definition)
Define an alias of a sort.
|
QuotedObject |
echo(QuotedObject msg)
Echo a message on the regular output channel of the solver.
|
void |
exit()
Exit the solver.
|
Term[] |
findImpliedEquality(Term[] x,
Term[] y)
Try to find an equality between
x and y that
is implied in the current satisfiable context. |
Term[] |
getAssertions()
Get all assertions contained in the assertion stack.
|
Assignments |
getAssignment()
Get values for all named boolean terms in the model.
|
java.lang.Object |
getInfo(java.lang.String info)
Get information from the solver.
|
Term[] |
getInterpolants(Term[] partition)
Get interpolants for the partitions.
|
Term[] |
getInterpolants(Term[] partition,
int[] startOfSubtree)
Compute a sequence of interpolants.
|
Model |
getModel()
Retrieve a complete model from the solver.
|
java.lang.Object |
getOption(java.lang.String opt)
Get the value of an option.
|
Term |
getProof()
Trigger a call to a proof processor.
|
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.
|
Term |
hexadecimal(java.lang.String hex)
Create a hexadecimal term.
|
Term |
let(TermVariable[] vars,
Term[] values,
Term body)
Create a let term.
|
Term |
numeral(java.math.BigInteger num)
Create a numeral term.
|
Term |
numeral(java.lang.String num)
Create a numeral term.
|
void |
pop(int levels)
Pop some levels from the assertion stack.
|
void |
push(int levels)
Push some levels onto the assertion stack.
|
Term |
quantifier(int quantor,
TermVariable[] vars,
Term body,
Term[]... patterns)
Create a quantified formula.
|
void |
reset()
Reset the solver completely.
|
void |
resetAssertions()
Resets the assertion stack.
|
void |
setInfo(java.lang.String info,
java.lang.Object value)
Set some information for the solver.
|
void |
setLogic(Logics logic)
Set the logic for the solver.
|
void |
setLogic(java.lang.String logic)
Set the logic for the solver.
|
void |
setOption(java.lang.String opt,
java.lang.Object value)
Set an option for the solver.
|
Term |
simplify(Term term)
Simplify a term.
|
Sort |
sort(java.lang.String sortname,
java.math.BigInteger[] indices,
Sort... params)
Instantiate an indexed n-ary sort with parameters.
|
Sort |
sort(java.lang.String sortname,
Sort... params)
Instantiate an n-ary sort with parameters.
|
Sort[] |
sortVariables(java.lang.String... names)
Create an array of sort parameters.
|
Term |
string(java.lang.String str)
Create a string term.
|
Term |
term(java.lang.String funcname,
java.math.BigInteger[] indices,
Sort returnSort,
Term... params)
Create an n-ary term by name, indices and return sort.
|
Term |
term(java.lang.String funcname,
Term... params)
Create an n-ary term by name.
|
TermVariable |
variable(java.lang.String varname,
Sort sort)
Create a term variable.
|
public LoggingScript(java.lang.String file, boolean autoFlush) throws java.io.FileNotFoundException
file
- The name of the logging file (should end in .smt2).autoFlush
- Automatically flush the output stream after every
command.java.io.FileNotFoundException
- If the file cannot be opened.public LoggingScript(Script script, java.lang.String file, boolean autoFlush) throws java.io.FileNotFoundException
script
- The wrapped script.file
- The name of the logging file (should end in .smt2).autoFlush
- Automatically flush the output stream after every
command.java.io.FileNotFoundException
- If the file cannot be opened.public LoggingScript(Script script, java.lang.String file, boolean autoFlush, boolean useCSE) throws java.io.FileNotFoundException
script
- The wrapped script.file
- The name of the logging file (should end in .smt2).autoFlush
- Automatically flush the output stream after every
command.useCSE
- Use common subexpression elimination in output
(introduces let terms)java.io.FileNotFoundException
- If the file cannot be opened.public void setLogic(java.lang.String logic) throws java.lang.UnsupportedOperationException, SMTLIBException
Script
Logics
enumeration.setLogic
in interface Script
logic
- Name of the logic to set.java.lang.UnsupportedOperationException
- If the logic is not supported by
the solver.SMTLIBException
- If a logic is already set.public void setLogic(Logics logic) throws java.lang.UnsupportedOperationException, SMTLIBException
Script
setLogic
in interface Script
logic
- Name of the logic to set.java.lang.UnsupportedOperationException
- If the logic is not supported by
the solver.SMTLIBException
- If a logic is already set.public void setOption(java.lang.String opt, java.lang.Object value) throws java.lang.UnsupportedOperationException, SMTLIBException
Script
setOption
in interface Script
opt
- Name of the option. Note that it has to start with
:.
value
- Value for this option.java.lang.UnsupportedOperationException
- If the option is unsupported.SMTLIBException
- In case of type errors.public void setInfo(java.lang.String info, java.lang.Object value)
Script
public void declareSort(java.lang.String sort, int arity) throws SMTLIBException
Script
declareSort
in interface Script
sort
- The name of the new sort.arity
- The arity of the new sort.SMTLIBException
- If no logic is set, the logic does not allow
user-defined sorts, or a sort with this
name already exists.public void defineSort(java.lang.String sort, Sort[] sortParams, Sort definition) throws SMTLIBException
Script
defineSort
in interface Script
sort
- Name of the alias.sortParams
- Sort parameters.definition
- Original sort.SMTLIBException
- If no logic is set, the logic does not allow
user-defined sorts, or a sort with this
name already exists.public void declareFun(java.lang.String fun, Sort[] paramSorts, Sort resultSort) throws SMTLIBException
Script
declareFun
in interface Script
fun
- Name of the function symbol.paramSorts
- Sorts of the parameters.resultSort
- Sort of the result of an application of this function.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.public void defineFun(java.lang.String fun, TermVariable[] params, Sort resultSort, Term definition) throws SMTLIBException
Script
defineFun
in interface Script
fun
- Name of the alias.params
- Parameters of the alias.resultSort
- Return sort of the alias.definition
- Definition of the function alias.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.public void push(int levels) throws SMTLIBException
Script
push
in interface Script
levels
- The number of levels to push.SMTLIBException
- If logic is not set.public void pop(int levels) throws SMTLIBException
Script
pop
in interface Script
levels
- The number of levels to pop.SMTLIBException
- If not enough stack levels are available.public Script.LBool assertTerm(Term term) throws SMTLIBException
Script
Script.LBool.UNKNOWN
.assertTerm
in interface Script
term
- The Boolean term to assert.SMTLIBException
- If the term is not Boolean or a named term
matches an already defined function.public Script.LBool checkSat() throws SMTLIBException
Script
Script.LBool.UNKNOWN
in case of
errors.checkSat
in interface Script
SMTLIBException
- If the logic is not set.public Script.LBool checkSatAssuming(Term... assumptions) throws SMTLIBException
Script
Script.LBool.UNKNOWN
in case of
errors.checkSatAssuming
in interface Script
assumptions
- Additional assumptions as Boolean constants (nullary
ApplicationTerms of sort Bool or their negations).SMTLIBException
- If the logic is not set.public Term[] getAssertions() throws SMTLIBException
Script
setOption
(":interactive-mode", true).getAssertions
in interface Script
SMTLIBException
- If interactive mode is not enabled.public Term getProof() throws SMTLIBException, java.lang.UnsupportedOperationException
Script
Script.checkSat()
returned Script.LBool.UNSAT
. To enable proof production, call
setOption
(":produce-proofs", true).getProof
in interface Script
SMTLIBException
- If proof production is not enabled or the solver
did not detect unsatisfiability.java.lang.UnsupportedOperationException
- If proof generation is unsupported.public Term[] getUnsatCore() throws SMTLIBException, java.lang.UnsupportedOperationException
Script
Script.checkSat()
returned
Script.LBool.UNSAT
. To enable unsat core production, call
setOption
(":produce-unsat-cores",
true).getUnsatCore
in interface Script
SMTLIBException
- If proof production is not enabled or the solver
did not detect unsatisfiability.java.lang.UnsupportedOperationException
- If unsat core computation is
unsupported.public java.util.Map<Term,Term> getValue(Term[] terms) throws SMTLIBException, java.lang.UnsupportedOperationException
Script
Script.checkSat()
did not return Script.LBool.UNSAT
. To enable model production, call
setOption
(":produce-models", true).getValue
in interface Script
terms
- an array of terms whose value should be computed.SMTLIBException
- If model production is not enabled or the solver
detected unsatisfiability.java.lang.UnsupportedOperationException
- If model computation is
unsupportedpublic Assignments getAssignment() throws SMTLIBException, java.lang.UnsupportedOperationException
Script
Script.checkSat()
did not return Script.LBool.UNSAT
. To
enable assignment production, call
setOption
(":produce-assignments",
true).getAssignment
in interface Script
Assignments
.SMTLIBException
- If assignment production is not enabled, or the
solver did not detect unsatisfiability.java.lang.UnsupportedOperationException
- If model computation is
unsupportedpublic java.lang.Object getOption(java.lang.String opt) throws java.lang.UnsupportedOperationException
Script
public java.lang.Object getInfo(java.lang.String info) throws java.lang.UnsupportedOperationException
Script
public Term simplify(Term term) throws SMTLIBException
Script
simplify
in interface Script
term
- A (usually Boolean) term to simplify.SMTLIBException
- If an error occurred or unsupported.public void reset()
Script
public Term[] getInterpolants(Term[] partition) throws SMTLIBException, java.lang.UnsupportedOperationException
Script
getInterpolants
in interface Script
partition
- Partitioning of the assertion stack.SMTLIBException
- An error occurred.java.lang.UnsupportedOperationException
- If interpolant computation is
unsupported.public Term[] getInterpolants(Term[] partition, int[] startOfSubtree) throws SMTLIBException, java.lang.UnsupportedOperationException
Script
getInterpolants
in interface Script
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.SMTLIBException
- An error occurred.java.lang.UnsupportedOperationException
- If interpolant computation is
unsupported.public void exit()
Script
public Sort sort(java.lang.String sortname, Sort... params) throws SMTLIBException
Script
sort
in interface Script
sortname
- Name of the sort.params
- Sort parameters.SMTLIBException
- If and only if the sort does not exist.public Sort sort(java.lang.String sortname, java.math.BigInteger[] indices, Sort... params) throws SMTLIBException
Script
sort
in interface Script
sortname
- Name of the sort.indices
- Sort indices.params
- Sort parameters.SMTLIBException
- If and only if the sort does not exist.public Term term(java.lang.String funcname, Term... params) throws SMTLIBException
Script
term
in interface Script
funcname
- Name of the function.params
- The parameters of the function application.SMTLIBException
- If an error occurred.public Term term(java.lang.String funcname, java.math.BigInteger[] indices, Sort returnSort, Term... params) throws SMTLIBException
Script
term
in interface Script
funcname
- Name of the function.indices
- Indices for the function.returnSort
- Return sort of the function.params
- The parameters of the function application.SMTLIBException
- If an error occurred.public TermVariable variable(java.lang.String varname, Sort sort) throws SMTLIBException
Script
variable
in interface Script
varname
- Name of the variable.sort
- Sort of the variable.SMTLIBException
- If no name or an invalid sort is given.public Term quantifier(int quantor, TermVariable[] vars, Term body, Term[]... patterns) throws SMTLIBException
Script
quantifier
in interface Script
quantor
- The quantor flag (one of Script.EXISTS
, or
Script.FORALL
)vars
- The quantified variables.body
- The body of the quantified formula.patterns
- Possible patterns for e-matching (may be
null
).SMTLIBException
- If an error occurred.public Term let(TermVariable[] vars, Term[] values, Term body) throws SMTLIBException
Script
let
in interface Script
vars
- Variables bound by a let.values
- Values for these variables.body
- Body of the let term.SMTLIBException
- If an error occurred.public Term annotate(Term t, Annotation... annotations) throws SMTLIBException
Script
annotate
in interface Script
t
- Term to annotate.annotations
- Annotations for this term.SMTLIBException
- If the annotation is invalid, or the evaluation
of :named produces an error.public Term numeral(java.lang.String num) throws SMTLIBException
Script
numeral
in interface Script
num
- String representation of the numeral.SMTLIBException
- If an error occurred.public Term numeral(java.math.BigInteger num) throws SMTLIBException
Script
numeral
in interface Script
num
- the numeral as a big integer.SMTLIBException
- If an error occurred.public Term decimal(java.lang.String decimal) throws SMTLIBException
Script
decimal
in interface Script
decimal
- String representation of the decimal.SMTLIBException
public Term decimal(java.math.BigDecimal decimal) throws SMTLIBException
Script
decimal
in interface Script
decimal
- the decimal as a big decimal.SMTLIBException
public Term string(java.lang.String str) throws SMTLIBException
Script
string
in interface Script
str
- The parsed string with quotes removed.SMTLIBException
- If an error occurred.public Term hexadecimal(java.lang.String hex) throws SMTLIBException
Script
hexadecimal
in interface Script
hex
- String representation of the hexadecimal.SMTLIBException
- If an error occurred.public Term binary(java.lang.String bin) throws SMTLIBException
Script
binary
in interface Script
bin
- String representation of the binary.SMTLIBException
- If an error occurred.public Sort[] sortVariables(java.lang.String... names) throws SMTLIBException
Script
sortVariables
in interface Script
names
- The names of the variablesSMTLIBException
- If an error occured.public Model getModel() throws SMTLIBException, java.lang.UnsupportedOperationException
Script
Script.checkSat()
returned Script.LBool.SAT
or (optionally)
Script.LBool.UNKNOWN
and no assertion stack command was issued after
this check.getModel
in interface Script
SMTLIBException
- Model production was not enabled.java.lang.UnsupportedOperationException
- The solver does not support this operation.public java.lang.Iterable<Term[]> checkAllsat(Term[] predicates) throws SMTLIBException, java.lang.UnsupportedOperationException
Script
checkAllsat
in interface Script
predicates
- The important predicates. Must be Boolean.SMTLIBException
- If a predicate is non-Boolean.java.lang.UnsupportedOperationException
- If the operation is unsupported.public Term[] findImpliedEquality(Term[] x, Term[] y)
Script
x
and y
that
is implied in the current satisfiable context. If successful, this
method returns an array of parameters a,b,c
such that the
equality a*x = b*y + c
is implied by the current context.
Note that the x
array and the y
array must be
of equal length and of length at least 2.findImpliedEquality
in interface Script
x
- The different incarnations of the lhs variable.y
- The different incarnations of the rhs variable.public QuotedObject echo(QuotedObject msg)
Script
public void comment(java.lang.String comment)
Script
since it only makes sense for logging and not for solving.comment
- The comment to write to the dump file.public void resetAssertions()
Script
resetAssertions
in interface Script
public Term[] getUnsatAssumptions() throws SMTLIBException, java.lang.UnsupportedOperationException
Script
Script.checkSatAssuming(Term...)
returned
Script.LBool.UNSAT
. To enable unsat assumption production, call
setOption
(":produce-unsat-assumptions", true).getUnsatAssumptions
in interface Script
SMTLIBException
- If unsat assumption production is not enabled or
the solver did not detect unsatisfiability.java.lang.UnsupportedOperationException
- If unsat assumption computation is
unsupported.