Reputation: 15
How can I access the values of parameterized sorts?
For instance, if I have the following declarations:
(declare-sort Pair 2)
(declare-const x (Pair Int Int))
How do I access the first element in the pair which x
represents?
Upvotes: 1
Views: 167
Reputation: 41290
You can create a parametric record with two selectors first
and second
for accessing its field.
Here is 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)
There is also a comprehensive introduction on algebraic datatypes in Z3 SMT guide.
Upvotes: 1