具有PDR和muZ答案的Fixpoint未知

时间:2017-05-03 13:18:30

标签: z3

我创建了这个代表Dekker算法

的文件
  • 给定Turn类型的变量proc和两个数组wantcritproc映射到bools
  • 所有want[p] = false
  • 的初始状态为crit[p] = falseproc p
  • 我可以非确定地采取以下三种转变之一:
    • req:如果proc p存在want[p] = false,那么want'[p] = true
    • enter:如果存在proc p want[p] = trueturn = p,那么crit'[p] = true
    • exit:如果存在proc p crit[p] = true,则want'[p] = falsecrit'[p] = falseturn = ??代表事实上任何proc p'都可归因于turn)。
  • 如果proc p1p2存在crit[p1] = crit[p2] = true
  • ,则状态不安全

我这样表示:

(set-logic HORN)

(define-sort proc () Int)
(define-sort myarray () (Array proc Bool))

(declare-var turn proc)
(declare-var want myarray)
(declare-var crit myarray)

(declare-fun reachable (proc myarray myarray) Bool)

;; Init
(rule
 (=>
  (forall ((z proc))
          (and
           (= (select want z) false)
           (= (select crit z) false)
           )
          )
  (reachable turn want crit)
  )
 )

;; Unsafe
(assert
 (exists ((z1 proc) (z2 proc))
         (=>
          (and
           (not (= z1 z2))
           (= (select want z1) true)
           (= (select want z2) true)
           )
          (reachable turn want crit)
          )
         )
 )

;; Req
(assert 
 (exists ((z proc))
         (=>
          (and
           (= (select want z) false)
           (reachable turn want crit)
           )
           (reachable turn (store want z true) crit)
           )
         )
 )

;; Enter
(assert 
 (exists ((z proc))
         (=>
          (and
           (= (select want z) true)
           (= turn z)
           (reachable turn want crit)
           )
          (reachable turn want (store crit z true))
          )
         )
 )

;; Exit
(assert 
 (exists ((z1 proc)
          (z2 proc)
          )
         (=>
          (and
           (= (select crit z1) true)
           (reachable turn want crit)
           )
          (and
           (reachable
            z2 
            (store want z1 false)
            (store crit z1 false)
            )
           )
          )
         )
 )

(check-sat)

但是当我致电z3 dekker.smt2时,它会给我unknown作为答案。

如果我尝试这样做:

(set-logic HORN)

(declare-fun reachable (Int
                        (Array Int Bool)
                        (Array Int Bool)) Bool)


;; Init
(assert
 (forall ((Turn Int)
          (Want (Array Int Bool))
          (Crit (Array Int Bool))
          )

         (=>
          (forall ((z Int))
                  (and
                   (= (select Want z) false)
                   (= (select Crit z) false)
                   ))
          (reachable Turn Want Crit)
          )))


;; Unsafe
(assert 
 (forall ((Turn Int)
          (Want (Array Int Bool))
          (Crit (Array Int Bool))
          )

         (=>
          (reachable Turn Want Crit)

          (not
           (exists ((z1 Int) (z2 Int))
                   (and (not (= z1 z2))
                        (= (select Crit z1) true)
                        (= (select Crit z2) true)
                        )
                   )
           )
          )
         )
 )


;; Transitions
(assert 
 (forall (
          (Turn Int)
          (Want (Array Int Bool))
          (Crit (Array Int Bool))

          (Turn_ Int)
          (Want_ (Array Int Bool))
          (Crit_ (Array Int Bool))
          )

         (=>
          (and
           (reachable Turn Want Crit)
           (or

            ;;req
            (exists ((n Int))
                    (and (= (select Want n) false)

                         (= Turn_ Turn)
                         (= Want_ (store Want n true))
                         (= Crit_ Crit)
                         )
                    )

            ;;req
            (exists ((n Int))
                    (and (= (select Want n) true)
                         (= Turn n)

                         (= Turn_ Turn)
                         (= Want_ Want)
                         (= Crit_ (store Crit n true))
                         )
                    )

            ;;req
            (exists ((n Int) (n2 Int))
                    (and (= (select Crit n) true)

                         (= Turn_ n2)
                         (= Want_ (store Want n false))
                         (= Crit_ (store Crit n false))
                         )
                    )
            )

           )
          (reachable Turn_ Want_ Crit_)
          )
         )
 )

(check-sat)

我得到了这个答案:

PDR cannot solve non-ground tails: (let ((a!1 (forall ((z Int))
             (and (= (select reachable_1_n z) false)
                  (= (select reachable_2_n z) false)))))
  (= a!1 true))
unknown

0 个答案:

没有答案