Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iZ3 - wrong interpolant from Farkas proof #48

Closed
agriggio opened this issue Apr 21, 2015 · 3 comments
Closed

iZ3 - wrong interpolant from Farkas proof #48

agriggio opened this issue Apr 21, 2015 · 3 comments
Assignees

Comments

@agriggio
Copy link

Z3 computes a wrong interpolant for the example below.

I think this is due to the "rounding off" done in order to deal with
integer inequalities, which is performed regardless of whether the input
inequality is over the integer or over the rationals.

I'm also attaching a tentative patch for the issue.

Here's an SMT-LIB2 example showing the problem:

(set-logic QF_LRA)

(declare-fun x () Real)
(declare-fun y () Real)
(declare-fun z () Real)

(define-fun A () Bool
  (and
   (not (<= x 0.0))
   (>= (+ (* 10.0 y) (* (- 9.0) x)) 0.0)
   )
  )

(define-fun B () Bool
  (and (>= z 0.0)
       (<= (+ (* 10.0 y) (* 9.0 z)) 0.0))
  )

(compute-interpolant (and (interp A) B))
(exit)

;; computed wrong interpolant:
(define-fun I () Bool
  (>= y (/ 9.0 10.0)))
;; a correct interpolant is: (not (<= y 0.0))

(assert (or (and A (not I)) (and B I)))
(check-sat)

Here's a tentative patch:

diff --git a/src/interp/iz3proof_itp.cpp b/src/interp/iz3proof_itp.cpp
--- a/src/interp/iz3proof_itp.cpp
+++ b/src/interp/iz3proof_itp.cpp
@@ -2590,6 +2590,9 @@
         if(pstrict && qstrict && round_off)
             Qrhs = make(Sub,Qrhs,make_int(rational(1)));
 #else
+        if (round_off && get_type(Qrhs) != int_type()) {
+            round_off = false;
+        }
         bool pstrict = op(P) == Lt;
         if(qstrict && round_off && (pstrict || !(c == make_int(rational(1))))){
             Qrhs = make(Sub,Qrhs,make_int(rational(1)));
@kenmcmil
Copy link
Contributor

Interpolation doesn't actually support reals. Just the theory AUFLIA. I suspect there are several places it needs to be patched for real support. Thanks for sending the patch, though.

@wintersteiger
Copy link
Contributor

Ken, could you add a check so we get better error messages for this and similar cases? We have existing probes for QF_AUFLIA in probe_arith.h/.cpp

@NikolajBjorner NikolajBjorner changed the title wrong interpolant from Farkas proof iZ3 - wrong interpolant from Farkas proof May 21, 2015
@kenmcmil
Copy link
Contributor

I fixed this problem (wrong interpolant) by preventing rounding of real inequalities in a couple of places. The question of how to give a better error message when interpolation fails is still open. Closing this issue, however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants