8000 Potential correctness issue in integer arithmetic optimization · Issue #7641 · Z3Prover/z3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Potential correctness issue in integer arithmetic optimization #7641
Open
@merlinsun

Description

@merlinsun

Hi,

I’ve encountered a potential correctness issue related to integer arithmetic optimization in Z3 a51239c.
Specifically, Z3 appears to return an incorrect result for the objective function in the following example, while Optimathsat behaves as expected.

$ cat small.smt2 
(declare-const a Int)
(declare-const b Int)
(assert (and (< 0 a) (>= a 1)))
(minimize (abs (div (div (- (div (- a) (- (abs (- (mod a 6)))))) b) b (abs (- b)))))
(check-sat)
(get-objectives)
$ z3 small.smt2 
sat
(objectives
 ((let ((a!1 (- (abs (- (mod a 6))))))
(let ((a!2 (div (- (div (- a) a!1)) b)))
  (abs (div (div a!2 b) (abs (- b)))))) (* (- 1) oo))
)
$ optimathsat small.smt2 
sat

(objectives
 ((let ...) 0)
)

Interestingly, if we slightly modify the expression — for example, replacing (abs (- b)) with (abs b) — Z3 produces the correct result:

$ cat pass.smt2 
(declare-const a Int)
(declare-const b Int)
(assert (and (< 0 a) (>= a 1)))
(minimize (abs (div (div (- (div (- a) (- (abs (- (mod a 6)))))) b) b (abs b))))
(check-sat)
(get-objectives)
$ z3 pass.smt2 
sat
(objectives
 ((let ((a!1 (- (abs (- (mod a 6))))))
(let ((a!2 (div (- (div (- a) a!1)) b)))
  (abs (div (div a!2 b) (abs b))))) 0)
)

I would appreciate it if you could take a look at this issue. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0