Fix for learned rewrite pass, add regression (#6850)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Mon, 12 Jul 2021 19:18:17 +0000 (14:18 -0500)
committerGitHub <noreply@github.com>
Mon, 12 Jul 2021 19:18:17 +0000 (19:18 +0000)
Fixes #4791.

src/preprocessing/passes/learned_rewrite.cpp
test/regress/CMakeLists.txt
test/regress/regress1/nl/issue4791-llr.smt2 [new file with mode: 0644]

index fd3cf832b1d2362d79a535c7231dd8d718935d0b..81fbf1ea1c56164b9ce451bc1f5c68e45d42d041 100644 (file)
@@ -293,7 +293,7 @@ Node LearnedRewrite::rewriteLearned(Node n,
         || (!db.upper_value.isNull()
             && db.upper_value.getConst<Rational>().sgn() == -1))
     {
-      Rational bden = db.lower_value.isNull()
+      Rational bden = db.upper_value.isNull()
                           ? db.lower_value.getConst<Rational>()
                           : db.upper_value.getConst<Rational>().abs();
       // if 0 <= UB(num) < LB(den) or 0 <= UB(num) < -UB(den)
index cdc77c980f703702ec82009fdc0ae3ad8644f738..be0815668e982ef9ba03c27a626a7128fbd3a3ec 100644 (file)
@@ -1676,6 +1676,7 @@ set(regress_1_tests
   regress1/nl/issue3656.smt2
   regress1/nl/issue3803-nl-check-model.smt2
   regress1/nl/issue3955-ee-double-notify.smt2
+  regress1/nl/issue4791-llr.smt2
   regress1/nl/issue5372-2-no-m-presolve.smt2
   regress1/nl/issue5662-nl-tc.smt2
   regress1/nl/issue5662-nl-tc-min.smt2
diff --git a/test/regress/regress1/nl/issue4791-llr.smt2 b/test/regress/regress1/nl/issue4791-llr.smt2
new file mode 100644 (file)
index 0000000..d29a163
--- /dev/null
@@ -0,0 +1,21 @@
+; COMMAND-LINE: --learned-rewrite --no-check-unsat-cores
+; EXPECT: unsat
+;
+;!(a,b,c).( 0<=b & 1<=c & 0<=a & 1<=c
+;               =>
+;               (a+(b mod c)) mod c = (a+b) mod c)
+;
+(set-logic QF_NIA)
+(set-option :print-success false)
+
+(declare-fun a () Int)
+(declare-fun b () Int)
+(declare-fun c () Int)
+
+(assert (<= 0 a))
+(assert (<= 1 c))
+(assert (<= 0 b))
+
+(assert (! (not (= (mod (+ a (mod b c)) c) (mod (+ a b) c))) :named goal))
+(check-sat)
+(exit)