Class AbstractSolver
- All Implemented Interfaces:
ISolver
- Direct Known Subclasses:
Solver_altergo,Solver_bitwuzla,Solver_cvc5,Solver_simplify,Solver_smt,Solver_smtinterpol,Solver_z3_4_3,Solver_z3_recent
translate(INode) and sent via sendCommand(ICommand). get_assertions/get_value/get_assignment/get_unsat_core/
get_unsat_assumptions additionally reparse a non-flat response as the structured list
they're actually specified to return (a (term value) pair list, a name list,
etc. — see Parser.parseValueList() and its siblings), since
parseResponse(String)'s generic parse only handles flat outcomes and just
returns a raw s-expression for anything else. A subclass whose target solver deviates
from strict SMT-LIB concrete syntax or response format overrides translate(INode) and/or parseResponse(String); a subclass whose target
solver deviates in some other way overrides the individual ISolver method itself,
same as before.
start() still throws UnsupportedOperationException, because AbstractSolver has
no generic way to provide it: constructing the solver process and choosing its command
line is inherently solver-specific, so every concrete adapter must override it.
exit(), by contrast, has a working default (send the exit command tolerating a
silent process exit, then tear down the process) that's generic enough to cover every
solver seen so far; a subclass only overrides it when exiting needs solver-specific
handling beyond that.
Thus this class can still be used as a base class for a solver adapter class that wants the convenience of not having to implement every operation at once (remove AbstractSolver as a base class and retain ISolver as an interface to check that all ISolver methods are indeed present in the derived class), while getting working default behavior for the operations that don't need solver-specific handling.
- Author:
- David Cok
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe response returned for a command sent bysendPipelined(ICommand)whose actual response has not yet been read;AbstractSolver.Pending.isReady()tells when it has (seereadPipelined(boolean)), andAbstractSolver.Pending.response()then gives it.protected static enumThe kinds of response a command has besides an error or unsupported (#149)static enumThe kinds of command that change the assertion stack: each returns a conforming solver to assert mode, where the get- commands about the last check are errors (declare-const is declare-fun, declare-datatypes is declare-datatype, define-funs-rec is define-fun-rec), as does a set-logic that a solver accepts after a check (SMT-LIB makes that an error, but --relax may allow it)Nested classes/interfaces inherited from interface org.smtlib.ISolver
ISolver.CreationException -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IResponseThe response to the most recent check-sat or check-sat-assuming, or null if there is none.protected static final longHow long (ms) to wait for the solver process to end, once a send has found it gone or endingprotected booleanTrue once the solver's whole-run time limit (smtConfig.timeoutTotal) has ended it; every later command then gets responseFactory.timeout() (exit tolerates it), rather than an error about the process having exited.protected static booleanprotected static booleanprotected intThe correction to a line number the solver reports for the command whose response is being read: line N of the solver's input is shown as lineN - linesOffset, the line of the user's source on which that command starts.protected Map<String, IAttributeValue> Map that keeps current values of options.protected final IExpr.IKeywordprotected booleanprotected SMT.ConfigurationSMT configuration — set by each concrete subclass constructor.static final StringThe error every command answers once the solver process has exited (other than by its whole-run time limit)protected SolverProcessThe object that interacts with external processes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassertExpr(IExpr sexpr) Adds the given expression to the current assertion-stack frame.Checks whether the current assertion set is satisfiable under the current logic.check_sat_assuming(IExpr... exprs) Checks satisfiability under the current assertion set plus the given propositional assumptions.protected IResponsecheckImmediateExit(IResponse result) Called with each response parsed from the solver.checkPrintSuccess(SMT.Configuration smtConfig, IExpr.IKeyword key, IAttributeValue value) Answers a set-option of :print-success locally (it is never sent), else returns nullReturns the result of the most recent check-sat or check-sat-assuming, or null if none has been issued since the last push/pop/assert/declare/define.protected IResponsecheckShape(AbstractSolver.Shape shape, String sent, String text, IResponse r) r, if it has the given shape; else the error for a response out of step with the command sent, whose raw response was textprotected IResponseThe response to the most recent check command, or null if there is none or the solver has accepted a command that changes the assertion stack since (after reading the responses to the pipelined commands): sat or unknown in SMT-LIB's sat mode, unsat in its unsat modevoidForwards a standalone comment (its own C_comment pseudo-command -- see issue #42) to the solver process, uniformly for every solver adapter: a comment is legal SMT-LIB input (any conforming solver must silently ignore it), and the solver's log then shows the script's comments.protected StringcorrectResponse(ICommand cmd, String response) The solver's raw response to cmd (sent by sendCommand and waited for), corrected where the solver departs from SMT-LIB; an adapter overrides this to patch a specific non-conforming responseDeclares a new uninterpreted constant; returns success or an SMT error responseDeclares a new datatype sort; returns success or an SMT error responseDeclares mutually recursive datatype sorts; returns success or an SMT error responseDeclares a new uninterpreted function (or constant); returns success or an SMT error responseDeclares a new uninterpreted sort; returns success or an SMT error responseDeclares a new sort parameter (polymorphic sort variable); returns success or an SMT error responseDefines a named constant — syntactic sugar fordefine-funwith no parameters; returns success or an SMT error responseDefines a named function or constant; returns success or an SMT error responseDefines a named recursive function; returns success or an SMT error responseDefines a group of mutually recursive functions; returns success or an SMT error responseDefines a sort abbreviation; returns success or an SMT error responseprotected intearlierSourceLine(int n) The source line for line n of the solver's input, which may be that of an earlier commandecho(IExpr.IStringLiteral arg) Echoes the argument string back to the output channel.protected booleanerrorStopsSolver(IResponse error) Whether, after the given error response, the solver stops processing input (whether or not its process actually exits).Once the solver process has exited, every command but exit (and a comment, which has no response) answersexitedResponse(), including those an adapter answers itself or checks with its own queriesexecutePipelined(List<ICommand> commands) Executes the commands in order, as a script does: returns the first error, or else the last command's response.exit()Terminates the solver; no further commands are permitted.The response to any command once the solver process has exited: timeout if its whole-run time limit ended it, else the errorSOLVER_EXITED; null while the process runs (or has not been started)voidAt the end of a pipelined run: waits briefly for output still arriving after the last response, and reports any as out of stepvoidTerminates the solver forcibly without sending commands (e.g.Returns the list of formulae in the current assertion set, in the order they were asserted.Returns the truth-value assignments for all named Boolean formulae in the current model.get_info(IExpr.IKeyword option) Returns the value of the named info item.Returns a satisfying model for the current assertion set.get_option(IExpr.IKeyword option) Returns the current value of the named option.Returns a proof of unsatisfiability for the current assertion set.Returns the subset of check-sat-assuming assumptions that caused the result to be unsat.Returns the named formulae that form an unsatisfiable core of the current assertion set.Returns the values of the given expressions in the current satisfying model.booleanWhether some pipelined command's response has not yet been readprotected booleanWhether the most recent check command was answered sat or unknown, with the assertion stack unchanged since: SMT-LIB's sat mode (false once the whole-run time limit has ended the solver)voidInterrupts the command the solver is running (seeSolverProcess.interrupt())protected booleanWhether the most recent check command was answered unsat, with the assertion stack unchanged since: SMT-LIB's unsat mode (false once the whole-run time limit has ended the solver)protected booleanisFlatResponse(String response) True if the given raw response text is a flat outcome (empty/success/unsupported/an(error ...)s-expression) rather than a structured list — used by the get_assertions/get_value/get_assignment/get_unsat_core/get_unsat_assumptions defaults below to decide whether to delegate toparseResponse(String)or reparse the response as the structured list they actually expect.protected booleanisTimeLimitResponse(String rawResponse) Whether the raw response text is this solver's report that its whole-run time limit (smtConfig.timeoutTotal) ended it; consulted only when that limit is set.Patterns matching the line numbers in this solver's messages about the command answered: group 1 is the text before the number, group 2 the number, group 3 the text after itprotected voidLogs the standard-error text the solver wrote along with its replies (see SolverProcess.takeDiagnosticOutput), noting a whole-run time-limit report there: the reply stands, but the solver has endedprotected IResponseThe get-model response r, without the leading symbolmodelif it has one: z3 4.3 to 4.7 and yices2 2.6.5 (with --smt2-model-format) answer(model (define-fun ...) ...), where SMT-LIB has the plain list((define-fun ...) ...).protected intThe solver line, as the solver numbers lines in its messages, on which the next text sent starts; overridden for a solver that does not number the lines of its whole inputprotected static StringnormalizeForTesting(String raw, IExpr.IKeyword infoflag) Replaces known sources of non-deterministic content in a raw solver response with a fixed placeholder, so that --testing runs produce byte-for-byte reproducible output across machines and repeated runs.booleanWhether pipelined responses have been found out of step with their commands (#149)protected IResponseparseResponse(String response) Parses the solver's raw response text.booleanWhethersendPipelined(ICommand)may send the command without waiting for its response.pop(int number) Removes the given number of assertion-stack frames from the solver state.protected IResponseWraps a parsed get-proof answer as an IProofResponse; anything else (an error, unsupported) is returned unchanged.push(int number) Adds the given number of empty assertion-stack frames to the solver state.voidreadPipelined(boolean wait) Reads what the solver has written for pipelined commands, matching each response to its command in order; with wait, until every pending command has its response (or the solver has stopped), else only what has already arrived.protected IResponserecordChange(AbstractSolver.StackChange kind, IResponse response) Records the response to a command of the given kind that changes the assertion stack, and returns it.protected booleanWhether the solver's messages name lines of earlier commands (seeearlierSourceLine(int))protected voidReports that --seed, if given, is ignored, for an adapter whose solver has no random seedprotected IResponserequireNoChangeSinceCheck(String commandName, Set<AbstractSolver.StackChange> answeredAfter) Returns an error response if, since a check command, the solver has accepted a command of one of the given kinds (after which the solver wrongly keeps answering the get- commands about that check, which SMT-LIB's assert mode makes errors), else nullprotected IResponserequireOptionEnabled(String commandName, String option) Returns an error response if the given option has not been enabled (perget_option(IKeyword)), else null.protected IResponserequireSatOrUnknown(String commandName) Returns an error response unlesscheckStatus()is sat or unknown, else null.protected IResponserequireUnsat(String commandName, String afterWhat) Returns an error response unlesscheckStatus()is unsat, else null.reset()Resets the solver to the initial state, clearing all assertions, declarations, and options.Removes asserted formulae (but not global declarations when :global-declarations is true).static intresponseEnd(CharSequence s, int start) The index just past the response that starts at start (an atom, a string literal, a quoted symbol, or one balanced S-expression), or -1 if that response is not yet completeprotected booleanOverridden by a subclass whose target solver's :error-behavior is immediate-exit (e.g.protected IResponsesendChange(AbstractSolver.StackChange kind, ICommand cmd) Sends a command that changes the assertion stack, recording it (see recordChange)protected IResponsesendCommand(ICommand cmd) Translates the given command and sends it to the solver process, returning the parsed response.protected IResponseSends the exit command, tolerating the solver producing literally no response (SolverProcess.NoResponseException) as a benign, expected outcome rather than an error -- many solvers legitimately print nothing before terminating in response to exit.protected IResponsesendFailure(Exception e, IResponse otherwise) The response to a command whose sending failed with e: if the solver process has exited (waiting briefly for that), timeout if its whole-run time limit ended it, else the errorSOLVER_EXITED; otherwise otherwiseprotected IResponsesendFailure(String text, Exception e) AssendFailure(Exception, IResponse), with an error giving text and e otherwisesendPipelined(ICommand cmd) Executes a command for whichpipelines(ICommand)is true, sending it to the solver without waiting for the response.protected StringsendScriptText(boolean listen, String... text) Sends text for the command being executed (not text the adapter adds of its own accord), first setting linesOffset for it; returns the response if listen is true, else nullprotected IResponsesendSeed()Passes --seed, if given, as the standard :random-seed option, for an adapter whose solver uses that option; called from start(), while :print-success is true.set_info(IExpr.IKeyword key, IAttributeValue value) Annotates the problem with an info attribute (e.g.A set-logic the solver accepts ends sat or unsat mode; one it rejects (as SMT-LIB requires outside start mode) changes nothing.set_option(IExpr.IKeyword key, IAttributeValue value) Sets an SMT-LIB option.protected IResponseset_option_impl(IExpr.IKeyword key, IAttributeValue value) Override in subclasses to handle solver-specific options.voidsetSourceLine(int line) Tells the solver the line of the user's source on which the command about to be executed starts (counted from 1), or 0 if it has none, so that the line numbers in the solver's messages can be given as lines of that sourceprotected static AbstractSolver.ShapeThe kind of response cmd hassmt()Returns the configuration object with which the solver is initializedA public, user-readable name for the solver adapter classprotected booleanWhether the solver writes 'success' for a successful command, so that every command gets one response.start()Starts the solver; this is not an SMT-LIB command, but it is convenient in some implementations to separate the starting and initialization from the construction of the solver instance.successOrEmpty(SMT.Configuration smtConfig) protected IResponsetimeLimitResponse(String rawResponse) Returns responseFactory.timeout(), recording that the solver has ended, if the raw response reports that the solver's whole-run time limit ended it; otherwise null.protected IResponseFor when a send has found the solver process gone: the timeout response if the process left this solver's report that its whole-run time limit ended it unread (that limit runs on the wall clock, so it can end the solver between commands, and its report then answers no command), or if it ended once that limit had passed; otherwise nullprotected StringTranslates an in-memory node into the text sent to the solver process.unsatAssumptionsElements(List<IExpr> reply) The elements of a get-unsat-assumptions reply that belong in the response (all of them); an adapter whose solver's reply holds others filters them outunsatCoreElements(List<IExpr> reply) The elements of a get-unsat-core reply that belong in the unsat core (all of them); an adapter whose solver's reply holds others filters them outprotected StringwithSourceLines(String text) The text with each line number lineNumberPatterns finds in it rewritten as a source line (see linesOffset)
-
Field Details
-
isWindows
protected static boolean isWindows -
isMac
protected static boolean isMac -
printSuccess
-
printSuccessResponse
protected boolean printSuccessResponse -
solverProcess
The object that interacts with external processes -
linesOffset
protected int linesOffsetThe correction to a line number the solver reports for the command whose response is being read: line N of the solver's input is shown as lineN - linesOffset, the line of the user's source on which that command starts. The solver numbers the lines it receives, which are not the source's: jSMTLIB adds lines (a priming :print-success, a pipelining barrier, an adapter's own query), omits lines (blank lines, commands answered here) and sends each command on one line. So rather than tracking each such difference, linesOffset is set bysendScriptText(boolean, java.lang.String...)whenever text is sent for a command of the script, from the solver line that text starts on and the command's source line (seesetSourceLine(int)). A command without a source line (one built through the API) counts as the line after the previous one. An adapter rewrites the line numbers in its solver's messages withwithSourceLines(java.lang.String). -
smtConfig
SMT configuration — set by each concrete subclass constructor. -
options
Map that keeps current values of options. -
checkSatStatus
The response to the most recent check-sat or check-sat-assuming, or null if there is none. Whether the solver is still in the mode it set is given bycheckStatus(). -
endedByTimeLimit
protected boolean endedByTimeLimitTrue once the solver's whole-run time limit (smtConfig.timeoutTotal) has ended it; every later command then gets responseFactory.timeout() (exit tolerates it), rather than an error about the process having exited. -
END_WAIT_MILLIS
protected static final long END_WAIT_MILLISHow long (ms) to wait for the solver process to end, once a send has found it gone or ending- See Also:
-
SOLVER_EXITED
The error every command answers once the solver process has exited (other than by its whole-run time limit)- See Also:
-
-
Constructor Details
-
AbstractSolver
public AbstractSolver()
-
-
Method Details
-
setSourceLine
public void setSourceLine(int line) Description copied from interface:ISolverTells the solver the line of the user's source on which the command about to be executed starts (counted from 1), or 0 if it has none, so that the line numbers in the solver's messages can be given as lines of that source- Specified by:
setSourceLinein interfaceISolver
-
nextSolverLine
protected int nextSolverLine()The solver line, as the solver numbers lines in its messages, on which the next text sent starts; overridden for a solver that does not number the lines of its whole input -
reportsEarlierLines
protected boolean reportsEarlierLines()Whether the solver's messages name lines of earlier commands (seeearlierSourceLine(int)) -
sendScriptText
Sends text for the command being executed (not text the adapter adds of its own accord), first setting linesOffset for it; returns the response if listen is true, else null- Throws:
IOException
-
logSolverDiagnostics
protected void logSolverDiagnostics()Logs the standard-error text the solver wrote along with its replies (see SolverProcess.takeDiagnosticOutput), noting a whole-run time-limit report there: the reply stands, but the solver has ended -
earlierSourceLine
protected int earlierSourceLine(int n) The source line for line n of the solver's input, which may be that of an earlier command -
lineNumberPatterns
Patterns matching the line numbers in this solver's messages about the command answered: group 1 is the text before the number, group 2 the number, group 3 the text after it -
withSourceLines
The text with each line number lineNumberPatterns finds in it rewritten as a source line (see linesOffset) -
selfReportsImmediateExit
protected boolean selfReportsImmediateExit()Overridden by a subclass whose target solver's :error-behavior is immediate-exit (e.g. cvc5, yices2) rather than the SMT-LIB default of continued-execution -- such a solver's process may start exiting asynchronously right after it reports an error, andSolverProcess.send(boolean, String...)'s own process.isAlive() check can still read true for a brief window afterward (OS process-death bookkeeping lags the actual exit) -- seesendCommand(ICommand, boolean), which uses this to give a solver that just reported an error a moment to actually finish dying before the next command's liveness check runs, closing that race deterministically rather than guessing from the error's content whether the process will actually exit. -
checkImmediateExit
Called with each response parsed from the solver. After an error response from aselfReportsImmediateExit()solver, gives its process a moment to finish exiting (seeIMMEDIATE_EXIT_SETTLE_MILLIS). If the error is one after which the solver no longer processes input (errorStopsSolver(IResponse)) and the process is still alive, it is stopped, since a later command -- or exit() -- would otherwise wait forever for a reply. Only the OS process is stopped; the adapter is left as it is, so later commands answer that the solver process has exited and exit() cleans up normally. -
errorStopsSolver
Whether, after the given error response, the solver stops processing input (whether or not its process actually exits). False by default; see Solver_cvc5. -
solverName
Description copied from interface:ISolverA public, user-readable name for the solver adapter class- Specified by:
solverNamein interfaceISolver
-
forceExit
public void forceExit()Description copied from interface:ISolverTerminates the solver forcibly without sending commands (e.g. by killing the process). -
interrupt
public void interrupt()Interrupts the command the solver is running (seeSolverProcess.interrupt()) -
successOrEmpty
-
checkPrintSuccess
public IResponse checkPrintSuccess(SMT.Configuration smtConfig, IExpr.IKeyword key, IAttributeValue value) Answers a set-option of :print-success locally (it is never sent), else returns null -
translate
Translates an in-memory node into the text sent to the solver process. The base behavior assumes the solver is fully SMT-LIB compliant, so it is exactly what the default printer produces. Override in a subclass whose target solver deviates from strict SMT-LIB concrete syntax.- Throws:
IVisitor.VisitorException
-
parseResponse
Parses the solver's raw response text. The base behavior assumes the response is exactly standard SMT-LIB concrete syntax: success/sat/unsat/unknown/unsupported/ true/false, an(error "...")s-expression, a bare value (get-option), or a single(:keyword value)attribute pair (get-info). It does not build the richer structured IResponse subtypes that get_value/get_model/get_proof/ get_assertions/get_unsat_core/get_unsat_assumptions/get_assignment need, nor does it correct for any real solver's non-compliant quirks (e.g. legacy bit-vector literal syntax) — override in a subclass whose target solver needs either. -
sendCommand
Translates the given command and sends it to the solver process, returning the parsed response. This is the mechanism behind the default implementations below; a subclass may also call it directly to send a command built some other way. -
sendExitCommand
Sends the exit command, tolerating the solver producing literally no response (SolverProcess.NoResponseException) as a benign, expected outcome rather than an error -- many solvers legitimately print nothing before terminating in response to exit. The tolerated result is "", which Parser.parseResponse("") already turns into a plain empty response -- the same outcome a real empty response (e.g. under :print-success false) already produces, so no separate response-construction case is needed here. A subclass's exit() should call this instead of sendCommand(commandFactory.exit()) directly. -
normalizeForTesting
Replaces known sources of non-deterministic content in a raw solver response with a fixed placeholder, so that --testing runs produce byte-for-byte reproducible output across machines and repeated runs. Deliberately a short, explicit list rather than a broad catch-all, so it can't silently mask an actual difference in solver output: elapsed-time figures (e.g. cvc5's :all-statistics response embeds these as bare, unquoted "NNNms" tokens, which aren't valid SMT-LIB syntax at all and would otherwise cascade into a wall of "Invalid token" parse errors that also differ every run), and, in a reply toget-info :all-statistics, every number: statistics are run-dependent by nature, and solvers name them as they please. Their names are kept. -
isTimeLimitResponse
Whether the raw response text is this solver's report that its whole-run time limit (smtConfig.timeoutTotal) ended it; consulted only when that limit is set. Solvers report this in their own ways, so an adapter whose solver has such a limit overrides this; the default recognizes nothing. -
timeLimitResponse
Returns responseFactory.timeout(), recording that the solver has ended, if the raw response reports that the solver's whole-run time limit ended it; otherwise null. For adapters that send commands by their own means. -
timeLimitResponseAfterExit
For when a send has found the solver process gone: the timeout response if the process left this solver's report that its whole-run time limit ended it unread (that limit runs on the wall clock, so it can end the solver between commands, and its report then answers no command), or if it ended once that limit had passed; otherwise null -
sendFailure
The response to a command whose sending failed with e: if the solver process has exited (waiting briefly for that), timeout if its whole-run time limit ended it, else the errorSOLVER_EXITED; otherwise otherwise -
sendFailure
AssendFailure(Exception, IResponse), with an error giving text and e otherwise -
exitedResponse
The response to any command once the solver process has exited: timeout if its whole-run time limit ended it, else the errorSOLVER_EXITED; null while the process runs (or has not been started) -
execute
Once the solver process has exited, every command but exit (and a comment, which has no response) answersexitedResponse(), including those an adapter answers itself or checks with its own queries -
correctResponse
The solver's raw response to cmd (sent by sendCommand and waited for), corrected where the solver departs from SMT-LIB; an adapter overrides this to patch a specific non-conforming response -
pipelines
WhethersendPipelined(ICommand)may send the command without waiting for its response. True for the commands whose execution here sends the command (once) and has nothing to do with its response beyond returning it -- except check-sat, whose response becomescheckSatStatuswhen it is read. A subclass returns false for a command whose solver response needs correcting before it is compliant, or that it executes otherwise, and for all commands if it does not send them through sendCommand. -
sendPipelined
Executes a command for whichpipelines(ICommand)is true, sending it to the solver without waiting for the response. Returns aAbstractSolver.Pendingresponse if the command was sent, or the actual response if it was not (e.g. an error found before sending). Any other request to this solver first waits for the pending responses, but a caller must callreadPipelined(boolean)with true itself before executing a command that is checked against an earlier response (such as get-value against check-sat). -
executePipelined
Executes the commands in order, as a script does: returns the first error, or else the last command's response. Commands thatpipelines(ICommand)allows are sent without waiting for their responses; check-sat, check-sat-assuming and every other command first wait for the pending responses, so that none is executed after an error. Used by IScript.execute whenSMT.Configuration.pipelineis set. -
hasPending
public boolean hasPending()Whether some pipelined command's response has not yet been read -
readPipelined
public void readPipelined(boolean wait) Reads what the solver has written for pipelined commands, matching each response to its command in order; with wait, until every pending command has its response (or the solver has stopped), else only what has already arrived. Standard error is checked each time output is read. Which command its text belongs to is not known while the solver runs, so it is kept until either the solver stops, when it becomes the response of the first command without one (as listen() would return it), or every pending response has been read, when it is logged as diagnostic output. -
finishPipelined
public void finishPipelined()At the end of a pipelined run: waits briefly for output still arriving after the last response, and reports any as out of step -
solverPrintsSuccess
protected boolean solverPrintsSuccess()Whether the solver writes 'success' for a successful command, so that every command gets one response. True by default (the solver process is kept at :print-success true); an adapter whose solver does not (alt-ergo) returns false, and its responses are then matched by shape (see matchSilent), its commands being sent as when pipelining even when not (see sendCommand). -
outOfStep
public boolean outOfStep()Whether pipelined responses have been found out of step with their commands (#149) -
shapeOf
The kind of response cmd has -
checkShape
r, if it has the given shape; else the error for a response out of step with the command sent, whose raw response was text -
responseEnd
The index just past the response that starts at start (an atom, a string literal, a quoted symbol, or one balanced S-expression), or -1 if that response is not yet complete -
start
Description copied from interface:ISolverStarts the solver; this is not an SMT-LIB command, but it is convenient in some implementations to separate the starting and initialization from the construction of the solver instance. -
sendSeed
Passes --seed, if given, as the standard :random-seed option, for an adapter whose solver uses that option; called from start(), while :print-success is true. Returns an error if the solver rejects it, else null.- Throws:
IOException
-
reportSeedIgnored
protected void reportSeedIgnored()Reports that --seed, if given, is ignored, for an adapter whose solver has no random seed -
exit
Description copied from interface:ISolverTerminates the solver; no further commands are permitted. -
echo
Description copied from interface:ISolverEchoes the argument string back to the output channel. -
comment
Forwards a standalone comment (its own C_comment pseudo-command -- see issue #42) to the solver process, uniformly for every solver adapter: a comment is legal SMT-LIB input (any conforming solver must silently ignore it), and the solver's log then shows the script's comments. It has no response to wait for. A trailing, same-line comment never reaches here -- it's captured as Command.trailingText instead (see Parser.parseCommand()) and is never sent to a solver. -
set_logic
A set-logic the solver accepts ends sat or unsat mode; one it rejects (as SMT-LIB requires outside start mode) changes nothing. -
reset
Description copied from interface:ISolverResets the solver to the initial state, clearing all assertions, declarations, and options. -
reset_assertions
Description copied from interface:ISolverRemoves asserted formulae (but not global declarations when :global-declarations is true).- Specified by:
reset_assertionsin interfaceISolver- Returns:
- success or an SMT error response
- See Also:
-
push
Description copied from interface:ISolverAdds the given number of empty assertion-stack frames to the solver state. -
pop
Description copied from interface:ISolverRemoves the given number of assertion-stack frames from the solver state. -
assertExpr
Description copied from interface:ISolverAdds the given expression to the current assertion-stack frame. The SMT-LIB command name isassert; the Java method name differs to avoid the Java reserved word.- Specified by:
assertExprin interfaceISolver- Returns:
- success or an SMT error response
- See Also:
-
check_sat
Description copied from interface:ISolverChecks whether the current assertion set is satisfiable under the current logic. -
check_sat_assuming
Description copied from interface:ISolverChecks satisfiability under the current assertion set plus the given propositional assumptions.- Specified by:
check_sat_assumingin interfaceISolver- Returns:
- sat, unsat, unknown, or an SMT error response
- See Also:
-
define_const
Description copied from interface:ISolverDefines a named constant — syntactic sugar fordefine-funwith no parameters; returns success or an SMT error response- Specified by:
define_constin interfaceISolver- See Also:
-
define_fun
Description copied from interface:ISolverDefines a named function or constant; returns success or an SMT error response- Specified by:
define_funin interfaceISolver- See Also:
-
define_fun_rec
Description copied from interface:ISolverDefines a named recursive function; returns success or an SMT error response- Specified by:
define_fun_recin interfaceISolver- See Also:
-
define_funs_rec
Description copied from interface:ISolverDefines a group of mutually recursive functions; returns success or an SMT error response- Specified by:
define_funs_recin interfaceISolver- See Also:
-
declare_const
Description copied from interface:ISolverDeclares a new uninterpreted constant; returns success or an SMT error response- Specified by:
declare_constin interfaceISolver- See Also:
-
declare_fun
Description copied from interface:ISolverDeclares a new uninterpreted function (or constant); returns success or an SMT error response- Specified by:
declare_funin interfaceISolver- See Also:
-
define_sort
Description copied from interface:ISolverDefines a sort abbreviation; returns success or an SMT error response- Specified by:
define_sortin interfaceISolver- See Also:
-
declare_sort
Description copied from interface:ISolverDeclares a new uninterpreted sort; returns success or an SMT error response- Specified by:
declare_sortin interfaceISolver- See Also:
-
declare_sort_parameter
Description copied from interface:ISolverDeclares a new sort parameter (polymorphic sort variable); returns success or an SMT error response- Specified by:
declare_sort_parameterin interfaceISolver- See Also:
-
set_option
Description copied from interface:ISolverSets an SMT-LIB option.- Specified by:
set_optionin interfaceISolver- Parameters:
key- the keyword naming the optionvalue- the value to set- Returns:
- success, unsupported, or an SMT error response
- See Also:
-
set_option_impl
Override in subclasses to handle solver-specific options. Channel options are handled by set_option and never reach here. This default handles :print-success client-side (seecheckPrintSuccess(org.smtlib.SMT.Configuration, org.smtlib.IExpr.IKeyword, org.smtlib.IAttributeValue)): the solver process is always left with :print-success true at the wire level (see start()/sendCommand()) -- without that, we'd get no acknowledgment at all for other commands once a script turns it off -- so it is answered entirely client-side, matching the local smtConfig.nosuccess flag, and is never itself forwarded to the solver process. A subclass that overrides set_option_impl for other reasons (e.g. to also track option values locally) needs its own checkPrintSuccess call, same as it always has -- this default is only reached by a subclass that doesn't override set_option_impl at all. -
set_info
Description copied from interface:ISolverAnnotates the problem with an info attribute (e.g.:status sat). -
sendChange
Sends a command that changes the assertion stack, recording it (see recordChange) -
recordChange
Records the response to a command of the given kind that changes the assertion stack, and returns it. The command counts as a change only once its response is known not to be an error: a command the solver rejects changes nothing. -
checkStatus
The response to the most recent check command, or null if there is none or the solver has accepted a command that changes the assertion stack since (after reading the responses to the pipelined commands): sat or unknown in SMT-LIB's sat mode, unsat in its unsat mode -
inSatMode
protected boolean inSatMode()Whether the most recent check command was answered sat or unknown, with the assertion stack unchanged since: SMT-LIB's sat mode (false once the whole-run time limit has ended the solver) -
inUnsatMode
protected boolean inUnsatMode()Whether the most recent check command was answered unsat, with the assertion stack unchanged since: SMT-LIB's unsat mode (false once the whole-run time limit has ended the solver) -
requireNoChangeSinceCheck
protected IResponse requireNoChangeSinceCheck(String commandName, Set<AbstractSolver.StackChange> answeredAfter) Returns an error response if, since a check command, the solver has accepted a command of one of the given kinds (after which the solver wrongly keeps answering the get- commands about that check, which SMT-LIB's assert mode makes errors), else null -
requireOptionEnabled
Returns an error response if the given option has not been enabled (perget_option(IKeyword)), else null. -
requireSatOrUnknown
Returns an error response unlesscheckStatus()is sat or unknown, else null. -
requireUnsat
Returns an error response unlesscheckStatus()is unsat, else null. -
isFlatResponse
True if the given raw response text is a flat outcome (empty/success/unsupported/an(error ...)s-expression) rather than a structured list — used by the get_assertions/get_value/get_assignment/get_unsat_core/get_unsat_assumptions defaults below to decide whether to delegate toparseResponse(String)or reparse the response as the structured list they actually expect. -
get_assertions
Description copied from interface:ISolverReturns the list of formulae in the current assertion set, in the order they were asserted. Requires :produce-assertions to be enabled; returns an error if it is not. SMT-LIB does not stipulate the order of the terms in the returned list.- Specified by:
get_assertionsin interfaceISolver- Returns:
- a sequence of asserted terms, unsupported, or an SMT error response
- See Also:
-
get_proof
Description copied from interface:ISolverReturns a proof of unsatisfiability for the current assertion set. Requires :produce-proofs to be enabled; returns an error if it is not. -
proofResponse
Wraps a parsed get-proof answer as an IProofResponse; anything else (an error, unsupported) is returned unchanged. -
get_model
Description copied from interface:ISolverReturns a satisfying model for the current assertion set. Requires :produce-models to be enabled and the last check-sat to have returned sat; returns an error if these preconditions are not met. -
modelResponse
The get-model response r, without the leading symbolmodelif it has one: z3 4.3 to 4.7 and yices2 2.6.5 (with --smt2-model-format) answer(model (define-fun ...) ...), where SMT-LIB has the plain list((define-fun ...) ...). A conforming response, whose elements are all lists, is unchanged. -
unsatCoreElements
The elements of a get-unsat-core reply that belong in the unsat core (all of them); an adapter whose solver's reply holds others filters them out -
unsatAssumptionsElements
The elements of a get-unsat-assumptions reply that belong in the response (all of them); an adapter whose solver's reply holds others filters them out -
get_unsat_assumptions
Description copied from interface:ISolverReturns the subset of check-sat-assuming assumptions that caused the result to be unsat. Requires :produce-unsat-assumptions to be enabled; returns an error if it is not.- Specified by:
get_unsat_assumptionsin interfaceISolver- Returns:
- a list of assumption literals, unsupported, or an SMT error response
- See Also:
-
get_unsat_core
Description copied from interface:ISolverReturns the named formulae that form an unsatisfiable core of the current assertion set. Requires :produce-unsat-cores to be enabled; returns an error if it is not.- Specified by:
get_unsat_corein interfaceISolver- Returns:
- a list of formula names, unsupported, or an SMT error response
- See Also:
-
get_value
Description copied from interface:ISolverReturns the values of the given expressions in the current satisfying model. Requires :produce-models to be enabled and the last check-sat to have returned sat; returns an error if these preconditions are not met. -
get_assignment
Description copied from interface:ISolverReturns the truth-value assignments for all named Boolean formulae in the current model. Requires :produce-assignments to be enabled and the last check-sat to have returned sat; returns an error if these preconditions are not met.- Specified by:
get_assignmentin interfaceISolver- Returns:
- a list of name–Boolean pairs, unsupported, or an SMT error response
- See Also:
-
get_option
Description copied from interface:ISolverReturns the current value of the named option.- Specified by:
get_optionin interfaceISolver- Parameters:
option- the keyword naming the option- Returns:
- the option value, or unsupported, or an SMT error response
- See Also:
-
get_info
Description copied from interface:ISolverReturns the value of the named info item. -
smt
Description copied from interface:ISolverReturns the configuration object with which the solver is initialized -
checkSatStatus
Description copied from interface:ISolverReturns the result of the most recent check-sat or check-sat-assuming, or null if none has been issued since the last push/pop/assert/declare/define.- Specified by:
checkSatStatusin interfaceISolver- See Also:
-
declare_datatype
Description copied from interface:ISolverDeclares a new datatype sort; returns success or an SMT error response- Specified by:
declare_datatypein interfaceISolver
-
declare_datatypes
Description copied from interface:ISolverDeclares mutually recursive datatype sorts; returns success or an SMT error response- Specified by:
declare_datatypesin interfaceISolver
-