Parser¶
The parser reads SMT-LIB and SyGuS input into commands and terms. A symbol manager tracks the names that the input declares.
SymbolManager¶
Symbol manager. Internally, this class manages a symbol table and other meta-information pertaining to SMT2 file inputs (e.g. named assertions, declared functions, etc.).
A symbol manager can be modified by invoking commands, see Command.invoke.
A symbol manager can be provided when constructing an InputParser, in which case that InputParser has symbols of this symbol manager preloaded.
The symbol manager's interface is otherwise not publicly available.
Wrapper class for the C++ class parser::SymbolManager.
5 of the 5 mirrored methods of SymbolManager are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
isLogicSet |
Returns true if the logic of this symbol manager has been set. | auto | ✓ |
getLogic |
Returns the logic used by this symbol manager. | auto | ✓ |
getDeclaredSorts |
Get the list of sorts that have been declared via declare-sort. | auto | ✓ |
getDeclaredTerms |
Get the list of terms that have been declared via declare-fun and declare-const. | auto | ✓ |
getNamedTerms |
Get a mapping from terms to names that have been given to them via the :named attribute. | auto | ✓ |
SymbolManager.isLogicSet¶
Mojo declaration:
def isLogicSet(self) raises -> Bool
Upstream Python signature:
SymbolManager.isLogicSet()
Returns
True if the logic of this symbol manager has been set.
Binding: Generated from cvc5_sm_is_logic_set.
SymbolManager.getLogic¶
Mojo declaration:
def getLogic(self) raises -> String
Upstream Python signature:
SymbolManager.getLogic()
Note
Asserts isLogicSet().
Returns
The logic used by this symbol manager.
Binding: Generated from cvc5_sm_get_logic.
SymbolManager.getDeclaredSorts¶
Mojo declaration:
def getDeclaredSorts(self) raises -> List[Sort]
Upstream Python signature:
SymbolManager.getDeclaredSorts()
Get the list of sorts that have been declared via declare-sort. These are the sorts that are printed in response to a get-model command.
Returns
The declared sorts.
Binding: Generated from cvc5_sm_get_declared_sorts.
SymbolManager.getDeclaredTerms¶
Mojo declaration:
def getDeclaredTerms(self) raises -> List[Term]
Upstream Python signature:
SymbolManager.getDeclaredTerms()
Get the list of terms that have been declared via declare-fun and declare-const. These are the terms that are printed in response to a get-model command.
Returns
The declared terms.
Binding: Generated from cvc5_sm_get_declared_terms.
SymbolManager.getNamedTerms¶
Mojo declaration:
def getNamedTerms(self) raises -> Dict[Term, String]
Upstream Python signature:
SymbolManager.getNamedTerms()
Get a mapping from terms to names that have been given to them via the :named attribute.
Returns
A map of the named terms to their names.
Binding: Generated from cvc5_sm_get_named_terms.
InputParser¶
This class is the main interface for retrieving commands and expressions from an input using a parser.
After construction, it is expected that an input is first set via e.g.
setFileInput, setStringInput, or
setIncrementalStringInput and appendIncrementalStringInput.
Then, the methods nextCommand and
nextExpression can be invoked to parse the input.
The input parser interacts with a symbol manager, which determines which symbols are defined in the current context, based on the background logic and user-defined symbols. If no symbol manager is provided, then the input parser will construct (an initially empty) one.
If provided, the symbol manager must have a logic that is compatible
with the provided solver. That is, if both the solver and symbol
manager have their logics set (SymbolManager.isLogicSet and
Solver.isLogicSet), then their logics must be the same.
Upon setting an input source, if either the solver (resp. symbol manager) has its logic set, then the symbol manager (resp. solver) is set to use that logic, if its logic is not already set.
Wrapper class for the C++ class parser::InputParser.
9 of the 9 mirrored methods of InputParser are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
getSolver |
Returns the underlying solver of this input parser. | override | ✓ |
getSymbolManager |
Returns the underlying symbol manager of this input parser. | override | ✓ |
setFileInput |
Set the input for the given file. | auto | ✓ |
setStringInput |
Set the input to the given concrete string | auto | ✓ |
setIncrementalStringInput |
Set that we will be feeding strings to this parser via appendIncrementalStringInput | auto | ✓ |
appendIncrementalStringInput |
Append string to the input being parsed by this parser. | auto | ✓ |
nextCommand |
Parse and return the next command. | auto | ✓ |
nextTerm |
Parse and return the next term. | auto | ✓ |
done |
Is this parser done reading input? | auto | ✓ |
InputParser.getSolver¶
Mojo declaration:
def getSolver(self) raises -> Solver
Upstream Python signature:
InputParser.getSolver()
Returns
The underlying solver of this input parser.
Binding: Bound to cvc5_parser_get_solver by bindgen/overrides.toml.
InputParser.getSymbolManager¶
Mojo declaration:
def getSymbolManager(self) raises -> SymbolManager
Upstream Python signature:
InputParser.getSymbolManager()
Returns
The underlying symbol manager of this input parser.
Binding: Bound to cvc5_parser_get_sm by bindgen/overrides.toml.
InputParser.setFileInput¶
Mojo declaration:
def setFileInput(self, lang: InputLanguage, filename: String) raises
Upstream Python signature:
InputParser.setFileInput(lang, filename: str)
Set the input for the given file.
Parameters
lang: The input language (e.g. InputLanguage.SMT_LIB_2_6).filename: The input filename.
Binding: Generated from cvc5_parser_set_file_input.
InputParser.setStringInput¶
Mojo declaration:
def setStringInput(self, lang: InputLanguage, input: String, name: String) raises
Upstream Python signature:
InputParser.setStringInput(lang, input: str, name: str)
Set the input to the given concrete string
Parameters
lang: The input language (e.g. InputLanguage.SMT_LIB_2_6).input: The input string.name: The name of the stream, for use in error messages.
Binding: Generated from cvc5_parser_set_str_input.
InputParser.setIncrementalStringInput¶
Mojo declaration:
def setIncrementalStringInput(self, lang: InputLanguage, name: String) raises
Upstream Python signature:
InputParser.setIncrementalStringInput(lang, name: str)
Set that we will be feeding strings to this parser via appendIncrementalStringInput
Parameters
lang: The input language (e.g. InputLanguage.SMT_LIB_2_6).name: The name of the stream, for use in error messages.
Binding: Generated from cvc5_parser_set_inc_str_input.
InputParser.appendIncrementalStringInput¶
Mojo declaration:
def appendIncrementalStringInput(self, input: String) raises
Upstream Python signature:
InputParser.appendIncrementalStringInput(input: str)
Append string to the input being parsed by this parser. Should be called after calling setIncrementalStringInput.
Parameters
input: The input string.
Binding: Generated from cvc5_parser_append_inc_str_input.
InputParser.nextCommand¶
Mojo declaration:
def nextCommand(self) raises -> Command
Upstream Python signature:
InputParser.nextCommand()
Parse and return the next command. Will initialize the logic to "ALL" or the forced logic if no logic is set prior to this point and a command is read that requires initializing the logic.
Returns
The parsed command. This is the null command if no command was read.
Binding: Generated from cvc5_parser_next_command.
InputParser.nextTerm¶
Mojo declaration:
def nextTerm(self) raises -> Term
Upstream Python signature:
InputParser.nextTerm()
Parse and return the next term. Requires setting the logic prior to this point.
Binding: Generated from cvc5_parser_next_term.
InputParser.done¶
Mojo declaration:
def done(self) raises -> Bool
Upstream Python signature:
InputParser.done()
Is this parser done reading input?
Binding: Generated from cvc5_parser_done.
Command¶
Encapsulation of a command.
Commands are constructed by the input parser and can be invoked on the solver and symbol manager.
Wrapper class for the C++ class parser::Command.
6 of the 6 mirrored methods of Command are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
__str__ |
auto | ✓ | |
__repr__ |
auto | ✓ | |
toString |
Returns a string representation of this result. | auto | ✓ |
invoke |
Invoke the command on the solver and symbol manager, and returns the result. | auto | ✓ |
getCommandName |
Get the name for this command, e.g. | auto | ✓ |
isNull |
Returns true if this command is null. | rule | ✓ |
Command.__str__¶
Mojo declaration:
def write_to(self, mut writer: Some[Writer])
Upstream Python signature:
Command.__str__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_cmd_to_string.
Command.__repr__¶
Mojo declaration:
Upstream Python signature:
Command.__repr__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_cmd_to_string.
Command.toString¶
Mojo declaration:
def toString(self) raises -> String
Upstream Python signature:
Command.toString()
Returns
A string representation of this result.
Binding: Generated from cvc5_cmd_to_string.
Command.invoke¶
Mojo declaration:
def invoke(self, solver: Solver, sm: SymbolManager) raises -> String
Upstream Python signature:
Command.invoke(solver: Solver, sm: SymbolManager)
Invoke the command on the solver and symbol manager, and returns the result.
Parameters
solver: The solver to invoke the command on.sm: The symbol manager to invoke the command on.
Returns
A string representation of the result.
Binding: Generated from cvc5_cmd_invoke.
Command.getCommandName¶
Mojo declaration:
def getCommandName(self) raises -> String
Upstream Python signature:
Command.getCommandName()
Get the name for this command, e.g. "assert".
Returns
The name of this command.
Binding: Generated from cvc5_cmd_get_name.
Command.isNull¶
Mojo declaration:
def isNull(self) -> Bool
Upstream Python signature:
Command.isNull()
Returns
True if this command is null.
Binding: Generated by a rule: a check for a NULL handle, which is how the C API represents a null object.