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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
;;;;;;;;;;;;;;;;;;
;; From repro-constraineq
;; repro-constraineq
(push)
(rule ((= x 1) (= y x) (= z y)) ())
(run 1)
(pop)
;; repro-constraineq2
(push)
(rule ((= x 1) (= y x)) ())
(run 1)
(pop)
;; repro-constraineq3
(push)
(relation f (i64))
(rule ((= x 1)
(= x 2))
((f x)))
(run 1)
(print-function f 10)
(pop)
;;;;;;;;;;;;;;;;;;
;; Atoms need to be order-insensitive
;; Issue #196
(push)
(relation R (i64))
(rule
((= x y)
(= y 1))
((R x)))
(run 1)
(check (R 1))
(pop)
(push)
(relation R (i64))
(rule
((= x (+ y 1))
(= y 1))
((R x)))
(run 1)
(check (R 2))
(pop)
;; Issue #80
(push)
(datatype TYPE)
(datatype TERM)
(constructor type (TERM) TYPE)
(constructor Ob () TYPE)
(constructor Hom (TERM TERM) TYPE)
(constructor id (TERM) TERM)
(rule ((type (id A)))
((type A)))
(rewrite (type (id A))
(Hom A A)
:when ((= (type A) (Ob))))
(constructor compose (TERM TERM) TERM)
(rule ((type (compose f g)))
((type f)
(type g)))
(rewrite (type (compose f g))
(Hom A C)
:when ((= (type f) (Hom A B))
(= (type g) (Hom B C))))
(birewrite (compose (compose f g) h)
(compose f (compose g h))
:when ((= (type A) (Ob))
(= (type B) (Ob))
(= (type C) (Ob))
(= (type D) (Ob))
(= (type f) (Hom A B))
(= (type g) (Hom B C))
(= (type h) (Hom C D))))
(birewrite (compose f (id B)) f
:when ((= (type A) (Ob))
(= (type B) (Ob))
(= (type f) (Hom A B))))
(birewrite (compose (id A) f) f
:when ((= (type A) (Ob))
(= (type B) (Ob))
(= (type f) (Hom A B))))
(constructor AConst () TERM)
(let $A (AConst))
(constructor BConst () TERM)
(let $B (BConst))
(constructor fConst () TERM)
(let $f (fConst))
(constructor gConst () TERM)
(let $g (gConst))
(let $fog (compose $g $f))
(union (type $f) (Hom $A $B))
(union (type $g) (Hom $B $A))
(union (type $A) (Ob))
(union (type $B) (Ob))
(type $fog)
(run 10)
(print-function type 10)
(check (= (type $f)
(type (compose (id $A)
(compose $f (id $B))))))
(check (= (type $fog)
(Hom $B $B)))
(pop)
;;;;;;;;;;;;;;;;;;
;; Finding the right type in case of container types and primitives
;; Issue #113
(push)
(sort MyMap (Map i64 String))
(sort MyMap1 (Map i64 i64))
(let $my_map1 (map-insert (map-empty) 1 "one"))
(pop)
(push)
(sort MyMap1 (Map i64 i64))
(sort MyMap (Map i64 String))
(let $my_map1 (map-insert (map-empty) 1 "one"))
(pop)