I don't understand where I went wrong. Mutual exclusion is return by SAT
in the Z3 solver. Did I make an error? I'm using four arrays for the four places in my picture, and I want to check that no two processes enter the critical section at the same time.
(declare-const p0 (Array Int Int))
(declare-const p1 (Array Int Int))
(declare-const p2 (Array Int Int))
(declare-const p3 (Array Int Int))
(declare-const p4 (Array Int Int))
(define-fun t0 ((i Int)) Bool
(and
(= (select p1 (+ i 1)) (- (select p1 i) 1))
(>= (select p1 i) 1)
(= (select p2 (+ i 1)) (- (select p2 i) 1))
(>= (select p2 i) 1)
(= (select p0 (+ i 1)) (+ (select p0 i) 1))
)
)
(define-fun t1 ((i Int)) Bool
(and
(= (select p0 (+ i 1)) (- (select p0 i) 1))
(>= (select p0 i) 1)
(= (select p1 (+ i 1)) (+ (select p1 i) 1))
(= (select p2 (+ i 1)) (+ (select p2 i) 1))
)
)
(define-fun t2 ((i Int)) Bool
(and
(= (select p4 (+ i 1)) (- (select p4 i) 1))
(>= (select p4 i) 1)
(= (select p2 (+ i 1)) (- (select p2 i) 1))
(>= (select p2 i) 1)
(= (select p3 (+ i 1)) (+ (select p3 i) 1))
)
)
(define-fun t3 ((i Int)) Bool
(and
(= (select p3 (+ i 1)) (- (select p3 i) 1))
(>= (select p3 i) 1)
(= (select p4 (+ i 1)) (+ (select p4 i) 1))
(= (select p2 (+ i 1)) (+ (select p2 i) 1))
)
)
(define-fun prop0 ((i Int)) Bool
(and
(> (select p0 i) 0)
(> (select p3 i) 0)
)
)
(define-fun prop1 ((i Int)) Bool
(> (select p0 i) 0)
)
(assert (= (select p0 0) 0))
(assert (= (select p1 0) 1))
(assert (= (select p2 0) 1))
(assert (= (select p3 0) 0))
(assert (= (select p4 0) 1))
(assert (or (t0 0) (t1 0)))
;(assert (or (t0 1) (t1 1)))
;(assert (or (t0 2) (t1 2)))
;(assert (or (t0 3) (t1 3)))
;(assert (or (t0 4) (t1 4)))
;(assert (or (t0 5) (t1 5)))
;(assert (or (prop0 0) (prop0 1) (prop0 2)))
;(assert (and (or (t0 0) (t1 0)) (prop1 0)))
(assert (or (t0 1) (t1 1)))
;here i check p0 and p3 are never in critical section together
(assert (or (prop0 0) (prop0 1)))
(check-sat)