printModel no longer makes sense if the list of declared symbols is managed outside the solver.
Also, mkConst needs a variant to distinguish a provided name of "" vs. a name that is not provided.
<< endl;
prefixPrintGetValue(slv, assertions);
- cout << endl << endl << "Alternatively, print the model." << endl << endl;
-
- slv.printModel(cout);
-
cout << endl;
cout << "You can also use nested loops to iterate over terms." << endl;
for (Term::const_iterator it = assertions.begin();
" slv.getValue(...) on all terms")
prefixPrintGetValue(slv, assertions)
- print("Alternatively, print the model", "\n")
- slv.printModel()
-
print()
print("You can also use nested loops to iterate over terms")
for a in assertions:
CVC4_API_ARG_CHECK_EXPECTED(!sort.isNull(), sort) << "non-null sort";
CVC4_API_SOLVER_CHECK_SORT(sort);
- Expr res = symbol.empty() ? d_exprMgr->mkVar(sort.d_type->toType())
- : d_exprMgr->mkVar(symbol, sort.d_type->toType());
+ Expr res = d_exprMgr->mkVar(symbol, sort.d_type->toType());
+ (void)res.getType(true); /* kick off type checking */
+ return Term(this, res);
+
+ CVC4_API_SOLVER_TRY_CATCH_END;
+}
+
+Term Solver::mkConst(Sort sort) const
+{
+ NodeManagerScope scope(getNodeManager());
+ CVC4_API_SOLVER_TRY_CATCH_BEGIN;
+ CVC4_API_ARG_CHECK_EXPECTED(!sort.isNull(), sort) << "non-null sort";
+ CVC4_API_SOLVER_CHECK_SORT(sort);
+
+ Expr res = d_exprMgr->mkVar(sort.d_type->toType());
(void)res.getType(true); /* kick off type checking */
return Term(this, res);
CVC4_API_SOLVER_TRY_CATCH_END;
}
-void Solver::printModel(std::ostream& out) const
-{
- CVC4_API_SOLVER_TRY_CATCH_BEGIN;
- CVC4::ExprManagerScope exmgrs(*(d_exprMgr.get()));
- CVC4_API_CHECK(d_smtEngine->getOptions()[options::produceModels])
- << "Cannot get value unless model generation is enabled "
- "(try --produce-models)";
- CVC4_API_RECOVERABLE_CHECK(d_smtEngine->isSmtModeSat())
- << "Can only get value after sat or unknown response.";
- out << *d_smtEngine->getModel();
- CVC4_API_SOLVER_TRY_CATCH_END;
-}
-
void Solver::blockModel() const
{
CVC4_API_SOLVER_TRY_CATCH_BEGIN;
* @param symbol the name of the constant
* @return the first-order constant
*/
- Term mkConst(Sort sort, const std::string& symbol = std::string()) const;
+ Term mkConst(Sort sort, const std::string& symbol) const;
+ /**
+ * Create (first-order) constant (0-arity function symbol), with a default
+ * symbol name.
+ *
+ * @param sort the sort of the constant
+ * @return the first-order constant
+ */
+ Term mkConst(Sort sort) const;
/**
* Create a bound variable to be used in a binder (i.e. a quantifier, a
*/
bool getAbduct(Term conj, Grammar& g, Term& output) const;
- /**
- * Print the model of a satisfiable query to the given output stream.
- * Requires to enable option 'produce-models'.
- * @param out the output stream
- */
- void printModel(std::ostream& out) const;
-
/**
* Block the current model. Can be called only if immediately preceded by a
* SAT or INVALID query.
Term getSeparationHeap() except +
Term getSeparationNilTerm() except +
void pop(uint32_t nscopes) except +
- void printModel(ostream& out)
void push(uint32_t nscopes) except +
void reset() except +
void resetAssertions() except +
def pop(self, nscopes=1):
self.csolver.pop(nscopes)
- def printModel(self):
- self.csolver.printModel(cout)
-
def push(self, nscopes=1):
self.csolver.push(nscopes)
void testPop1();
void testPop2();
void testPop3();
- void testPrintModel1();
- void testPrintModel2();
- void testPrintModel3();
void testBlockModel1();
void testBlockModel2();
d_solver->setOption("produce-models", "true");
Term x = d_solver->mkConst(d_solver->getBooleanSort(), "x");
d_solver->assertFormula(x.eqTerm(x).notTerm());
- TS_ASSERT_THROWS(d_solver->printModel(std::cout),
+ TS_ASSERT_THROWS(d_solver->getValue(x),
CVC4ApiRecoverableException&);
}
TS_ASSERT_THROWS(d_solver->pop(1), CVC4ApiException&);
}
-void SolverBlack::testPrintModel1()
-{
- d_solver->setOption("produce-models", "false");
- Term x = d_solver->mkConst(d_solver->getBooleanSort(), "x");
- d_solver->assertFormula(x.eqTerm(x));
- TS_ASSERT_THROWS(d_solver->printModel(std::cout), CVC4ApiException&);
-}
-
-void SolverBlack::testPrintModel2()
-{
- d_solver->setOption("produce-models", "true");
- Term x = d_solver->mkConst(d_solver->getBooleanSort(), "x");
- d_solver->assertFormula(x.eqTerm(x).notTerm());
- d_solver->checkSat();
- TS_ASSERT_THROWS(d_solver->printModel(std::cout), CVC4ApiException&);
-}
-
-void SolverBlack::testPrintModel3()
-{
- d_solver->setOption("produce-models", "true");
- Term x = d_solver->mkConst(d_solver->getBooleanSort(), "x");
- d_solver->assertFormula(x.eqTerm(x));
- d_solver->checkSat();
- TS_ASSERT_THROWS_NOTHING(d_solver->printModel(std::cout));
-}
-
void SolverBlack::testBlockModel1()
{
d_solver->setOption("produce-models", "true");