Class SMT
To extend this tool, e.g. to use it with other factory objects for a different implementation, or to add configuration options:
- Create subclasses of SMT, SMT.Configuration
- The SMT' should set a new object of type SMT.Configuration' in its constructor
- SMT' can override parseCommandLine, help, usage
- Create a new main method; the new main should also instantiate the derived SMT and call exec on it
- SMT.Configuration' can have new options added; it can also instantiate different object factories
- SMT.Configuration' can also instantiate a derived Utils or Log object
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe configuration object holds the values of all of the current options (e.g.static interfaceMarker interface for configuration objects; reserved for future extension.static classThis class is used to turn internal bugs that we do not want to try to recover into exceptions that can be reportedstatic classThis class is a prompter used when more data is needed from a data source -
Field Summary
FieldsModifier and TypeFieldDescriptionThe last check-sat status seen during execution; null if no check-sat has been executed yet.The response from the most recently executed command; used to export results in interactive mode.protected booleanWhether the input being processed may be pipelined (with --pipeline): file and --text input, not the socket or standard input, whose client needs each command's response at onceThe set of configuration settings for this instance of the SMT objectprotected ISolver -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Forcibly stops the active solver, if any.protected intprotected intprotected voidHelper function to log a command-line errorintexec()Executes, presuming all options (e.g.intThe method that does all the execution for the main method, here made a non-static method, so that multiple SMT operations can be proceeding independently.voidhelp()Prints a verbose message about command line argumentsstatic voidThe main method of the SMT applicationintprocessCommandLine(String[] args, SMT.Configuration options) Parses the command-line, setting any option in the given configuration argument.resolveExecutableForSolver(String solvername) Resolves the executable pathstartSolver(org.smtlib.SMT.Configuration, java.lang.String, java.lang.String)would use for the given solver name (absent an explicit caller-supplied override -- startSolver's own executable parameter takes precedence there, which this standalone method has no equivalent of), without instantiating an adapter or starting anything -- lets a caller check whether the file actually exists before committing to run tests against it (see the test harness's LogicTests#solversFromEnv, which filters the solver list against this up front so a missing binary is one WARNING line instead of a wall of per-file failures).static StringresolveExecutablePath(String exec, String solverDir) Resolves the path of a solver executable, whether from the properties (.exec or the solver name) or supplied by the caller: null, or an absolute path: returned unchanged; a relative path with a directory part (e.g.startSolver(SMT.Configuration smtConfig, String solvername, String executable) Starts the solver with the given name and executable, preset according to the given configuration.voidusage()Prints a summary of the command-line arguments
-
Field Details
-
smtConfig
The set of configuration settings for this instance of the SMT object -
checkSatStatus
The last check-sat status seen during execution; null if no check-sat has been executed yet. -
pipelineInput
protected boolean pipelineInputWhether the input being processed may be pipelined (with --pipeline): file and --text input, not the socket or standard input, whose client needs each command's response at once -
solver
-
lastResponse
The response from the most recently executed command; used to export results in interactive mode.
-
-
Constructor Details
-
SMT
public SMT()
-
-
Method Details
-
main
The main method of the SMT application -
exec
The method that does all the execution for the main method, here made a non-static method, so that multiple SMT operations can be proceeding independently.- Parameters:
args- the command-line arguments- Returns:
- the exit code to return to the command-line: 0 if every command succeeded (or for --help and --version); 1 for a command-line error, a solver that could not be started, an input file not found, or any command that reported an error; 2 if input could not be read or processing failed outright (an I/O or parser exception, stack overflow, out of memory). Over several files, the highest code wins.
-
exec
public int exec()Executes, presuming all options (e.g. from the command-line) are set in the configuration object -
doParser
-
cleanup
public void cleanup()Forcibly stops the active solver, if any. Safe to call when no solver is running. -
doParser
-
processCommandLine
Parses the command-line, setting any option in the given configuration argument. -
resolveExecutablePath
Resolves the path of a solver executable, whether from the properties (.exec or the solver name) or supplied by the caller:- null, or an absolute path: returned unchanged;
- a relative path with a directory part (e.g.
../bin/z3): relative to the current directory, as a shell would take it; returned as an absolute path; - a simple file name (e.g.
z3-5.1.0):solverDir/nameif that file exists (on Windows, also asname.exe); else the name unchanged if it is found on the PATH, so that the process launch finds it there; elsesolverDir/name(so an error names the expected file), or the name unchanged if there is no solverDir.
System.getenv("SMT_SOLVER_DIR")as solverDir in production; pass a literal in tests. -
resolveExecutableForSolver
Resolves the executable pathstartSolver(org.smtlib.SMT.Configuration, java.lang.String, java.lang.String)would use for the given solver name (absent an explicit caller-supplied override -- startSolver's own executable parameter takes precedence there, which this standalone method has no equivalent of), without instantiating an adapter or starting anything -- lets a caller check whether the file actually exists before committing to run tests against it (see the test harness's LogicTests#solversFromEnv, which filters the solver list against this up front so a missing binary is one WARNING line instead of a wall of per-file failures). Mirrors the same .exec.<platform> / .exec / bare-name-as-executable resolution order startSolver itself uses for that case, but intentionally not reused *by* startSolver: unlike this method, startSolver still needs a real executable value even for a solver configured via .command (to populate command[0]), where existence-checking a single array element in isolation wouldn't be meaningful -- the two methods' correct behavior genuinely diverges on that case, not just their implementation.Returns null for the "test" pseudo-solver (no executable at all -- pure Java) and for a solver configured via a multi-argument .command property, both treated as "don't existence-check this one" by the caller.
-
startSolver
Starts the solver with the given name and executable, preset according to the given configuration. If executable is null, the path is resolved from jsmtlib.properties -- the org.smtlib.solver_<name>.exec.<platform> entry, then org.smtlib.solver_<name>.exec, then the solver name itself. A simple file name is looked for in $SMT_SOLVER_DIR (else on the PATH); a relative path with a directory part is relative to the current directory (seeSMT.Configuration.createSolver(java.lang.String, java.lang.String)andresolveExecutablePath(java.lang.String, java.lang.String)).This is a thin, CLI-flavored wrapper around
SMT.Configuration.createSolver(java.lang.String, java.lang.String): it resolves and constructs the adapter by delegating there, translating a thrownISolver.CreationExceptioninto this method's ownerror()/usage()/null-return contract (preserved here unchanged for backward compatibility with the CLI's own--solverflag handling and its tests), then itself starts the constructed solver and applies the same response-checking this method has always done.- Parameters:
smtConfig- the configuration object to use for solver settingssolvername- the name of the solver to useexecutable- the executable path- Returns:
- the ISolver object, or null if errors happened
-
error
Helper function to log a command-line error -
usage
public void usage()Prints a summary of the command-line arguments -
help
public void help()Prints a verbose message about command line arguments
-