Z3的奇怪数组行为

时间:2013-07-30 08:43:11

标签: arrays z3

我尝试在Z3中使用数组,并注意到一个我无法解释的奇怪行为。我首先定义了一些在(Array Int Object)上运行的函数。后来我定义了一个(Array Int Real)类型的数组,它不应该与其他函数混淆,因为它们有不同的类型。然后我开始在我的数组中添加数字,并且在开始时everthing是正常的,但是将第三个元素添加到我的数组让我的规范一起分解。此外,如果我删除在(Array Int Object)上运行的函数的公理,一切都会再次起作用。我不知道,为什么会发生这种情况并希望有人对此有所了解。

; Declaration of concepts
(declare-datatypes () ((Object ObjectA ObjectB ObjectC)))

; Be aware that the following functions work on (Array Int Object) and we define an array of type (Array Int Real) later
(declare-fun Length ( (Array Int Object) ) Int)   ; The concrete length will be assert for each array of the type (Array Int Object)
(define-fun SameArray ( (array1 (Array Int Object)) (array2 (Array Int Object))) Bool
  (ite 
    (and
      (= (Length array1) (Length array2))
      (forall ((i Int)) (or (< i 0) (>= i (Length array1)) (= (select array1 i) (select array2 i) )) ) 
    )
    true
    false
  )
)

(declare-fun Match ((Array Int Object) (Array Int (Array Int Object))) Int) ; The concrete behavior for Match will be asserted for each necessary array.

; If the following axiom is deleted everything works fine
; Axioms: Equal arrays should behave equal for the Match function.
(assert (forall ( (array1 (Array Int Object)) (array2 (Array Int Object)) (list (Array Int (Array Int Object))))
  (ite
    (SameArray array1 array2)
    (= (Match array1 list) (Match array2 list))
    (not (= (Match array1 list) (Match array2 list)))
  )
))

(echo "General Definitions:")
(check-sat) ; Everything is OK here

(declare-const arr-Lookup-1 (Array Int Real))
(echo "Array Declaration:")
(check-sat) ; Everything is OK here

(assert (= (store arr-Lookup-1 0 0.0) arr-Lookup-1))
(echo "Array1 Definition 1:")
(check-sat) ; Everything is OK here

(assert (= (store arr-Lookup-1 1 100.0) arr-Lookup-1))
(echo "Array1 Definition 2:")
(check-sat) ; Everything is OK here

(assert (= (store arr-Lookup-1 2 1000.0) arr-Lookup-1))
(echo "Array1 Definition 3:")
(check-sat) ; This gives us an unknown 

(assert (= (store arr-Lookup-1 3 10000.0) arr-Lookup-1))
(echo "Array1 Definition 4:")
(check-sat)

0 个答案:

没有答案