Skip to content

Arithmetic operation with Boolean values #6719

@rodrigo7491

Description

@rodrigo7491

Z3 returns unsat for the instance below, which contains a subtraction involving an Int and a Bool variable, (- F B).

(set-logic QF_LIA)

(define-fun state ((A Bool) (B Bool) (C Bool) (D Bool) (E Int) (F Int) (G Int) (H Int)) Bool (or (or (or (or (or (or (or (or (or (or (or (or (and (and (and (and (= A true) (= C true)) (= D true)) (not (= B true))) (>= F 1)) (and (and (and (= A true) (= C true)) (and (not (= B true)) (not (= D true)))) (and (>= F 1) (>= H 1)))) (and (and (and (= A true) (= C true)) (not (= D true))) (and (and (>= (- F B) 1) (>= F 1)) (>= H 1)))) (and (and (and (= A true) (= D true)) (and (not (= B true)) (not (= C true)))) (and (>= F 1) (>= H 1)))) (and (and (and (= C true) (= D true)) (and (not (= A true)) (not (= B true)))) (and (>= F 1) (>= H 1)))) (and (and (and (= C true) (= D true)) (not (= A true))) (and (and (>= (- F B) 1) (>= F 1)) (>= H 1)))) (and (and (= C true) (and (and (not (= A true)) (not (= B true))) (not (= D true)))) (>= F 1))) (and (and (= C true) (and (not (= A true)) (not (= D true)))) (and (>= (- F B) 1) (>= F 1)))) (and (and (= D true) (and (and (not (= A true)) (not (= B true))) (not (= C true)))) (and (>= F 1) (>= H 1)))) (and (and (= D true) (and (not (= A true)) (not (= C true)))) (and (and (>= (- F B) 1) (>= F 1)) (>= H 1)))) (and (and (not (= A true)) (not (= C true))) (not (= D true)))) (and (and (not (= B true)) (not (= C true))) (not (= D true)))) (and (and (not (= C true)) (not (= D true))) (and (>= (- F B) 1) (>= F 1)))))

(declare-fun A ()  Bool)
(declare-fun B ()  Bool)
(declare-fun C ()  Int)
(declare-fun D ()  Int)
(declare-fun E ()  Int)
(declare-fun F ()  Int)
(declare-fun G ()  Bool)
(declare-fun H ()  Bool)

(assert
    (and
      (and (= A true) (not H) (not G) (not B))
      (not (state B A H G F E D C))
    )
)

(check-sat)
(exit)

It is unclear to me if Z3 encodes Booleans as integers, like Eldarica (see uuverifiers/eldarica#51), or if this is an edge case. I was not able to reproduce the behaviour with a toy example.

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