Fix proofs for trivial cases of datatypes tester merge (#7969)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Thu, 20 Jan 2022 20:39:59 +0000 (14:39 -0600)
committerGitHub <noreply@github.com>
Thu, 20 Jan 2022 20:39:59 +0000 (20:39 +0000)
Fixes cvc5/cvc5-projects#433.

Also ensures we don't add (= t t) as part of a reported conflict.

src/theory/datatypes/infer_proof_cons.cpp
src/theory/datatypes/theory_datatypes.cpp
test/regress/CMakeLists.txt
test/regress/regress1/datatypes/proj-issue433-tester-merge-pf.smt2 [new file with mode: 0644]

index d2e4947bba15602a65c856dfbdc64246520ec5a2..e49d58f9162e67fb96d8dc1a3f90e991db80e53a 100644 (file)
@@ -218,14 +218,17 @@ void InferProofCons::convert(InferenceId infer, TNode conc, TNode exp, CDProof*
     break;
     case InferenceId::DATATYPES_TESTER_MERGE_CONFLICT:
     {
-      Assert(expv.size() == 3);
+      Assert(2 <= expv.size() && expv.size() <= 3);
       Node tester1 = expv[0];
       Node tester1c =
           nm->mkNode(APPLY_TESTER, expv[1].getOperator(), expv[0][0]);
-      cdp->addStep(tester1c,
-                   PfRule::MACRO_SR_PRED_TRANSFORM,
-                   {expv[1], expv[2]},
-                   {tester1c});
+      std::vector<Node> targs{expv[1]};
+      if (expv.size() == 3)
+      {
+        targs.push_back(expv[2]);
+      }
+      cdp->addStep(
+          tester1c, PfRule::MACRO_SR_PRED_TRANSFORM, targs, {tester1c});
       Node fn = nm->mkConst(false);
       cdp->addStep(fn, PfRule::DT_CLASH, {tester1, tester1c}, {});
       success = true;
index f413015c4c8b1379ffb99ab2876983635d176335..a689be7c5c50b7cb0b4cea34734892732be71a74 100644 (file)
@@ -902,7 +902,10 @@ void TheoryDatatypes::addTester(
     std::vector<Node> conf;
     conf.push_back(j);
     conf.push_back(t);
-    conf.push_back(jt[0].eqNode(t_arg));
+    if (jt[0] != t_arg)
+    {
+      conf.push_back(jt[0].eqNode(t_arg));
+    }
     Trace("dt-conflict") << "CONFLICT: Tester conflict : " << conf << std::endl;
     d_im.sendDtConflict(conf, InferenceId::DATATYPES_TESTER_MERGE_CONFLICT);
   }
index 1358f7dc774e5df4f4baafdd1afcc6c7e0f4f5a4..53df6519e8229a71b0d7c3585acb20db535ecff1 100644 (file)
@@ -1708,6 +1708,7 @@ set(regress_1_tests
   regress1/datatypes/non-simple-rec.smt2
   regress1/datatypes/non-simple-rec-mut-unsat.smt2
   regress1/datatypes/non-simple-rec-param.smt2
+  regress1/datatypes/proj-issue433-tester-merge-pf.smt2
   regress1/datatypes/tuple_projection.smt2
   regress1/decision/bug374a.smtv1.smt2
   regress1/decision/error3.smtv1.smt2
diff --git a/test/regress/regress1/datatypes/proj-issue433-tester-merge-pf.smt2 b/test/regress/regress1/datatypes/proj-issue433-tester-merge-pf.smt2
new file mode 100644 (file)
index 0000000..9e2a428
--- /dev/null
@@ -0,0 +1,8 @@
+(set-logic ALL)
+(set-info :status unsat)
+(declare-datatypes ((L 0)) (((i))))
+(declare-datatypes ((O 0)) (((N) (S (i (_ BitVec 3))))))
+(declare-fun m (L) O)
+(declare-fun g ((_ BitVec 3) L) L)
+(assert (exists ((B L) (n (_ BitVec 3))) (not (ite ((_ is S) (m (g n B))) (not ((_ is N) (m (g n B)))) true))))
+(check-sat)