Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
z3支持证明归纳事实吗?_Z3 - Fatal编程技术网

z3支持证明归纳事实吗?

z3支持证明归纳事实吗?,z3,Z3,我理解z3一般不能验证归纳证明。但我很好奇是否有办法让它检查一些简单的东西,比如: ; returns the same input list after iterating through each element (declare-fun iterate ((List Int)) (List Int)) (declare-const l (List Int)) (assert (forall ((l (List Int))) (ite (= l nil) (= (iterat

我理解z3一般不能验证归纳证明。但我很好奇是否有办法让它检查一些简单的东西,比如:

; returns the same input list after iterating through each element
(declare-fun iterate ((List Int)) (List Int))

(declare-const l (List Int))

(assert (forall ((l (List Int)))
  (ite (= l nil)
    (= (iterate l) nil)
    (= (iterate l) (insert (head l) (iterate (tail l))))
  )
))

(assert (not (= l (iterate l))))
(check-sat)

现在,它只是在我的机器上永远循环。

Z3不会自己进行归纳论证。你可以手动给它归纳假设,并要求它完成证明。这适用于您的示例,如下所示:

(declare-fun iterate ((List Int)) (List Int))

(assert (forall ((l (List Int)))
  (ite (= l nil)
    (= (iterate l) nil)
    (= (iterate l) (insert (head l) (iterate (tail l)))))))

; define list length for convenience in stating the induction hypothesis
(declare-fun length ((List Int)) Int)
(assert (= (length nil) 0))
(assert (forall ((x Int) (l (List Int)))
  (= (length (insert x l)) (+ 1 (length l)))))

(declare-const l (List Int))

; here comes the induction hypothesis: 
; that the statement is true for all lists shorter than l
(assert (forall ((ihl (List Int))) 
  (=> (< (length ihl) (length l))
      (= ihl (iterate ihl)))))

; we now ask Z3 to show that the result follows for l        
(assert (not (= l (iterate l))))
(check-sat)  ; reports unsat as desired
(声明乐趣迭代((列表Int))(列表Int))
(assert(forall((l(List Int)))
(无)
(=(迭代l)零)
(=(迭代l)(插入(头部l)(迭代(尾部l‘‘‘‘‘‘)’))
; 定义列表长度以便于说明归纳假设
(声明长度((列表整数))整数)
(断言(=(长度为零)0))
(断言(对于所有((x Int)(l(List Int)))
(=(长度(插入x l))(+1(长度lЮЮ))
(声明常数l(列表Int))
; 归纳假说来了:
; 对于所有短于l的列表,该语句均为真
(assert(forall((ihl(List Int)))
(=>(<(长度ihl)(长度l))
(=国际人道主义法(迭代国际人道主义法(()())))
; 现在我们要求Z3证明l的结果如下
(断言(非(=l(迭代l)))
(检查sat);根据需要报告未统计数据