Fix subtyping for instantiations where internal representatives are chosen (#3641)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Wed, 22 Jan 2020 23:02:58 +0000 (17:02 -0600)
committerGitHub <noreply@github.com>
Wed, 22 Jan 2020 23:02:58 +0000 (17:02 -0600)
src/theory/quantifiers/equality_query.cpp
src/theory/quantifiers/instantiate.cpp
test/regress/CMakeLists.txt
test/regress/regress1/fmf/issue3626.smt2 [new file with mode: 0644]

index f72a0d1b49367c972fc2659d3c8736af1811f815..13e7b2eb7eaad3787dfdac266053dd5196ef63e4 100644 (file)
@@ -167,7 +167,9 @@ Node EqualityQueryQuantifiersEngine::getInternalRepresentative(Node a,
       if( d_rep_score.find( r_best )==d_rep_score.end() ){
         d_rep_score[ r_best ] = d_reset_count;
       }
-      Trace("internal-rep-select") << "...Choose " << r_best << " with score " << r_best_score << std::endl;
+      Trace("internal-rep-select")
+          << "...Choose " << r_best << " with score " << r_best_score
+          << " and type " << r_best.getType() << std::endl;
       Assert(r_best.getType().isSubtypeOf(v_tn));
       v_int_rep[r] = r_best;
       if( r_best!=a ){
index c6427a4c48619d2b4a8ac9e9f05f2615c1535fe7..aec648037c81f465346181625c2a86f72f6ea4bd 100644 (file)
@@ -126,17 +126,16 @@ bool Instantiate::addInstantiation(
     {
       terms[i] = getTermForType(tn);
     }
+    // Ensure the type is correct, this for instance ensures that real terms
+    // are cast to integers for { x -> t } where x has type Int and t has
+    // type Real.
+    terms[i] = quantifiers::TermUtil::ensureType(terms[i], tn);
     if (mkRep)
     {
       // pick the best possible representative for instantiation, based on past
       // use and simplicity of term
       terms[i] = d_qe->getInternalRepresentative(terms[i], q, i);
     }
-    else
-    {
-      // ensure the type is correct
-      terms[i] = quantifiers::TermUtil::ensureType(terms[i], tn);
-    }
     Trace("inst-add-debug") << " -> " << terms[i] << std::endl;
     if (terms[i].isNull())
     {
index 5020fe6fdae1d274d176826ef496baf8250b6cc7..65d7f2b31ad8c9989e44df8d6402a98f1aeaaba8 100644 (file)
@@ -1225,6 +1225,7 @@ set(regress_1_tests
   regress1/fmf/german73.smt2
   regress1/fmf/issue2034-preinit.smt2
   regress1/fmf/issue3587.smt2
+  regress1/fmf/issue3626.smt2
   regress1/fmf/issue916-fmf-or.smt2
   regress1/fmf/jasmin-cdt-crash.smt2
   regress1/fmf/ko-bound-set.cvc
diff --git a/test/regress/regress1/fmf/issue3626.smt2 b/test/regress/regress1/fmf/issue3626.smt2
new file mode 100644 (file)
index 0000000..9f27dee
--- /dev/null
@@ -0,0 +1,5 @@
+; COMMAND-LINE: --fmf-bound
+; EXPECT: sat
+(set-logic ALL)
+(assert (forall ((a Int)) (or (distinct (/ 0 0) a) (= (/ 0 a) 0))))
+(check-sat)