author | Christian Urban <urbanc@in.tum.de> |
Fri, 15 Jan 2010 15:56:06 +0100 | |
changeset 892 | 693aecde755d |
parent 874 | ab8a58973861 |
child 899 | 2468c0f2b276 |
permissions | -rw-r--r-- |
872
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory Terms |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports Nominal "../QuotMain" "../QuotList" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
atom_decl name |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
892
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
7 |
text {*** lets with binding patterns ***} |
872
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
datatype trm1 = |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
Vr1 "name" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
| Ap1 "trm1" "trm1" |
892
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
11 |
| Lm1 "name" "trm1" --"name is bound in trm1" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
12 |
| Lt1 "bp" "trm1" "trm1" --"all variables in bp are bound in the 2nd trm1" |
872
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
and bp = |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
BUnit |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
| BVr "name" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
| BPr "bp" "bp" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
|
874
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
18 |
(* to be given by the user *) |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
19 |
fun |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
20 |
bv1 |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
21 |
where |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
22 |
"bv1 (BUnit) = {}" |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
23 |
| "bv1 (BVr x) = {x}" |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
24 |
| "bv1 (BPr bp1 bp2) = (bv1 bp1) \<union> (bv1 bp1)" |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
25 |
|
892
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
26 |
(* needs to be calculated by the package *) |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
27 |
fun |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
28 |
fv_trm1 and fv_bp |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
29 |
where |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
30 |
"fv_trm1 (Vr1 x) = {x}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
31 |
| "fv_trm1 (Ap1 t1 t2) = (fv_trm1 t1) \<union> (fv_trm1 t2)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
32 |
| "fv_trm1 (Lm1 x t) = (fv_trm1 t) - {x}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
33 |
| "fv_trm1 (Lt1 bp t1 t2) = (fv_trm1 t1) \<union> (fv_trm1 t2 - bv1 bp)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
34 |
| "fv_bp (BUnit) = {}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
35 |
| "fv_bp (BVr x) = {x}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
36 |
| "fv_bp (BPr b1 b2) = (fv_bp b1) \<union> (fv_bp b2)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
37 |
|
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
38 |
text {*** lets with single assignments ***} |
872
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
datatype trm2 = |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
Vr2 "name" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
| Ap2 "trm2" "trm2" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
| Lm2 "name" "trm2" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
| Lt2 "assign" "trm2" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
and assign = |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
As "name" "trm2" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
|
874
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
47 |
(* to be given by the user *) |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
48 |
fun |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
49 |
bv2 |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
50 |
where |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
51 |
"bv2 (As x t) = {x}" |
872
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
|
892
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
53 |
(* needs to be calculated by the package *) |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
54 |
fun |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
55 |
fv_trm2 and fv_assign |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
56 |
where |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
57 |
"fv_trm2 (Vr2 x) = {x}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
58 |
| "fv_trm2 (Ap2 t1 t2) = (fv_trm2 t1) \<union> (fv_trm2 t2)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
59 |
| "fv_trm2 (Lm2 x t) = (fv_trm2 t) - {x}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
60 |
| "fv_trm2 (Lt2 as t) = (fv_trm2 t - bv2 as) \<union> (fv_assign as)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
61 |
| "fv_assign (As x t) = (fv_trm2 t)" |
874
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
62 |
|
892
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
63 |
|
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
64 |
text {*** lets with many assignments ***} |
872
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
datatype trm3 = |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
Vr3 "name" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
| Ap3 "trm3" "trm3" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
| Lm3 "name" "trm3" |
892
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
69 |
| Lt3 "assigns" "trm3" |
872
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
and assigns = |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
ANil |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
| ACons "name" "trm3" "assigns" |
2605ea41bbdd
added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
|
874
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
74 |
(* to be given by the user *) |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
75 |
fun |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
76 |
bv3 |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
77 |
where |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
78 |
"bv3 ANil = {}" |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
79 |
| "bv3 (ACons x t as) = {x} \<union> (bv3 as)" |
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
80 |
|
892
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
81 |
fun |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
82 |
fv_trm3 and fv_assigns |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
83 |
where |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
84 |
"fv_trm3 (Vr3 x) = {x}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
85 |
| "fv_trm3 (Ap3 t1 t2) = (fv_trm3 t1) \<union> (fv_trm3 t2)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
86 |
| "fv_trm3 (Lm3 x t) = (fv_trm3 t) - {x}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
87 |
| "fv_trm3 (Lt3 as t) = (fv_trm3 t - bv3 as) \<union> (fv_assigns as)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
88 |
| "fv_assigns (ANil) = {}" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
89 |
| "fv_assigns (ACons x t as) = (fv_trm3 t) \<union> (fv_assigns as)" |
693aecde755d
added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents:
874
diff
changeset
|
90 |
|
874
ab8a58973861
added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents:
872
diff
changeset
|
91 |
end |