44 apply(rule TrueI)+ |
43 apply(rule TrueI)+ |
45 apply(simp add: abs_fresh) |
44 apply(simp add: abs_fresh) |
46 apply(fresh_guess)+ |
45 apply(fresh_guess)+ |
47 done |
46 done |
48 |
47 |
49 text{* The next lemma is needed in the Var-case of the theorem. *} |
48 text{* The next lemma is needed in the Var-case of the theorem below. *} |
50 |
49 |
51 lemma height_ge_one: |
50 lemma height_ge_one: |
52 shows "1 \<le> (height e)" |
51 shows "1 \<le> (height e)" |
53 by (nominal_induct e rule: lam.induct) (simp_all) |
52 by (nominal_induct e rule: lam.induct) (simp_all) |
54 |
53 |
55 text {* |
54 text {* |
56 Unlike the proplem suggested by Wang, however, the |
55 Unlike the proplem suggested by Wang, however, the |
57 theorem is here formulated entirely by using functions. |
56 theorem is here formulated entirely by using functions. |
58 *} |
57 *} |
59 |
58 |
60 theorem height_subst: |
59 theorem height_subst: |
61 shows "height (e[x::=e']) \<le> (((height e) - 1) + (height e'))" |
60 shows "height (e[x::=e']) \<le> ((height e) - 1) + (height e')" |
62 proof (nominal_induct e avoiding: x e' rule: lam.induct) |
61 proof (nominal_induct e avoiding: x e' rule: lam.induct) |
63 case (Var y) |
62 case (Var y) |
64 have "1 \<le> height e'" by (rule height_ge_one) |
63 have "1 \<le> height e'" by (rule height_ge_one) |
65 then show "height (Var y[x::=e']) \<le> height (Var y) - 1 + height e'" by simp |
64 then show "height (Var y[x::=e']) \<le> height (Var y) - 1 + height e'" by simp |
66 next |
65 next |
67 case (Lam y e1) |
66 case (Lam y e1) |
68 hence ih: "height (e1[x::=e']) \<le> (((height e1) - 1) + (height e'))" by simp |
67 hence ih: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')" by simp |
69 moreover |
68 moreover |
70 have vc: "y\<sharp>x" "y\<sharp>e'" by fact+ (* usual variable convention *) |
69 have vc: "y\<sharp>x" "y\<sharp>e'" by fact+ (* usual variable convention *) |
71 ultimately show "height ((Lam [y].e1)[x::=e']) \<le> height (Lam [y].e1) - 1 + height e'" by simp |
70 ultimately show "height ((Lam [y].e1)[x::=e']) \<le> height (Lam [y].e1) - 1 + height e'" by simp |
72 next |
71 next |
73 case (App e1 e2) |
72 case (App e1 e2) |
74 hence ih1: "height (e1[x::=e']) \<le> (((height e1) - 1) + (height e'))" |
73 hence ih1: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')" |
75 and ih2: "height (e2[x::=e']) \<le> (((height e2) - 1) + (height e'))" by simp_all |
74 and ih2: "height (e2[x::=e']) \<le> ((height e2) - 1) + (height e')" by simp_all |
76 then show "height ((App e1 e2)[x::=e']) \<le> height (App e1 e2) - 1 + height e'" by simp |
75 then show "height ((App e1 e2)[x::=e']) \<le> height (App e1 e2) - 1 + height e'" by simp |
77 qed |
76 qed |
78 |
77 |
|
78 theorem height_subst: |
|
79 shows "height (e[x::=e']) \<le> ((height e) - 1) + (height e')" |
|
80 proof (nominal_induct e avoiding: x e' rule: lam.induct) |
|
81 case (Var y) |
|
82 have "1 \<le> height e'" by (rule height_ge_one) |
|
83 then show "height (Var y[x::=e']) \<le> height (Var y) - 1 + height e'" by simp |
|
84 next |
|
85 case (Lam y e1) |
|
86 hence ih: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')" by simp |
|
87 moreover |
|
88 have vc: "y\<sharp>x" "y\<sharp>e'" by fact+ (* usual variable convention *) |
|
89 ultimately show "height ((Lam [y].e1)[x::=e']) \<le> height (Lam [y].e1) - 1 + height e'" by simp |
|
90 next |
|
91 case (App e1 e2) |
|
92 hence ih1: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')" |
|
93 and ih2: "height (e2[x::=e']) \<le> ((height e2) - 1) + (height e')" by simp_all |
|
94 then show "height ((App e1 e2)[x::=e']) \<le> height (App e1 e2) - 1 + height e'" by simp |
|
95 qed |
|
96 |
|
97 |
79 end |
98 end |