|
1 theory Lambda |
|
2 imports "Nominal" |
|
3 begin |
|
4 |
|
5 atom_decl name |
|
6 |
|
7 section {* Alpha-Equated Lambda-Terms *} |
|
8 |
|
9 nominal_datatype lam = |
|
10 Var "name" |
|
11 | App "lam" "lam" |
|
12 | Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._") |
|
13 |
|
14 section {* Capture-Avoiding Substitution *} |
|
15 |
|
16 consts subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_[_::=_]") |
|
17 |
|
18 nominal_primrec |
|
19 "(Var x)[y::=s] = (if x=y then s else (Var x))" |
|
20 "(App t1 t2)[y::=s] = App (t1[y::=s]) (t2[y::=s])" |
|
21 "x\<sharp>(y,s) \<Longrightarrow> (Lam [x].t)[y::=s] = Lam [x].(t[y::=s])" |
|
22 apply(finite_guess)+ |
|
23 apply(rule TrueI)+ |
|
24 apply(simp add: abs_fresh)+ |
|
25 apply(fresh_guess)+ |
|
26 done |
|
27 |
|
28 lemma subst_eqvt[eqvt]: |
|
29 fixes pi::"name prm" |
|
30 shows "pi\<bullet>(t1[x::=t2]) = (pi\<bullet>t1)[(pi\<bullet>x)::=(pi\<bullet>t2)]" |
|
31 by (nominal_induct t1 avoiding: x t2 rule: lam.strong_induct) |
|
32 (auto simp add: perm_bij fresh_atm fresh_bij) |
|
33 |
|
34 lemma forget: |
|
35 assumes a: "x\<sharp>L" |
|
36 shows "L[x::=P] = L" |
|
37 using a |
|
38 by (nominal_induct L avoiding: x P rule: lam.strong_induct) |
|
39 (auto simp add: abs_fresh fresh_atm) |
|
40 |
|
41 lemma fresh_fact: |
|
42 fixes z::"name" |
|
43 shows "\<lbrakk>z\<sharp>s; (z=y \<or> z\<sharp>t)\<rbrakk> \<Longrightarrow> z\<sharp>t[y::=s]" |
|
44 by (nominal_induct t avoiding: z y s rule: lam.strong_induct) |
|
45 (auto simp add: abs_fresh fresh_prod fresh_atm) |
|
46 |
|
47 lemma subst_rename: |
|
48 assumes a: "y\<sharp>t" |
|
49 shows "t[x::=s] = ([(y,x)]\<bullet>t)[y::=s]" |
|
50 using a |
|
51 by (nominal_induct t avoiding: x y s rule: lam.strong_induct) |
|
52 (auto simp add: calc_atm fresh_atm abs_fresh) |
|
53 |
|
54 text {* |
|
55 The purpose of the two lemmas below is to work |
|
56 around some quirks in Isabelle's handling of |
|
57 meta_quantifiers and meta_implications. |
|
58 *} |
|
59 |
|
60 lemma meta_impCE: |
|
61 assumes major: "P ==> PROP Q" |
|
62 and 1: "~ P ==> R" |
|
63 and 2: "PROP Q ==> R" |
|
64 shows R |
|
65 proof (cases P) |
|
66 assume P |
|
67 then have "PROP Q" by (rule major) |
|
68 then show R by (rule 2) |
|
69 next |
|
70 assume "~ P" |
|
71 then show R by (rule 1) |
|
72 qed |
|
73 |
|
74 declare meta_allE [elim] |
|
75 and meta_impCE [elim!] |
|
76 |
|
77 end |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |