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
2784
+ − 5
1594
+ − 6
atom_decl name
+ − 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"
2683
+ − 11
| Lam x::"name" l::"lam" bind x in l ("Lam [_]. _" [100, 100] 100)
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 12
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 13
lemma cheat: "P" sorry
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 14
2814
+ − 15
thm lam.strong_exhaust
+ − 16
+ − 17
lemma lam_strong_exhaust2:
+ − 18
"\<lbrakk>\<And>name. y = Var name \<Longrightarrow> P;
+ − 19
\<And>lam1 lam2. y = App lam1 lam2 \<Longrightarrow> P;
+ − 20
\<And>name lam. \<lbrakk>{atom name} \<sharp>* c; y = Lam [name]. lam\<rbrakk> \<Longrightarrow> P;
+ − 21
finite (supp c)\<rbrakk>
+ − 22
\<Longrightarrow> P"
+ − 23
sorry
+ − 24
+ − 25
abbreviation
+ − 26
"FCB f \<equiv> \<forall>x t r. atom x \<sharp> f x t r"
+ − 27
2809
+ − 28
lemma Abs1_eq_fdest:
+ − 29
fixes x y :: "'a :: at_base"
+ − 30
and S T :: "'b :: fs"
+ − 31
assumes "(Abs_lst [atom x] T) = (Abs_lst [atom y] S)"
+ − 32
and "x \<noteq> y \<Longrightarrow> atom y \<sharp> T \<Longrightarrow> atom x \<sharp> f x T"
+ − 33
and "x \<noteq> y \<Longrightarrow> atom y \<sharp> T \<Longrightarrow> atom y \<sharp> f x T"
+ − 34
and "x \<noteq> y \<Longrightarrow> atom y \<sharp> T \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> T = S \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> (f x T) = f y S"
+ − 35
and "sort_of (atom x) = sort_of (atom y)"
+ − 36
shows "f x T = f y S"
+ − 37
using assms apply -
+ − 38
apply (subst (asm) Abs1_eq_iff')
+ − 39
apply simp_all
+ − 40
apply (elim conjE disjE)
+ − 41
apply simp
+ − 42
apply(rule trans)
+ − 43
apply (rule_tac p="(atom x \<rightleftharpoons> atom y)" in supp_perm_eq[symmetric])
+ − 44
apply(rule fresh_star_supp_conv)
+ − 45
apply(simp add: supp_swap fresh_star_def)
+ − 46
apply(simp add: swap_commute)
+ − 47
done
+ − 48
+ − 49
lemma fresh_fun_eqvt_app3:
+ − 50
assumes a: "eqvt f"
+ − 51
and b: "a \<sharp> x" "a \<sharp> y" "a \<sharp> z"
+ − 52
shows "a \<sharp> f x y z"
+ − 53
using fresh_fun_eqvt_app[OF a b(1)] a b
+ − 54
by (metis fresh_fun_app)
+ − 55
2814
+ − 56
locale test =
+ − 57
fixes f1::"name \<Rightarrow> ('a::pt)"
+ − 58
and f2::"lam \<Rightarrow> lam \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> ('a::pt)"
+ − 59
and f3::"name \<Rightarrow> lam \<Rightarrow> 'a \<Rightarrow> ('a::pt)"
+ − 60
assumes fs: "finite (supp (f1, f2, f3))"
+ − 61
and eq: "eqvt f1" "eqvt f2" "eqvt f3"
+ − 62
and fcb: "\<forall>x t r. atom x \<sharp> f3 x t r"
+ − 63
begin
+ − 64
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 65
nominal_primrec
2814
+ − 66
f :: "lam \<Rightarrow> ('a::pt)"
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 67
where
2814
+ − 68
"f (Var x) = f1 x"
+ − 69
| "f (App t1 t2) = f2 t1 t2 (f t1) (f t2)"
2816
+ − 70
| "f (Lam [x].t) = f3 x t (f t)"
2809
+ − 71
apply (simp add: eqvt_def f_graph_def)
2814
+ − 72
apply (perm_simp)
+ − 73
apply(simp add: eq[simplified eqvt_def])
2816
+ − 74
apply(rule_tac y="x" in lam.exhaust)
2809
+ − 75
apply(auto simp add: fresh_star_def)
+ − 76
apply(erule Abs1_eq_fdest)
+ − 77
apply simp_all
2814
+ − 78
apply(simp add: fcb)
2816
+ − 79
apply (rule fresh_fun_eqvt_app3[OF eq(3)])
+ − 80
apply (simp add: fresh_at_base)
+ − 81
apply assumption
+ − 82
apply (erule fresh_eqvt_at)
+ − 83
apply (simp add: finite_supp)
+ − 84
apply assumption
2814
+ − 85
apply (subgoal_tac "\<And>p y r. p \<bullet> (f3 x y r) = f3 (p \<bullet> x) (p \<bullet> y) (p \<bullet> r)")
2816
+ − 86
apply (simp add: eqvt_at_def)
+ − 87
apply (simp add: permute_fun_app_eq eq[unfolded eqvt_def])
+ − 88
done
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 89
2816
+ − 90
termination
+ − 91
by (relation "measure size") (auto simp add: lam.size)
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 92
2814
+ − 93
end
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 94
2814
+ − 95
thm test.f.simps
+ − 96
+ − 97
thm test_def
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 98
2816
+ − 99
interpretation hei: test
+ − 100
"%n. (1 :: nat)"
+ − 101
"%t1 t2 r1 r2. (r1 + r2)"
+ − 102
"%n t r. r + 1"
+ − 103
apply default
+ − 104
apply (auto simp add: pure_fresh supp_Pair)
+ − 105
apply (simp_all add: fresh_def supp_def permute_fun_def permute_pure)[3]
+ − 106
apply (simp_all add: eqvt_def permute_fun_def permute_pure)
+ − 107
done
+ − 108
+ − 109
thm hei.f.simps
+ − 110
2807
13af2c8d7329
a test with a recursion combinator defined on top of nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 111
2802
+ − 112
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 113
inductive
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 114
triv :: "lam \<Rightarrow> nat \<Rightarrow> bool"
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 115
where
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 116
Var: "triv (Var x) n"
2779
+ − 117
| App: "\<lbrakk>triv t1 n; triv t2 n\<rbrakk> \<Longrightarrow> triv (App t1 t2) n"
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 118
2777
75a95431cd8b
proved that lfp is equivariant (that simplifies equivariance proofs of inductively defined predicates)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 119
lemma
75a95431cd8b
proved that lfp is equivariant (that simplifies equivariance proofs of inductively defined predicates)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 120
"p \<bullet> (triv t x) = triv (p \<bullet> t) (p \<bullet> x)"
75a95431cd8b
proved that lfp is equivariant (that simplifies equivariance proofs of inductively defined predicates)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 121
unfolding triv_def
75a95431cd8b
proved that lfp is equivariant (that simplifies equivariance proofs of inductively defined predicates)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 122
apply(perm_simp)
2779
+ − 123
apply(rule refl)
2777
75a95431cd8b
proved that lfp is equivariant (that simplifies equivariance proofs of inductively defined predicates)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 124
oops
75a95431cd8b
proved that lfp is equivariant (that simplifies equivariance proofs of inductively defined predicates)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 125
(*apply(perm_simp)*)
75a95431cd8b
proved that lfp is equivariant (that simplifies equivariance proofs of inductively defined predicates)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 126
2779
+ − 127
ML {*
+ − 128
Inductive.the_inductive @{context} "Lambda.triv"
+ − 129
*}
+ − 130
+ − 131
thm triv_def
+ − 132
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 133
equivariance triv
2768
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 134
nominal_inductive triv avoids Var: "{}::name set"
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 135
apply(auto simp add: fresh_star_def)
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 136
done
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 137
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 138
inductive
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 139
triv2 :: "lam \<Rightarrow> nat \<Rightarrow> bool"
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 140
where
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 141
Var1: "triv2 (Var x) 0"
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 142
| Var2: "triv2 (Var x) (n + n)"
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 143
| Var3: "triv2 (Var x) n"
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 144
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 145
equivariance triv2
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 146
nominal_inductive triv2 .
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 147
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 148
2683
+ − 149
text {* height function *}
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 150
2666
+ − 151
nominal_primrec
2678
+ − 152
height :: "lam \<Rightarrow> int"
2666
+ − 153
where
2678
+ − 154
"height (Var x) = 1"
2683
+ − 155
| "height (App t1 t2) = max (height t1) (height t2) + 1"
+ − 156
| "height (Lam [x].t) = height t + 1"
2791
+ − 157
unfolding eqvt_def height_graph_def
+ − 158
apply (rule, perm_simp, rule)
2666
+ − 159
apply(rule_tac y="x" in lam.exhaust)
2683
+ − 160
apply(auto simp add: lam.distinct lam.eq_iff)
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 161
apply (erule Abs1_eq_fdest)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 162
apply(simp_all add: fresh_def pure_supp eqvt_at_def)
2666
+ − 163
done
+ − 164
+ − 165
termination
2683
+ − 166
by (relation "measure size") (simp_all add: lam.size)
2666
+ − 167
2707
+ − 168
thm height.simps
+ − 169
2683
+ − 170
+ − 171
text {* free name function - returns atom lists *}
2666
+ − 172
+ − 173
nominal_primrec
+ − 174
frees_lst :: "lam \<Rightarrow> atom list"
+ − 175
where
+ − 176
"frees_lst (Var x) = [atom x]"
2683
+ − 177
| "frees_lst (App t1 t2) = frees_lst t1 @ frees_lst t2"
+ − 178
| "frees_lst (Lam [x]. t) = removeAll (atom x) (frees_lst t)"
2791
+ − 179
unfolding eqvt_def frees_lst_graph_def
+ − 180
apply (rule, perm_simp, rule)
2666
+ − 181
apply(rule_tac y="x" in lam.exhaust)
2793
+ − 182
apply(auto)
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 183
apply (erule Abs1_eq_fdest)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 184
apply(simp add: supp_removeAll fresh_def)
2666
+ − 185
apply(drule supp_eqvt_at)
+ − 186
apply(simp add: finite_supp)
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 187
apply(auto simp add: fresh_def supp_removeAll eqvts eqvt_at_def)
2666
+ − 188
done
+ − 189
+ − 190
termination
2793
+ − 191
by (relation "measure size") (simp_all add: lam.size)
2666
+ − 192
2683
+ − 193
text {* a small test lemma *}
2666
+ − 194
lemma
2683
+ − 195
shows "supp t = set (frees_lst t)"
+ − 196
apply(induct t rule: frees_lst.induct)
2666
+ − 197
apply(simp_all add: lam.supp supp_at_base)
+ − 198
done
+ − 199
2683
+ − 200
text {* capture - avoiding substitution *}
+ − 201
2675
+ − 202
nominal_primrec
2683
+ − 203
subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_ [_ ::= _]" [90, 90, 90] 90)
2675
+ − 204
where
2683
+ − 205
"(Var x)[y ::= s] = (if x = y then s else (Var x))"
+ − 206
| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
+ − 207
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
2791
+ − 208
unfolding eqvt_def subst_graph_def
+ − 209
apply (rule, perm_simp, rule)
2683
+ − 210
apply(auto simp add: lam.distinct lam.eq_iff)
+ − 211
apply(rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust)
+ − 212
apply(blast)+
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 213
apply(simp_all add: fresh_star_def fresh_Pair_elim)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 214
apply (erule Abs1_eq_fdest)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 215
apply(simp_all add: Abs_fresh_iff)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 216
apply(drule_tac a="atom (xa)" in fresh_eqvt_at)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 217
apply(simp_all add: finite_supp fresh_Pair)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 218
apply(subgoal_tac "(atom x \<rightleftharpoons> atom xa) \<bullet> sa = sa")
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 219
apply(subgoal_tac "(atom x \<rightleftharpoons> atom xa) \<bullet> ya = ya")
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 220
apply(simp add: eqvt_at_def)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 221
apply(rule perm_supp_eq,simp add: fresh_star_def fresh_Pair supp_swap)+
2675
+ − 222
done
+ − 223
2678
+ − 224
termination
2793
+ − 225
by (relation "measure (\<lambda>(t,_,_). size t)") (simp_all add: lam.size)
2683
+ − 226
+ − 227
lemma subst_eqvt[eqvt]:
+ − 228
shows "(p \<bullet> t[x ::= s]) = (p \<bullet> t)[(p \<bullet> x) ::= (p \<bullet> s)]"
+ − 229
by (induct t x s rule: subst.induct) (simp_all)
+ − 230
+ − 231
lemma forget:
+ − 232
shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
+ − 233
apply(nominal_induct t avoiding: x s rule: lam.strong_induct)
+ − 234
apply(auto simp add: lam.fresh fresh_at_base)
+ − 235
done
+ − 236
+ − 237
text {* same lemma but with subst.induction *}
+ − 238
lemma forget2:
+ − 239
shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
+ − 240
apply(induct t x s rule: subst.induct)
+ − 241
apply(auto simp add: lam.fresh fresh_at_base fresh_Pair)
+ − 242
done
+ − 243
+ − 244
lemma fresh_fact:
+ − 245
fixes z::"name"
+ − 246
assumes a: "atom z \<sharp> s"
+ − 247
and b: "z = y \<or> atom z \<sharp> t"
+ − 248
shows "atom z \<sharp> t[y ::= s]"
+ − 249
using a b
+ − 250
apply (nominal_induct t avoiding: z y s rule: lam.strong_induct)
+ − 251
apply (auto simp add: lam.fresh fresh_at_base)
+ − 252
done
+ − 253
+ − 254
lemma substitution_lemma:
+ − 255
assumes a: "x \<noteq> y" "atom x \<sharp> u"
+ − 256
shows "t[x ::= s][y ::= u] = t[y ::= u][x ::= s[y ::= u]]"
+ − 257
using a
+ − 258
by (nominal_induct t avoiding: x y s u rule: lam.strong_induct)
+ − 259
(auto simp add: fresh_fact forget)
+ − 260
+ − 261
lemma subst_rename:
+ − 262
assumes a: "atom y \<sharp> t"
+ − 263
shows "t[x ::= s] = ((y \<leftrightarrow> x) \<bullet>t)[y ::= s]"
+ − 264
using a
+ − 265
apply (nominal_induct t avoiding: x y s rule: lam.strong_induct)
+ − 266
apply (auto simp add: lam.fresh fresh_at_base)
+ − 267
done
+ − 268
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 269
lemma height_ge_one:
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 270
shows "1 \<le> (height e)"
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 271
by (induct e rule: lam.induct) (simp_all)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 272
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 273
theorem height_subst:
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 274
shows "height (e[x::=e']) \<le> ((height e) - 1) + (height e')"
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 275
proof (nominal_induct e avoiding: x e' rule: lam.strong_induct)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 276
case (Var y)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 277
have "1 \<le> height e'" by (rule height_ge_one)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 278
then show "height (Var y[x::=e']) \<le> height (Var y) - 1 + height e'" by simp
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 279
next
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 280
case (Lam y e1)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 281
hence ih: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')" by simp
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 282
moreover
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 283
have vc: "atom y\<sharp>x" "atom y\<sharp>e'" by fact+ (* usual variable convention *)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 284
ultimately show "height ((Lam [y]. e1)[x::=e']) \<le> height (Lam [y]. e1) - 1 + height e'" by simp
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 285
next
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 286
case (App e1 e2)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 287
hence ih1: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')"
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 288
and ih2: "height (e2[x::=e']) \<le> ((height e2) - 1) + (height e')" by simp_all
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 289
then show "height ((App e1 e2)[x::=e']) \<le> height (App e1 e2) - 1 + height e'" by simp
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 290
qed
2683
+ − 291
+ − 292
subsection {* single-step beta-reduction *}
+ − 293
+ − 294
inductive
+ − 295
beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b _" [80,80] 80)
+ − 296
where
+ − 297
b1[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> App t1 s \<longrightarrow>b App t2 s"
+ − 298
| b2[intro]: "s1 \<longrightarrow>b s2 \<Longrightarrow> App t s1 \<longrightarrow>b App t s2"
+ − 299
| b3[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> Lam [x]. t1 \<longrightarrow>b Lam [x]. t2"
+ − 300
| b4[intro]: "atom x \<sharp> s \<Longrightarrow> App (Lam [x]. t) s \<longrightarrow>b t[x ::= s]"
+ − 301
+ − 302
equivariance beta
+ − 303
+ − 304
nominal_inductive beta
+ − 305
avoids b4: "x"
+ − 306
by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
+ − 307
+ − 308
text {* One-Reduction *}
+ − 309
+ − 310
inductive
+ − 311
One :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>1 _" [80,80] 80)
+ − 312
where
+ − 313
o1[intro]: "Var x \<longrightarrow>1 Var x"
+ − 314
| o2[intro]: "\<lbrakk>t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>1 App t2 s2"
+ − 315
| o3[intro]: "t1 \<longrightarrow>1 t2 \<Longrightarrow> Lam [x].t1 \<longrightarrow>1 Lam [x].t2"
+ − 316
| o4[intro]: "\<lbrakk>atom x \<sharp> (s1, s2); t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]"
+ − 317
+ − 318
equivariance One
+ − 319
+ − 320
nominal_inductive One
+ − 321
avoids o3: "x"
+ − 322
| o4: "x"
+ − 323
by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
+ − 324
+ − 325
lemma One_refl:
+ − 326
shows "t \<longrightarrow>1 t"
+ − 327
by (nominal_induct t rule: lam.strong_induct) (auto)
+ − 328
+ − 329
lemma One_subst:
+ − 330
assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
+ − 331
shows "t1[x ::= s1] \<longrightarrow>1 t2[x ::= s2]"
+ − 332
using a
+ − 333
apply(nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct)
+ − 334
apply(auto simp add: substitution_lemma fresh_at_base fresh_fact fresh_Pair)
+ − 335
done
+ − 336
+ − 337
lemma better_o4_intro:
+ − 338
assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
+ − 339
shows "App (Lam [x]. t1) s1 \<longrightarrow>1 t2[ x ::= s2]"
+ − 340
proof -
2685
+ − 341
obtain y::"name" where fs: "atom y \<sharp> (x, t1, s1, t2, s2)" by (rule obtain_fresh)
2683
+ − 342
have "App (Lam [x]. t1) s1 = App (Lam [y]. ((y \<leftrightarrow> x) \<bullet> t1)) s1" using fs
+ − 343
by (auto simp add: lam.eq_iff Abs1_eq_iff' flip_def fresh_Pair fresh_at_base)
+ − 344
also have "\<dots> \<longrightarrow>1 ((y \<leftrightarrow> x) \<bullet> t2)[y ::= s2]" using fs a by (auto simp add: One.eqvt)
+ − 345
also have "\<dots> = t2[x ::= s2]" using fs by (simp add: subst_rename[symmetric])
+ − 346
finally show "App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]" by simp
+ − 347
qed
+ − 348
+ − 349
+ − 350
+ − 351
section {* Locally Nameless Terms *}
2678
+ − 352
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 353
nominal_datatype ln =
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 354
LNBnd nat
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 355
| LNVar name
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 356
| LNApp ln ln
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 357
| LNLam ln
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 358
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 359
fun
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 360
lookup :: "name list \<Rightarrow> nat \<Rightarrow> name \<Rightarrow> ln"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 361
where
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 362
"lookup [] n x = LNVar x"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 363
| "lookup (y # ys) n x = (if x = y then LNBnd n else (lookup ys (n + 1) x))"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 364
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 365
lemma [eqvt]:
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 366
shows "(p \<bullet> lookup xs n x) = lookup (p \<bullet> xs) (p \<bullet> n) (p \<bullet> x)"
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 367
by (induct xs arbitrary: n) (simp_all add: permute_pure)
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 368
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 369
nominal_primrec
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 370
trans :: "lam \<Rightarrow> name list \<Rightarrow> ln"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 371
where
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 372
"trans (Var x) xs = lookup xs 0 x"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 373
| "trans (App t1 t2) xs = LNApp (trans t1 xs) (trans t2 xs)"
2685
+ − 374
| "atom x \<sharp> xs \<Longrightarrow> trans (Lam [x]. t) xs = LNLam (trans t (x # xs))"
2791
+ − 375
unfolding eqvt_def trans_graph_def
+ − 376
apply (rule, perm_simp, rule)
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 377
apply(case_tac x)
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 378
apply(simp)
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 379
apply(rule_tac y="a" and c="b" in lam.strong_exhaust)
2729
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 380
apply(simp_all add: fresh_star_def)[3]
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 381
apply(blast)
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 382
apply(blast)
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 383
apply(simp_all add: lam.distinct lam.eq_iff)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 384
apply(elim conjE)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 385
apply clarify
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 386
apply (erule Abs1_eq_fdest)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 387
apply (simp_all add: ln.fresh)
2675
+ − 388
prefer 2
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 389
apply(drule supp_eqvt_at)
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 390
apply (auto simp add: finite_supp supp_Pair fresh_def supp_Cons supp_at_base)[2]
2729
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 391
prefer 2
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 392
apply (subgoal_tac "(atom x \<rightleftharpoons> atom xa) \<bullet> xsa = xsa")
2729
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 393
apply (simp add: eqvt_at_def)
2767
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 394
apply (metis atom_name_def swap_fresh_fresh)
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 395
oops
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 396
2729
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 397
(* lemma helpr: "atom x \<sharp> ta \<Longrightarrow> Lam [xa]. ta = Lam [x]. ((xa \<leftrightarrow> x) \<bullet> ta)"
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 398
apply (case_tac "x = xa")
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 399
apply simp
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 400
apply (simp add: lam.eq_iff Abs1_eq_iff flip_def[symmetric])
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 401
by (metis atom_eqvt flip_at_simps(2) fresh_permute_iff)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 402
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 403
lemma supp_lookup: "supp (lookup l n name) = {atom name} - supp l"
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 404
apply (induct l arbitrary: n)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 405
apply (simp_all add: ln.supp supp_at_base supp_Nil supp_Cons pure_supp)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 406
done
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 407
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 408
lemma trans_eqvt[eqvt]: "p \<bullet> (trans t l) = trans (p \<bullet> t) (p \<bullet> l)"
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 409
apply (induct t l rule: trans.induct)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 410
apply simp_all
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 411
apply (simp add: eqvts permute_pure)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 412
done
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 413
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 414
lemma diff_un: "a - (b \<union> c) = a - b - c"
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 415
by blast
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 416
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 417
lemma supp_trans: "supp (trans t l) = supp t - supp l"
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 418
apply (induct t arbitrary: l rule: lam.induct)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 419
apply (simp_all add: lam.supp supp_at_base supp_lookup ln.supp)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 420
apply blast
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 421
apply (rule_tac x="(lam, l)" and ?'a="name" in obtain_fresh)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 422
apply (simp add: fresh_Pair)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 423
apply clarify
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 424
apply (subgoal_tac "supp (Lambda.trans (Lam [a]. ((name \<leftrightarrow> a) \<bullet> lam)) l) =
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 425
supp lam - {atom name} - supp l")
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 426
using helpr
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 427
apply simp
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 428
apply (simp add: ln.supp)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 429
apply (subgoal_tac "supp ((name \<leftrightarrow> a) \<bullet> (Lambda.trans lam ((name \<leftrightarrow> a) \<bullet> (a # l)))) = supp lam - {atom name} - supp l")
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 430
apply (simp add: trans_eqvt)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 431
apply (simp add: supp_eqvt[symmetric])
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 432
apply (simp add: Diff_eqvt)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 433
apply (simp add: supp_eqvt supp_Cons union_eqvt)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 434
apply (simp add: diff_un)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 435
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1*})
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 436
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1*})
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 437
apply rule
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 438
prefer 2
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 439
apply rule
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 440
apply (simp add: supp_at_base)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 441
apply (subgoal_tac "(name \<leftrightarrow> a) \<bullet> (supp lam - {atom name}) = supp lam - {atom name}")
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 442
apply (simp add: eqvts)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 443
unfolding flip_def
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 444
apply (rule swap_fresh_fresh)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 445
apply (metis fresh_at_base fresh_def fresh_minus_atom_set lam.fsupp supp_at_base)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 446
by (metis fresh_def fresh_finite_atom_set fresh_minus_atom_set lam.fsupp)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 447
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 448
lemma "atom x \<sharp> trans_sumC (t, x # xsa)"
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 449
by (simp add: fresh_def meta_eq_to_obj_eq[OF trans_def, symmetric, unfolded fun_eq_iff] supp_trans supp_Cons supp_at_base)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 450
*)
337748e9b6b5
Reduce the definition of trans to FCB; test that FCB can be proved with simp rules.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 451
2667
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 452
nominal_datatype db =
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 453
DBVar nat
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 454
| DBApp db db
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 455
| DBLam db
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 456
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 457
fun dbapp_in where
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 458
"dbapp_in None _ = None"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 459
| "dbapp_in (Some _ ) None = None"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 460
| "dbapp_in (Some x) (Some y) = Some (DBApp x y)"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 461
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 462
fun dblam_in where
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 463
"dblam_in None = None"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 464
| "dblam_in (Some x) = Some (DBLam x)"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 465
2798
+ − 466
lemma db_in_eqvt[eqvt]:
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 467
"p \<bullet> (dbapp_in x y) = dbapp_in (p \<bullet> x) (p \<bullet> y)"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 468
"p \<bullet> (dblam_in x) = dblam_in (p \<bullet> x)"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 469
apply (case_tac [!] x)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 470
apply (simp_all add: eqvts)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 471
apply (case_tac y)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 472
apply (simp_all add: eqvts)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 473
done
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 474
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 475
instance db :: pure
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 476
apply default
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 477
apply (induct_tac x rule: db.induct)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 478
apply (simp_all add: permute_pure)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 479
done
2795
+ − 480
+ − 481
lemma fresh_at_list: "atom x \<sharp> xs \<longleftrightarrow> x \<notin> set xs"
+ − 482
unfolding fresh_def supp_set[symmetric]
+ − 483
apply (induct xs)
+ − 484
apply (simp add: supp_set_empty)
+ − 485
apply simp
+ − 486
apply auto
+ − 487
apply (simp_all add: insert_absorb UnI2 finite_set supp_of_finite_insert supp_at_base)
+ − 488
done
+ − 489
2800
+ − 490
fun
+ − 491
vindex :: "name list \<Rightarrow> name \<Rightarrow> nat \<Rightarrow> db option"
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 492
where
2800
+ − 493
"vindex [] v n = None"
+ − 494
| "vindex (h # t) v n = (if v = h then (Some (DBVar n)) else (vindex t v (Suc n)))"
+ − 495
+ − 496
lemma vindex_eqvt[eqvt]:
+ − 497
"(p \<bullet> vindex l v n) = vindex (p \<bullet> l) (p \<bullet> v) (p \<bullet> n)"
+ − 498
by (induct l arbitrary: n) (simp_all add: permute_pure)
+ − 499
+ − 500
nominal_primrec
+ − 501
trans :: "lam \<Rightarrow> name list \<Rightarrow> db option"
+ − 502
where
+ − 503
"trans (Var x) l = vindex l x 0"
+ − 504
| "trans (App t1 t2) xs = dbapp_in (trans t1 xs) (trans t2 xs)"
+ − 505
| "x \<notin> set xs \<Longrightarrow> trans (Lam [x].t) xs = dblam_in (trans t (x # xs))"
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 506
unfolding eqvt_def trans_graph_def
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 507
apply (rule, perm_simp, rule)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 508
apply (case_tac x)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 509
apply (rule_tac y="a" and c="b" in lam.strong_exhaust)
2795
+ − 510
apply (auto simp add: fresh_star_def fresh_at_list)
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 511
apply (rule_tac f="dblam_in" in arg_cong)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 512
apply (erule Abs1_eq_fdest)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 513
apply (simp_all add: pure_fresh)
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 514
apply (subgoal_tac "(atom x \<rightleftharpoons> atom xa) \<bullet> xsa = xsa")
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 515
apply (simp add: eqvt_at_def)
2795
+ − 516
apply (metis atom_name_def swap_fresh_fresh fresh_at_list)
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 517
done
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 518
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 519
termination
2800
+ − 520
by (relation "measure (\<lambda>(t,_). size t)") (simp_all add: lam.size)
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 521
2797
+ − 522
lemma trans_eqvt[eqvt]:
2800
+ − 523
"p \<bullet> trans t l = trans (p \<bullet>t) (p \<bullet>l)"
+ − 524
apply (nominal_induct t avoiding: l p rule: lam.strong_induct)
+ − 525
apply (simp add: vindex_eqvt)
+ − 526
apply (simp_all add: permute_pure)
2797
+ − 527
apply (simp add: fresh_at_list)
+ − 528
apply (subst trans.simps)
+ − 529
apply (simp add: fresh_at_list[symmetric])
2800
+ − 530
apply (drule_tac x="name # l" in meta_spec)
+ − 531
apply auto
2797
+ − 532
done
+ − 533
2802
+ − 534
(*
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 535
lemma db_trans_test:
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 536
assumes a: "y \<noteq> x"
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 537
shows "trans (Lam [x]. Lam [y]. App (Var x) (Var y)) [] 0 = Some (DBLam (DBLam (DBApp (DBVar 1) (DBVar 0))))"
2795
+ − 538
using a by simp
2802
+ − 539
*)
2792
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 540
2667
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 541
abbreviation
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 542
mbind :: "'a option => ('a => 'b option) => 'b option" ("_ \<guillemotright>= _" [65,65] 65)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 543
where
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 544
"c \<guillemotright>= f \<equiv> case c of None => None | (Some v) => f v"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 545
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 546
lemma mbind_eqvt:
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 547
fixes c::"'a::pt option"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 548
shows "(p \<bullet> (c \<guillemotright>= f)) = ((p \<bullet> c) \<guillemotright>= (p \<bullet> f))"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 549
apply(cases c)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 550
apply(simp_all)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 551
apply(perm_simp)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 552
apply(rule refl)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 553
done
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 554
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 555
lemma mbind_eqvt_raw[eqvt_raw]:
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 556
shows "(p \<bullet> option_case) \<equiv> option_case"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 557
apply(rule eq_reflection)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 558
apply(rule ext)+
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 559
apply(case_tac xb)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 560
apply(simp_all)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 561
apply(rule_tac p="-p" in permute_boolE)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 562
apply(perm_simp add: permute_minus_cancel)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 563
apply(simp)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 564
apply(rule_tac p="-p" in permute_boolE)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 565
apply(perm_simp add: permute_minus_cancel)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 566
apply(simp)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 567
done
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 568
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 569
fun
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 570
index :: "atom list \<Rightarrow> nat \<Rightarrow> atom \<Rightarrow> nat option"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 571
where
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 572
"index [] n x = None"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 573
| "index (y # ys) n x = (if x = y then (Some n) else (index ys (n + 1) x))"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 574
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 575
lemma [eqvt]:
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 576
shows "(p \<bullet> index xs n x) = index (p \<bullet> xs) (p \<bullet> n) (p \<bullet> x)"
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 577
apply(induct xs arbitrary: n)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 578
apply(simp_all add: permute_pure)
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 579
done
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 580
2789
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 581
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 582
text {* tests of functions containing if and case *}
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 583
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 584
consts P :: "lam \<Rightarrow> bool"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 585
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 586
nominal_primrec
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 587
A :: "lam => lam"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 588
where
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 589
"A (App M N) = (if (True \<or> P M) then (A M) else (A N))"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 590
| "A (Var x) = (Var x)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 591
| "A (App M N) = (if True then M else A N)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 592
oops
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 593
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 594
nominal_primrec
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 595
C :: "lam => lam"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 596
where
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 597
"C (App M N) = (case (True \<or> P M) of True \<Rightarrow> (A M) | False \<Rightarrow> (A N))"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 598
| "C (Var x) = (Var x)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 599
| "C (App M N) = (if True then M else C N)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 600
oops
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 601
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 602
nominal_primrec
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 603
map_term :: "(lam \<Rightarrow> lam) \<Rightarrow> lam \<Rightarrow> lam"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 604
where
2794
+ − 605
"eqvt f \<Longrightarrow> map_term f (Var x) = f (Var x)"
+ − 606
| "eqvt f \<Longrightarrow> map_term f (App t1 t2) = App (f t1) (f t2)"
+ − 607
| "eqvt f \<Longrightarrow> map_term f (Lam [x].t) = Lam [x].(f t)"
+ − 608
| "\<not>eqvt f \<Longrightarrow> map_term f t = t"
+ − 609
apply (simp add: eqvt_def map_term_graph_def)
+ − 610
apply (rule, perm_simp, rule)
+ − 611
apply (case_tac x, case_tac "eqvt a", case_tac b rule: lam.exhaust)
+ − 612
apply auto
2806
+ − 613
apply (erule Abs1_eq_fdest)
+ − 614
apply (simp_all add: Abs_fresh_iff fresh_fun_eqvt_app)
2794
+ − 615
apply (simp add: eqvt_def permute_fun_app_eq)
+ − 616
done
+ − 617
+ − 618
termination
+ − 619
by (relation "measure (\<lambda>(_,t). size t)") (simp_all add: lam.size)
+ − 620
2789
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 621
nominal_primrec
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 622
A :: "lam => lam"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 623
where
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 624
"A (Lam [x].M) = (Lam [x].M)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 625
| "A (Var x) = (Var x)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 626
| "A (App M N) = (if True then M else A N)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 627
oops
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 628
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 629
nominal_primrec
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 630
B :: "lam => lam"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 631
where
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 632
"B (Lam [x].M) = (Lam [x].M)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 633
| "B (Var x) = (Var x)"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 634
| "B (App M N) = (if True then M else (B N))"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 635
unfolding eqvt_def
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 636
unfolding B_graph_def
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 637
apply(perm_simp)
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 638
apply(rule allI)
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 639
apply(rule refl)
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 640
oops
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 641
2796
+ − 642
text {* "HO" functions *}
2789
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 643
2667
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 644
nominal_primrec
2796
+ − 645
trans2 :: "lam \<Rightarrow> atom list \<Rightarrow> db option"
2667
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 646
where
2796
+ − 647
"trans2 (Var x) xs = (index xs 0 (atom x) \<guillemotright>= (\<lambda>n. Some (DBVar n)))"
+ − 648
| "trans2 (App t1 t2) xs = ((trans2 t1 xs) \<guillemotright>= (\<lambda>db1. (trans2 t2 xs) \<guillemotright>= (\<lambda>db2. Some (DBApp db1 db2))))"
+ − 649
| "trans2 (Lam [x].t) xs = (trans2 t (atom x # xs) \<guillemotright>= (\<lambda>db. Some (DBLam db)))"
+ − 650
oops
2667
e3f8673085b1
added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 651
2789
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 652
nominal_primrec
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 653
CPS :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 654
where
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 655
"CPS (Var x) k = Var x"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 656
| "CPS (App M N) k = CPS M (\<lambda>m. CPS N (\<lambda>n. n))"
2796
+ − 657
oops
2789
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 658
2799
+ − 659
(* Problem: nominal_primrec generates non-quantified free variable "x" *)
+ − 660
consts b :: name
+ − 661
nominal_primrec
+ − 662
Z :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
+ − 663
where
+ − 664
"Z (App M N) k = Z M (%m. (Z N (%n.(App m n))))"
2806
+ − 665
| "Z (App M N) k = Z M (%m. (Z N (%n.(App (App m n) (Abs b (k (Var b)))))))"
2799
+ − 666
unfolding eqvt_def Z_graph_def
+ − 667
apply (rule, perm_simp, rule)
+ − 668
oops
2789
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 669
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 670
(* function tests *)
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 671
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 672
(* similar problem with function package *)
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 673
function
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 674
f :: "int list \<Rightarrow> int"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 675
where
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 676
"f [] = 0"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 677
| "f [e] = e"
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 678
| "f (l @ m) = f l + f m"
2806
+ − 679
apply(simp_all)
2789
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 680
oops
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 681
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 682
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 683
32979078bfe9
functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 684
2675
+ − 685
2666
+ − 686
1594
+ − 687
end
+ − 688
+ − 689
+ − 690