This commit ensures we don't segfault in the SyGuS API (for non-text inputs) if the option sygus is not set to true. It also renames mkSygusVar to declareSygusVar for consistency with the sygus input format.
For SyGuS API inputs, we now use the option sygus to true instead of setting the language to sygus2.
This furthermore changes a few details in set-defaults regarding the relationship between the language, the sygus option, and when to apply default options for sygus.
It also adds a unit test for checkSynth.
Solver slv;
// required options
- slv.setOption("lang", "sygus2");
+ slv.setOption("sygus", "true");
slv.setOption("incremental", "false");
// set the logic
Term min = slv.synthFun("min", {x, y}, integer);
// declare universal variables.
- Term varX = slv.mkSygusVar(integer, "x");
- Term varY = slv.mkSygusVar(integer, "y");
+ Term varX = slv.declareSygusVar(integer, "x");
+ Term varY = slv.declareSygusVar(integer, "y");
Term max_x_y = slv.mkTerm(APPLY_UF, {max, varX, varY});
Term min_x_y = slv.mkTerm(APPLY_UF, {min, varX, varY});
Solver slv;
// required options
- slv.setOption("lang", "sygus2");
+ slv.setOption("sygus", "true");
slv.setOption("incremental", "false");
// set the logic
Term id4 = slv.synthFun("id4", {x}, integer, g1);
// declare universal variables.
- Term varX = slv.mkSygusVar(integer, "x");
+ Term varX = slv.declareSygusVar(integer, "x");
Term id1_x = slv.mkTerm(APPLY_UF, {id1, varX});
Term id2_x = slv.mkTerm(APPLY_UF, {id2, varX});
Solver slv;
// required options
- slv.setOption("lang", "sygus2");
+ slv.setOption("sygus", "true");
slv.setOption("incremental", "false");
// set the logic
try (Solver slv = new Solver())
{
// required options
- slv.setOption("lang", "sygus2");
+ slv.setOption("sygus", "true");
slv.setOption("incremental", "false");
// set the logic
Term min = slv.synthFun("min", new Term[] {x, y}, integer);
// declare universal variables.
- Term varX = slv.mkSygusVar(integer, "x");
- Term varY = slv.mkSygusVar(integer, "y");
+ Term varX = slv.declareSygusVar(integer, "x");
+ Term varY = slv.declareSygusVar(integer, "y");
Term max_x_y = slv.mkTerm(APPLY_UF, max, varX, varY);
Term min_x_y = slv.mkTerm(APPLY_UF, min, varX, varY);
try (Solver slv = new Solver())
{
// required options
- slv.setOption("lang", "sygus2");
+ slv.setOption("sygus", "true");
slv.setOption("incremental", "false");
// set the logic
Term id4 = slv.synthFun("id4", new Term[] {x}, integer, g1);
// declare universal variables.
- Term varX = slv.mkSygusVar(integer, "x");
+ Term varX = slv.declareSygusVar(integer, "x");
Term id1_x = slv.mkTerm(APPLY_UF, id1, varX);
Term id2_x = slv.mkTerm(APPLY_UF, id2, varX);
try (Solver slv = new Solver())
{
// required options
- slv.setOption("lang", "sygus2");
+ slv.setOption("sygus", "true");
slv.setOption("incremental", "false");
// set the logic
slv = cvc5.Solver()
# required options
- slv.setOption("lang", "sygus2")
+ slv.setOption("sygus", "true")
slv.setOption("incremental", "false")
# set the logic
min = slv.synthFun("min", [x, y], integer)
# declare universal variables.
- varX = slv.mkSygusVar(integer, "x")
- varY = slv.mkSygusVar(integer, "y")
+ varX = slv.declareSygusVar(integer, "x")
+ varY = slv.declareSygusVar(integer, "y")
max_x_y = slv.mkTerm(Kind.ApplyUf, max, varX, varY)
min_x_y = slv.mkTerm(Kind.ApplyUf, min, varX, varY)
slv = cvc5.Solver()
# required options
- slv.setOption("lang", "sygus2")
+ slv.setOption("sygus", "true")
slv.setOption("incremental", "false")
# set the logic
id4 = slv.synthFun("id4", {x}, integer, g1)
# declare universal variables.
- varX = slv.mkSygusVar(integer, "x")
+ varX = slv.declareSygusVar(integer, "x")
id1_x = slv.mkTerm(Kind.ApplyUf, id1, varX)
id2_x = slv.mkTerm(Kind.ApplyUf, id2, varX)
slv = cvc5.Solver()
# required options
- slv.setOption("lang", "sygus2")
+ slv.setOption("sygus", "true")
slv.setOption("incremental", "false")
# set the logic
#include "options/options.h"
#include "options/options_public.h"
#include "options/smt_options.h"
+#include "options/quantifiers_options.h"
#include "proof/unsat_core.h"
#include "smt/env.h"
#include "smt/model.h"
CVC5_API_TRY_CATCH_END;
}
-Term Solver::mkSygusVar(const Sort& sort, const std::string& symbol) const
+Term Solver::declareSygusVar(const Sort& sort, const std::string& symbol) const
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_SORT(sort);
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot call declareSygusVar unless sygus is enabled (use --sygus)";
//////// all checks before this line
Node res = getNodeManager()->mkBoundVar(symbol, *sort.d_type);
(void)res.getType(true); /* kick off type checking */
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_BOUND_VARS(boundVars);
CVC5_API_SOLVER_CHECK_SORT(sort);
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot call synthFun unless sygus is enabled (use --sygus)";
//////// all checks before this line
return synthFunHelper(symbol, boundVars, sort);
////////
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_BOUND_VARS(boundVars);
CVC5_API_SOLVER_CHECK_SORT(sort);
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot call synthFun unless sygus is enabled (use --sygus)";
//////// all checks before this line
return synthFunHelper(symbol, boundVars, sort, false, &grammar);
////////
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_BOUND_VARS(boundVars);
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot call synthInv unless sygus is enabled (use --sygus)";
//////// all checks before this line
return synthFunHelper(
symbol, boundVars, Sort(this, getNodeManager()->booleanType()), true);
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_BOUND_VARS(boundVars);
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot call synthInv unless sygus is enabled (use --sygus)";
//////// all checks before this line
return synthFunHelper(symbol,
boundVars,
CVC5_API_ARG_CHECK_EXPECTED(
term.d_node->getType() == getNodeManager()->booleanType(), term)
<< "boolean term";
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot addSygusConstraint unless sygus is enabled (use --sygus)";
//////// all checks before this line
d_slv->assertSygusConstraint(*term.d_node, false);
////////
CVC5_API_ARG_CHECK_EXPECTED(
term.d_node->getType() == getNodeManager()->booleanType(), term)
<< "boolean term";
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot addSygusAssume unless sygus is enabled (use --sygus)";
//////// all checks before this line
d_slv->assertSygusConstraint(*term.d_node, true);
////////
CVC5_API_CHECK(post.d_node->getType() == invType)
<< "Expected inv and post to have the same sort";
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot addSygusInvConstraint unless sygus is enabled (use --sygus)";
//////// all checks before this line
const std::vector<TypeNode>& invArgTypes = invType.getArgTypes();
Result Solver::checkSynth() const
{
CVC5_API_TRY_CATCH_BEGIN;
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot checkSynth unless sygus is enabled (use --sygus)";
//////// all checks before this line
return d_slv->checkSynth();
////////
Result Solver::checkSynthNext() const
{
CVC5_API_TRY_CATCH_BEGIN;
+ CVC5_API_CHECK(d_slv->getOptions().quantifiers.sygus)
+ << "Cannot checkSynthNext unless sygus is enabled (use --sygus)";
CVC5_API_CHECK(d_slv->getOptions().base.incrementalSolving)
<< "Cannot checkSynthNext when not solving incrementally (use "
"--incremental)";
* @param symbol the name of the universal variable
* @return the universal variable
*/
- Term mkSygusVar(const Sort& sort,
- const std::string& symbol = std::string()) const;
+ Term declareSygusVar(const Sort& sort,
+ const std::string& symbol = std::string()) const;
/**
* Create a Sygus grammar. The first non-terminal is treated as the starting
* @param sort the sort of the universal variable
* @return the universal variable
*/
- public Term mkSygusVar(Sort sort)
+ public Term declareSygusVar(Sort sort)
{
- return mkSygusVar(sort, "");
+ return declareSygusVar(sort, "");
}
/**
* Append \p symbol to the current list of universal variables.
* @param symbol the name of the universal variable
* @return the universal variable
*/
- public Term mkSygusVar(Sort sort, String symbol)
+ public Term declareSygusVar(Sort sort, String symbol)
{
- long termPointer = mkSygusVar(pointer, sort.getPointer(), symbol);
+ long termPointer = declareSygusVar(pointer, sort.getPointer(), symbol);
return new Term(this, termPointer);
}
- private native long mkSygusVar(long pointer, long sortPointer, String symbol);
+ private native long declareSygusVar(long pointer, long sortPointer, String symbol);
/**
* Create a Sygus grammar. The first non-terminal is treated as the starting
/*
* Class: io_github_cvc5_api_Solver
- * Method: mkSygusVar
+ * Method: declareSygusVar
* Signature: (JJLjava/lang/String;)J
*/
-JNIEXPORT jlong JNICALL Java_io_github_cvc5_api_Solver_mkSygusVar(
+JNIEXPORT jlong JNICALL Java_io_github_cvc5_api_Solver_declareSygusVar(
JNIEnv* env, jobject, jlong pointer, jlong sortPointer, jstring jSymbol)
{
CVC5_JAVA_API_TRY_CATCH_BEGIN;
Sort* sort = reinterpret_cast<Sort*>(sortPointer);
const char* s = env->GetStringUTFChars(jSymbol, nullptr);
std::string cSymbol(s);
- Term* retPointer = new Term(solver->mkSygusVar(*sort, cSymbol));
+ Term* retPointer = new Term(solver->declareSygusVar(*sort, cSymbol));
env->ReleaseStringUTFChars(jSymbol, s);
return reinterpret_cast<jlong>(retPointer);
CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, 0);
Op mkOp(Kind kind, const vector[uint32_t]& args) except +
# Sygus related functions
Grammar mkSygusGrammar(const vector[Term]& boundVars, const vector[Term]& ntSymbols) except +
- Term mkSygusVar(Sort sort, const string& symbol) except +
- Term mkSygusVar(Sort sort) except +
+ Term declareSygusVar(Sort sort, const string& symbol) except +
+ Term declareSygusVar(Sort sort) except +
void addSygusConstraint(Term term) except +
void addSygusInvConstraint(Term inv_f, Term pre_f, Term trans_f, Term post_f) except +
Term synthFun(const string& symbol, const vector[Term]& bound_vars, Sort sort) except +
grammar.cgrammar = self.csolver.mkSygusGrammar(<const vector[c_Term]&> bvc, <const vector[c_Term]&> ntc)
return grammar
- def mkSygusVar(self, Sort sort, str symbol=""):
+ def declareSygusVar(self, Sort sort, str symbol=""):
"""Append symbol to the current list of universal variables.
SyGuS v2:
:return: the universal variable
"""
cdef Term term = Term(self)
- term.cterm = self.csolver.mkSygusVar(sort.csort, symbol.encode())
+ term.cterm = self.csolver.declareSygusVar(sort.csort, symbol.encode())
return term
def addSygusConstraint(self, Term t):
}
}
}
+ if (solver->getOption("input-language") == "LANG_SYGUS_V2")
+ {
+ // Enable the sygus API. We set this here instead of in set defaults
+ // to simplify checking at the API level. In particular, the sygus
+ // option is the authority on whether sygus commands are currently
+ // allowed in the API.
+ solver->setOption("sygus", "true");
+ }
if (solver->getOption("output-language") == "LANG_AUTO")
{
{ PARSER_STATE->checkUserSymbol(name); }
sortSymbol[t,CHECK_DECLARED]
{
- api::Term var = SOLVER->mkSygusVar(t, name);
+ api::Term var = SOLVER->declareSygusVar(t, name);
PARSER_STATE->defineVar(name, var);
cmd.reset(new DeclareSygusVarCommand(name, var, t));
}
bool SetDefaults::isSygus(const Options& opts) const
{
- if (language::isLangSygus(opts.base.inputLanguage))
+ if (opts.quantifiers.sygus)
{
return true;
}
reason << "global-negate";
return true;
}
- if (isSygus(opts))
- {
- // When sygus answers "unsat", it is not due to showing a set of
- // formulas is unsat in the standard way. Thus, proofs do not apply.
- reason << "sygus";
- return true;
- }
// options that are automatically set to support proofs
if (opts.bv.bvAssertInput)
{
// apply sygus options
// if we are attempting to rewrite everything to SyGuS, use sygus()
- if (usesSygus(opts))
+ if (isSygus(opts))
{
std::stringstream reasonNoSygus;
if (incompatibleWithSygus(opts, reasonNoSygus))
// try a new core
std::unique_ptr<SolverEngine> checkSol;
initializeSubsolver(checkSol, d_env);
+ checkSol->setOption("sygus", "false");
checkSol->setOption("produce-unsat-cores", "true");
Trace("sygus-ccore") << "----- Check candidate " << an << std::endl;
std::vector<Node> rasserts = asserts;
/********************** Helper functions ***************************/
/********************** Helper functions ***************************/
-Node mkAnd(const std::vector<TNode>& conjunctions)
-{
- Assert(conjunctions.size() > 0);
-
- std::set<TNode> all;
- for (unsigned i = 0; i < conjunctions.size(); ++i)
- {
- TNode t = conjunctions[i];
- if (t.getKind() == kind::AND)
- {
- for (TNode::iterator child_it = t.begin(); child_it != t.end();
- ++child_it)
- {
- Assert((*child_it).getKind() != kind::AND);
- all.insert(*child_it);
- }
- }
- else
- {
- all.insert(t);
- }
- }
-
- Assert(all.size() > 0);
- if (all.size() == 1)
- {
- // All the same, or just one
- return conjunctions[0];
- }
-
- NodeBuilder conjunction(kind::AND);
- std::set<TNode>::const_iterator it = all.begin();
- std::set<TNode>::const_iterator it_end = all.end();
- while (it != it_end)
- {
- conjunction << *it;
- ++it;
- }
- return conjunction;
-} /* mkAnd() */
-
Valuation& TheorySetsPrivate::getValuation() { return d_external.d_valuation; }
bool TheorySetsPrivate::isEntailed(Node n, bool pol)
<< polarity << "); kind" << atom.getKind() << std::endl;
Unhandled();
}
-
- return mkAnd(assumptions);
+ return NodeManager::currentNM()->mkAnd(assumptions);
}
void TheorySetsPrivate::preRegisterTerm(TNode node)
regress1/quantifiers/issue3765.smt2
regress1/quantifiers/issue3765-quant-dd.smt2
regress1/quantifiers/issue4021-ind-opts.smt2
- regress1/quantifiers/issue4062-cegqi-aux.smt2
regress1/quantifiers/issue4243-prereg-inc.smt2
regress1/quantifiers/issue4290-cegqi-r.smt2
regress1/quantifiers/issue4328-nqe.smt2
regress1/quantifiers/subtype-param.smt2
# timeout after changes to theory preprocessing, note is non-linear and does not involve sygus-inst
regress1/quantifiers/sygus-inst-ufnia-sat-t3_rw1505.smt2
+ # timeout on some builds after not applying default sygus options when using sygus-inst
+ regress1/quantifiers/issue4062-cegqi-aux.smt2
###
regress1/rels/garbage_collect.cvc.smt2
regress1/sets/setofsets-disequal.smt2
; SCRUBBER: grep -v -E '(\(define-fun)'
; EXIT: 0
-
(set-info :smt-lib-version 2.6)
(set-logic QF_SLIA)
(set-info :source |
TEST_F(TestApiBlackGrammar, addRule)
{
+ d_solver.setOption("sygus", "true");
Sort boolean = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
TEST_F(TestApiBlackGrammar, addRules)
{
+ d_solver.setOption("sygus", "true");
Sort boolean = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
TEST_F(TestApiBlackGrammar, addAnyConstant)
{
+ d_solver.setOption("sygus", "true");
Sort boolean = d_solver.getBooleanSort();
Term nullTerm;
TEST_F(TestApiBlackGrammar, addAnyVariable)
{
+ d_solver.setOption("sygus", "true");
Sort boolean = d_solver.getBooleanSort();
Term nullTerm;
d_solver.checkSatAssuming({slt, ule});
}
-TEST_F(TestApiBlackSolver, mkSygusVar)
+TEST_F(TestApiBlackSolver, declareSygusVar)
{
+ d_solver.setOption("sygus", "true");
Sort boolSort = d_solver.getBooleanSort();
Sort intSort = d_solver.getIntegerSort();
Sort funSort = d_solver.mkFunctionSort(intSort, boolSort);
- ASSERT_NO_THROW(d_solver.mkSygusVar(boolSort));
- ASSERT_NO_THROW(d_solver.mkSygusVar(funSort));
- ASSERT_NO_THROW(d_solver.mkSygusVar(boolSort, std::string("b")));
- ASSERT_NO_THROW(d_solver.mkSygusVar(funSort, ""));
- ASSERT_THROW(d_solver.mkSygusVar(Sort()), CVC5ApiException);
- ASSERT_THROW(d_solver.mkSygusVar(d_solver.getNullSort(), "a"),
+ ASSERT_NO_THROW(d_solver.declareSygusVar(boolSort));
+ ASSERT_NO_THROW(d_solver.declareSygusVar(funSort));
+ ASSERT_NO_THROW(d_solver.declareSygusVar(boolSort, std::string("b")));
+ ASSERT_NO_THROW(d_solver.declareSygusVar(funSort, ""));
+ ASSERT_THROW(d_solver.declareSygusVar(Sort()), CVC5ApiException);
+ ASSERT_THROW(d_solver.declareSygusVar(d_solver.getNullSort(), "a"),
CVC5ApiException);
Solver slv;
- ASSERT_THROW(slv.mkSygusVar(boolSort), CVC5ApiException);
+ ASSERT_THROW(slv.declareSygusVar(boolSort), CVC5ApiException);
}
TEST_F(TestApiBlackSolver, mkSygusGrammar)
TEST_F(TestApiBlackSolver, synthFun)
{
+ d_solver.setOption("sygus", "true");
Sort null = d_solver.getNullSort();
Sort boolean = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
ASSERT_THROW(d_solver.synthFun("f4", {}, null), CVC5ApiException);
ASSERT_THROW(d_solver.synthFun("f6", {x}, boolean, g2), CVC5ApiException);
Solver slv;
+ slv.setOption("sygus", "true");
Term x2 = slv.mkVar(slv.getBooleanSort());
ASSERT_NO_THROW(slv.synthFun("f1", {x2}, slv.getBooleanSort()));
ASSERT_THROW(slv.synthFun("", {}, d_solver.getBooleanSort()),
TEST_F(TestApiBlackSolver, synthInv)
{
+ d_solver.setOption("sygus", "true");
Sort boolean = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
TEST_F(TestApiBlackSolver, addSygusConstraint)
{
+ d_solver.setOption("sygus", "true");
Term nullTerm;
Term boolTerm = d_solver.mkBoolean(true);
Term intTerm = d_solver.mkInteger(1);
ASSERT_THROW(d_solver.addSygusConstraint(intTerm), CVC5ApiException);
Solver slv;
+ slv.setOption("sygus", "true");
ASSERT_THROW(slv.addSygusConstraint(boolTerm), CVC5ApiException);
}
TEST_F(TestApiBlackSolver, addSygusAssume)
{
+ d_solver.setOption("sygus", "true");
Term nullTerm;
Term boolTerm = d_solver.mkBoolean(false);
Term intTerm = d_solver.mkInteger(1);
ASSERT_THROW(d_solver.addSygusAssume(intTerm), CVC5ApiException);
Solver slv;
+ slv.setOption("sygus", "true");
ASSERT_THROW(slv.addSygusAssume(boolTerm), CVC5ApiException);
}
TEST_F(TestApiBlackSolver, addSygusInvConstraint)
{
+ d_solver.setOption("sygus", "true");
Sort boolean = d_solver.getBooleanSort();
Sort real = d_solver.getRealSort();
ASSERT_THROW(d_solver.addSygusInvConstraint(inv, pre, trans, trans),
CVC5ApiException);
Solver slv;
+ slv.setOption("sygus", "true");
Sort boolean2 = slv.getBooleanSort();
Sort real2 = slv.getRealSort();
Term inv22 = slv.declareFun("inv", {real2}, boolean2);
CVC5ApiException);
}
+TEST_F(TestApiBlackSolver, checkSynth)
+{
+ // requires option to be set
+ ASSERT_THROW(d_solver.checkSynth(), CVC5ApiException);
+ d_solver.setOption("sygus", "true");
+ ASSERT_NO_THROW(d_solver.checkSynth());
+}
+
TEST_F(TestApiBlackSolver, getSynthSolution)
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "false");
Term nullTerm;
TEST_F(TestApiBlackSolver, getSynthSolutions)
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "false");
Term nullTerm;
TEST_F(TestApiBlackSolver, checkSynthNext)
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "true");
Term f = d_solver.synthFun("f", {}, d_solver.getBooleanSort());
TEST_F(TestApiBlackSolver, checkSynthNext2)
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "false");
Term f = d_solver.synthFun("f", {}, d_solver.getBooleanSort());
TEST_F(TestApiBlackSolver, checkSynthNext3)
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "true");
Term f = d_solver.synthFun("f", {}, d_solver.getBooleanSort());
@Test void addRule()
{
+ d_solver.setOption("sygus", "true");
Sort bool = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
@Test void addRules()
{
+ d_solver.setOption("sygus", "true");
Sort bool = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
@Test void addAnyConstant()
{
+ d_solver.setOption("sygus", "true");
Sort bool = d_solver.getBooleanSort();
Term nullTerm = d_solver.getNullTerm();
@Test void addAnyVariable()
{
+ d_solver.setOption("sygus", "true");
Sort bool = d_solver.getBooleanSort();
Term nullTerm = d_solver.getNullTerm();
d_solver.checkSatAssuming(new Term[] {slt, ule});
}
- @Test void mkSygusVar() throws CVC5ApiException
+ @Test void declareSygusVar() throws CVC5ApiException
{
+ d_solver.setOption("sygus", "true");
Sort boolSort = d_solver.getBooleanSort();
Sort intSort = d_solver.getIntegerSort();
Sort funSort = d_solver.mkFunctionSort(intSort, boolSort);
- assertDoesNotThrow(() -> d_solver.mkSygusVar(boolSort));
- assertDoesNotThrow(() -> d_solver.mkSygusVar(funSort));
- assertDoesNotThrow(() -> d_solver.mkSygusVar(boolSort, ("b")));
- assertDoesNotThrow(() -> d_solver.mkSygusVar(funSort, ""));
+ assertDoesNotThrow(() -> d_solver.declareSygusVar(boolSort));
+ assertDoesNotThrow(() -> d_solver.declareSygusVar(funSort));
+ assertDoesNotThrow(() -> d_solver.declareSygusVar(boolSort, ("b")));
+ assertDoesNotThrow(() -> d_solver.declareSygusVar(funSort, ""));
- assertThrows(CVC5ApiException.class, () -> d_solver.mkSygusVar(d_solver.getNullSort()));
- assertThrows(CVC5ApiException.class, () -> d_solver.mkSygusVar(d_solver.getNullSort(), "a"));
+ assertThrows(CVC5ApiException.class, () -> d_solver.declareSygusVar(d_solver.getNullSort()));
+ assertThrows(CVC5ApiException.class, () -> d_solver.declareSygusVar(d_solver.getNullSort(), "a"));
Solver slv = new Solver();
- assertThrows(CVC5ApiException.class, () -> slv.mkSygusVar(boolSort));
+ slv.setOption("sygus", "true");
+ assertThrows(CVC5ApiException.class, () -> slv.declareSygusVar(boolSort));
slv.close();
}
() -> d_solver.mkSygusGrammar(new Term[] {boolTerm}, new Term[] {intVar}));
Solver slv = new Solver();
+ slv.setOption("sygus", "true");
Term boolVar2 = slv.mkVar(slv.getBooleanSort());
Term intVar2 = slv.mkVar(slv.getIntegerSort());
assertDoesNotThrow(() -> slv.mkSygusGrammar(new Term[] {boolVar2}, new Term[] {intVar2}));
@Test void synthFun() throws CVC5ApiException
{
+ d_solver.setOption("sygus", "true");
Sort nullSort = d_solver.getNullSort();
Sort bool = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
assertThrows(CVC5ApiException.class, () -> d_solver.synthFun("f6", new Term[] {x}, bool, g2));
Solver slv = new Solver();
+ slv.setOption("sygus", "true");
Term x2 = slv.mkVar(slv.getBooleanSort());
assertDoesNotThrow(() -> slv.synthFun("f1", new Term[] {x2}, slv.getBooleanSort()));
@Test void synthInv() throws CVC5ApiException
{
+ d_solver.setOption("sygus", "true");
Sort bool = d_solver.getBooleanSort();
Sort integer = d_solver.getIntegerSort();
@Test void addSygusConstraint() throws CVC5ApiException
{
+ d_solver.setOption("sygus", "true");
Term nullTerm = d_solver.getNullTerm();
Term boolTerm = d_solver.mkBoolean(true);
Term intTerm = d_solver.mkInteger(1);
assertThrows(CVC5ApiException.class, () -> d_solver.addSygusConstraint(intTerm));
Solver slv = new Solver();
+ slv.setOption("sygus", "true");
assertThrows(CVC5ApiException.class, () -> slv.addSygusConstraint(boolTerm));
slv.close();
}
@Test void addSygusAssume()
{
+ d_solver.setOption("sygus", "true");
Term nullTerm = d_solver.getNullTerm();
Term boolTerm = d_solver.mkBoolean(false);
Term intTerm = d_solver.mkInteger(1);
assertThrows(CVC5ApiException.class, () -> d_solver.addSygusAssume(intTerm));
Solver slv = new Solver();
+ slv.setOption("sygus", "true");
assertThrows(CVC5ApiException.class, () -> slv.addSygusAssume(boolTerm));
slv.close();
}
@Test void addSygusInvConstraint() throws CVC5ApiException
{
+ d_solver.setOption("sygus", "true");
Sort bool = d_solver.getBooleanSort();
Sort real = d_solver.getRealSort();
CVC5ApiException.class, () -> d_solver.addSygusInvConstraint(inv, pre, trans, trans));
Solver slv = new Solver();
+ slv.setOption("sygus", "true");
Sort boolean2 = slv.getBooleanSort();
Sort real2 = slv.getRealSort();
Term inv22 = slv.declareFun("inv", new Sort[] {real2}, boolean2);
slv.close();
}
+ @Test void checkSynth() throws CVC5ApiException
+ {
+ assertThrows(CVC5ApiException.class, () -> d_solver.checkSynth());
+ d_solver.setOption("sygus", "true");
+ assertDoesNotThrow(() -> d_solver.checkSynth());
+ }
+
@Test void getSynthSolution() throws CVC5ApiException
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "false");
Term nullTerm = d_solver.getNullTerm();
@Test void getSynthSolutions() throws CVC5ApiException
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "false");
Term nullTerm = d_solver.getNullTerm();
}
@Test void checkSynthNext() throws CVC5ApiException
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "true");
Term f = d_solver.synthFun("f", new Term[] {}, d_solver.getBooleanSort());
@Test void checkSynthNext2() throws CVC5ApiException
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "false");
Term f = d_solver.synthFun("f", new Term[] {}, d_solver.getBooleanSort());
@Test void checkSynthNext3() throws CVC5ApiException
{
- d_solver.setOption("lang", "sygus2");
+ d_solver.setOption("sygus", "true");
d_solver.setOption("incremental", "true");
Term f = d_solver.synthFun("f", new Term[] {}, d_solver.getBooleanSort());
def test_add_rule(solver):
+ solver.setOption("sygus", "true")
boolean = solver.getBooleanSort()
integer = solver.getIntegerSort()
def test_add_rules(solver):
+ solver.setOption("sygus", "true")
boolean = solver.getBooleanSort()
integer = solver.getIntegerSort()
def test_add_any_constant(solver):
+ solver.setOption("sygus", "true")
boolean = solver.getBooleanSort()
null_term = Term(solver)
def test_add_any_variable(solver):
+ solver.setOption("sygus", "true")
boolean = solver.getBooleanSort()
null_term = Term(solver)
def test_synth_inv(solver):
+ solver.setOption("sygus", "true")
boolean = solver.getBooleanSort()
integer = solver.getIntegerSort()
def test_add_sygus_constraint(solver):
+ solver.setOption("sygus", "true")
nullTerm = cvc5.Term(solver)
boolTerm = solver.mkBoolean(True)
intTerm = solver.mkInteger(1)
def test_add_sygus_inv_constraint(solver):
+ solver.setOption("sygus", "true")
boolean = solver.getBooleanSort()
real = solver.getRealSort()
with pytest.raises(RuntimeError):
solver.addSygusInvConstraint(inv, pre, trans, trans)
slv = cvc5.Solver()
+ slv.setOption("sygus", "true")
boolean2 = slv.getBooleanSort()
real2 = slv.getRealSort()
inv22 = slv.declareFun("inv", [real2], boolean2)
slv.addSygusInvConstraint(inv22, pre22, trans22, post)
+def test_check_synth(solver):
+ with pytest.raises(RuntimeError):
+ solver.checkSynth()
+ solver.setOption("sygus", "true")
+ solver.checkSynth()
+
def test_get_synth_solution(solver):
- solver.setOption("lang", "sygus2")
+ solver.setOption("sygus", "true")
solver.setOption("incremental", "false")
nullTerm = cvc5.Term(solver)
slv.getSynthSolution(f)
def test_check_synth_next(solver):
- solver.setOption("lang", "sygus2")
+ solver.setOption("sygus", "true")
solver.setOption("incremental", "true")
f = solver.synthFun("f", [], solver.getBooleanSort())
solver.getSynthSolutions([f])
def test_check_synth_next2(solver):
- solver.setOption("lang", "sygus2")
+ solver.setOption("sygus", "true")
solver.setOption("incremental", "false")
f = solver.synthFun("f", [], solver.getBooleanSort())
solver.checkSynthNext()
def test_check_synth_next3(solver):
- solver.setOption("lang", "sygus2")
+ solver.setOption("sygus", "true")
solver.setOption("incremental", "true")
f = solver.synthFun("f", [], solver.getBooleanSort())
with pytest.raises(RuntimeError):
def test_get_synth_solutions(solver):
- solver.setOption("lang", "sygus2")
+ solver.setOption("sygus", "true")
solver.setOption("incremental", "false")
nullTerm = cvc5.Term(solver)
intSort = solver.getIntegerSort()
funSort = solver.mkFunctionSort(intSort, boolSort)
- solver.mkSygusVar(boolSort)
- solver.mkSygusVar(funSort)
- solver.mkSygusVar(boolSort, "b")
- solver.mkSygusVar(funSort, "")
+ solver.declareSygusVar(boolSort)
+ solver.declareSygusVar(funSort)
+ solver.declareSygusVar(boolSort, "b")
+ solver.declareSygusVar(funSort, "")
with pytest.raises(RuntimeError):
- solver.mkSygusVar(cvc5.Sort(solver))
+ solver.declareSygusVar(cvc5.Sort(solver))
with pytest.raises(RuntimeError):
- solver.mkSygusVar(solver.getNullSort(), "a")
+ solver.declareSygusVar(solver.getNullSort(), "a")
slv = cvc5.Solver()
+ solver.setOption("sygus", "true")
with pytest.raises(RuntimeError):
- slv.mkSygusVar(boolSort)
+ slv.declareSygusVar(boolSort)
def test_synth_fun(solver):
+ solver.setOption("sygus", "true")
null = solver.getNullSort()
boolean = solver.getBooleanSort()
integer = solver.getIntegerSort()
with pytest.raises(RuntimeError):
solver.synthFun("f6", [x], boolean, g2)
slv = cvc5.Solver()
+ solver.setOption("sygus", "true")
x2 = slv.mkVar(slv.getBooleanSort())
slv.synthFun("f1", [x2], slv.getBooleanSort())
with pytest.raises(RuntimeError):