This decouples asserting a formula with initialization (previously it was a complex process to assert a formula due to having to clone/export to a new ExprManager). Now it is trivial.
This commit fixes an unintended consequence of the previous complications. Previously, SmtEngine::setOption would be set after asserting formulas to an SmtEngine subsolver, which is technically incorrect, as options should be finalized before the first assert.
This is required for further cleaning up of options listeners.
#include "theory/quantifiers/quantifiers_attributes.h"
#include "theory/quantifiers/quantifiers_rewriter.h"
#include "theory/quantifiers/sygus/sygus_grammar_cons.h"
+#include "theory/smt_engine_subsolver.h"
using namespace std;
using namespace CVC4::kind;
Trace("sygus-infer") << "*** Return sygus inference : " << body << std::endl;
// make a separate smt call
- SmtEngine* currSmt = smt::currentSmtEngine();
- SmtEngine rrSygus(nm->toExprManager(), &currSmt->getOptions());
- rrSygus.setLogic(currSmt->getLogicInfo());
- rrSygus.assertFormula(body.toExpr());
+ std::unique_ptr<SmtEngine> rrSygus;
+ theory::initializeSubsolver(rrSygus);
+ rrSygus->assertFormula(body.toExpr());
Trace("sygus-infer") << "*** Check sat..." << std::endl;
- Result r = rrSygus.checkSat();
+ Result r = rrSygus->checkSat();
Trace("sygus-infer") << "...result : " << r << std::endl;
if (r.asSatisfiabilityResult().isSat() != Result::UNSAT)
{
}
// get the synthesis solutions
std::map<Expr, Expr> synth_sols;
- rrSygus.getSynthSolutions(synth_sols);
+ rrSygus->getSynthSolutions(synth_sols);
std::vector<Node> final_ff;
std::vector<Node> final_ff_sol;
void ExprMiner::initializeChecker(std::unique_ptr<SmtEngine>& checker,
Node query)
{
- // Convert bound variables to skolems. This ensures the satisfiability
- // check is ground.
- Node squery = convertToSkolem(query);
- initializeSubsolver(checker, squery.toExpr());
+ Assert (!query.isNull());
+ initializeSubsolver(checker);
// also set the options
checker->setOption("sygus-rr-synth-input", false);
checker->setOption("input-language", "smt2");
+ // Convert bound variables to skolems. This ensures the satisfiability
+ // check is ground.
+ Node squery = convertToSkolem(query);
+ checker->assertFormula(squery.toExpr());
}
Result ExprMiner::doCheck(Node query)
}
// solve the single invocation conjecture using a fresh copy of SMT engine
std::unique_ptr<SmtEngine> siSmt;
- initializeSubsolver(siSmt, siq);
+ initializeSubsolver(siSmt);
+ siSmt->assertFormula(siq.toExpr());
Result r = siSmt->checkSat();
Trace("sygus-si") << "Result: " << r << std::endl;
if (r.asSatisfiabilityResult().isSat() != Result::UNSAT)
std::unique_ptr<SmtEngine> repcChecker;
// initialize the subsolver using the standard method
initializeSubsolver(repcChecker,
- fo_body.toExpr(),
options::sygusRepairConstTimeout.wasSetByUser(),
options::sygusRepairConstTimeout());
// renable options disabled by sygus
repcChecker->setOption("miniscope-quant", true);
repcChecker->setOption("miniscope-quant-fv", true);
repcChecker->setOption("quant-split", true);
+ repcChecker->assertFormula(fo_body.toExpr());
// check satisfiability
Result r = repcChecker->checkSat();
Trace("sygus-repair-const") << "...got : " << r << std::endl;
}
void initializeSubsolver(std::unique_ptr<SmtEngine>& smte,
- Node query,
bool needsTimeout,
unsigned long timeout)
{
smte->setTimeLimit(timeout, true);
}
smte->setLogic(smt::currentSmtEngine()->getLogicInfo());
- if (!query.isNull())
- {
- smte->assertFormula(query.toExpr());
- }
}
Result checkWithSubsolver(std::unique_ptr<SmtEngine>& smte,
{
return r;
}
- initializeSubsolver(smte, query, needsTimeout, timeout);
+ initializeSubsolver(smte, needsTimeout, timeout);
+ smte->assertFormula(query.toExpr());
return smte->checkSat();
}
return r;
}
std::unique_ptr<SmtEngine> smte;
- initializeSubsolver(smte, query, needsTimeout, timeout);
+ initializeSubsolver(smte, needsTimeout, timeout);
+ smte->assertFormula(query.toExpr());
r = smte->checkSat();
if (r.asSatisfiabilityResult().isSat() == Result::SAT)
{
* of the argument "query".
*
* @param smte The smt engine pointer to initialize
- * @param query The query to check (if provided)
* @param needsTimeout Whether we would like to set a timeout
* @param timeout The timeout (in milliseconds)
*/
void initializeSubsolver(std::unique_ptr<SmtEngine>& smte,
- Node query = Node::null(),
bool needsTimeout = false,
unsigned long timeout = 0);