Added the operator choice to Smt2.g and Cvc.g.
Removed the unused parameter hasBoundVars from TheoryModel::getModelValue
FORALL_TOK = 'FORALL';
EXISTS_TOK = 'EXISTS';
+ CHOICE_TOK = 'CHOICE';
PATTERN_TOK = 'PATTERN';
LAMBDA_TOK = 'LAMBDA';
case IMPLIES_TOK: return 30;// right-to-left
case IFF_TOK: return 31;
case FORALL_TOK:
- case EXISTS_TOK: return 32;
+ case EXISTS_TOK:
+ case CHOICE_TOK: return 32;
case ASSIGN_TOK:
case IN_TOK: return 33;
api::Term ipl;
}
/* quantifiers */
- : ( FORALL_TOK { k = api::FORALL; } | EXISTS_TOK { k = api::EXISTS; } )
+ : ( FORALL_TOK { k = api::FORALL; } | EXISTS_TOK { k = api::EXISTS; } | CHOICE_TOK { k = api::CHOICE; } )
{ PARSER_STATE->pushScope(); } LPAREN
boundVarDecl[ids,t]
{ for(std::vector<std::string>::const_iterator i = ids.begin(); i != ids.end(); ++i) {
}
: EXISTS_TOK { $kind = api::EXISTS; }
| FORALL_TOK { $kind = api::FORALL; }
+ | CHOICE_TOK { $kind = api::CHOICE; }
;
/**
// operators (NOTE: theory symbols go here)
EXISTS_TOK : 'exists';
FORALL_TOK : 'forall';
+CHOICE_TOK : { !PARSER_STATE->strictModeEnabled() }? 'choice';
EMP_TOK : { PARSER_STATE->isTheoryEnabled(theory::THEORY_SEP) }? 'emp';
TUPLE_CONST_TOK: { PARSER_STATE->isTheoryEnabled(theory::THEORY_DATATYPES) }? 'mkTuple';
**/
#include "theory/builtin/theory_builtin.h"
-#include "theory/valuation.h"
+
#include "expr/kind.h"
#include "theory/theory_model.h"
+#include "theory/valuation.h"
using namespace std;
namespace theory {
namespace builtin {
-}/* CVC4::theory::builtin namespace */
-}/* CVC4::theory */
-}/* CVC4 namespace */
+TheoryBuiltin::TheoryBuiltin(context::Context* c,
+ context::UserContext* u,
+ OutputChannel& out,
+ Valuation valuation,
+ const LogicInfo& logicInfo)
+ : Theory(THEORY_BUILTIN, c, u, out, valuation, logicInfo)
+{
+}
+
+std::string TheoryBuiltin::identify() const
+{
+ return std::string("TheoryBuiltin");
+}
+
+void TheoryBuiltin::finishInit()
+{
+ // choice nodes are not evaluated in getModelValue
+ TheoryModel* theoryModel = d_valuation.getModel();
+ Assert(theoryModel != nullptr);
+ theoryModel->setUnevaluatedKind(kind::CHOICE);
+}
+
+} // namespace builtin
+} // namespace theory
+} // namespace CVC4
namespace theory {
namespace builtin {
-class TheoryBuiltin : public Theory {
-public:
- TheoryBuiltin(context::Context* c, context::UserContext* u,
- OutputChannel& out, Valuation valuation,
- const LogicInfo& logicInfo)
- : Theory(THEORY_BUILTIN, c, u, out, valuation, logicInfo) {}
- std::string identify() const override { return std::string("TheoryBuiltin"); }
-};/* class TheoryBuiltin */
-
-}/* CVC4::theory::builtin namespace */
-}/* CVC4::theory namespace */
-}/* CVC4 namespace */
+class TheoryBuiltin : public Theory
+{
+ public:
+ TheoryBuiltin(context::Context* c,
+ context::UserContext* u,
+ OutputChannel& out,
+ Valuation valuation,
+ const LogicInfo& logicInfo);
+
+ std::string identify() const override;
+
+ /** finish initialization */
+ void finishInit() override;
+}; /* class TheoryBuiltin */
+
+} // namespace builtin
+} // namespace theory
+} // namespace CVC4
#endif /* CVC4__THEORY__BUILTIN__THEORY_BUILTIN_H */
Node nn = d_substitutions.apply(n);
Debug("model-getvalue-debug") << "[model-getvalue] getValue : substitute " << n << " to " << nn << std::endl;
//get value in model
- nn = getModelValue(nn, false);
+ nn = getModelValue(nn);
if (nn.isNull()) return nn;
if(options::condenseFunctionValues() || nn.getKind() != kind::LAMBDA) {
//normalize
}
}
-Node TheoryModel::getModelValue(TNode n, bool hasBoundVars) const
+Node TheoryModel::getModelValue(TNode n) const
{
std::unordered_map<Node, Node, NodeHashFunction>::iterator it = d_modelCache.find(n);
if (it != d_modelCache.end()) {
std::vector<Node> children;
if (n.getKind() == APPLY_UF)
{
- Node op = getModelValue(n.getOperator(), hasBoundVars);
+ Node op = getModelValue(n.getOperator());
Debug("model-getvalue-debug") << " operator : " << op << std::endl;
children.push_back(op);
}
// evaluate the children
for (unsigned i = 0, nchild = n.getNumChildren(); i < nchild; ++i)
{
- ret = getModelValue(n[i], hasBoundVars);
+ ret = getModelValue(n[i]);
Debug("model-getvalue-debug")
<< " " << n << "[" << i << "] is " << ret << std::endl;
children.push_back(ret);
/** Get model value function.
*
* This function is a helper function for getValue.
- * hasBoundVars is whether n may contain bound variables
*/
- Node getModelValue(TNode n, bool hasBoundVars = false) const;
+ Node getModelValue(TNode n) const;
/** add term internal
*
* This will do any model-specific processing necessary for n,
regress0/parser/as.smt2
regress0/parser/bv_arity_smt2.6.smt2
regress0/parser/bv_nat.smt2
+ regress0/parser/choice.cvc
+ regress0/parser/choice.smt2
regress0/parser/constraint.smt2
regress0/parser/declarefun-emptyset-uf.smt2
regress0/parser/force_logic_set_logic.smt2
--- /dev/null
+% EXPECT: sat
+
+a : INT;
+b : INT;
+c : INT;
+
+ASSERT (CHOICE(x: INT): x = a) = 1;
+ASSERT (CHOICE(x: INT): x = b) = 2;
+
+CHECKSAT;
\ No newline at end of file
--- /dev/null
+(set-logic ALL)
+(set-info :status sat)
+(declare-fun a () Int)
+(declare-fun b () Int)
+(declare-fun c () Int)
+(assert (= (choice ((x Int)) (= x a)) 1))
+(assert (= (choice ((x Int)) (= x b)) 2))
+;(assert (let ((x (choice ((x Int)) true))) (and (distinct a b x)(= x c))))
+(check-sat)
+