-
Notifications
You must be signed in to change notification settings - Fork 0
/
terms.mod
56 lines (43 loc) · 1.13 KB
/
terms.mod
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
module terms.
tm_fun_linear F :-
pi v\
tm_linear_aux v true fail =>
tm_linear_aux (F v) true _.
tm_linear_aux u X X :- !.
tm_linear_aux (pair T1 T2) A C :-
!,
tm_linear_aux T1 A B,
tm_linear_aux T2 B C.
tm_linear_aux (fst T) A B :- !, tm_linear_aux T A B.
tm_linear_aux (snd T) A B :- !, tm_linear_aux T A B.
tm_linear_aux (inl T) A B :- !, tm_linear_aux T A B.
tm_linear_aux (inr T) A B :- !, tm_linear_aux T A B.
tm_linear_aux (case CT LF RF) A C :-
!,
tm_linear_aux CT A B,
tm_fun_linear_aux LF B C1,
tm_fun_linear_aux RF B C2,
(
C1,
C = C2
;
C = fail
).
tm_linear_aux (lam F) A B :- !, tm_fun_linear_aux F A B.
tm_linear_aux (rec F) A B :-
!,
pi f\
(pi X\ tm_linear_aux f X X) =>
tm_fun_linear_aux (F f) A B.
tm_linear_aux (app T1 T2) A C :-
!,
tm_linear_aux T1 A B,
tm_linear_aux T2 B C.
tm_linear_aux (abs_rtp T) A B :- !, tm_linear_aux T A B.
tm_linear_aux (rep_rtp T) A B :- !, tm_linear_aux T A B.
tm_fun_linear_aux F A B :-
pi x\
(pi X\ tm_linear_aux x X X) =>
tm_linear_aux (F x) A B.
output_tm Ch T :- printterm Ch T.
print_tm T :- output_tm std_out T.