Always introduce fresh variable for unconstrained APPLY_UF (#4472)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Tue, 5 May 2020 21:35:44 +0000 (16:35 -0500)
committerGitHub <noreply@github.com>
Tue, 5 May 2020 21:35:44 +0000 (14:35 -0700)
Fixes an unsoundness in unconstrained simplification, fixes #4469.

src/preprocessing/passes/unconstrained_simplifier.cpp
test/regress/CMakeLists.txt
test/regress/regress0/issue4469-unc-no-reuse-var.smt2 [new file with mode: 0644]

index 8a2c58b99581d560282f2a41bda51e74a709bbd3..7cf6a79bd35c5f3622cd70b1419af59ebc11b12b 100644 (file)
@@ -577,10 +577,9 @@ void UnconstrainedSimplifier::processUnconstrained()
             {
               currentSub = current;
             }
-            if (parent.getType() != current.getType())
-            {
-              currentSub = newUnconstrainedVar(parent.getType(), currentSub);
-            }
+            // always introduce a new variable; it is unsound to try to reuse
+            // currentSub as the variable, see issue #4469.
+            currentSub = newUnconstrainedVar(parent.getType(), currentSub);
             current = parent;
           }
           else
@@ -779,6 +778,10 @@ void UnconstrainedSimplifier::processUnconstrained()
     }
     if (!currentSub.isNull())
     {
+      Trace("unc-simp")
+          << "UnconstrainedSimplifier::processUnconstrained: introduce "
+          << currentSub << " for " << current << ", parent " << parent
+          << std::endl;
       Assert(currentSub.isVar());
       d_substitutions.addSubstitution(current, currentSub, false);
     }
index 97a5210286dd27e2d3d3eac88d86742fc682eff5..b8304f7222ecd38cba03ee60c45c44804f5a547d 100644 (file)
@@ -552,6 +552,7 @@ set(regress_0_tests
   regress0/issue1063-overloading-dt-sel.smt2
   regress0/issue2832-qualId.smt2
   regress0/issue4010-sort-inf-var.smt2
+  regress0/issue4469-unc-no-reuse-var.smt2
   regress0/ite.cvc
   regress0/ite2.smt2
   regress0/ite3.smt2
diff --git a/test/regress/regress0/issue4469-unc-no-reuse-var.smt2 b/test/regress/regress0/issue4469-unc-no-reuse-var.smt2
new file mode 100644 (file)
index 0000000..3bc7957
--- /dev/null
@@ -0,0 +1,7 @@
+; COMMAND-LINE: --unconstrained-simp --no-check-models
+; EXPECT: sat
+(set-logic QF_AUFBVLIA)
+(declare-fun a () Int)
+(declare-fun b (Int) Int)
+(assert (distinct (b a) (b (b a))))
+(check-sat)