summaryrefslogtreecommitdiff
path: root/src/theory
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2017-09-10 08:12:34 +0200
committerGitHub <noreply@github.com>2017-09-10 08:12:34 +0200
commitd5b0866bd2a2551143caf591d453993ab5a48840 (patch)
tree71d9bf61a8134be3ca13596ab0d8f278a2021eb9 /src/theory
parent8a68cca2f9cf76b42187c39d09a4a40bd19622c1 (diff)
Ensure that expand definitions is called on all non-variable expressi… (#1070)
* Ensure that expand definitions is called on all non-variable expressions. In particular, it is necessary that the sets theory is notified when a set universe term occurs in the input to ensure options are set correctly. The commit moves this check from within check() to expandDefinitions(), and also adds the check for join image which relies on universe set. This fixes a bug reported by Arjun. Add and update regressions. * Add comments concerning expandDefinitions * Expand comment, move to .h
Diffstat (limited to 'src/theory')
-rw-r--r--src/theory/sets/theory_sets.cpp4
-rw-r--r--src/theory/sets/theory_sets.h2
-rw-r--r--src/theory/sets/theory_sets_private.cpp21
-rw-r--r--src/theory/sets/theory_sets_private.h32
-rw-r--r--src/theory/theory.h6
5 files changed, 58 insertions, 7 deletions
diff --git a/src/theory/sets/theory_sets.cpp b/src/theory/sets/theory_sets.cpp
index 4992f654f..263d61934 100644
--- a/src/theory/sets/theory_sets.cpp
+++ b/src/theory/sets/theory_sets.cpp
@@ -74,6 +74,10 @@ void TheorySets::preRegisterTerm(TNode node) {
d_internal->preRegisterTerm(node);
}
+Node TheorySets::expandDefinition(LogicRequest &logicRequest, Node n) {
+ return d_internal->expandDefinition(logicRequest, n);
+}
+
Theory::PPAssertStatus TheorySets::ppAssert(TNode in, SubstitutionMap& outSubstitutions) {
return d_internal->ppAssert( in, outSubstitutions );
}
diff --git a/src/theory/sets/theory_sets.h b/src/theory/sets/theory_sets.h
index bbc6ae0c4..3ecd404bb 100644
--- a/src/theory/sets/theory_sets.h
+++ b/src/theory/sets/theory_sets.h
@@ -66,6 +66,8 @@ public:
void preRegisterTerm(TNode node);
+ Node expandDefinition(LogicRequest &logicRequest, Node n);
+
PPAssertStatus ppAssert(TNode in, SubstitutionMap& outSubstitutions);
void presolve();
diff --git a/src/theory/sets/theory_sets_private.cpp b/src/theory/sets/theory_sets_private.cpp
index a2a56e137..3013711eb 100644
--- a/src/theory/sets/theory_sets_private.cpp
+++ b/src/theory/sets/theory_sets_private.cpp
@@ -604,13 +604,8 @@ void TheorySetsPrivate::fullEffortCheck(){
}else if( n.getKind()==kind::EMPTYSET ){
d_eqc_emptyset[tnn] = eqc;
}else if( n.getKind()==kind::UNIVERSE_SET ){
- if( options::setsExt() ){
- d_eqc_univset[tnn] = eqc;
- }else{
- std::stringstream ss;
- ss << "Symbols complement and universe set are not supported in default mode, try --sets-ext." << std::endl;
- throw LogicException(ss.str());
- }
+ Assert( options::setsExt() );
+ d_eqc_univset[tnn] = eqc;
}else{
Node r1 = d_equalityEngine.getRepresentative( n[0] );
Node r2 = d_equalityEngine.getRepresentative( n[1] );
@@ -2155,8 +2150,20 @@ void TheorySetsPrivate::preRegisterTerm(TNode node)
}
}
+Node TheorySetsPrivate::expandDefinition(LogicRequest &logicRequest, Node n) {
+ Debug("sets-proc") << "expandDefinition : " << n << std::endl;
+ if( n.getKind()==kind::UNIVERSE_SET || n.getKind()==kind::COMPLEMENT || n.getKind()==kind::JOIN_IMAGE ){
+ if( !options::setsExt() ){
+ std::stringstream ss;
+ ss << "Extended set operators are not supported in default mode, try --sets-ext.";
+ throw LogicException(ss.str());
+ }
+ }
+ return n;
+}
Theory::PPAssertStatus TheorySetsPrivate::ppAssert(TNode in, SubstitutionMap& outSubstitutions) {
+ Debug("sets-proc") << "ppAssert : " << in << std::endl;
Theory::PPAssertStatus status = Theory::PP_ASSERT_STATUS_UNSOLVED;
//TODO: allow variable elimination for sets when setsExt = true
diff --git a/src/theory/sets/theory_sets_private.h b/src/theory/sets/theory_sets_private.h
index 7bc17c927..175e82bb8 100644
--- a/src/theory/sets/theory_sets_private.h
+++ b/src/theory/sets/theory_sets_private.h
@@ -188,6 +188,38 @@ public:
void preRegisterTerm(TNode node);
+ /** expandDefinition
+ * If the sets-ext option is not set and we have an extended operator,
+ * we throw an exception. This function is a no-op otherwise.
+ *
+ * This is related to github issue #1076
+ * TheorySets uses expandDefinition as an entry point to see if the input
+ * contains extended operators.
+ *
+ * We need to be notified when a universe set occurs in our input,
+ * before preprocessing and simplification takes place. Otherwise the models
+ * may be inaccurate when setsExt is false, here is an example:
+ *
+ * x,y : (Set Int)
+ * x = (as univset (Set Int));
+ * 0 in y;
+ * check-sat;
+ *
+ * If setsExt is enabled, the model value of (as univset (Set Int)) is always accurate.
+ *
+ * If setsExt is not enabled, the following can happen for the above example:
+ * x = (as univset (Set Int)) is made into a model substitution during
+ * simplification. This means (as univset (Set Int)) is not a term in any assertion,
+ * and hence we do not throw an exception, nor do we infer that 0 is a member of
+ * (as univset (Set Int)). We instead report a model where x = {}. The correct behavior
+ * is to throw an exception that says universe set is not supported when setsExt disabled.
+ * Hence we check for the existence of universe set before simplification here.
+ *
+ * Another option to fix this is to make TheoryModel::getValue more general
+ * so that it makes theory-specific calls to evaluate interpreted symbols.
+ */
+ Node expandDefinition(LogicRequest &logicRequest, Node n);
+
Theory::PPAssertStatus ppAssert(TNode in, SubstitutionMap& outSubstitutions);
void presolve();
diff --git a/src/theory/theory.h b/src/theory/theory.h
index 73102a6e2..1a72944ff 100644
--- a/src/theory/theory.h
+++ b/src/theory/theory.h
@@ -424,6 +424,12 @@ public:
* used, definitions should only be used when rewrites are not
* possible, for example in handling under-specified operations
* using partially defined functions.
+ *
+ * TODO (github issue #1076):
+ * some theories like sets use expandDefinition as a "context
+ * independent preRegisterTerm". This is required for cases where
+ * a theory wants to be notified about a term before preprocessing
+ * and simplification but doesn't necessarily want to rewrite it.
*/
virtual Node expandDefinition(LogicRequest &logicRequest, Node node) {
// by default, do nothing
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback