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
2440
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 6
declare [[STEPS = 100]]
1594
+ − 7
2436
+ − 8
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
+ − 9
Var "name"
2436
+ − 10
| App "lam" "lam"
+ − 11
| 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
+ − 12
2436
+ − 13
thm lam.distinct
+ − 14
thm lam.induct
+ − 15
thm lam.exhaust
+ − 16
thm lam.fv_defs
+ − 17
thm lam.bn_defs
+ − 18
thm lam.perm_simps
+ − 19
thm lam.eq_iff
2442
+ − 20
thm lam.eq_iff[folded alphas]
2436
+ − 21
thm lam.fv_bn_eqvt
+ − 22
thm lam.size_eqvt
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 23
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
+ − 24
2497
+ − 25
section {* Strong Exhausts Lemma and Strong Induction Lemma via Induct_schema *}
+ − 26
+ − 27
lemma strong_exhaust:
+ − 28
fixes c::"'a::fs"
+ − 29
assumes "\<And>name ca. \<lbrakk>c = ca; y = Var name\<rbrakk> \<Longrightarrow> P"
+ − 30
and "\<And>lam1 lam2 ca. \<lbrakk>c = ca; y = App lam1 lam2\<rbrakk> \<Longrightarrow> P"
+ − 31
and "\<And>name lam ca. \<lbrakk>c = ca; atom name \<sharp> ca; y = Lam name lam\<rbrakk> \<Longrightarrow> P"
+ − 32
shows "P"
+ − 33
apply(rule_tac y="y" in lam.exhaust)
+ − 34
apply(rule assms(1))
+ − 35
apply(auto)[2]
+ − 36
apply(rule assms(2))
+ − 37
apply(auto)[2]
+ − 38
apply(subgoal_tac "\<exists>q. (q \<bullet> (atom name)) \<sharp> c \<and> supp (Lam name lam) \<sharp>* q")
+ − 39
apply(erule exE)
+ − 40
apply(erule conjE)
+ − 41
apply(rule assms(3))
+ − 42
apply(rule refl)
+ − 43
apply(simp add: atom_eqvt)
+ − 44
apply(clarify)
+ − 45
apply(drule supp_perm_eq[symmetric])
+ − 46
apply(simp)
+ − 47
apply(rule at_set_avoiding2_atom)
+ − 48
apply(simp add: finite_supp)
+ − 49
apply(simp add: finite_supp)
+ − 50
apply(simp add: lam.fresh)
+ − 51
done
+ − 52
+ − 53
+ − 54
lemma strong_induct:
+ − 55
fixes c::"'a::fs"
+ − 56
assumes a1: "\<And>name c. P c (Var name)"
+ − 57
and a2: "\<And>lam1 lam2 c. \<lbrakk>\<And>d. P d lam1; \<And>d. P d lam2\<rbrakk> \<Longrightarrow> P c (App lam1 lam2)"
+ − 58
and a3: "\<And>name lam c. \<lbrakk>atom name \<sharp> c; \<And>d. P d lam\<rbrakk> \<Longrightarrow> P c (Lam name lam)"
+ − 59
shows "P c lam"
+ − 60
using assms
+ − 61
apply(induction_schema)
+ − 62
apply(rule_tac y="lam" in strong_exhaust)
+ − 63
apply(blast)
+ − 64
apply(blast)
+ − 65
apply(blast)
+ − 66
apply(relation "measure (\<lambda>(x,y). size y)")
+ − 67
apply(auto)[1]
+ − 68
apply(simp add: lam.size)
+ − 69
apply(simp add: lam.size)
+ − 70
apply(simp add: lam.size)
+ − 71
done
2082
0854af516f14
cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 72
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
+ − 73
section {* Strong Induction Principles*}
1594
+ − 74
2041
+ − 75
(*
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
+ − 76
Old way of establishing strong induction
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 77
principles by chosing a fresh name.
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 78
*)
2436
+ − 79
(*
1594
+ − 80
lemma
+ − 81
fixes c::"'a::fs"
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
+ − 82
assumes a1: "\<And>name c. P c (Var name)"
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
+ − 83
and a2: "\<And>lam1 lam2 c. \<lbrakk>\<And>d. P d lam1; \<And>d. P d lam2\<rbrakk> \<Longrightarrow> P c (App lam1 lam2)"
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
+ − 84
and a3: "\<And>name lam c. \<lbrakk>atom name \<sharp> c; \<And>d. P d lam\<rbrakk> \<Longrightarrow> P c (Lam name lam)"
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
+ − 85
shows "P c lam"
1594
+ − 86
proof -
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
+ − 87
have "\<And>p. P c (p \<bullet> lam)"
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
+ − 88
apply(induct lam arbitrary: c rule: lam.induct)
1805
+ − 89
apply(perm_simp)
1594
+ − 90
apply(rule a1)
1805
+ − 91
apply(perm_simp)
1594
+ − 92
apply(rule a2)
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
+ − 93
apply(assumption)
1594
+ − 94
apply(assumption)
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
+ − 95
apply(subgoal_tac "\<exists>new::name. (atom new) \<sharp> (c, Lam (p \<bullet> name) (p \<bullet> lam))")
1594
+ − 96
defer
+ − 97
apply(simp add: fresh_def)
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
+ − 98
apply(rule_tac X="supp (c, Lam (p \<bullet> name) (p \<bullet> lam))" in obtain_at_base)
1594
+ − 99
apply(simp add: supp_Pair finite_supp)
+ − 100
apply(blast)
+ − 101
apply(erule exE)
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
+ − 102
apply(rule_tac t="p \<bullet> Lam name lam" and
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
+ − 103
s="(((p \<bullet> name) \<leftrightarrow> new) + p) \<bullet> Lam name lam" in subst)
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
+ − 104
apply(simp del: lam.perm)
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
+ − 105
apply(subst lam.perm)
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
+ − 106
apply(subst (2) lam.perm)
1594
+ − 107
apply(rule flip_fresh_fresh)
+ − 108
apply(simp add: fresh_def)
+ − 109
apply(simp only: supp_fn')
+ − 110
apply(simp)
+ − 111
apply(simp add: fresh_Pair)
+ − 112
apply(simp)
+ − 113
apply(rule a3)
+ − 114
apply(simp add: fresh_Pair)
+ − 115
apply(drule_tac x="((p \<bullet> name) \<leftrightarrow> new) + p" in meta_spec)
+ − 116
apply(simp)
+ − 117
done
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
+ − 118
then have "P c (0 \<bullet> lam)" by 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
+ − 119
then show "P c lam" by simp
1594
+ − 120
qed
2436
+ − 121
*)
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
+ − 122
(*
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 123
New way of establishing strong induction
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 124
principles by using a appropriate permutation.
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 125
*)
2436
+ − 126
(*
1594
+ − 127
lemma
+ − 128
fixes c::"'a::fs"
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
+ − 129
assumes a1: "\<And>name c. P c (Var name)"
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
+ − 130
and a2: "\<And>lam1 lam2 c. \<lbrakk>\<And>d. P d lam1; \<And>d. P d lam2\<rbrakk> \<Longrightarrow> P c (App lam1 lam2)"
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
+ − 131
and a3: "\<And>name lam c. \<lbrakk>atom name \<sharp> c; \<And>d. P d lam\<rbrakk> \<Longrightarrow> P c (Lam name lam)"
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
+ − 132
shows "P c lam"
1594
+ − 133
proof -
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
+ − 134
have "\<And>p. P c (p \<bullet> lam)"
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
+ − 135
apply(induct lam arbitrary: c rule: lam.induct)
1805
+ − 136
apply(perm_simp)
1594
+ − 137
apply(rule a1)
1805
+ − 138
apply(perm_simp)
1594
+ − 139
apply(rule a2)
+ − 140
apply(assumption)
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
+ − 141
apply(assumption)
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
+ − 142
apply(subgoal_tac "\<exists>q. (q \<bullet> {p \<bullet> atom name}) \<sharp>* c \<and> supp (p \<bullet> Lam name lam) \<sharp>* q")
1594
+ − 143
apply(erule exE)
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
+ − 144
apply(rule_tac t="p \<bullet> Lam name lam" and
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
+ − 145
s="q \<bullet> p \<bullet> Lam name lam" in subst)
1594
+ − 146
defer
1805
+ − 147
apply(simp)
1594
+ − 148
apply(rule a3)
+ − 149
apply(simp add: eqvts fresh_star_def)
+ − 150
apply(drule_tac x="q + p" in meta_spec)
+ − 151
apply(simp)
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
+ − 152
apply(rule at_set_avoiding2)
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 153
apply(simp add: finite_supp)
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 154
apply(simp add: finite_supp)
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 155
apply(simp add: finite_supp)
1805
+ − 156
apply(perm_simp)
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
+ − 157
apply(simp add: fresh_star_def fresh_def supp_fn')
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 158
apply(rule supp_perm_eq)
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 159
apply(simp)
fddb470720f1
renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 160
done
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
+ − 161
then have "P c (0 \<bullet> lam)" by 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
+ − 162
then show "P c lam" by simp
1594
+ − 163
qed
2436
+ − 164
*)
1594
+ − 165
1805
+ − 166
section {* Typing *}
+ − 167
+ − 168
nominal_datatype ty =
+ − 169
TVar string
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
+ − 170
| TFun ty ty
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
+ − 171
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
+ − 172
notation
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
+ − 173
TFun ("_ \<rightarrow> _")
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
+ − 174
2436
+ − 175
(*
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
+ − 176
declare ty.perm[eqvt]
1805
+ − 177
+ − 178
inductive
+ − 179
valid :: "(name \<times> ty) list \<Rightarrow> bool"
+ − 180
where
+ − 181
"valid []"
+ − 182
| "\<lbrakk>atom x \<sharp> Gamma; valid Gamma\<rbrakk> \<Longrightarrow> valid ((x, T)#Gamma)"
+ − 183
1828
+ − 184
inductive
+ − 185
typing :: "(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow> bool" ("_ \<turnstile> _ : _" [60,60,60] 60)
+ − 186
where
+ − 187
t_Var[intro]: "\<lbrakk>valid \<Gamma>; (x, T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T"
1947
+ − 188
| t_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : T1 \<rightarrow> T2; \<Gamma> \<turnstile> t2 : T1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App t1 t2 : T2"
1828
+ − 189
| t_Lam[intro]: "\<lbrakk>atom x \<sharp> \<Gamma>; (x, T1) # \<Gamma> \<turnstile> t : T2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam x t : T1 \<rightarrow> T2"
+ − 190
1831
+ − 191
equivariance valid
+ − 192
equivariance typing
1816
+ − 193
1831
+ − 194
thm valid.eqvt
+ − 195
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
+ − 196
thm eqvts
ae176476b525
implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 197
thm eqvts_raw
ae176476b525
implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 198
1949
+ − 199
thm typing.induct[of "\<Gamma>" "t" "T", no_vars]
+ − 200
+ − 201
lemma
+ − 202
fixes c::"'a::fs"
+ − 203
assumes a: "\<Gamma> \<turnstile> t : T"
+ − 204
and a1: "\<And>\<Gamma> x T c. \<lbrakk>valid \<Gamma>; (x, T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> P c \<Gamma> (Var x) T"
+ − 205
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>
+ − 206
\<Longrightarrow> P c \<Gamma> (App t1 t2) T2"
+ − 207
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>
+ − 208
\<Longrightarrow> P c \<Gamma> (Lam x t) T1 \<rightarrow> T2"
+ − 209
shows "P c \<Gamma> t T"
+ − 210
proof -
+ − 211
from a have "\<And>p c. P c (p \<bullet> \<Gamma>) (p \<bullet> t) (p \<bullet> T)"
+ − 212
proof (induct)
+ − 213
case (t_Var \<Gamma> x T p c)
+ − 214
then show ?case
+ − 215
apply -
+ − 216
apply(perm_strict_simp)
+ − 217
apply(rule a1)
1954
+ − 218
apply(drule_tac p="p" in permute_boolI)
1949
+ − 219
apply(perm_strict_simp add: permute_minus_cancel)
+ − 220
apply(assumption)
1954
+ − 221
apply(rotate_tac 1)
+ − 222
apply(drule_tac p="p" in permute_boolI)
1949
+ − 223
apply(perm_strict_simp add: permute_minus_cancel)
+ − 224
apply(assumption)
+ − 225
done
+ − 226
next
+ − 227
case (t_App \<Gamma> t1 T1 T2 t2 p c)
+ − 228
then show ?case
+ − 229
apply -
+ − 230
apply(perm_strict_simp)
1954
+ − 231
apply(rule a2)
+ − 232
apply(drule_tac p="p" in permute_boolI)
1949
+ − 233
apply(perm_strict_simp add: permute_minus_cancel)
+ − 234
apply(assumption)
+ − 235
apply(assumption)
1954
+ − 236
apply(rotate_tac 2)
+ − 237
apply(drule_tac p="p" in permute_boolI)
1949
+ − 238
apply(perm_strict_simp add: permute_minus_cancel)
+ − 239
apply(assumption)
+ − 240
apply(assumption)
+ − 241
done
+ − 242
next
+ − 243
case (t_Lam x \<Gamma> T1 t T2 p c)
+ − 244
then show ?case
+ − 245
apply -
+ − 246
apply(subgoal_tac "\<exists>q. (q \<bullet> {p \<bullet> atom x}) \<sharp>* c \<and>
+ − 247
supp (p \<bullet> \<Gamma>, p \<bullet> Lam x t, p \<bullet> (T1 \<rightarrow> T2)) \<sharp>* q")
+ − 248
apply(erule exE)
1954
+ − 249
apply(rule_tac t="p \<bullet> \<Gamma>" and s="(q + p) \<bullet> \<Gamma>" in subst)
+ − 250
apply(simp only: permute_plus)
1949
+ − 251
apply(rule supp_perm_eq)
+ − 252
apply(simp add: supp_Pair fresh_star_union)
1954
+ − 253
apply(rule_tac t="p \<bullet> Lam x t" and s="(q + p) \<bullet> Lam x t" in subst)
+ − 254
apply(simp only: permute_plus)
1949
+ − 255
apply(rule supp_perm_eq)
+ − 256
apply(simp add: supp_Pair fresh_star_union)
1954
+ − 257
apply(rule_tac t="p \<bullet> (T1 \<rightarrow> T2)" and s="(q + p) \<bullet> (T1 \<rightarrow> T2)" in subst)
+ − 258
apply(simp only: permute_plus)
+ − 259
apply(rule supp_perm_eq)
+ − 260
apply(simp add: supp_Pair fresh_star_union)
+ − 261
apply(simp (no_asm) only: eqvts)
1949
+ − 262
apply(rule a3)
1954
+ − 263
apply(simp only: eqvts permute_plus)
1949
+ − 264
apply(simp add: fresh_star_def)
1954
+ − 265
apply(drule_tac p="q + p" in permute_boolI)
1949
+ − 266
apply(perm_strict_simp add: permute_minus_cancel)
+ − 267
apply(assumption)
1954
+ − 268
apply(rotate_tac 1)
+ − 269
apply(drule_tac p="q + p" in permute_boolI)
1949
+ − 270
apply(perm_strict_simp add: permute_minus_cancel)
+ − 271
apply(assumption)
+ − 272
apply(drule_tac x="d" in meta_spec)
+ − 273
apply(drule_tac x="q + p" in meta_spec)
1954
+ − 274
apply(perm_strict_simp add: permute_minus_cancel)
+ − 275
apply(assumption)
1949
+ − 276
apply(rule at_set_avoiding2)
+ − 277
apply(simp add: finite_supp)
+ − 278
apply(simp add: finite_supp)
+ − 279
apply(simp add: finite_supp)
+ − 280
apply(rule_tac p="-p" in permute_boolE)
+ − 281
apply(perm_strict_simp add: permute_minus_cancel)
2436
+ − 282
--"supplied by the user"
1949
+ − 283
apply(simp add: fresh_star_prod)
+ − 284
apply(simp add: fresh_star_def)
1954
+ − 285
sorry
+ − 286
qed
+ − 287
then have "P c (0 \<bullet> \<Gamma>) (0 \<bullet> t) (0 \<bullet> T)" .
+ − 288
then show "P c \<Gamma> t T" by simp
+ − 289
qed
1949
+ − 290
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 291
*)
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 292
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
+ − 293
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
+ − 294
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
+ − 295
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
+ − 296
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
+ − 297
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
+ − 298
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
+ − 299
"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
+ − 300
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
+ − 301
(*
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
+ − 302
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
+ − 303
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
+ − 304
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
+ − 305
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
+ − 306
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
+ − 307
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
+ − 308
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
+ − 309
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
+ − 310
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
+ − 311
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
+ − 312
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
+ − 313
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
+ − 314
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
+ − 315
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
+ − 316
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
+ − 317
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
+ − 318
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
+ − 319
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
+ − 320
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
+ − 321
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
+ − 322
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
+ − 323
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
+ − 324
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
+ − 325
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
+ − 326
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
+ − 327
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
+ − 328
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
+ − 329
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
+ − 330
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
+ − 331
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
+ − 332
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
+ − 333
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
+ − 334
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
+ − 335
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
+ − 336
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
+ − 337
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
+ − 338
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
+ − 339
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
+ − 340
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
+ − 341
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
+ − 342
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
+ − 343
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
+ − 344
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
+ − 345
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
+ − 346
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
+ − 347
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
+ − 348
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
+ − 349
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
+ − 350
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
+ − 351
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
+ − 352
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
+ − 353
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
+ − 354
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
+ − 355
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
+ − 356
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
+ − 357
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
+ − 358
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
+ − 359
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
+ − 360
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
+ − 361
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
+ − 362
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
+ − 363
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
+ − 364
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
+ − 365
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
+ − 366
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
+ − 367
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
+ − 368
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
+ − 369
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
+ − 370
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
+ − 371
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
+ − 372
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
+ − 373
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
+ − 374
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
+ − 375
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
+ − 376
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
+ − 377
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
+ − 378
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
+ − 379
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
+ − 380
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
+ − 381
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
+ − 382
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
+ − 383
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
+ − 384
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
+ − 385
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
+ − 386
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
+ − 387
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
+ − 388
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
+ − 389
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
+ − 390
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
+ − 391
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
+ − 392
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
+ − 393
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
+ − 394
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
+ − 395
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
+ − 396
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
+ − 397
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
+ − 398
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
+ − 399
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
+ − 400
*)
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
+ − 401
1954
+ − 402
ML {*
+ − 403
fun mk_avoids ctxt params name set =
+ − 404
let
+ − 405
val (_, ctxt') = ProofContext.add_fixes
+ − 406
(map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params) ctxt;
+ − 407
fun mk s =
+ − 408
let
+ − 409
val t = Syntax.read_term ctxt' s;
+ − 410
val t' = list_abs_free (params, t) |>
+ − 411
funpow (length params) (fn Abs (_, _, t) => t)
+ − 412
in (t', HOLogic.dest_setT (fastype_of t)) end
+ − 413
handle TERM _ =>
+ − 414
error ("Expression " ^ quote s ^ " to be avoided in case " ^
+ − 415
quote name ^ " is not a set type");
+ − 416
fun add_set p [] = [p]
+ − 417
| add_set (t, T) ((u, U) :: ps) =
+ − 418
if T = U then
+ − 419
let val S = HOLogic.mk_setT T
+ − 420
in (Const (@{const_name sup}, S --> S --> S) $ u $ t, T) :: ps
+ − 421
end
+ − 422
else (u, U) :: add_set (t, T) ps
+ − 423
in
+ − 424
(mk #> add_set) set
+ − 425
end;
+ − 426
*}
+ − 427
+ − 428
+ − 429
ML {*
+ − 430
writeln (commas (map (Syntax.string_of_term @{context} o fst)
+ − 431
(mk_avoids @{context} [] "t_Var" "{x}" [])))
+ − 432
*}
+ − 433
1947
+ − 434
1949
+ − 435
ML {*
+ − 436
+ − 437
fun prove_strong_ind (pred_name, avoids) ctxt =
+ − 438
Proof.theorem NONE (K I) [] ctxt
+ − 439
2169
+ − 440
local structure P = Parse and K = Keyword in
1949
+ − 441
+ − 442
val _ =
2169
+ − 443
Outer_Syntax.local_theory_to_proof "nominal_inductive"
1949
+ − 444
"proves strong induction theorem for inductive predicate involving nominal datatypes" K.thy_goal
+ − 445
(P.xname -- (Scan.optional (P.$$$ "avoids" |-- P.enum1 "|" (P.name --
+ − 446
(P.$$$ ":" |-- P.and_list1 P.term))) []) >> prove_strong_ind)
+ − 447
+ − 448
end;
+ − 449
+ − 450
*}
+ − 451
1950
+ − 452
(*
1949
+ − 453
nominal_inductive typing
1950
+ − 454
*)
1949
+ − 455
2157
+ − 456
(* Substitution *)
2159
+ − 457
2165
+ − 458
primrec match_Var_raw where
+ − 459
"match_Var_raw (Var_raw x) = Some x"
+ − 460
| "match_Var_raw (App_raw x y) = None"
+ − 461
| "match_Var_raw (Lam_raw n t) = None"
+ − 462
+ − 463
quotient_definition
+ − 464
"match_Var :: lam \<Rightarrow> name option"
+ − 465
is match_Var_raw
+ − 466
+ − 467
lemma [quot_respect]: "(alpha_lam_raw ===> op =) match_Var_raw match_Var_raw"
+ − 468
apply rule
+ − 469
apply (induct_tac a b rule: alpha_lam_raw.induct)
+ − 470
apply simp_all
+ − 471
done
+ − 472
+ − 473
lemmas match_Var_simps = match_Var_raw.simps[quot_lifted]
+ − 474
+ − 475
primrec match_App_raw where
+ − 476
"match_App_raw (Var_raw x) = None"
+ − 477
| "match_App_raw (App_raw x y) = Some (x, y)"
+ − 478
| "match_App_raw (Lam_raw n t) = None"
+ − 479
2436
+ − 480
(*
2165
+ − 481
quotient_definition
+ − 482
"match_App :: lam \<Rightarrow> (lam \<times> lam) option"
+ − 483
is match_App_raw
+ − 484
+ − 485
lemma [quot_respect]:
+ − 486
"(alpha_lam_raw ===> option_rel (prod_rel alpha_lam_raw alpha_lam_raw)) match_App_raw match_App_raw"
+ − 487
apply (intro fun_relI)
+ − 488
apply (induct_tac a b rule: alpha_lam_raw.induct)
+ − 489
apply simp_all
+ − 490
done
+ − 491
+ − 492
lemmas match_App_simps = match_App_raw.simps[quot_lifted]
+ − 493
2173
+ − 494
definition new where
+ − 495
"new (s :: 'a :: fs) = (THE x. \<forall>a \<in> supp s. atom x \<noteq> a)"
+ − 496
+ − 497
definition
+ − 498
"match_Lam (S :: 'a :: fs) t = (if (\<exists>n s. (t = Lam n s)) then
+ − 499
(let z = new (S, t) in Some (z, THE s. t = Lam z s)) else None)"
+ − 500
+ − 501
lemma lam_half_inj: "(Lam z s = Lam z sa) = (s = sa)"
+ − 502
apply auto
+ − 503
apply (simp only: lam.eq_iff alphas)
+ − 504
apply clarify
+ − 505
apply (simp add: eqvts)
+ − 506
sorry
+ − 507
+ − 508
lemma match_Lam_simps:
+ − 509
"match_Lam S (Var n) = None"
+ − 510
"match_Lam S (App l r) = None"
+ − 511
"z = new (S, (Lam z s)) \<Longrightarrow> match_Lam S (Lam z s) = Some (z, s)"
+ − 512
apply (simp_all add: match_Lam_def)
+ − 513
apply (simp add: lam_half_inj)
+ − 514
apply auto
+ − 515
done
2436
+ − 516
*)
2173
+ − 517
(*
+ − 518
lemma match_Lam_simps2:
+ − 519
"atom n \<sharp> ((S :: 'a :: fs), Lam n s) \<Longrightarrow> match_Lam S (Lam n s) = Some (n, s)"
+ − 520
apply (rule_tac t="Lam n s"
+ − 521
and s="Lam (new (S, (Lam n s))) ((n \<leftrightarrow> (new (S, (Lam n s)))) \<bullet> s)" in subst)
+ − 522
defer
+ − 523
apply (subst match_Lam_simps(3))
+ − 524
defer
+ − 525
apply simp
+ − 526
*)
+ − 527
+ − 528
(*primrec match_Lam_raw where
2165
+ − 529
"match_Lam_raw (S :: atom set) (Var_raw x) = None"
+ − 530
| "match_Lam_raw S (App_raw x y) = None"
+ − 531
| "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))"
+ − 532
+ − 533
quotient_definition
+ − 534
"match_Lam :: (atom set) \<Rightarrow> lam \<Rightarrow> (name \<times> lam) option"
+ − 535
is match_Lam_raw
+ − 536
2172
+ − 537
lemma swap_fresh:
+ − 538
assumes a: "fv_lam_raw t \<sharp>* p"
+ − 539
shows "alpha_lam_raw (p \<bullet> t) t"
+ − 540
using a apply (induct t)
+ − 541
apply (simp add: supp_at_base fresh_star_def)
+ − 542
apply (rule alpha_lam_raw.intros)
+ − 543
apply (metis Rep_name_inverse atom_eqvt atom_name_def fresh_perm)
+ − 544
apply (simp)
+ − 545
apply (simp only: fresh_star_union)
+ − 546
apply clarify
+ − 547
apply (rule alpha_lam_raw.intros)
+ − 548
apply simp
+ − 549
apply simp
+ − 550
apply simp
+ − 551
apply (rule alpha_lam_raw.intros)
+ − 552
sorry
+ − 553
2165
+ − 554
lemma [quot_respect]:
+ − 555
"(op = ===> alpha_lam_raw ===> option_rel (prod_rel op = alpha_lam_raw)) match_Lam_raw match_Lam_raw"
+ − 556
proof (intro fun_relI, clarify)
+ − 557
fix S t s
+ − 558
assume a: "alpha_lam_raw t s"
+ − 559
show "option_rel (prod_rel op = alpha_lam_raw) (match_Lam_raw S t) (match_Lam_raw S s)"
+ − 560
using a proof (induct t s rule: alpha_lam_raw.induct)
+ − 561
case goal1 show ?case by simp
+ − 562
next
+ − 563
case goal2 show ?case by simp
+ − 564
next
+ − 565
case (goal3 x t y s)
+ − 566
then obtain p where "({atom x}, t) \<approx>gen (\<lambda>x1 x2. alpha_lam_raw x1 x2 \<and>
+ − 567
option_rel (prod_rel op = alpha_lam_raw) (match_Lam_raw S x1)
+ − 568
(match_Lam_raw S x2)) fv_lam_raw p ({atom y}, s)" ..
+ − 569
then have
+ − 570
c: "fv_lam_raw t - {atom x} = fv_lam_raw s - {atom y}" and
+ − 571
d: "(fv_lam_raw t - {atom x}) \<sharp>* p" and
+ − 572
e: "alpha_lam_raw (p \<bullet> t) s" and
+ − 573
f: "option_rel (prod_rel op = alpha_lam_raw) (match_Lam_raw S (p \<bullet> t)) (match_Lam_raw S s)" and
+ − 574
g: "p \<bullet> {atom x} = {atom y}" unfolding alphas(1) by - (elim conjE, assumption)+
+ − 575
let ?z = "new (S \<union> (fv_lam_raw t - {atom x}))"
+ − 576
have h: "?z = new (S \<union> (fv_lam_raw s - {atom y}))" using c by simp
+ − 577
show ?case
+ − 578
unfolding match_Lam_raw.simps Let_def option_rel.simps prod_rel.simps split_conv
+ − 579
proof
+ − 580
show "?z = new (S \<union> (fv_lam_raw s - {atom y}))" by (fact h)
+ − 581
next
+ − 582
have "atom y \<sharp> p" sorry
+ − 583
have "fv_lam_raw t \<sharp>* ((x \<leftrightarrow> y) \<bullet> p)" sorry
2172
+ − 584
then have "alpha_lam_raw (((x \<leftrightarrow> y) \<bullet> p) \<bullet> t) t" using swap_fresh by auto
+ − 585
then have "alpha_lam_raw (p \<bullet> t) ((x \<leftrightarrow> y) \<bullet> t)" sorry
2165
+ − 586
have "alpha_lam_raw t ((x \<leftrightarrow> y) \<bullet> s)" sorry
+ − 587
then have "alpha_lam_raw ((x \<leftrightarrow> ?z) \<bullet> t) ((y \<leftrightarrow> ?z) \<bullet> s)" using eqvts(15) sorry
+ − 588
then show "alpha_lam_raw ((x \<leftrightarrow> new (S \<union> (fv_lam_raw t - {atom x}))) \<bullet> t)
+ − 589
((y \<leftrightarrow> new (S \<union> (fv_lam_raw s - {atom y}))) \<bullet> s)" unfolding h .
+ − 590
qed
+ − 591
qed
+ − 592
qed
+ − 593
+ − 594
lemmas match_Lam_simps = match_Lam_raw.simps[quot_lifted]
2173
+ − 595
*)
2436
+ − 596
(*
2165
+ − 597
lemma app_some: "match_App x = Some (a, b) \<Longrightarrow> x = App a b"
+ − 598
by (induct x rule: lam.induct) (simp_all add: match_App_simps)
+ − 599
+ − 600
lemma lam_some: "match_Lam S x = Some (z, s) \<Longrightarrow> x = Lam z s \<and> atom z \<sharp> S"
+ − 601
apply (induct x rule: lam.induct)
+ − 602
apply (simp_all add: match_Lam_simps)
2173
+ − 603
apply (thin_tac "match_Lam S lam = Some (z, s) \<Longrightarrow> lam = Lam z s \<and> atom z \<sharp> S")
+ − 604
apply (simp add: match_Lam_def)
+ − 605
apply (subgoal_tac "\<exists>n s. Lam name lam = Lam n s")
+ − 606
prefer 2
+ − 607
apply auto[1]
2165
+ − 608
apply (simp add: Let_def)
2173
+ − 609
apply (thin_tac "\<exists>n s. Lam name lam = Lam n s")
+ − 610
apply clarify
2165
+ − 611
apply (rule conjI)
2173
+ − 612
apply (rule_tac t="THE s. Lam name lam = Lam (new (S, Lam name lam)) s" and
+ − 613
s="(name \<leftrightarrow> (new (S, Lam name lam))) \<bullet> lam" in subst)
+ − 614
defer
2165
+ − 615
apply (simp add: lam.eq_iff)
2173
+ − 616
apply (rule_tac x="(name \<leftrightarrow> (new (S, Lam name lam)))" in exI)
2165
+ − 617
apply (simp add: alphas)
+ − 618
apply (simp add: eqvts)
2173
+ − 619
apply (rule conjI)
2172
+ − 620
sorry
2165
+ − 621
+ − 622
function subst where
+ − 623
"subst v s t = (
+ − 624
case match_Var t of Some n \<Rightarrow> if n = v then s else Var n | None \<Rightarrow>
+ − 625
case match_App t of Some (l, r) \<Rightarrow> App (subst v s l) (subst v s r) | None \<Rightarrow>
2173
+ − 626
case match_Lam (v,s) t of Some (n, t) \<Rightarrow> Lam n (subst v s t) | None \<Rightarrow> undefined)"
2165
+ − 627
by pat_completeness auto
+ − 628
+ − 629
termination apply (relation "measure (\<lambda>(_, _, t). size t)")
2172
+ − 630
apply auto[1]
+ − 631
apply (case_tac a) apply simp
+ − 632
apply (frule lam_some) apply simp
+ − 633
apply (case_tac a) apply simp
+ − 634
apply (frule app_some) apply simp
+ − 635
apply (case_tac a) apply simp
+ − 636
apply (frule app_some) apply simp
2165
+ − 637
done
+ − 638
+ − 639
lemmas lam_exhaust = lam_raw.exhaust[quot_lifted]
+ − 640
+ − 641
lemma subst_eqvt:
+ − 642
"p \<bullet> (subst v s t) = subst (p \<bullet> v) (p \<bullet> s) (p \<bullet> t)"
+ − 643
proof (induct v s t rule: subst.induct)
+ − 644
case (1 v s t)
+ − 645
show ?case proof (cases t rule: lam_exhaust)
+ − 646
fix n
+ − 647
assume "t = Var n"
+ − 648
then show ?thesis by (simp add: match_Var_simps)
+ − 649
next
+ − 650
fix l r
+ − 651
assume "t = App l r"
+ − 652
then show ?thesis
+ − 653
apply (simp only:)
+ − 654
apply (subst subst.simps)
+ − 655
apply (subst match_Var_simps)
+ − 656
apply (simp only: option.cases)
+ − 657
apply (subst match_App_simps)
+ − 658
apply (simp only: option.cases)
+ − 659
apply (simp only: prod.cases)
+ − 660
apply (simp only: lam.perm)
+ − 661
apply (subst (3) subst.simps)
+ − 662
apply (subst match_Var_simps)
2173
+ − 663
apply (simp only: option.cases)
2165
+ − 664
apply (subst match_App_simps)
+ − 665
apply (simp only: option.cases)
+ − 666
apply (simp only: prod.cases)
+ − 667
apply (subst 1(2)[of "(l, r)" "l" "r"])
+ − 668
apply (simp add: match_Var_simps)
+ − 669
apply (simp add: match_App_simps)
+ − 670
apply (rule refl)
+ − 671
apply (subst 1(3)[of "(l, r)" "l" "r"])
+ − 672
apply (simp add: match_Var_simps)
+ − 673
apply (simp add: match_App_simps)
+ − 674
apply (rule refl)
+ − 675
apply (rule refl)
+ − 676
done
+ − 677
next
+ − 678
fix n t'
+ − 679
assume "t = Lam n t'"
+ − 680
then show ?thesis
+ − 681
apply (simp only: )
+ − 682
apply (simp only: lam.perm)
+ − 683
apply (subst subst.simps)
+ − 684
apply (subst match_Var_simps)
+ − 685
apply (simp only: option.cases)
+ − 686
apply (subst match_App_simps)
+ − 687
apply (simp only: option.cases)
2173
+ − 688
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)
+ − 689
defer
2165
+ − 690
apply (subst match_Lam_simps)
2173
+ − 691
defer
2165
+ − 692
apply (simp only: option.cases)
+ − 693
apply (simp only: prod.cases)
+ − 694
apply (subst (2) subst.simps)
+ − 695
apply (subst match_Var_simps)
+ − 696
apply (simp only: option.cases)
+ − 697
apply (subst match_App_simps)
+ − 698
apply (simp only: option.cases)
2173
+ − 699
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)
+ − 700
defer
2165
+ − 701
apply (subst match_Lam_simps)
2173
+ − 702
defer
2165
+ − 703
apply (simp only: option.cases)
+ − 704
apply (simp only: prod.cases)
+ − 705
apply (simp only: lam.perm)
2173
+ − 706
thm 1(1)
2165
+ − 707
sorry
+ − 708
qed
+ − 709
qed
+ − 710
2172
+ − 711
lemma subst_proper_eqs:
+ − 712
"subst y s (Var x) = (if x = y then s else (Var x))"
+ − 713
"subst y s (App l r) = App (subst y s l) (subst y s r)"
+ − 714
"atom x \<sharp> (t, s) \<Longrightarrow> subst y s (Lam x t) = Lam x (subst y s t)"
+ − 715
apply (subst subst.simps)
+ − 716
apply (simp only: match_Var_simps)
+ − 717
apply (simp only: option.simps)
+ − 718
apply (subst subst.simps)
+ − 719
apply (simp only: match_App_simps)
+ − 720
apply (simp only: option.simps)
+ − 721
apply (simp only: prod.simps)
+ − 722
apply (simp only: match_Var_simps)
+ − 723
apply (simp only: option.simps)
+ − 724
apply (subst subst.simps)
+ − 725
apply (simp only: match_Var_simps)
2173
+ − 726
apply (simp only: option.simps)
2172
+ − 727
apply (simp only: match_App_simps)
+ − 728
apply (simp only: option.simps)
2173
+ − 729
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)
+ − 730
defer
+ − 731
apply (subst match_Lam_simps)
+ − 732
defer
2172
+ − 733
apply (simp only: option.simps)
+ − 734
apply (simp only: prod.simps)
2157
+ − 735
sorry
2436
+ − 736
*)
1594
+ − 737
end
+ − 738
+ − 739
+ − 740