Package org.smtlib.command
Class C_declare_fun
java.lang.Object
org.smtlib.impl.Pos.Posable
org.smtlib.impl.Pos.Printable
org.smtlib.impl.Command
org.smtlib.command.C_declare_fun
- All Implemented Interfaces:
ICommand,ICommand.Ideclare_fun,INode,IPos.IPosable
- Direct Known Subclasses:
C_declare_const
Implements the declare-fun command
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.smtlib.ICommand
ICommand.Iassert, ICommand.Icheck_sat, ICommand.Icheck_sat_assuming, ICommand.Icomment, ICommand.Ideclare_const, ICommand.Ideclare_datatype, ICommand.Ideclare_datatypes, ICommand.Ideclare_fun, ICommand.Ideclare_sort, ICommand.Ideclare_sort_parameter, ICommand.Idefine_const, ICommand.Idefine_fun, ICommand.Idefine_fun_rec, ICommand.Idefine_funs_rec, ICommand.Idefine_sort, ICommand.Iecho, ICommand.Iexit, ICommand.IFactory, ICommand.IFinder, ICommand.Iget_assertions, ICommand.Iget_assignment, ICommand.Iget_info, ICommand.Iget_model, ICommand.Iget_option, ICommand.Iget_proof, ICommand.Iget_unsat_assumptions, ICommand.Iget_unsat_core, ICommand.Iget_value, ICommand.Ipop, ICommand.Ipush, ICommand.Ireset, ICommand.Ireset_assertions, ICommand.IScript, ICommand.Iset_info, ICommand.Iset_logic, ICommand.Iset_option -
Field Summary
FieldsModifier and TypeFieldDescriptionThe sorts of the arguments of the function being declared -- never null (every construction path, parser or direct, always supplies a real list, empty for a zero-argument function).protected List<IExpr.IAttribute<?>> Any trailing attributes (see attributes()) -- never null,Collections.emptyList()if none (the common case: this is a non-standard extension, only meaningful at all under --relax).static final StringThe command nameprotected IExpr.ISymbolThe name of the function being declaredprotected List<ISort.IParameter> The par-polymorphic parameters (see parameters()).protected ISortThe result sort of the function being declaredFields inherited from class org.smtlib.impl.Command
trailingTextFields inherited from class org.smtlib.impl.Pos.Posable
pos -
Constructor Summary
ConstructorsConstructorDescriptionC_declare_fun(IExpr.ISymbol symbol, List<ISort> argSorts, ISort resultSort) Constructs a command instance for an ordinary (non-attributed, non-par) declarationC_declare_fun(IExpr.ISymbol symbol, List<ISort> argSorts, ISort resultSort, List<IExpr.IAttribute<?>> attributes) Constructs a command instance for an ordinary declaration, including any trailing attributes (see attributes()).C_declare_fun(IExpr.ISymbol symbol, List<ISort> argSorts, ISort resultSort, List<IExpr.IAttribute<?>> attributes, List<ISort.IParameter> parameters) Constructs a command instance from all of its components, including the par-polymorphic parameters (see parameters()) for the "(declare-fun par ...)" form. -
Method Summary
Modifier and TypeMethodDescription<T> TThe accept method corresponding to IVisitor, to be implemented in each subclass as { return v.visit(this); }argSorts()Returns the list of argument sorts.List<IExpr.IAttribute<?>> Returns any trailing attributes given after the result sort -- an experimental, non-standard extension (SMT-LIB's declare-fun has no attribute* production); accepting one at all is unconditional at parse time, but the command is rejected at type-checking time unless --relax is set.The command nameExecutes the command on the given solver; presumes that the command type-checked successfully.Returns the par-polymorphic type parameters, for the experimental, non-standard "(declare-fun par (param+) (name sort+ attribute*))" form -- mirrors exactly the par_fun_symbol_decl shape a theory's own :funs entry uses.static C_declare_funParses the arguments of the command, producing a new command instance.Returns the result sort.symbol()Returns the name of the function being declared.Methods inherited from class org.smtlib.impl.Command
error, setTrailingText, trailingText, write, writeArgsMethods inherited from class org.smtlib.impl.Pos.Printable
toStringMethods inherited from class org.smtlib.impl.Pos.Posable
equals, hashCode, pos, setPosMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.smtlib.IPos.IPosable
pos, setPos
-
Field Details
-
commandName
The command name- See Also:
-
fcnName
The name of the function being declared -
argSorts
The sorts of the arguments of the function being declared -- never null (every construction path, parser or direct, always supplies a real list, empty for a zero-argument function). -
resultSort
The result sort of the function being declared -
attributes
Any trailing attributes (see attributes()) -- never null,Collections.emptyList()if none (the common case: this is a non-standard extension, only meaningful at all under --relax). Unlikeparameters, null-vs-empty draws no real distinction here: the concrete syntax has no way to write an explicit-but-empty attribute clause (attributes are a bare trailing sequence, not a bracketed list), so there is nothing for a null/non-null split to usefully encode -- it would just be an arbitrary implementation detail, not a meaningful state. See issue #42 point 2. -
parameters
The par-polymorphic parameters (see parameters()). Unlikeattributes, null here is load-bearing, not just an empty-list stand-in: it distinguishes an ordinary declaration from the non-standard "(declare-fun par (params) (name sorts attrs))" form (SMT-LIB's declare-fun has no par production at all), andSolver_test.declare_fun(org.smtlib.ICommand.Ideclare_fun)branches on that distinction directly (e.g. requiring --relax only when this is non-null) -- collapsing it toCollections.emptyList()would erase real information (a par-polymorphic declaration's parameter list is never actually empty in practice -- the grammar requiresparam+-- so there is no "empty par-form" state this could be confused with). Null for an ordinary declaration. See issue #42 point 2.
-
-
Constructor Details
-
C_declare_fun
Constructs a command instance for an ordinary (non-attributed, non-par) declaration -
C_declare_fun
public C_declare_fun(IExpr.ISymbol symbol, List<ISort> argSorts, ISort resultSort, List<IExpr.IAttribute<?>> attributes) Constructs a command instance for an ordinary declaration, including any trailing attributes (see attributes()). -
C_declare_fun
public C_declare_fun(IExpr.ISymbol symbol, List<ISort> argSorts, ISort resultSort, List<IExpr.IAttribute<?>> attributes, List<ISort.IParameter> parameters) Constructs a command instance from all of its components, including the par-polymorphic parameters (see parameters()) for the "(declare-fun par ...)" form.
-
-
Method Details
-
commandName
The command name- Specified by:
commandNamein interfaceICommand- Specified by:
commandNamein classCommand
-
symbol
Description copied from interface:ICommand.Ideclare_funReturns the name of the function being declared.- Specified by:
symbolin interfaceICommand.Ideclare_fun
-
argSorts
Description copied from interface:ICommand.Ideclare_funReturns the list of argument sorts.- Specified by:
argSortsin interfaceICommand.Ideclare_fun
-
resultSort
Description copied from interface:ICommand.Ideclare_funReturns the result sort.- Specified by:
resultSortin interfaceICommand.Ideclare_fun
-
attributes
Description copied from interface:ICommand.Ideclare_funReturns any trailing attributes given after the result sort -- an experimental, non-standard extension (SMT-LIB's declare-fun has no attribute* production); accepting one at all is unconditional at parse time, but the command is rejected at type-checking time unless --relax is set. Never null; empty if none were given -- unlikeICommand.Ideclare_fun.parameters(), null-vs-empty has no real distinction to encode here (the concrete syntax has no way to write an explicit-but-empty attribute clause).- Specified by:
attributesin interfaceICommand.Ideclare_fun
-
parameters
Description copied from interface:ICommand.Ideclare_funReturns the par-polymorphic type parameters, for the experimental, non-standard "(declare-fun par (param+) (name sort+ attribute*))" form -- mirrors exactly the par_fun_symbol_decl shape a theory's own :funs entry uses. Accepting this form at all is unconditional at parse time, but the command is rejected at type-checking time unless --relax is set. Null for an ordinary (non-par) declare-fun -- this is load-bearing, not just an empty-list stand-in:Solver_test.declare_fun(org.smtlib.ICommand.Ideclare_fun)branches on null-vs-non-null directly to decide whether --relax is required, and a par-form's parameter list is never actually empty in practice (the grammar requiresparam+), so there is no "empty par-form" state this could be confused with.- Specified by:
parametersin interfaceICommand.Ideclare_fun
-
parse
Parses the arguments of the command, producing a new command instance. Two non-standard extensions, both parsed unconditionally (whether either is actually accepted, rather than rejected with a specific message, is decided at type-checking time in Solver_test.declare_fun() -- see there): - A trailing attribute* after the result sort (e.g. :left-assoc), the same production a theory's own fun_symbol_decl can carry, so a user-declared function can opt into the same n-ary sugar handling SymbolTable.lookup() already applies to theory-declared ones. Standard SMT-LIB declare-fun has no such production. - "(declare-fun par (param+) (name sort+ attribute*))": a par-polymorphic declaration, detected by the literal reserved word "par" appearing where the function's own symbol normally goes (the same technique parseDatatype() already uses to detect datatype's own optional par form). The nested (name sort+ attribute*) is exactly the par_fun_symbol_decl shape a theory's own :funs entry uses (e.g. Core.smt2's (par (A) (= A A Bool :chainable))) -- reusing that shape verbatim, under the familiar declare-fun command name, rather than inventing a different, unrelated syntax or a wholly new top-level command name. SMT-LIB's declare-fun has no par form at all (par otherwise only appears in declare-datatype's own constructor lists).- Throws:
IParser.ParserException
-
execute
Description copied from interface:ICommandExecutes the command on the given solver; presumes that the command type-checked successfully. -
accept
Description copied from interface:INodeThe accept method corresponding to IVisitor, to be implemented in each subclass as { return v.visit(this); }- Specified by:
acceptin interfaceINode- Type Parameters:
T- the return type desired from the visit methods- Parameters:
v- the visitor class- Returns:
- the value returned by the visit method
- Throws:
IVisitor.VisitorException
-