-
Notifications
You must be signed in to change notification settings - Fork 0
/
constr-~a.z3
104 lines (87 loc) · 2.65 KB
/
constr-~a.z3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
(declare-datatypes () ((NT Noob918)))
(define-fun empty () (Set NT)
((as const (Set NT)) false))
(define-fun singleton ((a NT)) (Set NT)
(store empty a true))
(define-fun union ((a (Set NT)) (b (Set NT))) (Set NT)
((_ map or) a b))
(define-fun imp ((b Bool) (s (Set NT))) (Set NT)
(ite b s empty))
(declare-datatypes () ((Type (mk-type (is-null Bool) (head-set (Set NT))))))
(declare-datatypes () ((INat (i (value Int)) Infty )) )
(define-fun lt ((a INat) (b INat)) (Bool)
(match a
(case (i n) (match b
(case (i m) (< n m))
(case Infty true) ))
(case Infty (match b
(case (i m) false)
(case Infty false)))))
(define-fun gt ((a INat) (b INat)) (Bool)
(match a
(case (i n) (match b
(case (i m) (> n m))
(case Infty false) ))
(case Infty (match b
(case (i m) true)
(case Infty false)))))
(define-fun isZero ((a INat)) (Bool)
(match a
(case (i n) (= n 0))
(case Infty false)))
(define-fun isInfty ((a INat)) (Bool)
(match a
(case (i n) false)
(case Infty true)))
(define-fun prod ((a Type) (b Type)) (Type)
(mk-type (and (is-null a) (is-null b))
(union (head-set a) (imp (is-null a) (head-set b)))))
(define-fun sum ((a Type) (b Type)) (Type)
(mk-type (or (is-null a)
(is-null b))
(union (head-set a)
(head-set b))))
(define-fun star ((a Type)) (Type)
(mk-type true
(head-set a)))
(define-fun neg ((a Type)) (Type)
(mk-type true
(head-set a)))
(define-fun member ((a NT) (t Type)) (Bool)
(select (head-set t) a))
(define-fun typow ((a Type) (i INat)) (Type)
(mk-type (or (isZero i) (is-null a))
(head-set a)))
(define-fun tyinter ((a Type) (i INat) (j INat)) (Type)
(mk-type (or (isZero i) (is-null a))
(head-set a)))
(declare-const t7 Type)
(declare-const t6 Type)
(declare-const t5 Type)
(declare-const t4 Type)
(declare-const t3 Type)
(declare-const t2 Type)
(declare-const t1 Type)
(declare-const t0 Type)
;v3 = <#f,{}>
(assert (= t3 (mk-type false empty)))
;v4 = <#f,{}>
(assert (= t4 (mk-type false empty)))
;v1 = ( v3 * v4 )
(assert (= t1 (prod t3 t4)))
;v6 = <#f,{}>
(assert (= t6 (mk-type false empty)))
;v7 = <#t,{}>
(assert (= t7 (mk-type true empty)))
;v5 = ( v6 + v7 )
(assert (= t5 (sum t6 t7)))
;v2 = v5 [ 0 , infty ]
(assert (= t2 (tyinter t5 (i 0) Infty)))
(assert (not (and (= Infty Infty ) (is-null t5) )))
(assert (lt (i 0) Infty))
;0 != infty
(assert (not (= (i 0) Infty)))
;v0 = ( v1 * v2 )
(assert (= t0 (prod t1 t2)))
(check-sat)
(get-model)