1797
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1
theory Lambda
2454
+ − 2
imports "../Nominal2"
1594
+ − 3
begin
+ − 4
+ − 5
atom_decl name
+ − 6
2436
+ − 7
nominal_datatype lam =
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 8
Var "name"
2436
+ − 9
| App "lam" "lam"
+ − 10
| Lam x::"name" l::"lam" bind x in l
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 11
2436
+ − 12
thm lam.distinct
+ − 13
thm lam.induct
2617
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 14
thm lam.exhaust lam.strong_exhaust
2436
+ − 15
thm lam.fv_defs
+ − 16
thm lam.bn_defs
+ − 17
thm lam.perm_simps
+ − 18
thm lam.eq_iff
+ − 19
thm lam.fv_bn_eqvt
+ − 20
thm lam.size_eqvt
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 21
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 22
1805
+ − 23
section {* Typing *}
+ − 24
+ − 25
nominal_datatype ty =
+ − 26
TVar string
2630
+ − 27
| TFun ty ty ("_ \<rightarrow> _")
1810
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 28
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 29
2436
+ − 30
(*
1810
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 31
declare ty.perm[eqvt]
1805
+ − 32
+ − 33
inductive
+ − 34
valid :: "(name \<times> ty) list \<Rightarrow> bool"
+ − 35
where
+ − 36
"valid []"
+ − 37
| "\<lbrakk>atom x \<sharp> Gamma; valid Gamma\<rbrakk> \<Longrightarrow> valid ((x, T)#Gamma)"
+ − 38
1828
+ − 39
inductive
+ − 40
typing :: "(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow> bool" ("_ \<turnstile> _ : _" [60,60,60] 60)
+ − 41
where
+ − 42
t_Var[intro]: "\<lbrakk>valid \<Gamma>; (x, T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T"
1947
+ − 43
| t_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : T1 \<rightarrow> T2; \<Gamma> \<turnstile> t2 : T1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App t1 t2 : T2"
1828
+ − 44
| t_Lam[intro]: "\<lbrakk>atom x \<sharp> \<Gamma>; (x, T1) # \<Gamma> \<turnstile> t : T2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam x t : T1 \<rightarrow> T2"
+ − 45
1831
+ − 46
equivariance valid
+ − 47
equivariance typing
1816
+ − 48
1831
+ − 49
thm valid.eqvt
+ − 50
thm typing.eqvt
1811
ae176476b525
implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 51
thm eqvts
ae176476b525
implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 52
thm eqvts_raw
ae176476b525
implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 53
1949
+ − 54
thm typing.induct[of "\<Gamma>" "t" "T", no_vars]
+ − 55
+ − 56
lemma
+ − 57
fixes c::"'a::fs"
+ − 58
assumes a: "\<Gamma> \<turnstile> t : T"
+ − 59
and a1: "\<And>\<Gamma> x T c. \<lbrakk>valid \<Gamma>; (x, T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> P c \<Gamma> (Var x) T"
+ − 60
and a2: "\<And>\<Gamma> t1 T1 T2 t2 c. \<lbrakk>\<Gamma> \<turnstile> t1 : T1 \<rightarrow> T2; \<And>d. P d \<Gamma> t1 T1 \<rightarrow> T2; \<Gamma> \<turnstile> t2 : T1; \<And>d. P d \<Gamma> t2 T1\<rbrakk>
+ − 61
\<Longrightarrow> P c \<Gamma> (App t1 t2) T2"
+ − 62
and a3: "\<And>x \<Gamma> T1 t T2 c. \<lbrakk>atom x \<sharp> c; atom x \<sharp> \<Gamma>; (x, T1) # \<Gamma> \<turnstile> t : T2; \<And>d. P d ((x, T1) # \<Gamma>) t T2\<rbrakk>
+ − 63
\<Longrightarrow> P c \<Gamma> (Lam x t) T1 \<rightarrow> T2"
+ − 64
shows "P c \<Gamma> t T"
+ − 65
proof -
+ − 66
from a have "\<And>p c. P c (p \<bullet> \<Gamma>) (p \<bullet> t) (p \<bullet> T)"
+ − 67
proof (induct)
+ − 68
case (t_Var \<Gamma> x T p c)
+ − 69
then show ?case
+ − 70
apply -
+ − 71
apply(perm_strict_simp)
+ − 72
apply(rule a1)
1954
+ − 73
apply(drule_tac p="p" in permute_boolI)
1949
+ − 74
apply(perm_strict_simp add: permute_minus_cancel)
+ − 75
apply(assumption)
1954
+ − 76
apply(rotate_tac 1)
+ − 77
apply(drule_tac p="p" in permute_boolI)
1949
+ − 78
apply(perm_strict_simp add: permute_minus_cancel)
+ − 79
apply(assumption)
+ − 80
done
+ − 81
next
+ − 82
case (t_App \<Gamma> t1 T1 T2 t2 p c)
+ − 83
then show ?case
+ − 84
apply -
+ − 85
apply(perm_strict_simp)
1954
+ − 86
apply(rule a2)
+ − 87
apply(drule_tac p="p" in permute_boolI)
1949
+ − 88
apply(perm_strict_simp add: permute_minus_cancel)
+ − 89
apply(assumption)
+ − 90
apply(assumption)
1954
+ − 91
apply(rotate_tac 2)
+ − 92
apply(drule_tac p="p" in permute_boolI)
1949
+ − 93
apply(perm_strict_simp add: permute_minus_cancel)
+ − 94
apply(assumption)
+ − 95
apply(assumption)
+ − 96
done
+ − 97
next
+ − 98
case (t_Lam x \<Gamma> T1 t T2 p c)
+ − 99
then show ?case
+ − 100
apply -
+ − 101
apply(subgoal_tac "\<exists>q. (q \<bullet> {p \<bullet> atom x}) \<sharp>* c \<and>
+ − 102
supp (p \<bullet> \<Gamma>, p \<bullet> Lam x t, p \<bullet> (T1 \<rightarrow> T2)) \<sharp>* q")
+ − 103
apply(erule exE)
1954
+ − 104
apply(rule_tac t="p \<bullet> \<Gamma>" and s="(q + p) \<bullet> \<Gamma>" in subst)
+ − 105
apply(simp only: permute_plus)
1949
+ − 106
apply(rule supp_perm_eq)
+ − 107
apply(simp add: supp_Pair fresh_star_union)
1954
+ − 108
apply(rule_tac t="p \<bullet> Lam x t" and s="(q + p) \<bullet> Lam x t" in subst)
+ − 109
apply(simp only: permute_plus)
1949
+ − 110
apply(rule supp_perm_eq)
+ − 111
apply(simp add: supp_Pair fresh_star_union)
1954
+ − 112
apply(rule_tac t="p \<bullet> (T1 \<rightarrow> T2)" and s="(q + p) \<bullet> (T1 \<rightarrow> T2)" in subst)
+ − 113
apply(simp only: permute_plus)
+ − 114
apply(rule supp_perm_eq)
+ − 115
apply(simp add: supp_Pair fresh_star_union)
+ − 116
apply(simp (no_asm) only: eqvts)
1949
+ − 117
apply(rule a3)
1954
+ − 118
apply(simp only: eqvts permute_plus)
1949
+ − 119
apply(simp add: fresh_star_def)
1954
+ − 120
apply(drule_tac p="q + p" in permute_boolI)
1949
+ − 121
apply(perm_strict_simp add: permute_minus_cancel)
+ − 122
apply(assumption)
1954
+ − 123
apply(rotate_tac 1)
+ − 124
apply(drule_tac p="q + p" in permute_boolI)
1949
+ − 125
apply(perm_strict_simp add: permute_minus_cancel)
+ − 126
apply(assumption)
+ − 127
apply(drule_tac x="d" in meta_spec)
+ − 128
apply(drule_tac x="q + p" in meta_spec)
1954
+ − 129
apply(perm_strict_simp add: permute_minus_cancel)
+ − 130
apply(assumption)
1949
+ − 131
apply(rule at_set_avoiding2)
+ − 132
apply(simp add: finite_supp)
+ − 133
apply(simp add: finite_supp)
+ − 134
apply(simp add: finite_supp)
+ − 135
apply(rule_tac p="-p" in permute_boolE)
+ − 136
apply(perm_strict_simp add: permute_minus_cancel)
2436
+ − 137
--"supplied by the user"
1949
+ − 138
apply(simp add: fresh_star_prod)
+ − 139
apply(simp add: fresh_star_def)
1954
+ − 140
sorry
+ − 141
qed
+ − 142
then have "P c (0 \<bullet> \<Gamma>) (0 \<bullet> t) (0 \<bullet> T)" .
+ − 143
then show "P c \<Gamma> t T" by simp
+ − 144
qed
1949
+ − 145
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 146
*)
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 147
1810
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 148
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 149
section {* Matching *}
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 150
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 151
definition
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 152
MATCH :: "('c::pt \<Rightarrow> (bool * 'a::pt * 'b::pt)) \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'b"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 153
where
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 154
"MATCH M d x \<equiv> if (\<exists>!r. \<exists>q. M q = (True, x, r)) then (THE r. \<exists>q. M q = (True, x, r)) else d"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 155
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 156
(*
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 157
lemma MATCH_eqvt:
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 158
shows "p \<bullet> (MATCH M d x) = MATCH (p \<bullet> M) (p \<bullet> d) (p \<bullet> x)"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 159
unfolding MATCH_def
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 160
apply(perm_simp the_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 161
apply (tactic {* Nominal_Permeq.eqvt_tac @{context} 1 *})
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 162
apply(simp)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 163
thm eqvts_raw
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 164
apply(subst if_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 165
apply(subst ex1_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 166
apply(subst permute_fun_def)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 167
apply(subst ex_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 168
apply(subst permute_fun_def)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 169
apply(subst eq_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 170
apply(subst permute_fun_app_eq[where f="M"])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 171
apply(simp only: permute_minus_cancel)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 172
apply(subst permute_prod.simps)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 173
apply(subst permute_prod.simps)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 174
apply(simp only: permute_minus_cancel)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 175
apply(simp only: permute_bool_def)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 176
apply(simp)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 177
apply(subst ex1_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 178
apply(subst permute_fun_def)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 179
apply(subst ex_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 180
apply(subst permute_fun_def)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 181
apply(subst eq_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 182
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 183
apply(simp only: eqvts)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 184
apply(simp)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 185
apply(subgoal_tac "(p \<bullet> (\<exists>!r. \<exists>q. M q = (True, x, r))) = (\<exists>!r. \<exists>q. (p \<bullet> M) q = (True, p \<bullet> x, r))")
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 186
apply(drule sym)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 187
apply(simp)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 188
apply(rule impI)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 189
apply(simp add: perm_bool)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 190
apply(rule trans)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 191
apply(rule pt_the_eqvt[OF pta at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 192
apply(assumption)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 193
apply(simp add: pt_ex_eqvt[OF pt at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 194
apply(simp add: pt_eq_eqvt[OF ptb at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 195
apply(rule cheat)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 196
apply(rule trans)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 197
apply(rule pt_ex1_eqvt)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 198
apply(rule pta)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 199
apply(rule at)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 200
apply(simp add: pt_ex_eqvt[OF pt at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 201
apply(simp add: pt_eq_eqvt[OF ptb at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 202
apply(subst pt_pi_rev[OF pta at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 203
apply(subst pt_fun_app_eq[OF pt at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 204
apply(subst pt_pi_rev[OF pt at])
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 205
apply(simp)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 206
done
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 207
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 208
lemma MATCH_cng:
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 209
assumes a: "M1 = M2" "d1 = d2"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 210
shows "MATCH M1 d1 x = MATCH M2 d2 x"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 211
using a by simp
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 212
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 213
lemma MATCH_eq:
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 214
assumes a: "t = l x" "G x" "\<And>x'. t = l x' \<Longrightarrow> G x' \<Longrightarrow> r x' = r x"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 215
shows "MATCH (\<lambda>x. (G x, l x, r x)) d t = r x"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 216
using a
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 217
unfolding MATCH_def
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 218
apply(subst if_P)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 219
apply(rule_tac a="r x" in ex1I)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 220
apply(rule_tac x="x" in exI)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 221
apply(blast)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 222
apply(erule exE)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 223
apply(drule_tac x="q" in meta_spec)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 224
apply(auto)[1]
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 225
apply(rule the_equality)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 226
apply(blast)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 227
apply(erule exE)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 228
apply(drule_tac x="q" in meta_spec)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 229
apply(auto)[1]
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 230
done
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 231
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 232
lemma MATCH_eq2:
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 233
assumes a: "t = l x1 x2" "G x1 x2" "\<And>x1' x2'. t = l x1' x2' \<Longrightarrow> G x1' x2' \<Longrightarrow> r x1' x2' = r x1 x2"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 234
shows "MATCH (\<lambda>(x1,x2). (G x1 x2, l x1 x2, r x1 x2)) d t = r x1 x2"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 235
sorry
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 236
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 237
lemma MATCH_neq:
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 238
assumes a: "\<And>x. t = l x \<Longrightarrow> G x \<Longrightarrow> False"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 239
shows "MATCH (\<lambda>x. (G x, l x, r x)) d t = d"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 240
using a
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 241
unfolding MATCH_def
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 242
apply(subst if_not_P)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 243
apply(blast)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 244
apply(rule refl)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 245
done
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 246
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 247
lemma MATCH_neq2:
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 248
assumes a: "\<And>x1 x2. t = l x1 x2 \<Longrightarrow> G x1 x2 \<Longrightarrow> False"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 249
shows "MATCH (\<lambda>(x1,x2). (G x1 x2, l x1 x2, r x1 x2)) d t = d"
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 250
using a
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 251
unfolding MATCH_def
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 252
apply(subst if_not_P)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 253
apply(auto)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 254
done
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 255
*)
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 256
1954
+ − 257
ML {*
+ − 258
fun mk_avoids ctxt params name set =
+ − 259
let
+ − 260
val (_, ctxt') = ProofContext.add_fixes
+ − 261
(map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params) ctxt;
+ − 262
fun mk s =
+ − 263
let
+ − 264
val t = Syntax.read_term ctxt' s;
+ − 265
val t' = list_abs_free (params, t) |>
+ − 266
funpow (length params) (fn Abs (_, _, t) => t)
+ − 267
in (t', HOLogic.dest_setT (fastype_of t)) end
+ − 268
handle TERM _ =>
+ − 269
error ("Expression " ^ quote s ^ " to be avoided in case " ^
+ − 270
quote name ^ " is not a set type");
+ − 271
fun add_set p [] = [p]
+ − 272
| add_set (t, T) ((u, U) :: ps) =
+ − 273
if T = U then
+ − 274
let val S = HOLogic.mk_setT T
+ − 275
in (Const (@{const_name sup}, S --> S --> S) $ u $ t, T) :: ps
+ − 276
end
+ − 277
else (u, U) :: add_set (t, T) ps
+ − 278
in
+ − 279
(mk #> add_set) set
+ − 280
end;
+ − 281
*}
+ − 282
+ − 283
+ − 284
ML {*
+ − 285
writeln (commas (map (Syntax.string_of_term @{context} o fst)
+ − 286
(mk_avoids @{context} [] "t_Var" "{x}" [])))
+ − 287
*}
+ − 288
1947
+ − 289
1949
+ − 290
ML {*
+ − 291
+ − 292
fun prove_strong_ind (pred_name, avoids) ctxt =
+ − 293
Proof.theorem NONE (K I) [] ctxt
+ − 294
2169
+ − 295
local structure P = Parse and K = Keyword in
1949
+ − 296
+ − 297
val _ =
2169
+ − 298
Outer_Syntax.local_theory_to_proof "nominal_inductive"
1949
+ − 299
"proves strong induction theorem for inductive predicate involving nominal datatypes" K.thy_goal
+ − 300
(P.xname -- (Scan.optional (P.$$$ "avoids" |-- P.enum1 "|" (P.name --
+ − 301
(P.$$$ ":" |-- P.and_list1 P.term))) []) >> prove_strong_ind)
+ − 302
+ − 303
end;
+ − 304
+ − 305
*}
+ − 306
1950
+ − 307
(*
1949
+ − 308
nominal_inductive typing
1950
+ − 309
*)
1949
+ − 310
2157
+ − 311
(* Substitution *)
2159
+ − 312
2165
+ − 313
primrec match_Var_raw where
+ − 314
"match_Var_raw (Var_raw x) = Some x"
+ − 315
| "match_Var_raw (App_raw x y) = None"
+ − 316
| "match_Var_raw (Lam_raw n t) = None"
+ − 317
+ − 318
quotient_definition
+ − 319
"match_Var :: lam \<Rightarrow> name option"
+ − 320
is match_Var_raw
+ − 321
+ − 322
lemma [quot_respect]: "(alpha_lam_raw ===> op =) match_Var_raw match_Var_raw"
+ − 323
apply rule
2559
add799cf0817
adapted to changes by Florian on the quotient package and removed local fix for function package
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 324
apply (induct_tac x y rule: alpha_lam_raw.induct)
2165
+ − 325
apply simp_all
+ − 326
done
+ − 327
+ − 328
lemmas match_Var_simps = match_Var_raw.simps[quot_lifted]
+ − 329
+ − 330
primrec match_App_raw where
+ − 331
"match_App_raw (Var_raw x) = None"
+ − 332
| "match_App_raw (App_raw x y) = Some (x, y)"
+ − 333
| "match_App_raw (Lam_raw n t) = None"
+ − 334
2436
+ − 335
(*
2165
+ − 336
quotient_definition
+ − 337
"match_App :: lam \<Rightarrow> (lam \<times> lam) option"
+ − 338
is match_App_raw
+ − 339
+ − 340
lemma [quot_respect]:
+ − 341
"(alpha_lam_raw ===> option_rel (prod_rel alpha_lam_raw alpha_lam_raw)) match_App_raw match_App_raw"
+ − 342
apply (intro fun_relI)
+ − 343
apply (induct_tac a b rule: alpha_lam_raw.induct)
+ − 344
apply simp_all
+ − 345
done
+ − 346
+ − 347
lemmas match_App_simps = match_App_raw.simps[quot_lifted]
+ − 348
2173
+ − 349
definition new where
+ − 350
"new (s :: 'a :: fs) = (THE x. \<forall>a \<in> supp s. atom x \<noteq> a)"
+ − 351
+ − 352
definition
+ − 353
"match_Lam (S :: 'a :: fs) t = (if (\<exists>n s. (t = Lam n s)) then
+ − 354
(let z = new (S, t) in Some (z, THE s. t = Lam z s)) else None)"
+ − 355
+ − 356
lemma lam_half_inj: "(Lam z s = Lam z sa) = (s = sa)"
+ − 357
apply auto
+ − 358
apply (simp only: lam.eq_iff alphas)
+ − 359
apply clarify
+ − 360
apply (simp add: eqvts)
+ − 361
sorry
+ − 362
+ − 363
lemma match_Lam_simps:
+ − 364
"match_Lam S (Var n) = None"
+ − 365
"match_Lam S (App l r) = None"
+ − 366
"z = new (S, (Lam z s)) \<Longrightarrow> match_Lam S (Lam z s) = Some (z, s)"
+ − 367
apply (simp_all add: match_Lam_def)
+ − 368
apply (simp add: lam_half_inj)
+ − 369
apply auto
+ − 370
done
2436
+ − 371
*)
2173
+ − 372
(*
+ − 373
lemma match_Lam_simps2:
+ − 374
"atom n \<sharp> ((S :: 'a :: fs), Lam n s) \<Longrightarrow> match_Lam S (Lam n s) = Some (n, s)"
+ − 375
apply (rule_tac t="Lam n s"
+ − 376
and s="Lam (new (S, (Lam n s))) ((n \<leftrightarrow> (new (S, (Lam n s)))) \<bullet> s)" in subst)
+ − 377
defer
+ − 378
apply (subst match_Lam_simps(3))
+ − 379
defer
+ − 380
apply simp
+ − 381
*)
+ − 382
+ − 383
(*primrec match_Lam_raw where
2165
+ − 384
"match_Lam_raw (S :: atom set) (Var_raw x) = None"
+ − 385
| "match_Lam_raw S (App_raw x y) = None"
+ − 386
| "match_Lam_raw S (Lam_raw n t) = (let z = new (S \<union> (fv_lam_raw t - {atom n})) in Some (z, (n \<leftrightarrow> z) \<bullet> t))"
+ − 387
+ − 388
quotient_definition
+ − 389
"match_Lam :: (atom set) \<Rightarrow> lam \<Rightarrow> (name \<times> lam) option"
+ − 390
is match_Lam_raw
+ − 391
2172
+ − 392
lemma swap_fresh:
+ − 393
assumes a: "fv_lam_raw t \<sharp>* p"
+ − 394
shows "alpha_lam_raw (p \<bullet> t) t"
+ − 395
using a apply (induct t)
+ − 396
apply (simp add: supp_at_base fresh_star_def)
+ − 397
apply (rule alpha_lam_raw.intros)
+ − 398
apply (metis Rep_name_inverse atom_eqvt atom_name_def fresh_perm)
+ − 399
apply (simp)
+ − 400
apply (simp only: fresh_star_union)
+ − 401
apply clarify
+ − 402
apply (rule alpha_lam_raw.intros)
+ − 403
apply simp
+ − 404
apply simp
+ − 405
apply simp
+ − 406
apply (rule alpha_lam_raw.intros)
+ − 407
sorry
+ − 408
2165
+ − 409
lemma [quot_respect]:
+ − 410
"(op = ===> alpha_lam_raw ===> option_rel (prod_rel op = alpha_lam_raw)) match_Lam_raw match_Lam_raw"
+ − 411
proof (intro fun_relI, clarify)
+ − 412
fix S t s
+ − 413
assume a: "alpha_lam_raw t s"
+ − 414
show "option_rel (prod_rel op = alpha_lam_raw) (match_Lam_raw S t) (match_Lam_raw S s)"
+ − 415
using a proof (induct t s rule: alpha_lam_raw.induct)
+ − 416
case goal1 show ?case by simp
+ − 417
next
+ − 418
case goal2 show ?case by simp
+ − 419
next
+ − 420
case (goal3 x t y s)
+ − 421
then obtain p where "({atom x}, t) \<approx>gen (\<lambda>x1 x2. alpha_lam_raw x1 x2 \<and>
+ − 422
option_rel (prod_rel op = alpha_lam_raw) (match_Lam_raw S x1)
+ − 423
(match_Lam_raw S x2)) fv_lam_raw p ({atom y}, s)" ..
+ − 424
then have
+ − 425
c: "fv_lam_raw t - {atom x} = fv_lam_raw s - {atom y}" and
+ − 426
d: "(fv_lam_raw t - {atom x}) \<sharp>* p" and
+ − 427
e: "alpha_lam_raw (p \<bullet> t) s" and
+ − 428
f: "option_rel (prod_rel op = alpha_lam_raw) (match_Lam_raw S (p \<bullet> t)) (match_Lam_raw S s)" and
+ − 429
g: "p \<bullet> {atom x} = {atom y}" unfolding alphas(1) by - (elim conjE, assumption)+
+ − 430
let ?z = "new (S \<union> (fv_lam_raw t - {atom x}))"
+ − 431
have h: "?z = new (S \<union> (fv_lam_raw s - {atom y}))" using c by simp
+ − 432
show ?case
+ − 433
unfolding match_Lam_raw.simps Let_def option_rel.simps prod_rel.simps split_conv
+ − 434
proof
+ − 435
show "?z = new (S \<union> (fv_lam_raw s - {atom y}))" by (fact h)
+ − 436
next
+ − 437
have "atom y \<sharp> p" sorry
+ − 438
have "fv_lam_raw t \<sharp>* ((x \<leftrightarrow> y) \<bullet> p)" sorry
2172
+ − 439
then have "alpha_lam_raw (((x \<leftrightarrow> y) \<bullet> p) \<bullet> t) t" using swap_fresh by auto
+ − 440
then have "alpha_lam_raw (p \<bullet> t) ((x \<leftrightarrow> y) \<bullet> t)" sorry
2165
+ − 441
have "alpha_lam_raw t ((x \<leftrightarrow> y) \<bullet> s)" sorry
+ − 442
then have "alpha_lam_raw ((x \<leftrightarrow> ?z) \<bullet> t) ((y \<leftrightarrow> ?z) \<bullet> s)" using eqvts(15) sorry
+ − 443
then show "alpha_lam_raw ((x \<leftrightarrow> new (S \<union> (fv_lam_raw t - {atom x}))) \<bullet> t)
+ − 444
((y \<leftrightarrow> new (S \<union> (fv_lam_raw s - {atom y}))) \<bullet> s)" unfolding h .
+ − 445
qed
+ − 446
qed
+ − 447
qed
+ − 448
+ − 449
lemmas match_Lam_simps = match_Lam_raw.simps[quot_lifted]
2173
+ − 450
*)
2436
+ − 451
(*
2165
+ − 452
lemma app_some: "match_App x = Some (a, b) \<Longrightarrow> x = App a b"
+ − 453
by (induct x rule: lam.induct) (simp_all add: match_App_simps)
+ − 454
+ − 455
lemma lam_some: "match_Lam S x = Some (z, s) \<Longrightarrow> x = Lam z s \<and> atom z \<sharp> S"
+ − 456
apply (induct x rule: lam.induct)
+ − 457
apply (simp_all add: match_Lam_simps)
2173
+ − 458
apply (thin_tac "match_Lam S lam = Some (z, s) \<Longrightarrow> lam = Lam z s \<and> atom z \<sharp> S")
+ − 459
apply (simp add: match_Lam_def)
+ − 460
apply (subgoal_tac "\<exists>n s. Lam name lam = Lam n s")
+ − 461
prefer 2
+ − 462
apply auto[1]
2165
+ − 463
apply (simp add: Let_def)
2173
+ − 464
apply (thin_tac "\<exists>n s. Lam name lam = Lam n s")
+ − 465
apply clarify
2165
+ − 466
apply (rule conjI)
2173
+ − 467
apply (rule_tac t="THE s. Lam name lam = Lam (new (S, Lam name lam)) s" and
+ − 468
s="(name \<leftrightarrow> (new (S, Lam name lam))) \<bullet> lam" in subst)
+ − 469
defer
2165
+ − 470
apply (simp add: lam.eq_iff)
2173
+ − 471
apply (rule_tac x="(name \<leftrightarrow> (new (S, Lam name lam)))" in exI)
2165
+ − 472
apply (simp add: alphas)
+ − 473
apply (simp add: eqvts)
2173
+ − 474
apply (rule conjI)
2172
+ − 475
sorry
2165
+ − 476
+ − 477
function subst where
+ − 478
"subst v s t = (
+ − 479
case match_Var t of Some n \<Rightarrow> if n = v then s else Var n | None \<Rightarrow>
+ − 480
case match_App t of Some (l, r) \<Rightarrow> App (subst v s l) (subst v s r) | None \<Rightarrow>
2173
+ − 481
case match_Lam (v,s) t of Some (n, t) \<Rightarrow> Lam n (subst v s t) | None \<Rightarrow> undefined)"
2165
+ − 482
by pat_completeness auto
+ − 483
+ − 484
termination apply (relation "measure (\<lambda>(_, _, t). size t)")
2172
+ − 485
apply auto[1]
+ − 486
apply (case_tac a) apply simp
+ − 487
apply (frule lam_some) apply simp
+ − 488
apply (case_tac a) apply simp
+ − 489
apply (frule app_some) apply simp
+ − 490
apply (case_tac a) apply simp
+ − 491
apply (frule app_some) apply simp
2165
+ − 492
done
+ − 493
+ − 494
lemmas lam_exhaust = lam_raw.exhaust[quot_lifted]
+ − 495
+ − 496
lemma subst_eqvt:
+ − 497
"p \<bullet> (subst v s t) = subst (p \<bullet> v) (p \<bullet> s) (p \<bullet> t)"
+ − 498
proof (induct v s t rule: subst.induct)
+ − 499
case (1 v s t)
+ − 500
show ?case proof (cases t rule: lam_exhaust)
+ − 501
fix n
+ − 502
assume "t = Var n"
+ − 503
then show ?thesis by (simp add: match_Var_simps)
+ − 504
next
+ − 505
fix l r
+ − 506
assume "t = App l r"
+ − 507
then show ?thesis
+ − 508
apply (simp only:)
+ − 509
apply (subst subst.simps)
+ − 510
apply (subst match_Var_simps)
+ − 511
apply (simp only: option.cases)
+ − 512
apply (subst match_App_simps)
+ − 513
apply (simp only: option.cases)
+ − 514
apply (simp only: prod.cases)
+ − 515
apply (simp only: lam.perm)
+ − 516
apply (subst (3) subst.simps)
+ − 517
apply (subst match_Var_simps)
2173
+ − 518
apply (simp only: option.cases)
2165
+ − 519
apply (subst match_App_simps)
+ − 520
apply (simp only: option.cases)
+ − 521
apply (simp only: prod.cases)
+ − 522
apply (subst 1(2)[of "(l, r)" "l" "r"])
+ − 523
apply (simp add: match_Var_simps)
+ − 524
apply (simp add: match_App_simps)
+ − 525
apply (rule refl)
+ − 526
apply (subst 1(3)[of "(l, r)" "l" "r"])
+ − 527
apply (simp add: match_Var_simps)
+ − 528
apply (simp add: match_App_simps)
+ − 529
apply (rule refl)
+ − 530
apply (rule refl)
+ − 531
done
+ − 532
next
+ − 533
fix n t'
+ − 534
assume "t = Lam n t'"
+ − 535
then show ?thesis
+ − 536
apply (simp only: )
+ − 537
apply (simp only: lam.perm)
+ − 538
apply (subst subst.simps)
+ − 539
apply (subst match_Var_simps)
+ − 540
apply (simp only: option.cases)
+ − 541
apply (subst match_App_simps)
+ − 542
apply (simp only: option.cases)
2173
+ − 543
apply (rule_tac t="Lam n t'" and s="Lam (new ((v, s), Lam n t')) ((n \<leftrightarrow> new ((v, s), Lam n t')) \<bullet> t')" in subst)
+ − 544
defer
2165
+ − 545
apply (subst match_Lam_simps)
2173
+ − 546
defer
2165
+ − 547
apply (simp only: option.cases)
+ − 548
apply (simp only: prod.cases)
+ − 549
apply (subst (2) subst.simps)
+ − 550
apply (subst match_Var_simps)
+ − 551
apply (simp only: option.cases)
+ − 552
apply (subst match_App_simps)
+ − 553
apply (simp only: option.cases)
2173
+ − 554
apply (rule_tac t="Lam (p \<bullet> n) (p \<bullet> t')" and s="Lam (new ((p \<bullet> v, p \<bullet> s), Lam (p \<bullet> n) (p \<bullet> t'))) (((p \<bullet> n) \<leftrightarrow> new ((p \<bullet> v, p \<bullet> s), Lam (p \<bullet> n) (p \<bullet> t'))) \<bullet> t')" in subst)
+ − 555
defer
2165
+ − 556
apply (subst match_Lam_simps)
2173
+ − 557
defer
2165
+ − 558
apply (simp only: option.cases)
+ − 559
apply (simp only: prod.cases)
+ − 560
apply (simp only: lam.perm)
2173
+ − 561
thm 1(1)
2165
+ − 562
sorry
+ − 563
qed
+ − 564
qed
+ − 565
2172
+ − 566
lemma subst_proper_eqs:
+ − 567
"subst y s (Var x) = (if x = y then s else (Var x))"
+ − 568
"subst y s (App l r) = App (subst y s l) (subst y s r)"
+ − 569
"atom x \<sharp> (t, s) \<Longrightarrow> subst y s (Lam x t) = Lam x (subst y s t)"
+ − 570
apply (subst subst.simps)
+ − 571
apply (simp only: match_Var_simps)
+ − 572
apply (simp only: option.simps)
+ − 573
apply (subst subst.simps)
+ − 574
apply (simp only: match_App_simps)
+ − 575
apply (simp only: option.simps)
+ − 576
apply (simp only: prod.simps)
+ − 577
apply (simp only: match_Var_simps)
+ − 578
apply (simp only: option.simps)
+ − 579
apply (subst subst.simps)
+ − 580
apply (simp only: match_Var_simps)
2173
+ − 581
apply (simp only: option.simps)
2172
+ − 582
apply (simp only: match_App_simps)
+ − 583
apply (simp only: option.simps)
2173
+ − 584
apply (rule_tac t="Lam x t" and s="Lam (new ((y, s), Lam x t)) ((x \<leftrightarrow> new ((y, s), Lam x t)) \<bullet> t)" in subst)
+ − 585
defer
+ − 586
apply (subst match_Lam_simps)
+ − 587
defer
2172
+ − 588
apply (simp only: option.simps)
+ − 589
apply (simp only: prod.simps)
2157
+ − 590
sorry
2436
+ − 591
*)
1594
+ − 592
end
+ − 593
+ − 594
+ − 595