Class Solver

java.lang.Object
io.github.cvc5.Solver
All Implemented Interfaces:
AutoCloseable

public class Solver extends Object implements AutoCloseable
A cvc5 solver.
  • Field Details

    • pointer

      protected long pointer
      The raw native pointer value.
  • Constructor Details

    • Solver

      public Solver(TermManager tm)
      Create solver instance.
      Parameters:
      tm - The associated term manager.
  • Method Details

    • close

      public void close()
      Free the native solver, see deletePointer().
      Specified by:
      close in interface AutoCloseable
    • toString

      protected String toString(long pointer)
      Return a string representation of the specified native pointer.

      Subclasses must implement this method to convert the native pointer into a meaningful string.

      Parameters:
      pointer - the native pointer
      Returns:
      a string representation of the pointer
    • equals

      public boolean equals(Object s)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Return a hash code value for this solver. The hash code is derived from the underlying native pointer, which is what equals(Object) compares, so that instances that are equal have the same hash code.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this solver
    • getTermManager

      public TermManager getTermManager()
      Get the associated term manager instance.

      The returned object refers to the same term manager as the one this solver was created with: closing it releases that term manager and every object derived from it, including this solver, see TermManager.close().

      Returns:
      The term manager.
    • simplify

      public Term simplify(Term t)
      Simplify a term or formula based on rewriting.
      Parameters:
      t - The term to simplify.
      Returns:
      The simplified term.
      Note:
      This function is experimental and may change in future versions.
    • simplify

      public Term simplify(Term t, boolean applySubs)
      Simplify a term or formula based on rewriting and (optionally) applying substitutions for solved variables. If applySubs is true, then for example, if `(= x 0)` was asserted to this solver, this method may replace occurrences of `x` with `0`.
      Parameters:
      t - The term to simplify.
      applySubs - Whether to apply substitutions for solved variables.
      Returns:
      The simplified term.
      Note:
      This function is experimental and may change in future versions.
    • assertFormula

      public void assertFormula(Term term)
      Assert a formula. SMT-LIB: ( assert <term> )
      Parameters:
      term - The formula to assert.
    • checkSat

      public Result checkSat()
      Check satisfiability. SMT-LIB: ( check-sat )
      Returns:
      The result of the satisfiability check.
    • checkSatAssuming

      public Result checkSatAssuming(Term assumption)
      Check satisfiability assuming the given formula. SMT-LIB: ( check-sat-assuming ( <prop_literal> ) )
      Parameters:
      assumption - The formula to assume.
      Returns:
      The result of the satisfiability check.
    • checkSatAssuming

      public Result checkSatAssuming(Term[] assumptions)
      Check satisfiability assuming the given formulas. SMT-LIB: ( check-sat-assuming ( <prop_literal>+ ) )
      Parameters:
      assumptions - The formulas to assume.
      Returns:
      The result of the satisfiability check.
    • declareDatatype

      public Sort declareDatatype(String symbol, DatatypeConstructorDecl[] ctors)
      Create datatype sort. SMT-LIB: ( declare-datatype <symbol> <datatype_decl> )
      Parameters:
      symbol - The name of the datatype sort.
      ctors - The constructor declarations of the datatype sort.
      Returns:
      The datatype sort.
    • declareFun

      public Term declareFun(String symbol, Sort[] sorts, Sort sort)
      Declare n-ary function symbol. SMT-LIB: ( declare-fun <symbol> ( <sort>* ) <sort> )
      Parameters:
      symbol - The name of the function.
      sorts - The sorts of the parameters to this function.
      sort - The sort of the return value of this function.
      Returns:
      The function.
    • declareFun

      public Term declareFun(String symbol, Sort[] sorts, Sort sort, boolean fresh)
      Declare n-ary function symbol. SMT-LIB: ( declare-fun <symbol> ( <sort>* ) <sort> )
      Parameters:
      symbol - The name of the function.
      sorts - The sorts of the parameters to this function.
      sort - The sort of the return value of this function.
      fresh - If true, then this method always returns a new Term. Otherwise, this method will always return the same Term for each call with the given sorts and symbol where fresh is false.
      Returns:
      The function.
    • declareSort

      public Sort declareSort(String symbol, int arity) throws CVC5ApiException
      Declare uninterpreted sort. SMT-LIB: ( declare-sort <symbol> <numeral> )
      Parameters:
      symbol - The name of the sort.
      arity - The arity of the sort.
      Returns:
      The sort.
      Throws:
      CVC5ApiException - on error
      Note:
      This corresponds to TermManager.mkUninterpretedSort(java.lang.String) if arity = 0, and to TermManager.mkUninterpretedSortConstructorSort(int, java.lang.String) if arity > 0.
    • declareSort

      public Sort declareSort(String symbol, int arity, boolean fresh) throws CVC5ApiException
      Declare uninterpreted sort. SMT-LIB: ( declare-sort <symbol> <numeral> )
      Parameters:
      symbol - The name of the sort.
      arity - The arity of the sort.
      fresh - If true, then this method always returns a new Sort. Otherwise, this method will always return the same Sort for each call with the given arity and symbol where fresh is false.
      Returns:
      The sort.
      Throws:
      CVC5ApiException - on error
      Note:
      This corresponds to TermManager.mkUninterpretedSort(java.lang.String) if arity = 0, and to TermManager.mkUninterpretedSortConstructorSort(int, java.lang.String) if arity > 0.
    • defineFun

      public Term defineFun(String symbol, Term[] boundVars, Sort sort, Term term)
      Define n-ary function in the current context. SMT-LIB: ( define-fun <function_def> )
      Parameters:
      symbol - The name of the function.
      boundVars - The parameters to this function.
      sort - The sort of the return value of this function.
      term - The function body.
      Returns:
      The function.
    • defineFun

      public Term defineFun(String symbol, Term[] boundVars, Sort sort, Term term, boolean global)
      Define n-ary function. SMT-LIB: ( define-fun <function_def> )
      Parameters:
      symbol - The name of the function.
      boundVars - The parameters to this function.
      sort - The sort of the return value of this function.
      term - The function body.
      global - Determines whether this definition is global (i.e., persists when popping the context).
      Returns:
      The function.
    • defineFunRec

      public Term defineFunRec(String symbol, Term[] boundVars, Sort sort, Term term)
      Define recursive function in the current context. SMT-LIB: ( define-fun-rec <function_def> )
      Parameters:
      symbol - The name of the function.
      boundVars - The parameters to this function.
      sort - The sort of the return value of this function.
      term - The function body.
      Returns:
      The function.
    • defineFunRec

      public Term defineFunRec(String symbol, Term[] boundVars, Sort sort, Term term, boolean global)
      Define recursive function. SMT-LIB: ( define-fun-rec <function_def> )
      Parameters:
      symbol - The name of the function.
      boundVars - The parameters to this function.
      sort - The sort of the return value of this function.
      term - The function body.
      global - Determines whether this definition is global (i.e., persists when popping the context).
      Returns:
      The function.
    • defineFunRec

      public Term defineFunRec(Term fun, Term[] boundVars, Term term)
      Define recursive function in the current context. SMT-LIB: ( define-fun-rec <function_def> ) Create parameter fun with TermManager.mkConst(Sort).
      Parameters:
      fun - The sorted function.
      boundVars - The parameters to this function.
      term - The function body.
      Returns:
      The function.
    • defineFunRec

      public Term defineFunRec(Term fun, Term[] boundVars, Term term, boolean global)
      Define recursive function. SMT-LIB: ( define-fun-rec <function_def> ) Create parameter fun with TermManager.mkConst(Sort).
      Parameters:
      fun - The sorted function.
      boundVars - The parameters to this function.
      term - The function body.
      global - Determines whether this definition is global (i.e., persists when popping the context).
      Returns:
      The function.
    • defineFunsRec

      public void defineFunsRec(Term[] funs, Term[][] boundVars, Term[] terms)
      Define recursive functions in the current context. SMT-LIB: ( define-funs-rec ( <function_decl>^{n+1} ) ( <term>^{n+1} ) ) Create elements of parameter funs with TermManager.mkConst(Sort).
      Parameters:
      funs - The sorted functions.
      boundVars - The list of parameters to the functions.
      terms - The list of function bodies of the functions.
    • defineFunsRec

      public void defineFunsRec(Term[] funs, Term[][] boundVars, Term[] terms, boolean global)
      Define recursive functions. SMT-LIB: ( define-funs-rec ( <function_decl>^{n+1} ) ( <term>^{n+1} ) ) Create elements of parameter funs with TermManager.mkConst(Sort).
      Parameters:
      funs - The sorted functions.
      boundVars - The list of parameters to the functions.
      terms - The list of function bodies of the functions.
      global - Determines whether this definition is global (i.e., persists when popping the context).
    • getLearnedLiterals

      public Term[] getLearnedLiterals()
      Get a list of input literals that are entailed by the current set of assertions. SMT-LIB: ( get-learned-literals )
      Returns:
      The list of learned literals.
      Note:
      This method is experimental and may change in future versions.
    • getLearnedLiterals

      public Term[] getLearnedLiterals(LearnedLitType type)
      Get a list of literals that are entailed by the current set of assertions. SMT-LIB: ( get-learned-literals :type )
      Parameters:
      type - The type of learned literals to return
      Returns:
      The list of learned literals.
      Note:
      This method is experimental and may change in future versions.
    • getAssertions

      public Term[] getAssertions()
      Get the list of asserted formulas. SMT-LIB: ( get-assertions )
      Returns:
      The list of asserted formulas.
    • getInfo

      public String getInfo(String flag)
      Get info from the solver. SMT-LIB: ( get-info <info_flag> )
      Parameters:
      flag - The get-info flag.
      Returns:
      The info.
    • getOption

      public String getOption(String option)
      Get the value of a given option. SMT-LIB: ( get-option <keyword> )
      Parameters:
      option - The option for which the value is queried.
      Returns:
      A string representation of the option value.
    • getOptionNames

      public String[] getOptionNames()
      Get all option names that can be used with setOption(String, String), getOption(String) and getOptionInfo(String).
      Returns:
      All option names.
    • getOptionInfo

      public OptionInfo getOptionInfo(String option)
      Get some information about the given option. Check the OptionInfo class for more details on which information is available.
      Parameters:
      option - The name of the option.
      Returns:
      Information about the given option.
    • getUnsatAssumptions

      public Term[] getUnsatAssumptions()
      Get the set of unsat ("failed") assumptions. SMT-LIB: ( get-unsat-assumptions ) Requires to enable option produce-unsat-assumptions.
      Returns:
      The set of unsat assumptions.
    • getUnsatCore

      public Term[] getUnsatCore()
      Get the unsatisfiable core. SMT-LIB: (get-unsat-core) Requires to enable option produce-unsat-cores.
      Returns:
      A set of terms representing the unsatisfiable core.
      Note:
      In contrast to SMT-LIB, cvc5's API does not distinguish between named and unnamed assertions when producing an unsatisfiable core. Additionally, the API allows this option to be called after a check with assumptions. A subset of those assumptions may be included in the unsatisfiable core returned by this method.
    • getUnsatCoreLemmas

      public Term[] getUnsatCoreLemmas()
      Get the lemmas used to derive unsatisfiability. SMT-LIB: (get-unsat-core-lemmas) Requires the SAT proof unsat core mode, so to enable option unsat-core-mode=sat-proof
      Returns:
      A set of terms representing the lemmas used to derive unsatisfiability.
      Note:
      This method is experimental and may change in future versions.
    • getDifficulty

      public Map<Term,Term> getDifficulty()
      Get a difficulty estimate for an asserted formula. This method is intended to be called immediately after any response to a checkSat.
      Returns:
      A map from (a subset of) the input assertions to a real value that. is an estimate of how difficult each assertion was to solve. Unmentioned assertions can be assumed to have zero difficulty.
      Note:
      This method is experimental and may change in future versions.
    • getTimeoutCore

      public Pair<Result,Term[]> getTimeoutCore()
      Get a timeout core, which computes a subset of the current assertions that cause a timeout. Note it does not require being proceeded by a call to checkSat. SMT-LIB: (get-timeout-core)
      Returns:
      The result of the timeout core computation. This is a pair containing a result and a list of formulas. If the result is unknown and the reason is timeout, then the list of formulas correspond to a subset of the current assertions that cause a timeout in the specified time timeout-core-timeout. If the result is unsat, then the list of formulas correspond to an unsat core for the current assertions. If the computation was terminated by the connected terminator, the result is unknown with explanation UnknownExplanation.INTERRUPTED, and the list of formulas is empty. Otherwise, the result is sat, indicating that the current assertions are satisfiable, and the list of formulas is empty. This method may make multiple checks for satisfiability internally, each limited by the timeout value given by timeout-core-timeout.
      Note:
      This method is experimental and may change in future versions.
    • getTimeoutCoreAssuming

      public Pair<Result,Term[]> getTimeoutCoreAssuming(Term[] assumptions)
      Get a timeout core, which computes a subset of the given assumptions that cause a timeout when added to the current assertions. Note it does not require being proceeded by a call to checkSat. SMT-LIB: (get-timeout-core)
      Parameters:
      assumptions - The formulas to assume.
      Returns:
      The result of the timeout core computation. This is a pair containing a result and a list of formulas. If the result is unknown and the reason is timeout, then the list of formulas correspond to a subset of assumptions that cause a timeout when added to the current assertions in the specified time timeout-core-timeout. If the result is unsat, then the list of formulas plus the current assertions correspond to an unsat core for the current assertions. If the computation was terminated by the connected terminator, the result is unknown with explanation UnknownExplanation.INTERRUPTED, and the list of formulas is empty. Otherwise, the result is sat, indicating that the given assumptions plus the current assertions are satisfiable, and the list of formulas is empty. This method may make multiple checks for satisfiability internally, each limited by the timeout value given by timeout-core-timeout.
      Note:
      This method is experimental and may change in future versions.
    • getProof

      public Proof[] getProof()
      Get refutation proof for the most recent call to checkSat. SMT-LIB: ( get-proof ) Requires to enable option produce-proofs.
      Returns:
      A vector of proof nodes. This is equivalent to getProof when c is FULL.
      Note:
      This method is experimental and may change in future versions.
    • getProof

      public Proof[] getProof(ProofComponent c)
      Get a proof associated with the most recent call to checkSat. SMT-LIB: ( get-proof :c) Requires to enable option produce-proofs.
      Parameters:
      c - The component of the proof to return
      Returns:
      A vector of proof nodes.
      Note:
      This method is experimental and may change in future versions.
    • proofToString

      public String proofToString(Proof proof)
      Prints a proof into a string with a slected proof format mode. Other aspects of printing are taken from the solver options.
      Parameters:
      proof - A proof.
      Returns:
      The proof printed in the current format.
      Note:
      This method is experimental and may change in future versions.
    • proofToString

      public String proofToString(Proof proof, ProofFormat format)
      Prints a proof into a string with a slected proof format mode. Other aspects of printing are taken from the solver options.
      Parameters:
      proof - A proof.
      format - The proof format used to print the proof. Must be `PROOF_FORMAT_NONE` if the proof is from a component other than `PROOF_COMPONENT_FULL`.
      Returns:
      The proof printed in the current format.
      Note:
      This method is experimental and may change in future versions.
    • proofToString

      public String proofToString(Proof proof, ProofFormat format, Map assertionNames)
      Prints a proof into a string with a slected proof format mode. Other aspects of printing are taken from the solver options.
      Parameters:
      proof - A proof.
      format - The proof format used to print the proof. Must be `PROOF_FORMAT_NONE` if the proof is from a component other than `PROOF_COMPONENT_FULL`.
      assertionNames - Mapping between assertions and names, if they were given by the user. This is used by the Alethe proof format.
      Returns:
      The proof printed in the current format.
      Note:
      This method is experimental and may change in future versions.
    • getValue

      public Term getValue(Term term)
      Get the value of the given term in the current model. SMT-LIB: ( get-value ( <term> ) )
      Parameters:
      term - The term for which the value is queried.
      Returns:
      The value of the given term.
    • getValue

      public Term[] getValue(Term[] terms)
      Get the values of the given terms in the current model. SMT-LIB: ( get-value ( <term>+ ) )
      Parameters:
      terms - The terms for which the value is queried.
      Returns:
      The values of the given terms.
    • getModelDomainElements

      public Term[] getModelDomainElements(Sort s)
      Get the domain elements of uninterpreted sort s in the current model. The current model interprets s as the finite sort whose domain elements are given in the return value of this method.
      Parameters:
      s - The uninterpreted sort in question.
      Returns:
      The domain elements of s in the current model.
    • isModelCoreSymbol

      public boolean isModelCoreSymbol(Term v)
      This returns false if the model value of free constant v was not essential for showing the satisfiability of the last call to checkSat() using the current model. This method will only return false (for any v) if the option model-cores has been set.
      Parameters:
      v - The term in question.
      Returns:
      True if v is a model core symbol.
      Note:
      This method is experimental and may change in future versions.
    • getModel

      public String getModel(Sort[] sorts, Term[] vars)
      Get the model SMT-LIB: ( get-model ) Requires to enable option produce-models.
      Parameters:
      sorts - The list of uninterpreted sorts that should be printed in the. model.
      vars - The list of free constants that should be printed in the. model. A subset of these may be printed based on isModelCoreSymbol(Term).
      Returns:
      A string representing the model.
      Note:
      This method is experimental and may change in future versions.
    • getQuantifierElimination

      public Term getQuantifierElimination(Term q)
      Do quantifier elimination. SMT-LIB: ( get-qe <q> ) Quantifier Elimination is only complete for logics such as LRA, LIA and BV. The formula q must not contain free variables, i.e., variables constructed via TermManager.mkVar(Sort) that are not bound by a quantifier in q. The symbols y1...yn should be free constants constructed via TermManager.mkConst(Sort). An exception is thrown if q contains free variables.
      Parameters:
      q - A quantified formula of the form: Q x1...xn. P( x1...xn, y1...yn ) where P( x1...xn, y1...yn ) is a quantifier-free formula.
      Returns:
      A formula ret such that, given the current set of formulas A asserted to this solver: - ( A && q ) and ( A && ret ) are equivalent - ret is quantifier-free formula containing only free constants in y1...yn.
      Note:
      This method is experimental and may change in future versions.
    • getQuantifierEliminationDisjunct

      public Term getQuantifierEliminationDisjunct(Term q)
      Do partial quantifier elimination, which can be used for incrementally computing the result of a quantifier elimination. SMT-LIB: ( get-qe-disjunct <q> ) Quantifier Elimination is only complete for logics such as LRA, LIA and BV. The formula q must not contain free variables, i.e., variables constructed via TermManager.mkVar(Sort) that are not bound by a quantifier in q. The symbols y1...yn should be free constants constructed via TermManager.mkConst(Sort). An exception is thrown if q contains free variables.
      Parameters:
      q - A quantified formula of the form: Q x1...xn. P( x1...xn, y1...yn ) where P( x1...xn, y1...yn ) is a quantifier-free formula.
      Returns:
      A formula ret such that, given the current set of formulas A asserted to this solver: - (A ^ q) => (A ^ ret) if Q is forall or (A ^ ret) => (A ^ q) if Q is exists, - ret is quantifier-free formula containing only free constants in y1...yn, - If Q is exists, let A && Q_n be the formula A && ~(ret && Q_1) && ... && ~(ret && Q_n) where for each i=1,...n, formula ret && Q_i is the result of calling getQuantifierEliminationDisjunct(Term) for q with the set of assertions A && Q_{i-1}. Similarly, if Q is forall, then let A && Q_n be A && (ret && Q_1) && ... && (ret&& Q_n) where ret && Q_i is the same as above. In either case, we have that ret && Q_j will eventually be true or false, for some finite j.
      Note:
      This method is experimental and may change in future versions.
    • declareSepHeap

      public void declareSepHeap(Sort locSort, Sort dataSort)
      When using separation logic, this sets the location sort and the datatype sort to the given ones. This method should be invoked exactly once, before any separation logic constraints are provided.
      Parameters:
      locSort - The location sort of the heap.
      dataSort - The data sort of the heap.
      Note:
      This method is experimental and may change in future versions.
    • getValueSepHeap

      public Term getValueSepHeap()
      When using separation logic, obtain the term for the heap.
      Returns:
      The term for the heap.
      Note:
      This method is experimental and may change in future versions.
    • getValueSepNil

      public Term getValueSepNil()
      When using separation logic, obtain the term for nil.
      Returns:
      The term for nil.
      Note:
      This method is experimental and may change in future versions.
    • declarePool

      public Term declarePool(String symbol, Sort sort, Term[] initValue)
      Declare a symbolic pool of terms with the given initial value. SMT-LIB: ( declare-pool <symbol> <sort> ( <term>* ) )
      Parameters:
      symbol - The name of the pool.
      sort - The sort of the elements of the pool.
      initValue - The initial value of the pool.
      Returns:
      The pool.
      Note:
      This method is experimental and may change in future versions.
    • declareOracleFun

      public Term declareOracleFun(String symbol, Sort[] sorts, Sort sort, IOracle oracle)
      Declare an oracle function with reference to an implementation. Oracle functions have a different semantics with respect to ordinary declared functions. In particular, for an input to be satisfiable, its oracle functions are implicitly universally quantified. This method is used in part for implementing this command: (declare-oracle-fun <sym> (<sort>*) <sort> <sym>) In particular, the above command is implemented by constructing a function over terms that wraps a call to binary sym via a text interface.
      Parameters:
      symbol - The name of the oracle
      sorts - The sorts of the parameters to this function
      sort - The sort of the return value of this function
      oracle - An object that implements the oracle interface.
      Returns:
      The oracle function
      Note:
      This method is experimental and may change in future versions.
    • addPlugin

      public void addPlugin(AbstractPlugin p)
      Add plugin to this solver. Its callbacks will be called throughout the lifetime of this solver.
      Parameters:
      p - The plugin to add to this solver.
    • setTerminator

      public void setTerminator(ITerminator terminator)
      Connect a terminator to this solver, which is called periodically during queries to determine whether the current query should be terminated. See ITerminator for details.

      Only one terminator can be connected at a time, connecting a terminator disconnects the previously connected terminator.

      Parameters:
      terminator - The terminator to connect, or null to disconnect the currently connected terminator.
      Note:
      This method is experimental and may change in future versions.
    • pop

      public void pop() throws CVC5ApiException
      Pop a level from the assertion stack. SMT-LIB: ( pop <numeral> )
      Throws:
      CVC5ApiException - on error
    • pop

      public void pop(int nscopes) throws CVC5ApiException
      Pop (a) level(s) from the assertion stack. SMT-LIB: ( pop <numeral> )
      Parameters:
      nscopes - The number of levels to pop.
      Throws:
      CVC5ApiException - on error
    • getInterpolant

      public Term getInterpolant(Term conj)
      Get an interpolant.

      Given that A->B is valid, this function determines a term I over the shared variables of A and B, such that A->I and I->B are valid. A is the current set of assertions and B is the conjecture, given as conj.

      SMT-LIB: ( get-interpolant <symbol> <conj> )
      Parameters:
      conj - The conjecture term.
      Returns:
      The interpolant, if an interpolant exists, else the null term.
      Note:
      In SMT-LIB, <symbol> assigns a symbol to the interpolant., Requires option produce-interpolants to be set to a mode different from none., This method is experimental and may change in future versions.
    • getInterpolant

      public Term getInterpolant(Term conj, Grammar grammar)
      Get an interpolant.

      Given that A->B is valid, this function determines a term I, over the shared variables of A and B, with respect to a given grammar, such that A->I and I->B are valid, if such a term exits. A is the current set of assertions and B is the conjecture, given as conj.

      SMT-LIB: ( get-interpolant <symbol> <conj> <g> )
      Parameters:
      conj - The conjecture term.
      grammar - The grammar for the interpolant I.
      Returns:
      The interpolant, if an interpolant exists, else the null term.
      Note:
      In SMT-LIB, <symbol> assigns a symbol to the interpolant., Requires option produce-interpolants to be set to a mode different from none., This method is experimental and may change in future versions.
    • getInterpolantNext

      public Term getInterpolantNext()
      Get the next interpolant. Can only be called immediately after a successful call to get-interpolant or get-interpolant-next. Is guaranteed to produce a syntactically different interpolant wrt the last returned interpolant if successful. SMT-LIB: (get-interpolant-next) Requires to enable incremental mode, and option produce-interpolants to be set to a mode different from none.
      Returns:
      A Term I such that A->I and I->B are valid, where A is the current set of assertions and B is given in the input by conj on the last call to getInterpolant, or the null term if such a term cannot be found.
      Note:
      This method is experimental and may change in future versions.
    • getAbduct

      public Term getAbduct(Term conj)
      Get an abduct. SMT-LIB: ( get-abduct <conj> ) Requires enabling option produce-abducts.
      Parameters:
      conj - The conjecture term.
      Returns:
      A term C such that A && C is satisfiable, and A && ~B && C is unsatisfiable, where A is the current set of assertions and B is given in the input by conj, or the null term if such a term cannot be found.
      Note:
      This method is experimental and may change in future versions.
    • getAbduct

      public Term getAbduct(Term conj, Grammar grammar)
      Get an abduct. SMT-LIB: ( get-abduct <conj> <g> ) Requires enabling option produce-abducts.
      Parameters:
      conj - The conjecture term.
      grammar - The grammar for the abduct C.
      Returns:
      A term C such that A && C is satisfiable, and A && ~B && C is unsatisfiable, where A is the current set of assertions and B is given in the input by conj, or the null term if such a term cannot be found.
      Note:
      This method is experimental and may change in future versions.
    • getAbductNext

      public Term getAbductNext()
      Get the next abduct. Can only be called immediately after a successful call to get-abduct or get-abduct-next. Is guaranteed to produce a syntactically different abduct wrt the last returned abduct if successful. SMT-LIB: ( get-abduct-next ) Requires enabling incremental mode and option produce-abducts.
      Returns:
      A term C such that A^C is satisfiable, and A^~B^C is. unsatisfiable, where A is the current set of assertions and B is given in the input by conj in the last call to getAbduct, or the null term if such a term cannot be found.
      Note:
      This method is experimental and may change in future versions.
    • blockModel

      public void blockModel(BlockModelsMode mode)
      Block the current model. Can be called only if immediately preceded by a SAT or INVALID query. SMT-LIB: ( block-model ) Requires enabling option produce-models.
      Parameters:
      mode - The mode to use for blocking.
      Note:
      This method is experimental and may change in future versions.
    • blockModelValues

      public void blockModelValues(Term[] terms)
      Block the current model values of (at least) the values in terms. Can be called only if immediately preceded by a SAT query. SMT-LIB: ( block-model-values ( <terms>+ ) ) Requires enabling option produce-models.
      Parameters:
      terms - The model values to block.
      Note:
      This method is experimental and may change in future versions.
    • getInstantiations

      public String getInstantiations()
      Get a string that contains information about all instantiations made by the quantifiers module.
      Returns:
      The string representing the information about all instantiations.
      Note:
      This method is experimental and may change in future versions.
    • push

      public void push() throws CVC5ApiException
      Push a level to the assertion stack. SMT-LIB: ( push <numeral> )
      Throws:
      CVC5ApiException - on error
    • push

      public void push(int nscopes) throws CVC5ApiException
      Push (a) level(s) to the assertion stack. SMT-LIB: ( push <numeral> )
      Parameters:
      nscopes - The number of levels to push.
      Throws:
      CVC5ApiException - on error
    • resetAssertions

      public void resetAssertions()
      Remove all assertions. SMT-LIB: ( reset-assertions )
    • setInfo

      public void setInfo(String keyword, String value) throws CVC5ApiException
      Set info. SMT-LIB: ( set-info <attribute> )
      Parameters:
      keyword - The info flag.
      value - The value of the info flag.
      Throws:
      CVC5ApiException - on error
    • setLogic

      public void setLogic(String logic) throws CVC5ApiException
      Set logic. SMT-LIB: ( set-logic <symbol> )
      Parameters:
      logic - The logic to set.
      Throws:
      CVC5ApiException - on error
    • isLogicSet

      public boolean isLogicSet()
      Is logic set? Returns whether we called setLogic yet for this solver.
      Returns:
      whether we called setLogic yet for this solver.
    • getLogic

      public String getLogic() throws CVC5ApiException
      Get the logic set the solver.
      Returns:
      The logic used by the solver.
      Throws:
      CVC5ApiException - on error
      Note:
      Asserts isLogicSet().
    • setOption

      public void setOption(String option, String value)
      Set option. SMT-LIB: ( set-option <option> )
      Parameters:
      option - The option name.
      value - The option value.
    • declareSygusVar

      public Term declareSygusVar(String symbol, Sort sort)
      Append symbol to the current list of universal variables. SyGuS v2: ( declare-var <symbol> <sort> )
      Parameters:
      symbol - The name of the universal variable.
      sort - The sort of the universal variable.
      Returns:
      The universal variable.
    • synthFun

      public Term synthFun(String symbol, Term[] boundVars, Sort sort)
      Synthesize n-ary function. SyGuS v2: ( synth-fun <symbol> ( <boundVars>* ) <sort> )
      Parameters:
      symbol - The name of the function.
      boundVars - The parameters to this function.
      sort - The sort of the return value of this function.
      Returns:
      The function.
    • synthFun

      public Term synthFun(String symbol, Term[] boundVars, Sort sort, Grammar grammar)
      Synthesize n-ary function following specified syntactic constraints. SyGuS v2: ( synth-fun <symbol> ( <boundVars>* ) <sort> <g> )
      Parameters:
      symbol - The name of the function.
      boundVars - The parameters to this function.
      sort - The sort of the return value of this function.
      grammar - The syntactic constraints.
      Returns:
      The function.
    • addSygusConstraint

      public void addSygusConstraint(Term term)
      Add a forumla to the set of Sygus constraints. SyGuS v2: ( constraint <term> )
      Parameters:
      term - The formula to add as a constraint.
    • getSygusConstraints

      public Term[] getSygusConstraints()
      Get the list of sygus constraints.
      Returns:
      The list of sygus constraints.
    • addSygusAssume

      public void addSygusAssume(Term term)
      Add a forumla to the set of Sygus assumptions. SyGuS v2: ( assume <term> )
      Parameters:
      term - The formula to add as an assumption.
    • getSygusAssumptions

      public Term[] getSygusAssumptions()
      Get the list of sygus assumptions.
      Returns:
      The list of sygus assumptions.
    • addSygusInvConstraint

      public void addSygusInvConstraint(Term inv, Term pre, Term trans, Term post)
      Add a set of Sygus constraints to the current state that correspond to an invariant synthesis problem. SyGuS v2: ( inv-constraint <inv> <pre> <trans> <post> )
      Parameters:
      inv - The function-to-synthesize.
      pre - The pre-condition.
      trans - The transition relation.
      post - The post-condition.
    • checkSynth

      public SynthResult checkSynth()
      Try to find a solution for the synthesis conjecture corresponding to the current list of functions-to-synthesize, universal variables and constraints. SyGuS v2: ( check-synth )
      Returns:
      The result of the check, which is "solution" if the check found a. solution in which case solutions are available via getSynthSolutions, "no solution" if it was determined there is no solution, or "unknown" otherwise.
    • checkSynthNext

      public SynthResult checkSynthNext()
      Try to find a next solution for the synthesis conjecture corresponding to the current list of functions-to-synthesize, universal variables and constraints. Must be called immediately after a successful call to check-synth or check-synth-next.
      Returns:
      The result of the check, which is "solution" if the check found a solution in which case solutions are available via getSynthSolutions, "no solution" if it was determined there is no solution, or "unknown" otherwise.
      Note:
      Requires incremental mode. SyGuS v2: ( check-synth-next )
    • getSynthSolution

      public Term getSynthSolution(Term term)
      Get the synthesis solution of the given term. This method should be called immediately after the solver answers unsat for sygus input.
      Parameters:
      term - The term for which the synthesis solution is queried.
      Returns:
      The synthesis solution of the given term.
    • getSynthSolutions

      public Term[] getSynthSolutions(Term[] terms)
      Get the synthesis solutions of the given terms. This method should be called immediately after the solver answers unsat for sygus input.
      Parameters:
      terms - The terms for which the synthesis solutions is queried.
      Returns:
      The synthesis solutions of the given terms.
    • findSynth

      public Term findSynth(FindSynthTarget fst)
      Find a target term of interest using sygus enumeration, with no provided grammar. The solver will infer which grammar to use in this call, which by default will be the grammars specified by the function(s)-to-synthesize in the current context. SyGuS v2: (find-synth :target)
      Parameters:
      fst - The identifier specifying what kind of term to find
      Returns:
      The result of the find, which is the null term if this call failed.
      Note:
      This method is experimental and may change in future versions.
    • findSynth

      public Term findSynth(FindSynthTarget fst, Grammar grammar)
      Find a target term of interest using sygus enumeration with a provided grammar. SyGuS v2: (find-synth :target G)
      Parameters:
      fst - The identifier specifying what kind of term to find
      grammar - The grammar for the term
      Returns:
      The result of the find, which is the null term if this call failed.
      Note:
      This method is experimental and may change in future versions.
    • findSynthNext

      public Term findSynthNext()
      Try to find a next target term of interest using sygus enumeration. Must be called immediately after a successful call to find-synth or find-synth-next. SyGuS v2: (find-synth-next)
      Returns:
      The result of the find, which is the null term if this call failed.
      Note:
      This method is experimental and may change in future versions.
    • getStatistics

      public Statistics getStatistics()
      Get a snapshot of the current state of the statistic values of this solver. The returned object will not change when the solver is used again. Like every object derived from a term manager, it is released when that term manager is closed, see TermManager.close().
      Returns:
      A snapshot of the current state of the statistic values.
    • getVersion

      public String getVersion()
      Get a string representation of the version of this solver.
      Returns:
      The version string.
    • getPointer

      public long getPointer()
      Return the raw native pointer.

      Every native call obtains the pointers of the objects it uses through this method, so that using an object after its native resource has been released raises an exception instead of crashing the JVM.

      Returns:
      the pointer value
      Throws:
      IllegalStateException - if the native resource of this object has been released, e.g., via deletePointer()
    • deletePointer

      public void deletePointer()
      Free the native resource associated with this pointer.

      Native resources are freed automatically once the Java object is no longer reachable. This method frees the native resource immediately instead; afterwards, using the object raises an IllegalStateException. It must be called from the thread that is using the associated term manager. Calling it more than once has no further effect.

    • toString

      public String toString()
      Return a string representation of the pointer.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the pointer