Make it consistent with other declare*/define* functions.
Term min = slv.synthFun("min", {x, y}, integer);
// declare universal variables.
- Term varX = slv.declareSygusVar(integer, "x");
- Term varY = slv.declareSygusVar(integer, "y");
+ Term varX = slv.declareSygusVar("x", integer);
+ Term varY = slv.declareSygusVar("y", integer);
Term max_x_y = slv.mkTerm(APPLY_UF, {max, varX, varY});
Term min_x_y = slv.mkTerm(APPLY_UF, {min, varX, varY});
Term id4 = slv.synthFun("id4", {x}, integer, g1);
// declare universal variables.
- Term varX = slv.declareSygusVar(integer, "x");
+ Term varX = slv.declareSygusVar("x", integer);
Term id1_x = slv.mkTerm(APPLY_UF, {id1, varX});
Term id2_x = slv.mkTerm(APPLY_UF, {id2, varX});
Term min = slv.synthFun("min", new Term[] {x, y}, integer);
// declare universal variables.
- Term varX = slv.declareSygusVar(integer, "x");
- Term varY = slv.declareSygusVar(integer, "y");
+ Term varX = slv.declareSygusVar("x", integer);
+ Term varY = slv.declareSygusVar("y", integer);
Term max_x_y = slv.mkTerm(APPLY_UF, max, varX, varY);
Term min_x_y = slv.mkTerm(APPLY_UF, min, varX, varY);
Term id4 = slv.synthFun("id4", new Term[] {x}, integer, g1);
// declare universal variables.
- Term varX = slv.declareSygusVar(integer, "x");
+ Term varX = slv.declareSygusVar("x", integer);
Term id1_x = slv.mkTerm(APPLY_UF, id1, varX);
Term id2_x = slv.mkTerm(APPLY_UF, id2, varX);
min = slv.synthFun("min", [x, y], integer)
# declare universal variables.
- varX = slv.declareSygusVar(integer, "x")
- varY = slv.declareSygusVar(integer, "y")
+ varX = slv.declareSygusVar("x", integer)
+ varY = slv.declareSygusVar("y", integer)
max_x_y = slv.mkTerm(Kind.ApplyUf, max, varX, varY)
min_x_y = slv.mkTerm(Kind.ApplyUf, min, varX, varY)
id4 = slv.synthFun("id4", {x}, integer, g1)
# declare universal variables.
- varX = slv.declareSygusVar(integer, "x")
+ varX = slv.declareSygusVar("x", integer)
id1_x = slv.mkTerm(Kind.ApplyUf, id1, varX)
id2_x = slv.mkTerm(Kind.ApplyUf, id2, varX)
CVC5_API_TRY_CATCH_END;
}
-Term Solver::declareSygusVar(const Sort& sort, const std::string& symbol) const
+Term Solver::declareSygusVar(const std::string& symbol, const Sort& sort) const
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_SORT(sort);
* @param symbol the name of the universal variable
* @return the universal variable
*/
- Term declareSygusVar(const Sort& sort,
- const std::string& symbol = std::string()) const;
+ Term declareSygusVar(const std::string& symbol, const Sort& sort) const;
/**
* Create a Sygus grammar. The first non-terminal is treated as the starting
private native void setOption(long pointer, String option, String value);
- /**
- * Append \p symbol to the current list of universal variables.
- * @param sort the sort of the universal variable
- * @return the universal variable
- */
- public Term declareSygusVar(Sort sort)
- {
- return declareSygusVar(sort, "");
- }
/**
* Append \p symbol to the current list of universal variables.
* SyGuS v2:
* @param symbol the name of the universal variable
* @return the universal variable
*/
- public Term declareSygusVar(Sort sort, String symbol)
+ public Term declareSygusVar(String symbol, Sort sort)
{
- long termPointer = declareSygusVar(pointer, sort.getPointer(), symbol);
+ long termPointer = declareSygusVar(pointer, symbol, sort.getPointer());
return new Term(this, termPointer);
}
- private native long declareSygusVar(long pointer, long sortPointer, String symbol);
+ private native long declareSygusVar(long pointer, String symbol, long sortPointer);
/**
* Create a Sygus grammar. The first non-terminal is treated as the starting
/*
* Class: io_github_cvc5_Solver
* Method: declareSygusVar
- * Signature: (JJLjava/lang/String;)J
+ * Signature: (JJjava/lang/String;L)J
*/
JNIEXPORT jlong JNICALL Java_io_github_cvc5_Solver_declareSygusVar(
- JNIEnv* env, jobject, jlong pointer, jlong sortPointer, jstring jSymbol)
+ JNIEnv* env, jobject, jlong pointer, jstring jSymbol, jlong sortPointer)
{
CVC5_JAVA_API_TRY_CATCH_BEGIN;
Solver* solver = reinterpret_cast<Solver*>(pointer);
Sort* sort = reinterpret_cast<Sort*>(sortPointer);
const char* s = env->GetStringUTFChars(jSymbol, nullptr);
std::string cSymbol(s);
- Term* retPointer = new Term(solver->declareSygusVar(*sort, cSymbol));
+ Term* retPointer = new Term(solver->declareSygusVar(cSymbol, *sort));
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 declareSygusVar(Sort sort, const string& symbol) except +
- Term declareSygusVar(Sort sort) except +
+ Term declareSygusVar(const string& symbol, Sort sort) except +
void addSygusConstraint(Term term) except +
void addSygusAssume(Term term) except +
void addSygusInvConstraint(Term inv_f, Term pre_f, Term trans_f, Term post_f) except +
grammar.cgrammar = self.csolver.mkSygusGrammar(<const vector[c_Term]&> bvc, <const vector[c_Term]&> ntc)
return grammar
- def declareSygusVar(self, Sort sort, str symbol=""):
+ def declareSygusVar(self, str symbol, Sort sort):
"""Append symbol to the current list of universal variables.
SyGuS v2:
:return: the universal variable
"""
cdef Term term = Term(self)
- term.cterm = self.csolver.declareSygusVar(sort.csort, symbol.encode())
+ term.cterm = self.csolver.declareSygusVar(symbol.encode(), sort.csort)
return term
def addSygusConstraint(self, Term t):
{ PARSER_STATE->checkUserSymbol(name); }
sortSymbol[t,CHECK_DECLARED]
{
- cvc5::Term var = SOLVER->declareSygusVar(t, name);
+ cvc5::Term var = SOLVER->declareSygusVar(name, t);
PARSER_STATE->defineVar(name, var);
cmd.reset(new DeclareSygusVarCommand(name, var, t));
}
Sort intSort = d_solver.getIntegerSort();
Sort funSort = d_solver.mkFunctionSort(intSort, boolSort);
- 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"),
+ ASSERT_NO_THROW(d_solver.declareSygusVar("", boolSort));
+ ASSERT_NO_THROW(d_solver.declareSygusVar("", funSort));
+ ASSERT_NO_THROW(d_solver.declareSygusVar(std::string("b"), boolSort));
+ ASSERT_THROW(d_solver.declareSygusVar("", Sort()), CVC5ApiException);
+ ASSERT_THROW(d_solver.declareSygusVar("a", d_solver.getNullSort()),
CVC5ApiException);
Solver slv;
- ASSERT_THROW(slv.declareSygusVar(boolSort), CVC5ApiException);
+ ASSERT_THROW(slv.declareSygusVar("", boolSort), CVC5ApiException);
}
TEST_F(TestApiBlackSolver, mkSygusGrammar)
Sort intSort = d_solver.getIntegerSort();
Sort funSort = d_solver.mkFunctionSort(intSort, boolSort);
- assertDoesNotThrow(() -> d_solver.declareSygusVar(boolSort));
- assertDoesNotThrow(() -> d_solver.declareSygusVar(funSort));
- assertDoesNotThrow(() -> d_solver.declareSygusVar(boolSort, ("b")));
- assertDoesNotThrow(() -> d_solver.declareSygusVar(funSort, ""));
+ assertDoesNotThrow(() -> d_solver.declareSygusVar("", boolSort));
+ assertDoesNotThrow(() -> d_solver.declareSygusVar("", funSort));
+ assertDoesNotThrow(() -> d_solver.declareSygusVar(("b"), boolSort));
- assertThrows(CVC5ApiException.class, () -> d_solver.declareSygusVar(d_solver.getNullSort()));
assertThrows(
- CVC5ApiException.class, () -> d_solver.declareSygusVar(d_solver.getNullSort(), "a"));
+ CVC5ApiException.class, () -> d_solver.declareSygusVar("", d_solver.getNullSort()));
+ assertThrows(
+ CVC5ApiException.class, () -> d_solver.declareSygusVar("a", d_solver.getNullSort()));
Solver slv = new Solver();
slv.setOption("sygus", "true");
- assertThrows(CVC5ApiException.class, () -> slv.declareSygusVar(boolSort));
+ assertThrows(CVC5ApiException.class, () -> slv.declareSygusVar("", boolSort));
slv.close();
}
intSort = solver.getIntegerSort()
funSort = solver.mkFunctionSort(intSort, boolSort)
- solver.declareSygusVar(boolSort)
- solver.declareSygusVar(funSort)
- solver.declareSygusVar(boolSort, "b")
- solver.declareSygusVar(funSort, "")
+ solver.declareSygusVar("", boolSort)
+ solver.declareSygusVar("", funSort)
+ solver.declareSygusVar("b", boolSort)
with pytest.raises(RuntimeError):
- solver.declareSygusVar(cvc5.Sort(solver))
+ solver.declareSygusVar("", cvc5.Sort(solver))
with pytest.raises(RuntimeError):
- solver.declareSygusVar(solver.getNullSort(), "a")
+ solver.declareSygusVar("a", solver.getNullSort())
slv = cvc5.Solver()
solver.setOption("sygus", "true")
with pytest.raises(RuntimeError):
- slv.declareSygusVar(boolSort)
+ slv.declareSygusVar("", boolSort)
def test_synth_fun(solver):