author | Cezary Kaliszyk <cezarykaliszyk@gmail.com> |
Mon, 26 Mar 2012 16:28:17 +0200 | |
changeset 3139 | e05c033d69c1 |
parent 3132 | 87eca760dcba |
child 3183 | 313e6f2cdd89 |
permissions | -rw-r--r-- |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory Lambda |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports "../Nominal/Nominal2" |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
section {* Definitions for Lambda Terms *} |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
2684
diff
changeset
|
7 |
|
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
text {* type of variables *} |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
atom_decl name |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
subsection {* Alpha-Equated Lambda Terms *} |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
nominal_datatype lam = |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
Var "name" |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
| App "lam" "lam" |
3132
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
18 |
| Lam x::"name" l::"lam" binds x in l ("Lam [_]. _" [100, 100] 100) |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
text {* some automatically derived theorems *} |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
thm lam.distinct |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
thm lam.eq_iff |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
thm lam.fresh |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
thm lam.size |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
thm lam.exhaust |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
thm lam.strong_exhaust |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
thm lam.induct |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
30 |
thm lam.strong_induct |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
subsection {* Height Function *} |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
nominal_primrec |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
height :: "lam \<Rightarrow> int" |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
where |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
"height (Var x) = 1" |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
| "height (App t1 t2) = max (height t1) (height t2) + 1" |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
| "height (Lam [x].t) = height t + 1" |
3132
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
41 |
apply(simp add: eqvt_def height_graph_def) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
42 |
apply (rule, perm_simp, rule) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
43 |
apply(rule TrueI) |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
apply(rule_tac y="x" in lam.exhaust) |
3132
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
45 |
apply(auto) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
46 |
apply(erule_tac c="()" in Abs_lst1_fcb2) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
47 |
apply(simp_all add: fresh_def pure_supp eqvt_at_def fresh_star_def) |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
done |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
|
3132
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
50 |
termination (eqvt) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
51 |
by lexicographic_order |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
2684
diff
changeset
|
54 |
subsection {* Capture-Avoiding Substitution *} |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
nominal_primrec |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_ [_ ::= _]" [90,90,90] 90) |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
where |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
"(Var x)[y ::= s] = (if x = y then s else (Var x))" |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])" |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])" |
3132
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
62 |
unfolding eqvt_def subst_graph_def |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
63 |
apply(rule, perm_simp, rule) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
64 |
apply(rule TrueI) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
65 |
apply(auto) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
66 |
apply(rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
67 |
apply(blast)+ |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
68 |
apply(simp_all add: fresh_star_def fresh_Pair_elim) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
69 |
apply(erule_tac c="(ya,sa)" in Abs_lst1_fcb2) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
70 |
apply(simp_all add: Abs_fresh_iff) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
71 |
apply(simp add: fresh_star_def fresh_Pair) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
72 |
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
73 |
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq) |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
74 |
done |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
|
3132
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
76 |
termination (eqvt) |
87eca760dcba
updated tutorial to latest version and added it to the tests
Christian Urban <urbanc@in.tum.de>
parents:
2718
diff
changeset
|
77 |
by lexicographic_order |
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
|
2701 | 79 |
lemma fresh_fact: |
80 |
assumes a: "atom z \<sharp> s" |
|
81 |
and b: "z = y \<or> atom z \<sharp> t" |
|
82 |
shows "atom z \<sharp> t[y ::= s]" |
|
83 |
using a b |
|
84 |
by (nominal_induct t avoiding: z y s rule: lam.strong_induct) |
|
85 |
(auto simp add: lam.fresh fresh_at_base) |
|
2684
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
86 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
end |
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
|
d72a7168f1cb
base file for the tutorial (contains definitions for heigt, subst and beta-reduction)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |