Package com.microsoft.z3
Class Solver
- java.lang.Object
-
- com.microsoft.z3.Z3Object
-
- com.microsoft.z3.Solver
-
public class Solver extends Z3Object
Solvers.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(BoolExpr... constraints)Assert a multiple constraints into the solver.voidassertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)Assert multiple constraints into the solver, and track them (in the unsat) core using the Boolean constants in ps.voidassertAndTrack(BoolExpr constraint, BoolExpr p)Assert a constraint into the solver, and track it (in the unsat) core using the Boolean constant p.Statuscheck()Checks whether the assertions in the solver are consistent or not.Statuscheck(Expr... assumptions)Checks whether the assertions in the solver are consistent or not.voidfromFile(String file)voidfromString(String str)BoolExpr[]getAssertions()The set of asserted formulas.StatusgetConsequences(BoolExpr[] assumptions, Expr[] variables, List<BoolExpr> consequences)Retrieve fixed assignments to the set of variables in the form of consequences.StringgetHelp()A string that describes all available solver parameters.ModelgetModel()The model of the lastCheck.intgetNumAssertions()The number of assertions in the solver.intgetNumScopes()The current number of backtracking points (scopes).ParamDescrsgetParameterDescriptions()Retrieves parameter descriptions for solver.ExprgetProof()The proof of the lastCheck.StringgetReasonUnknown()A brief justification of why the last call toCheckreturnedUNKNOWN.StatisticsgetStatistics()Solver statistics.BoolExpr[]getUnsatCore()The unsat core of the lastCheck.voidinterrupt()Interrupt the execution of the solver object.voidpop()Backtracks one backtracking point.voidpop(int n)Backtracksnbacktracking points.voidpush()Creates a backtracking point.voidreset()Resets the Solver.voidsetParameters(Params value)Sets the solver parameters.StringtoString()A string representation of the solver.Solvertranslate(Context ctx)Create a clone of the current solver with respect toctx.-
Methods inherited from class com.microsoft.z3.Z3Object
arrayLength, arrayToNative
-
-
-
-
Method Detail
-
getHelp
public String getHelp()
A string that describes all available solver parameters.
-
setParameters
public void setParameters(Params value)
Sets the solver parameters.- Throws:
Z3Exception
-
getParameterDescriptions
public ParamDescrs getParameterDescriptions()
Retrieves parameter descriptions for solver.- Throws:
Z3Exception
-
getNumScopes
public int getNumScopes()
The current number of backtracking points (scopes).
-
push
public void push()
Creates a backtracking point.- See Also:
pop()
-
pop
public void pop()
Backtracks one backtracking point. Remarks: .
-
pop
public void pop(int n)
Backtracksnbacktracking points. Remarks: Note that an exception is thrown ifnis not smaller thanNumScopes- See Also:
push()
-
reset
public void reset()
Resets the Solver. Remarks: This removes all assertions from the solver.
-
interrupt
public void interrupt()
Interrupt the execution of the solver object. Remarks: This ensures that the interrupt applies only to the given solver object and it applies only if it is running.
-
add
public void add(BoolExpr... constraints)
Assert a multiple constraints into the solver.- Throws:
Z3Exception
-
assertAndTrack
public void assertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
Assert multiple constraints into the solver, and track them (in the unsat) core using the Boolean constants in ps. Remarks: This API is an alternative tocheck()with assumptions for extracting unsat cores. Both APIs can be used in the same solver. The unsat core will contain a combination of the Boolean variables provided using#assertAndTrackand the Boolean literals provided usingcheck()with assumptions.
-
assertAndTrack
public void assertAndTrack(BoolExpr constraint, BoolExpr p)
Assert a constraint into the solver, and track it (in the unsat) core using the Boolean constant p. Remarks: This API is an alternative tocheck(com.microsoft.z3.Expr...)with assumptions for extracting unsat cores. Both APIs can be used in the same solver. The unsat core will contain a combination of the Boolean variables provided usingassertAndTrack(com.microsoft.z3.BoolExpr[], com.microsoft.z3.BoolExpr[])and the Boolean literals provided usingcheck(com.microsoft.z3.Expr...)with assumptions.
-
fromFile
public void fromFile(String file)
-
fromString
public void fromString(String str)
-
getNumAssertions
public int getNumAssertions()
The number of assertions in the solver.- Throws:
Z3Exception
-
getAssertions
public BoolExpr[] getAssertions()
The set of asserted formulas.- Throws:
Z3Exception
-
check
public Status check(Expr... assumptions)
Checks whether the assertions in the solver are consistent or not. Remarks:- See Also:
getModel(),getUnsatCore(),getProof()
-
check
public Status check()
Checks whether the assertions in the solver are consistent or not. Remarks:- See Also:
getModel(),getUnsatCore(),getProof()
-
getConsequences
public Status getConsequences(BoolExpr[] assumptions, Expr[] variables, List<BoolExpr> consequences)
Retrieve fixed assignments to the set of variables in the form of consequences. Each consequence is an implication of the form relevant-assumptions Implies variable = value where the relevant assumptions is a subset of the assumptions that are passed in and the equality on the right side of the implication indicates how a variable is fixed.
-
getModel
public Model getModel()
The model of the lastCheck. Remarks: The result isnullifCheckwas not invoked before, if its results was notSATISFIABLE, or if model production is not enabled.- Throws:
Z3Exception
-
getProof
public Expr getProof()
The proof of the lastCheck. Remarks: The result isnullifCheckwas not invoked before, if its results was notUNSATISFIABLE, or if proof production is disabled.- Throws:
Z3Exception
-
getUnsatCore
public BoolExpr[] getUnsatCore()
The unsat core of the lastCheck. Remarks: The unsat core is a subset ofAssertionsThe result is empty ifCheckwas not invoked before, if its results was notUNSATISFIABLE, or if core production is disabled.- Throws:
Z3Exception
-
getReasonUnknown
public String getReasonUnknown()
A brief justification of why the last call toCheckreturnedUNKNOWN.
-
translate
public Solver translate(Context ctx)
Create a clone of the current solver with respect toctx.
-
getStatistics
public Statistics getStatistics()
Solver statistics.- Throws:
Z3Exception
-
-