Z3中的量词模式

时间:2019-05-15 02:26:07

标签: z3 smt quantifiers

我在尝试证明这个相当简单的Z3查询时遇到麻烦。

(set-option :smt.auto-config false) ; disable automatic self configuration
(set-option :smt.mbqi false) ; disable model-based quantifier instantiation
(declare-fun sum (Int) Int)
(declare-fun list () (Array Int Int))
(declare-fun i0 () Int)
(declare-fun s0 () Int)
(declare-fun i1 () Int)
(declare-fun s1 () Int)
(assert (forall ((n Int))
  (! (or (not (<= n 0)) (= (sum n) 0)) 
     :pattern ((sum n)))))
(assert (forall ((n Int))
  (! (let ((a1 (= (sum n)
                   (+ (select list (- n 1))
                      (sum (- n 1))))))
       (or (<= n 0) a1))
     :pattern ((sum n)))))
(assert (>= i0 0))
(assert (= s0 (sum i0)))
(assert (= i1 (+ 1 i0)))
(assert (= s1 (+ 1 s0 (select list i0))))
(assert (not (= s1 (sum i1))))

(check-sat)

在我看来,最终断言应为i1实例化第二个量化语句,而涉及s0的断言应为i0实例化量词。这两个应该很容易导致UNSAT。

但是,Z3返回未知。我想念什么?

1 个答案:

答案 0 :(得分:1)

没关系,我的查询中有一个愚蠢的错误。

此代码:

data['demands'] = [(0,0), (1,3), (1,4), (1,3), (5,8), (2,4), (5,6), (6,6), (5,5), (1,4), (1,2), (3,4), (2,4), (1,3), (2,4),(1,3), (5,6)]

data['time_windows'] = [
  (0, 5),  # depot
  (7, 12),  # 1
  (10, 15),  # 2
  (16, 18),  # 3
  (10, 13),  # 4
  (0, 5),  # 5
  (5, 10),  # 6
  (0, 4),  # 7
  (5, 10),  # 8
  (0, 3),  # 9
  (10, 16),  # 10
  (10, 15),  # 11
  (0, 5),  # 12
  (5, 10),  # 13
  (7, 8),  # 14
  (10, 15),  # 15
  (11, 15),  # 16]

应该是:

(assert (= s1 (+ 1 s0 (select list i0))))