This makes simplifications to the internal sygus API now that the SmtEngine interface is independent of parsing.
Node res = getNodeManager()->mkBoundVar(symbol, *sort.d_type);
(void)res.getType(true); /* kick off type checking */
- d_smtEngine->declareSygusVar(symbol, res, *sort.d_type);
+ d_smtEngine->declareSygusVar(res);
return Term(this, res);
std::vector<Node> bvns = termVectorToNodes(boundVars);
d_smtEngine->declareSynthFun(
- symbol, fun, g == nullptr ? funType : *g->resolve().d_type, isInv, bvns);
+ fun, g == nullptr ? funType : *g->resolve().d_type, isInv, bvns);
return Term(this, fun);
--------------------------------------------------------------------------
*/
-void SmtEngine::declareSygusVar(const std::string& id, Node var, TypeNode type)
+void SmtEngine::declareSygusVar(Node var)
{
SmtScope smts(this);
- d_sygusSolver->declareSygusVar(id, var, type);
+ d_sygusSolver->declareSygusVar(var);
if (Dump.isOn("raw-benchmark"))
{
getOutputManager().getPrinter().toStreamCmdDeclareVar(
// don't need to set that the conjecture is stale
}
-void SmtEngine::declareSynthFun(const std::string& id,
- Node func,
+void SmtEngine::declareSynthFun(Node func,
TypeNode sygusType,
bool isInv,
const std::vector<Node>& vars)
{
SmtScope smts(this);
d_state->doPendingPops();
- d_sygusSolver->declareSynthFun(id, func, sygusType, isInv, vars);
+ d_sygusSolver->declareSynthFun(func, sygusType, isInv, vars);
// !!! TEMPORARY: We cannot construct a SynthFunCommand since we cannot
// construct a Term-level Grammar from a Node-level sygus TypeNode. Thus we
getOutputManager().getDumpOut(), func, vars, isInv, sygusType);
}
}
+void SmtEngine::declareSynthFun(Node func,
+ bool isInv,
+ const std::vector<Node>& vars)
+{
+ // use a null sygus type
+ TypeNode sygusType;
+ declareSynthFun(func, sygusType, isInv, vars);
+}
void SmtEngine::assertSygusConstraint(Node constraint)
{
* which a function is being synthesized. Thus declared functions should use
* this method as well.
*/
- void declareSygusVar(const std::string& id, Node var, TypeNode type);
+ void declareSygusVar(Node var);
/**
* Add a function-to-synthesize declaration.
*
- * The given type may not correspond to the actual function type but to a
- * datatype encoding the syntax restrictions for the
+ * The given sygusType may not correspond to the actual function type of func
+ * but to a datatype encoding the syntax restrictions for the
* function-to-synthesize. In this case this information is stored to be used
* during solving.
*
* invariant. This information is necessary if we are dumping a command
* corresponding to this declaration, so that it can be properly printed.
*/
- void declareSynthFun(const std::string& id,
- Node func,
- TypeNode type,
+ void declareSynthFun(Node func,
+ TypeNode sygusType,
bool isInv,
const std::vector<Node>& vars);
+ /**
+ * Same as above, without a sygus type.
+ */
+ void declareSynthFun(Node func, bool isInv, const std::vector<Node>& vars);
/** Add a regular sygus constraint.*/
void assertSygusConstraint(Node constraint);
#include "smt/smt_solver.h"
#include "theory/quantifiers/quantifiers_attributes.h"
#include "theory/quantifiers/sygus/sygus_grammar_cons.h"
+#include "theory/quantifiers/sygus/sygus_utils.h"
#include "theory/smt_engine_subsolver.h"
using namespace CVC4::theory;
SygusSolver::~SygusSolver() {}
-void SygusSolver::declareSygusVar(const std::string& id,
- Node var,
- TypeNode type)
+void SygusSolver::declareSygusVar(Node var)
{
- Trace("smt") << "SygusSolver::declareSygusVar: " << id << " " << var << " "
- << type << "\n";
- Assert(var.getType() == type);
+ Trace("smt") << "SygusSolver::declareSygusVar: " << var << " "
+ << var.getType() << "\n";
d_sygusVars.push_back(var);
// don't need to set that the conjecture is stale
}
-void SygusSolver::declareSynthFun(const std::string& id,
- Node fn,
+void SygusSolver::declareSynthFun(Node fn,
TypeNode sygusType,
bool isInv,
const std::vector<Node>& vars)
{
- Trace("smt") << "SygusSolver::declareSynthFun: " << id << "\n";
+ Trace("smt") << "SygusSolver::declareSynthFun: " << fn << "\n";
NodeManager* nm = NodeManager::currentNM();
d_sygusFunSymbols.push_back(fn);
if (!vars.empty())
fn.setAttribute(ssfvla, bvl);
}
// whether sygus type encodes syntax restrictions
- if (sygusType.isDatatype() && sygusType.getDType().isSygus())
+ if (!sygusType.isNull() && sygusType.isDatatype()
+ && sygusType.getDType().isSygus())
{
Node sym = nm->mkBoundVar("sfproxy", sygusType);
// use an attribute to mark its grammar
NodeManager* nm = NodeManager::currentNM();
// build synthesis conjecture from asserted constraints and declared
// variables/functions
- Node sygusVar = nm->mkSkolem("sygus", nm->booleanType());
- Node inst_attr = nm->mkNode(INST_ATTRIBUTE, sygusVar);
- Node sygusAttr = nm->mkNode(INST_PATTERN_LIST, inst_attr);
std::vector<Node> bodyv;
Trace("smt") << "Sygus : Constructing sygus constraint...\n";
size_t nconstraints = d_sygusConstraints.size();
}
if (!d_sygusFunSymbols.empty())
{
- Node boundVars = nm->mkNode(BOUND_VAR_LIST, d_sygusFunSymbols);
- body = nm->mkNode(FORALL, boundVars, body, sygusAttr);
+ body =
+ quantifiers::SygusUtils::mkSygusConjecture(d_sygusFunSymbols, body);
}
Trace("smt") << "...constructed forall " << body << std::endl;
- // set attribute for synthesis conjecture
- SygusAttribute sa;
- sygusVar.setAttribute(sa, true);
-
Trace("smt") << "Check synthesis conjecture: " << body << std::endl;
if (Dump.isOn("raw-benchmark"))
{
* which a function is being synthesized. Thus declared functions should use
* this method as well.
*/
- void declareSygusVar(const std::string& id, Node var, TypeNode type);
+ void declareSygusVar(Node var);
/**
* Add a function-to-synthesize declaration.
* invariant. This information is necessary if we are dumping a command
* corresponding to this declaration, so that it can be properly printed.
*/
- void declareSynthFun(const std::string& id,
- Node func,
+ void declareSynthFun(Node func,
TypeNode type,
bool isInv,
const std::vector<Node>& vars);
// set the sygus bound variable list
Trace("sygus-interpol-debug") << "Set attributes..." << std::endl;
itp.setAttribute(SygusSynthFunVarListAttribute(), d_ibvlShared);
- // sygus attribute
- Node sygusVar = nm->mkSkolem("sygus", nm->booleanType());
- SygusAttribute ca;
- sygusVar.setAttribute(ca, true);
- Node instAttr = nm->mkNode(kind::INST_ATTRIBUTE, sygusVar);
- std::vector<Node> iplc;
- iplc.push_back(instAttr);
- Node instAttrList = nm->mkNode(kind::INST_PATTERN_LIST, iplc);
Trace("sygus-interpol-debug") << "...finish" << std::endl;
// Fa( x )
l.enableSygus();
subSolver->setLogic(l);
- for (Node var : d_vars)
+ for (const Node& var : d_vars)
{
- subSolver->declareSygusVar(name, var, var.getType());
+ subSolver->declareSygusVar(var);
}
std::vector<Node> vars_empty;
- subSolver->declareSynthFun(name, itp, grammarType, false, vars_empty);
+ subSolver->declareSynthFun(itp, grammarType, false, vars_empty);
Trace("sygus-interpol") << "SmtEngine::getInterpol: made conjecture : "
<< d_sygusConj << ", solving for "
<< d_sygusConj[0][0] << std::endl;