参数化的排序

时间:2012-10-16 21:33:13

标签: z3 smt

如何访问参数化排序的值?

例如,如果我有以下声明:

(declare-sort Pair 2)
(declare-const x (Pair Int Int))

如何访问x代表的对中的第一个元素?

1 个答案:

答案 0 :(得分:1)

您可以使用两个选择器firstsecond创建参数记录,以便访问其字段。

以下是an example

(declare-datatypes (T1 T2) ((Pair (mk-pair (first T1) (second T2)))))
(declare-const p1 (Pair Bool Int))
(declare-const p2 (Pair Int Int))
(assert (first p1))
(assert (> (first p2) 2))
(assert (= (second p1) (second p2)))
(check-sat)
(get-model)

Z3 SMT指南中还对algebraic datatypes进行了全面介绍。

相关问题