1600
+ − 1
theory ExLet
1651
+ − 2
imports "Parser" "../Attic/Prove"
1600
+ − 3
begin
+ − 4
+ − 5
text {* example 3 or example 5 from Terms.thy *}
+ − 6
+ − 7
atom_decl name
+ − 8
+ − 9
ML {* val _ = recursive := false *}
1685
+ − 10
ML {* val _ = alpha_type := AlphaLst *}
1600
+ − 11
nominal_datatype trm =
+ − 12
Vr "name"
+ − 13
| Ap "trm" "trm"
+ − 14
| Lm x::"name" t::"trm" bind x in t
1602
+ − 15
| Lt a::"lts" t::"trm" bind "bn a" in t
1600
+ − 16
and lts =
1602
+ − 17
Lnil
+ − 18
| Lcons "name" "trm" "lts"
1600
+ − 19
binder
+ − 20
bn
+ − 21
where
1685
+ − 22
"bn Lnil = []"
+ − 23
| "bn (Lcons x t l) = (atom x) # (bn l)"
1600
+ − 24
+ − 25
thm trm_lts.fv
+ − 26
thm trm_lts.eq_iff
+ − 27
thm trm_lts.bn
+ − 28
thm trm_lts.perm
1638
+ − 29
thm trm_lts.induct[no_vars]
+ − 30
thm trm_lts.inducts[no_vars]
1600
+ − 31
thm trm_lts.distinct
1685
+ − 32
thm trm_lts.fv[simplified trm_lts.supp(1-2)]
1600
+ − 33
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 34
primrec
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 35
permute_bn_raw
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 36
where
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 37
"permute_bn_raw pi (Lnil_raw) = Lnil_raw"
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 38
| "permute_bn_raw pi (Lcons_raw a t l) = Lcons_raw (pi \<bullet> a) t (permute_bn_raw pi l)"
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 39
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 40
quotient_definition
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 41
"permute_bn :: perm \<Rightarrow> lts \<Rightarrow> lts"
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 42
is
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 43
"permute_bn_raw"
1639
+ − 44
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 45
lemma [quot_respect]: "((op =) ===> alpha_lts_raw ===> alpha_lts_raw) permute_bn_raw permute_bn_raw"
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 46
apply simp
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 47
apply clarify
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 48
apply (erule alpha_trm_raw_alpha_lts_raw_alpha_bn_raw.inducts)
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 49
apply simp_all
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 50
apply (rule alpha_trm_raw_alpha_lts_raw_alpha_bn_raw.intros)
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 51
apply simp
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 52
apply (rule alpha_trm_raw_alpha_lts_raw_alpha_bn_raw.intros)
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 53
apply simp
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 54
done
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 55
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 56
lemmas permute_bn = permute_bn_raw.simps[quot_lifted]
1639
+ − 57
1642
+ − 58
lemma permute_bn_zero:
+ − 59
"permute_bn 0 a = a"
+ − 60
apply(induct a rule: trm_lts.inducts(2))
+ − 61
apply(rule TrueI)
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 62
apply(simp_all add:permute_bn eqvts)
1642
+ − 63
done
+ − 64
1640
+ − 65
lemma permute_bn_add:
+ − 66
"permute_bn (p + q) a = permute_bn p (permute_bn q a)"
+ − 67
oops
+ − 68
1643
+ − 69
lemma permute_bn_alpha_bn: "alpha_bn lts (permute_bn q lts)"
+ − 70
apply(induct lts rule: trm_lts.inducts(2))
+ − 71
apply(rule TrueI)
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 72
apply(simp_all add:permute_bn eqvts trm_lts.eq_iff)
1643
+ − 73
done
1641
+ − 74
1642
+ − 75
lemma perm_bn:
+ − 76
"p \<bullet> bn l = bn(permute_bn p l)"
+ − 77
apply(induct l rule: trm_lts.inducts(2))
+ − 78
apply(rule TrueI)
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 79
apply(simp_all add:permute_bn eqvts)
1642
+ − 80
done
+ − 81
1643
+ − 82
lemma Lt_subst:
1685
+ − 83
"supp (Abs_lst (bn lts) trm) \<sharp>* q \<Longrightarrow> (Lt lts trm) = Lt (permute_bn q lts) (q \<bullet> trm)"
1643
+ − 84
apply (simp only: trm_lts.eq_iff)
+ − 85
apply (rule_tac x="q" in exI)
+ − 86
apply (simp add: alphas)
+ − 87
apply (simp add: permute_bn_alpha_bn)
+ − 88
apply (simp add: perm_bn[symmetric])
+ − 89
apply (simp add: eqvts[symmetric])
1658
+ − 90
apply (simp add: supp_abs)
1643
+ − 91
apply (simp add: trm_lts.supp)
+ − 92
apply (rule supp_perm_eq[symmetric])
+ − 93
apply (subst supp_finite_atom_set)
+ − 94
apply (rule finite_Diff)
+ − 95
apply (simp add: finite_supp)
+ − 96
apply (assumption)
+ − 97
done
+ − 98
+ − 99
1642
+ − 100
lemma fin_bn:
1685
+ − 101
"finite (set (bn l))"
1642
+ − 102
apply(induct l rule: trm_lts.inducts(2))
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 103
apply(simp_all add:permute_bn eqvts)
1642
+ − 104
done
+ − 105
1638
+ − 106
lemma
+ − 107
fixes t::trm
+ − 108
and l::lts
+ − 109
and c::"'a::fs"
1640
+ − 110
assumes a1: "\<And>name c. P1 c (Vr name)"
1638
+ − 111
and a2: "\<And>trm1 trm2 c. \<lbrakk>\<And>d. P1 d trm1; \<And>d. P1 d trm2\<rbrakk> \<Longrightarrow> P1 c (Ap trm1 trm2)"
1640
+ − 112
and a3: "\<And>name trm c. \<lbrakk>atom name \<sharp> c; \<And>d. P1 d trm\<rbrakk> \<Longrightarrow> P1 c (Lm name trm)"
1685
+ − 113
and a4: "\<And>lts trm c. \<lbrakk>set (bn lts) \<sharp>* c; \<And>d. P2 d lts; \<And>d. P1 d trm\<rbrakk> \<Longrightarrow> P1 c (Lt lts trm)"
1638
+ − 114
and a5: "\<And>c. P2 c Lnil"
+ − 115
and a6: "\<And>name trm lts c. \<lbrakk>\<And>d. P1 d trm; \<And>d. P2 d lts\<rbrakk> \<Longrightarrow> P2 c (Lcons name trm lts)"
+ − 116
shows "P1 c t" and "P2 c l"
+ − 117
proof -
+ − 118
have "(\<And>(p::perm) (c::'a::fs). P1 c (p \<bullet> t))" and
1642
+ − 119
b': "(\<And>(p::perm) (q::perm) (c::'a::fs). P2 c (permute_bn p (q \<bullet> l)))"
1638
+ − 120
apply(induct rule: trm_lts.inducts)
+ − 121
apply(simp)
+ − 122
apply(rule a1)
+ − 123
apply(simp)
+ − 124
apply(rule a2)
+ − 125
apply(simp)
+ − 126
apply(simp)
+ − 127
apply(simp)
+ − 128
apply(subgoal_tac "\<exists>q. (q \<bullet> (atom (p \<bullet> name))) \<sharp> c \<and> supp (Lm (p \<bullet> name) (p \<bullet> trm)) \<sharp>* q")
+ − 129
apply(erule exE)
+ − 130
apply(rule_tac t="Lm (p \<bullet> name) (p \<bullet> trm)"
+ − 131
and s="q\<bullet> Lm (p \<bullet> name) (p \<bullet> trm)" in subst)
+ − 132
apply(rule supp_perm_eq)
+ − 133
apply(simp)
+ − 134
apply(simp)
+ − 135
apply(rule a3)
+ − 136
apply(simp add: atom_eqvt)
+ − 137
apply(subst permute_plus[symmetric])
+ − 138
apply(blast)
+ − 139
apply(rule at_set_avoiding2_atom)
+ − 140
apply(simp add: finite_supp)
+ − 141
apply(simp add: finite_supp)
+ − 142
apply(simp add: fresh_def)
+ − 143
apply(simp add: trm_lts.fv[simplified trm_lts.supp])
+ − 144
apply(simp)
1685
+ − 145
apply(subgoal_tac "\<exists>q. (q \<bullet> set (bn (p \<bullet> lts))) \<sharp>* c \<and> supp (Abs_lst (bn (p \<bullet> lts)) (p \<bullet> trm)) \<sharp>* q")
1638
+ − 146
apply(erule exE)
1641
+ − 147
apply(erule conjE)
+ − 148
apply(subst Lt_subst)
+ − 149
apply assumption
1638
+ − 150
apply(rule a4)
1685
+ − 151
apply(simp add:perm_bn[symmetric])
+ − 152
apply(simp add: eqvts)
1641
+ − 153
apply (simp add: fresh_star_def fresh_def)
1640
+ − 154
apply(rotate_tac 1)
+ − 155
apply(drule_tac x="q + p" in meta_spec)
+ − 156
apply(simp)
1642
+ − 157
apply(rule at_set_avoiding2)
+ − 158
apply(rule fin_bn)
1641
+ − 159
apply(simp add: finite_supp)
+ − 160
apply(simp add: finite_supp)
1658
+ − 161
apply(simp add: fresh_star_def fresh_def supp_abs)
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 162
apply(simp add: eqvts permute_bn)
1640
+ − 163
apply(rule a5)
1644
0e705352bcef
Properly defined permute_bn. No more sorry's in Let strong induction.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 164
apply(simp add: permute_bn)
1640
+ − 165
apply(rule a6)
+ − 166
apply simp
+ − 167
apply simp
1642
+ − 168
done
+ − 169
then have a: "P1 c (0 \<bullet> t)" by blast
+ − 170
have "P2 c (permute_bn 0 (0 \<bullet> l))" using b' by blast
+ − 171
then show "P1 c t" and "P2 c l" using a permute_bn_zero by simp_all
+ − 172
qed
+ − 173
1638
+ − 174
+ − 175
1602
+ − 176
lemma lets_bla:
+ − 177
"x \<noteq> z \<Longrightarrow> y \<noteq> z \<Longrightarrow> x \<noteq> y \<Longrightarrow>(Lt (Lcons x (Vr y) Lnil) (Vr x)) \<noteq> (Lt (Lcons x (Vr z) Lnil) (Vr x))"
+ − 178
by (simp add: trm_lts.eq_iff)
+ − 179
+ − 180
lemma lets_ok:
+ − 181
"(Lt (Lcons x (Vr y) Lnil) (Vr x)) = (Lt (Lcons y (Vr y) Lnil) (Vr y))"
+ − 182
apply (simp add: trm_lts.eq_iff)
+ − 183
apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
+ − 184
apply (simp_all add: alphas)
+ − 185
apply (simp add: fresh_star_def eqvts)
+ − 186
done
+ − 187
+ − 188
lemma lets_ok3:
+ − 189
"x \<noteq> y \<Longrightarrow>
+ − 190
(Lt (Lcons x (Ap (Vr y) (Vr x)) (Lcons y (Vr y) Lnil)) (Ap (Vr x) (Vr y))) \<noteq>
+ − 191
(Lt (Lcons y (Ap (Vr x) (Vr y)) (Lcons x (Vr x) Lnil)) (Ap (Vr x) (Vr y)))"
+ − 192
apply (simp add: alphas trm_lts.eq_iff)
+ − 193
done
+ − 194
+ − 195
+ − 196
lemma lets_not_ok1:
1685
+ − 197
"x \<noteq> y \<Longrightarrow>
+ − 198
(Lt (Lcons x (Vr x) (Lcons y (Vr y) Lnil)) (Ap (Vr x) (Vr y))) \<noteq>
1602
+ − 199
(Lt (Lcons y (Vr x) (Lcons x (Vr y) Lnil)) (Ap (Vr x) (Vr y)))"
1685
+ − 200
apply (simp add: alphas trm_lts.eq_iff fresh_star_def eqvts)
1602
+ − 201
done
+ − 202
+ − 203
lemma lets_nok:
+ − 204
"x \<noteq> y \<Longrightarrow> x \<noteq> z \<Longrightarrow> z \<noteq> y \<Longrightarrow>
+ − 205
(Lt (Lcons x (Ap (Vr z) (Vr z)) (Lcons y (Vr z) Lnil)) (Ap (Vr x) (Vr y))) \<noteq>
+ − 206
(Lt (Lcons y (Vr z) (Lcons x (Ap (Vr z) (Vr z)) Lnil)) (Ap (Vr x) (Vr y)))"
+ − 207
apply (simp add: alphas trm_lts.eq_iff fresh_star_def)
+ − 208
done
+ − 209
+ − 210
1600
+ − 211
end
+ − 212
+ − 213
+ − 214