【发布时间】:2019-02-18 04:10:03
【问题描述】:
当一条记录包含多个相同类型的命名数组时,我在 z3 中遇到了一些意外行为:
(declare-datatypes () ((Record_lengths (Record_lengths (array (Array Int Int))))))
(declare-datatypes () ((ROI (ROI (array (Array Int Int))))))
(declare-datatypes () ((Record (Record (lengths Record_lengths) (roi ROI)))))
(declare-fun rec () Record)
(assert (= (select (array (lengths rec)) 1) 0))
(get-model)
我预计会有一个解决方案,其中 rec.lengths[1]=0,所有其他都是默认值或随机值。然而lengths 选择器总是有一个额外的ite 子句:
(model
(define-fun rec () Record
(Record (Record_lengths (_ as-array k!1)) (ROI (_ as-array k!0))))
(define-fun k!0 ((x!0 Int)) Int
(ite (= x!0 2) 4
4))
(define-fun k!1 ((x!0 Int)) Int
(ite (= x!0 1) 0
(ite (= x!0 2) 3 ;this is unexpected
0)))
)
似乎这些额外子句的数量与记录中相同数组类型的数量存在某种关系。
就像在这个例子中一样:Record_lengths 和 ROI 具有相同的类型,如果我在 Record 中添加更多 ROI 类型,那么额外的子句数也会增加。
这是示例的永久链接: https://rise4fun.com/Z3/geoo
【问题讨论】: