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
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2
imports
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 3
"../Nominal2"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 4
"~~/src/HOL/Library/Monad_Syntax"
1594
+ − 5
begin
+ − 6
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 7
1594
+ − 8
atom_decl name
+ − 9
3174
8f51702e1f2e
improved handling in the simplifier for inequalities derived from freshness assumptions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 10
3157
de89c95c5377
updated to latest changes (10 April) to quotient package (lift_raw_const only takes dummy theorem TrueI....in the future this will not work anymore)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 11
ML {* trace := true *}
de89c95c5377
updated to latest changes (10 April) to quotient package (lift_raw_const only takes dummy theorem TrueI....in the future this will not work anymore)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 12
2436
+ − 13
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
+ − 14
Var "name"
2436
+ − 15
| App "lam" "lam"
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 16
| Lam x::"name" l::"lam" binds 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
+ − 17
3047
+ − 18
lemma alpha_lam_raw_eqvt[eqvt]: "p \<bullet> (alpha_lam_raw x y) = alpha_lam_raw (p \<bullet> x) (p \<bullet> y)"
+ − 19
unfolding alpha_lam_raw_def
+ − 20
by perm_simp rule
+ − 21
+ − 22
lemma abs_lam_eqvt[eqvt]: "(p \<bullet> abs_lam t) = abs_lam (p \<bullet> t)"
+ − 23
proof -
+ − 24
have "alpha_lam_raw (rep_lam (abs_lam t)) t"
3157
de89c95c5377
updated to latest changes (10 April) to quotient package (lift_raw_const only takes dummy theorem TrueI....in the future this will not work anymore)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 25
using rep_abs_rsp_left Quotient3_lam equivp_reflp lam_equivp by metis
3047
+ − 26
then have "alpha_lam_raw (p \<bullet> rep_lam (abs_lam t)) (p \<bullet> t)"
+ − 27
unfolding alpha_lam_raw_eqvt[symmetric] permute_pure .
+ − 28
then have "abs_lam (p \<bullet> rep_lam (abs_lam t)) = abs_lam (p \<bullet> t)"
3157
de89c95c5377
updated to latest changes (10 April) to quotient package (lift_raw_const only takes dummy theorem TrueI....in the future this will not work anymore)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 29
using Quotient3_rel Quotient3_lam by metis
3047
+ − 30
thus ?thesis using permute_lam_def id_apply map_fun_apply by metis
+ − 31
qed
+ − 32
+ − 33
2951
+ − 34
section {* Simple examples from Norrish 2004 *}
+ − 35
+ − 36
nominal_primrec
+ − 37
is_app :: "lam \<Rightarrow> bool"
+ − 38
where
+ − 39
"is_app (Var x) = False"
+ − 40
| "is_app (App t1 t2) = True"
+ − 41
| "is_app (Lam [x]. t) = False"
+ − 42
apply(simp add: eqvt_def is_app_graph_def)
+ − 43
apply(rule TrueI)
+ − 44
apply(rule_tac y="x" in lam.exhaust)
+ − 45
apply(auto)[3]
+ − 46
apply(all_trivials)
+ − 47
done
+ − 48
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 49
termination (eqvt) by lexicographic_order
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 50
2974
+ − 51
thm is_app_def
2975
c62e26830420
preliminary version of automatically generation the eqvt-lemmas for functions defined with nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 52
thm is_app.eqvt
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 53
2975
c62e26830420
preliminary version of automatically generation the eqvt-lemmas for functions defined with nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 54
thm eqvts
2951
+ − 55
+ − 56
nominal_primrec
+ − 57
rator :: "lam \<Rightarrow> lam option"
+ − 58
where
+ − 59
"rator (Var x) = None"
+ − 60
| "rator (App t1 t2) = Some t1"
+ − 61
| "rator (Lam [x]. t) = None"
+ − 62
apply(simp add: eqvt_def rator_graph_def)
+ − 63
apply(rule TrueI)
+ − 64
apply(rule_tac y="x" in lam.exhaust)
+ − 65
apply(auto)[3]
+ − 66
apply(simp_all)
+ − 67
done
+ − 68
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 69
termination (eqvt) by lexicographic_order
2951
+ − 70
+ − 71
nominal_primrec
+ − 72
rand :: "lam \<Rightarrow> lam option"
+ − 73
where
+ − 74
"rand (Var x) = None"
+ − 75
| "rand (App t1 t2) = Some t2"
+ − 76
| "rand (Lam [x]. t) = None"
+ − 77
apply(simp add: eqvt_def rand_graph_def)
+ − 78
apply(rule TrueI)
+ − 79
apply(rule_tac y="x" in lam.exhaust)
+ − 80
apply(auto)[3]
+ − 81
apply(simp_all)
+ − 82
done
+ − 83
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 84
termination (eqvt) by lexicographic_order
2951
+ − 85
+ − 86
nominal_primrec
+ − 87
is_eta_nf :: "lam \<Rightarrow> bool"
+ − 88
where
+ − 89
"is_eta_nf (Var x) = True"
+ − 90
| "is_eta_nf (App t1 t2) = (is_eta_nf t1 \<and> is_eta_nf t2)"
+ − 91
| "is_eta_nf (Lam [x]. t) = (is_eta_nf t \<and>
+ − 92
((is_app t \<and> rand t = Some (Var x)) \<longrightarrow> atom x \<in> supp (rator t)))"
+ − 93
apply(simp add: eqvt_def is_eta_nf_graph_def)
+ − 94
apply(rule TrueI)
+ − 95
apply(rule_tac y="x" in lam.exhaust)
+ − 96
apply(auto)[3]
3192
+ − 97
using [[simproc del: alpha_lst]]
2951
+ − 98
apply(simp_all)
+ − 99
apply(erule_tac c="()" in Abs_lst1_fcb2')
+ − 100
apply(simp_all add: pure_fresh fresh_star_def)[3]
+ − 101
apply(simp add: eqvt_at_def conj_eqvt)
+ − 102
apply(simp add: eqvt_at_def conj_eqvt)
+ − 103
done
+ − 104
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 105
termination (eqvt) by lexicographic_order
2951
+ − 106
+ − 107
nominal_datatype path = Left | Right | In
+ − 108
+ − 109
section {* Paths to a free variables *}
+ − 110
+ − 111
instance path :: pure
+ − 112
apply(default)
+ − 113
apply(induct_tac "x::path" rule: path.induct)
+ − 114
apply(simp_all)
+ − 115
done
+ − 116
+ − 117
nominal_primrec
+ − 118
var_pos :: "name \<Rightarrow> lam \<Rightarrow> (path list) set"
+ − 119
where
+ − 120
"var_pos y (Var x) = (if y = x then {[]} else {})"
+ − 121
| "var_pos y (App t1 t2) = (Cons Left ` (var_pos y t1)) \<union> (Cons Right ` (var_pos y t2))"
+ − 122
| "atom x \<sharp> y \<Longrightarrow> var_pos y (Lam [x]. t) = (Cons In ` (var_pos y t))"
+ − 123
apply(simp add: eqvt_def var_pos_graph_def)
+ − 124
apply(rule TrueI)
+ − 125
apply(case_tac x)
+ − 126
apply(rule_tac y="b" and c="a" in lam.strong_exhaust)
+ − 127
apply(auto simp add: fresh_star_def)[3]
3192
+ − 128
using [[simproc del: alpha_lst]]
2951
+ − 129
apply(simp_all)
+ − 130
apply(erule conjE)+
+ − 131
apply(erule_tac Abs_lst1_fcb2)
+ − 132
apply(simp add: pure_fresh)
+ − 133
apply(simp add: fresh_star_def)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 134
apply(simp only: eqvt_at_def)
2951
+ − 135
apply(perm_simp)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 136
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 137
apply(simp add: perm_supp_eq)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 138
apply(simp only: eqvt_at_def)
2951
+ − 139
apply(perm_simp)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 140
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 141
apply(simp add: perm_supp_eq)
2951
+ − 142
done
+ − 143
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 144
termination (eqvt) by lexicographic_order
2951
+ − 145
+ − 146
lemma var_pos1:
+ − 147
assumes "atom y \<notin> supp t"
+ − 148
shows "var_pos y t = {}"
+ − 149
using assms
+ − 150
apply(induct t rule: var_pos.induct)
+ − 151
apply(simp_all add: lam.supp supp_at_base fresh_at_base)
+ − 152
done
+ − 153
+ − 154
lemma var_pos2:
+ − 155
shows "var_pos y (Lam [y].t) = {}"
+ − 156
apply(rule var_pos1)
+ − 157
apply(simp add: lam.supp)
+ − 158
done
+ − 159
+ − 160
+ − 161
text {* strange substitution operation *}
+ − 162
+ − 163
nominal_primrec
+ − 164
subst' :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_ [_ ::== _]" [90, 90, 90] 90)
+ − 165
where
+ − 166
"(Var x)[y ::== s] = (if x = y then s else (Var x))"
+ − 167
| "(App t1 t2)[y ::== s] = App (t1[y ::== s]) (t2[y ::== s])"
+ − 168
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::== s] = Lam [x].(t[y ::== (App (Var y) s)])"
+ − 169
apply(simp add: eqvt_def subst'_graph_def)
+ − 170
apply(rule TrueI)
+ − 171
apply(case_tac x)
+ − 172
apply(rule_tac y="a" and c="(b, c)" in lam.strong_exhaust)
+ − 173
apply(auto simp add: fresh_star_def)[3]
3192
+ − 174
using [[simproc del: alpha_lst]]
2951
+ − 175
apply(simp_all)
+ − 176
apply(erule conjE)+
+ − 177
apply (erule_tac c="(ya,sa)" in Abs_lst1_fcb2)
+ − 178
apply(simp_all add: Abs_fresh_iff)
+ − 179
apply(simp add: fresh_star_def fresh_Pair)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 180
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 181
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 182
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 183
apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 184
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 185
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 186
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 187
apply(simp add: fresh_star_Pair perm_supp_eq)
2951
+ − 188
done
+ − 189
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 190
termination (eqvt) by lexicographic_order
2951
+ − 191
+ − 192
2868
+ − 193
section {* free name function *}
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 194
2860
+ − 195
text {* first returns an atom list *}
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 196
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 197
nominal_primrec
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 198
frees_lst :: "lam \<Rightarrow> atom list"
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 199
where
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 200
"frees_lst (Var x) = [atom x]"
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 201
| "frees_lst (App t1 t2) = frees_lst t1 @ frees_lst t2"
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 202
| "frees_lst (Lam [x]. t) = removeAll (atom x) (frees_lst t)"
2868
+ − 203
unfolding eqvt_def
+ − 204
unfolding frees_lst_graph_def
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 205
apply(simp)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 206
apply(rule TrueI)
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 207
apply(rule_tac y="x" in lam.exhaust)
3192
+ − 208
using [[simproc del: alpha_lst]]
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 209
apply(auto)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 210
apply (erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 211
apply(simp add: supp_removeAll fresh_def)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 212
apply(simp add: fresh_star_def fresh_Unit)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 213
apply(simp add: eqvt_at_def removeAll_eqvt atom_eqvt)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 214
apply(simp add: eqvt_at_def removeAll_eqvt atom_eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 215
done
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 216
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 217
termination (eqvt) by lexicographic_order
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 218
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 219
text {* a small test lemma *}
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 220
lemma shows "supp t = set (frees_lst t)"
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 221
by (induct t rule: frees_lst.induct) (simp_all add: lam.supp supp_at_base)
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 222
2860
+ − 223
text {* second returns an atom set - therefore needs an invariant *}
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 224
2821
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 225
nominal_primrec (invariant "\<lambda>x (y::atom set). finite y")
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 226
frees_set :: "lam \<Rightarrow> atom set"
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 227
where
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 228
"frees_set (Var x) = {atom x}"
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 229
| "frees_set (App t1 t2) = frees_set t1 \<union> frees_set t2"
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 230
| "frees_set (Lam [x]. t) = (frees_set t) - {atom x}"
2845
+ − 231
apply(simp add: eqvt_def frees_set_graph_def)
+ − 232
apply(erule frees_set_graph.induct)
+ − 233
apply(auto)[9]
+ − 234
apply(rule_tac y="x" in lam.exhaust)
+ − 235
apply(auto)[3]
3192
+ − 236
using [[simproc del: alpha_lst]]
2845
+ − 237
apply(simp)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 238
apply(erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 239
apply(simp add: fresh_minus_atom_set)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 240
apply(simp add: fresh_star_def fresh_Unit)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 241
apply(simp add: Diff_eqvt eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 242
apply(simp add: Diff_eqvt eqvt_at_def)
2845
+ − 243
done
2821
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 244
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 245
termination (eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 246
by lexicographic_order
2821
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 247
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 248
lemma "frees_set t = supp t"
2845
+ − 249
by (induct rule: frees_set.induct) (simp_all add: lam.supp supp_at_base)
2821
c7d4bd9e89e0
fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 250
2868
+ − 251
section {* height function *}
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 252
2666
+ − 253
nominal_primrec
2678
+ − 254
height :: "lam \<Rightarrow> int"
2666
+ − 255
where
2678
+ − 256
"height (Var x) = 1"
2683
+ − 257
| "height (App t1 t2) = max (height t1) (height t2) + 1"
+ − 258
| "height (Lam [x].t) = height t + 1"
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 259
apply(simp add: eqvt_def height_graph_def)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 260
apply(rule TrueI)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 261
apply(rule_tac y="x" in lam.exhaust)
3192
+ − 262
using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 263
apply(auto)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 264
apply (erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 265
apply(simp_all add: fresh_def pure_supp eqvt_at_def fresh_star_def)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 266
done
2666
+ − 267
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 268
termination (eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 269
by lexicographic_order
2666
+ − 270
2707
+ − 271
thm height.simps
+ − 272
2683
+ − 273
2868
+ − 274
section {* capture-avoiding substitution *}
2683
+ − 275
2675
+ − 276
nominal_primrec
2683
+ − 277
subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_ [_ ::= _]" [90, 90, 90] 90)
2675
+ − 278
where
2683
+ − 279
"(Var x)[y ::= s] = (if x = y then s else (Var x))"
+ − 280
| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
+ − 281
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
2791
+ − 282
unfolding eqvt_def subst_graph_def
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 283
apply(simp)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 284
apply(rule TrueI)
3192
+ − 285
using [[simproc del: alpha_lst]]
3085
+ − 286
apply(auto)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 287
apply(rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 288
apply(blast)+
3192
+ − 289
using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 290
apply(simp_all add: fresh_star_def fresh_Pair_elim)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 291
apply (erule_tac c="(ya,sa)" in Abs_lst1_fcb2)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 292
apply(simp_all add: Abs_fresh_iff)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 293
apply(simp add: fresh_star_def fresh_Pair)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 294
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 295
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 296
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 297
apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 298
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 299
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 300
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 301
apply(simp add: fresh_star_Pair perm_supp_eq)
2675
+ − 302
done
+ − 303
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 304
termination (eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 305
by lexicographic_order
2683
+ − 306
2975
c62e26830420
preliminary version of automatically generation the eqvt-lemmas for functions defined with nominal_primrec
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 307
thm subst.eqvt
2683
+ − 308
+ − 309
lemma forget:
+ − 310
shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
2845
+ − 311
by (nominal_induct t avoiding: x s rule: lam.strong_induct)
3181
+ − 312
(auto simp add: fresh_at_base)
2683
+ − 313
+ − 314
text {* same lemma but with subst.induction *}
+ − 315
lemma forget2:
+ − 316
shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
3192
+ − 317
apply(induct t x s rule: subst.induct)
+ − 318
using [[simproc del: alpha_lst]]
+ − 319
apply(auto simp add: flip_fresh_fresh fresh_Pair fresh_at_base)
+ − 320
done
2683
+ − 321
+ − 322
lemma fresh_fact:
+ − 323
fixes z::"name"
+ − 324
assumes a: "atom z \<sharp> s"
2845
+ − 325
and b: "z = y \<or> atom z \<sharp> t"
2683
+ − 326
shows "atom z \<sharp> t[y ::= s]"
2845
+ − 327
using a b
+ − 328
by (nominal_induct t avoiding: z y s rule: lam.strong_induct)
3181
+ − 329
(auto simp add: fresh_at_base)
2683
+ − 330
+ − 331
lemma substitution_lemma:
+ − 332
assumes a: "x \<noteq> y" "atom x \<sharp> u"
+ − 333
shows "t[x ::= s][y ::= u] = t[y ::= u][x ::= s[y ::= u]]"
+ − 334
using a
+ − 335
by (nominal_induct t avoiding: x y s u rule: lam.strong_induct)
+ − 336
(auto simp add: fresh_fact forget)
+ − 337
+ − 338
lemma subst_rename:
+ − 339
assumes a: "atom y \<sharp> t"
+ − 340
shows "t[x ::= s] = ((y \<leftrightarrow> x) \<bullet>t)[y ::= s]"
+ − 341
using a
+ − 342
apply (nominal_induct t avoiding: x y s rule: lam.strong_induct)
3181
+ − 343
apply (auto simp add: fresh_at_base)
2683
+ − 344
done
+ − 345
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
+ − 346
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
+ − 347
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
+ − 348
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
+ − 349
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 350
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
+ − 351
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
+ − 352
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
+ − 353
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
+ − 354
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
+ − 355
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
+ − 356
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
+ − 357
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
+ − 358
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
+ − 359
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
+ − 360
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
+ − 361
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
+ − 362
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
+ − 363
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
+ − 364
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
+ − 365
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
+ − 366
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
+ − 367
qed
2683
+ − 368
+ − 369
subsection {* single-step beta-reduction *}
+ − 370
+ − 371
inductive
+ − 372
beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b _" [80,80] 80)
+ − 373
where
+ − 374
b1[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> App t1 s \<longrightarrow>b App t2 s"
+ − 375
| b2[intro]: "s1 \<longrightarrow>b s2 \<Longrightarrow> App t s1 \<longrightarrow>b App t s2"
+ − 376
| b3[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> Lam [x]. t1 \<longrightarrow>b Lam [x]. t2"
+ − 377
| b4[intro]: "atom x \<sharp> s \<Longrightarrow> App (Lam [x]. t) s \<longrightarrow>b t[x ::= s]"
+ − 378
+ − 379
equivariance beta
+ − 380
+ − 381
nominal_inductive beta
+ − 382
avoids b4: "x"
3181
+ − 383
by (simp_all add: fresh_star_def fresh_Pair fresh_fact)
2683
+ − 384
+ − 385
text {* One-Reduction *}
+ − 386
+ − 387
inductive
+ − 388
One :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>1 _" [80,80] 80)
+ − 389
where
+ − 390
o1[intro]: "Var x \<longrightarrow>1 Var x"
+ − 391
| o2[intro]: "\<lbrakk>t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>1 App t2 s2"
+ − 392
| o3[intro]: "t1 \<longrightarrow>1 t2 \<Longrightarrow> Lam [x].t1 \<longrightarrow>1 Lam [x].t2"
+ − 393
| 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]"
+ − 394
+ − 395
equivariance One
+ − 396
+ − 397
nominal_inductive One
+ − 398
avoids o3: "x"
+ − 399
| o4: "x"
3181
+ − 400
by (simp_all add: fresh_star_def fresh_Pair fresh_fact)
2683
+ − 401
+ − 402
lemma One_refl:
+ − 403
shows "t \<longrightarrow>1 t"
+ − 404
by (nominal_induct t rule: lam.strong_induct) (auto)
+ − 405
+ − 406
lemma One_subst:
+ − 407
assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
+ − 408
shows "t1[x ::= s1] \<longrightarrow>1 t2[x ::= s2]"
+ − 409
using a
+ − 410
apply(nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct)
+ − 411
apply(auto simp add: substitution_lemma fresh_at_base fresh_fact fresh_Pair)
+ − 412
done
+ − 413
+ − 414
lemma better_o4_intro:
+ − 415
assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
+ − 416
shows "App (Lam [x]. t1) s1 \<longrightarrow>1 t2[ x ::= s2]"
+ − 417
proof -
2685
+ − 418
obtain y::"name" where fs: "atom y \<sharp> (x, t1, s1, t2, s2)" by (rule obtain_fresh)
2683
+ − 419
have "App (Lam [x]. t1) s1 = App (Lam [y]. ((y \<leftrightarrow> x) \<bullet> t1)) s1" using fs
3085
+ − 420
by (auto simp add: Abs1_eq_iff' flip_def fresh_Pair fresh_at_base)
2683
+ − 421
also have "\<dots> \<longrightarrow>1 ((y \<leftrightarrow> x) \<bullet> t2)[y ::= s2]" using fs a by (auto simp add: One.eqvt)
+ − 422
also have "\<dots> = t2[x ::= s2]" using fs by (simp add: subst_rename[symmetric])
+ − 423
finally show "App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]" by simp
+ − 424
qed
+ − 425
+ − 426
section {* Locally Nameless Terms *}
2678
+ − 427
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
+ − 428
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
+ − 429
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
+ − 430
| 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
+ − 431
| 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
+ − 432
| 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
+ − 433
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
+ − 434
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
+ − 435
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
+ − 436
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
+ − 437
"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
+ − 438
| "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
+ − 439
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 440
lemma supp_lookup:
2824
+ − 441
shows "supp (lookup xs n x) \<subseteq> {atom x}"
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 442
apply(induct arbitrary: n rule: lookup.induct)
2824
+ − 443
apply(simp add: ln.supp supp_at_base)
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 444
apply(simp add: ln.supp pure_supp)
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 445
done
2824
+ − 446
+ − 447
lemma supp_lookup_in:
+ − 448
shows "x \<in> set xs \<Longrightarrow> supp (lookup xs n x) = {}"
+ − 449
by (induct arbitrary: n rule: lookup.induct)(auto simp add: ln.supp pure_supp)
+ − 450
+ − 451
lemma supp_lookup_notin:
+ − 452
shows "x \<notin> set xs \<Longrightarrow> supp (lookup xs n x) = {atom x}"
+ − 453
by (induct arbitrary: n rule: lookup.induct) (auto simp add: ln.supp pure_supp supp_at_base)
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 454
2829
+ − 455
lemma supp_lookup_fresh:
+ − 456
shows "atom ` set xs \<sharp>* lookup xs n x"
+ − 457
by (case_tac "x \<in> set xs") (auto simp add: fresh_star_def fresh_def supp_lookup_in supp_lookup_notin)
+ − 458
+ − 459
lemma lookup_eqvt[eqvt]:
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
+ − 460
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
+ − 461
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
+ − 462
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 463
text {* Function that translates lambda-terms into locally nameless terms *}
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 464
2826
+ − 465
nominal_primrec (invariant "\<lambda>(_, xs) y. atom ` set xs \<sharp>* y")
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
+ − 466
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
+ − 467
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
+ − 468
"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
+ − 469
| "trans (App t1 t2) xs = LNApp (trans t1 xs) (trans t2 xs)"
2685
+ − 470
| "atom x \<sharp> xs \<Longrightarrow> trans (Lam [x]. t) xs = LNLam (trans t (x # xs))"
2829
+ − 471
apply (simp add: eqvt_def trans_graph_def)
2824
+ − 472
apply (erule trans_graph.induct)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 473
apply (auto simp add: ln.fresh)[3]
2829
+ − 474
apply (simp add: supp_lookup_fresh)
2824
+ − 475
apply (simp add: fresh_star_def ln.fresh)
+ − 476
apply (simp add: ln.fresh fresh_star_def)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 477
apply(auto)[1]
2829
+ − 478
apply (rule_tac y="a" and c="b" in lam.strong_exhaust)
+ − 479
apply (auto simp add: fresh_star_def)[3]
3192
+ − 480
using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 481
apply(simp_all)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 482
apply(erule conjE)+
2948
+ − 483
apply (erule_tac c="xsa" in Abs_lst1_fcb2')
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 484
apply (simp add: fresh_star_def)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 485
apply (simp add: fresh_star_def)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 486
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 487
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 488
apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 489
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 490
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 491
apply(simp add: fresh_star_Pair perm_supp_eq)
2829
+ − 492
done
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
+ − 493
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 494
termination (eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 495
by lexicographic_order
2827
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 496
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 497
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 498
text {* count the occurences of lambdas in a term *}
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 499
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 500
nominal_primrec
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 501
cntlams :: "lam \<Rightarrow> nat"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 502
where
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 503
"cntlams (Var x) = 0"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 504
| "cntlams (App t1 t2) = (cntlams t1) + (cntlams t2)"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 505
| "cntlams (Lam [x]. t) = Suc (cntlams t)"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 506
apply(simp add: eqvt_def cntlams_graph_def)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 507
apply(rule TrueI)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 508
apply(rule_tac y="x" in lam.exhaust)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 509
apply(auto)[3]
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 510
apply(all_trivials)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 511
apply(simp)
3192
+ − 512
using [[simproc del: alpha_lst]]
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 513
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 514
apply(erule_tac c="()" in Abs_lst1_fcb2')
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 515
apply(simp add: pure_fresh)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 516
apply(simp add: fresh_star_def pure_fresh)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 517
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 518
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 519
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 520
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 521
termination (eqvt)
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 522
by lexicographic_order
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 523
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 524
2860
+ − 525
text {* count the bound-variable occurences in a lambda-term *}
2827
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 526
2828
+ − 527
nominal_primrec
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 528
cntbvs :: "lam \<Rightarrow> name list \<Rightarrow> nat"
2827
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 529
where
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 530
"cntbvs (Var x) xs = (if x \<in> set xs then 1 else 0)"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 531
| "cntbvs (App t1 t2) xs = (cntbvs t1 xs) + (cntbvs t2 xs)"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 532
| "atom x \<sharp> xs \<Longrightarrow> cntbvs (Lam [x]. t) xs = cntbvs t (x # xs)"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 533
apply(simp add: eqvt_def cntbvs_graph_def)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 534
apply(rule TrueI)
2828
+ − 535
apply(case_tac x)
+ − 536
apply(rule_tac y="a" and c="b" in lam.strong_exhaust)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 537
apply(auto simp add: fresh_star_def)[3]
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 538
apply(all_trivials)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 539
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 540
apply(simp)
3192
+ − 541
using [[simproc del: alpha_lst]]
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 542
apply(simp)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 543
apply(erule conjE)
2912
3c363a5070a5
copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 544
apply(erule Abs_lst1_fcb2')
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 545
apply(simp add: pure_fresh fresh_star_def)
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 546
apply(simp add: fresh_star_def)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 547
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 548
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 549
apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 550
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 551
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 552
apply(simp add: fresh_star_Pair perm_supp_eq)
2828
+ − 553
done
2827
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 554
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 555
termination (eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 556
by lexicographic_order
2827
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 557
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 558
section {* De Bruijn Terms *}
2827
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 559
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
+ − 560
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
+ − 561
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
+ − 562
| 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
+ − 563
| 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
+ − 564
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
+ − 565
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
+ − 566
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
+ − 567
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
+ − 568
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
+ − 569
done
2795
+ − 570
+ − 571
lemma fresh_at_list: "atom x \<sharp> xs \<longleftrightarrow> x \<notin> set xs"
+ − 572
unfolding fresh_def supp_set[symmetric]
2845
+ − 573
by (induct xs) (auto simp add: supp_of_finite_insert supp_at_base supp_set_empty)
2795
+ − 574
2800
+ − 575
fun
+ − 576
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
+ − 577
where
2800
+ − 578
"vindex [] v n = None"
+ − 579
| "vindex (h # t) v n = (if v = h then (Some (DBVar n)) else (vindex t v (Suc n)))"
+ − 580
+ − 581
lemma vindex_eqvt[eqvt]:
+ − 582
"(p \<bullet> vindex l v n) = vindex (p \<bullet> l) (p \<bullet> v) (p \<bullet> n)"
+ − 583
by (induct l arbitrary: n) (simp_all add: permute_pure)
+ − 584
+ − 585
nominal_primrec
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 586
transdb :: "lam \<Rightarrow> name list \<Rightarrow> db option"
2800
+ − 587
where
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 588
"transdb (Var x) l = vindex l x 0"
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 589
| "transdb (App t1 t2) xs =
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 590
Option.bind (transdb t1 xs) (\<lambda>d1. Option.bind (transdb t2 xs) (\<lambda>d2. Some (DBApp d1 d2)))"
2942
fac8895b109a
Express trans_db with Option.map and Option.bind. Possibly mbind is a copy of bind?
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 591
| "x \<notin> set xs \<Longrightarrow> transdb (Lam [x].t) xs = Option.map DBLam (transdb t (x # xs))"
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 592
unfolding eqvt_def transdb_graph_def
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 593
apply(simp)
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 594
apply(rule TrueI)
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
+ − 595
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
+ − 596
apply (rule_tac y="a" and c="b" in lam.strong_exhaust)
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 597
apply (auto simp add: fresh_star_def fresh_at_list)[3]
3192
+ − 598
using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 599
apply(simp_all)
2942
fac8895b109a
Express trans_db with Option.map and Option.bind. Possibly mbind is a copy of bind?
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 600
apply(elim conjE)
2912
3c363a5070a5
copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 601
apply (erule_tac c="xsa" in Abs_lst1_fcb2')
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 602
apply (simp add: pure_fresh)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 603
apply(simp add: fresh_star_def fresh_at_list)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 604
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 605
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 606
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 607
apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 608
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 609
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 610
apply(simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 611
apply(simp add: fresh_star_Pair perm_supp_eq)
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
+ − 612
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
+ − 613
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 614
termination (eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 615
by lexicographic_order
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
+ − 616
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 617
lemma transdb_eqvt[eqvt]:
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 618
"p \<bullet> transdb t l = transdb (p \<bullet>t) (p \<bullet>l)"
2942
fac8895b109a
Express trans_db with Option.map and Option.bind. Possibly mbind is a copy of bind?
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 619
apply (nominal_induct t avoiding: l rule: lam.strong_induct)
2800
+ − 620
apply (simp add: vindex_eqvt)
+ − 621
apply (simp_all add: permute_pure)
2797
+ − 622
apply (simp add: fresh_at_list)
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 623
apply (subst transdb.simps)
2797
+ − 624
apply (simp add: fresh_at_list[symmetric])
2800
+ − 625
apply (drule_tac x="name # l" in meta_spec)
+ − 626
apply auto
2797
+ − 627
done
+ − 628
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
+ − 629
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
+ − 630
assumes a: "y \<noteq> x"
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 631
shows "transdb (Lam [x]. Lam [y]. App (Var x) (Var y)) [] =
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 632
Some (DBLam (DBLam (DBApp (DBVar 1) (DBVar 0))))"
2795
+ − 633
using a by simp
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
+ − 634
2841
+ − 635
lemma supp_subst:
2972
+ − 636
shows "supp (t[x ::= s]) \<subseteq> (supp t - {atom x}) \<union> supp s"
+ − 637
by (induct t x s rule: subst.induct) (auto simp add: lam.supp supp_at_base)
2841
+ − 638
+ − 639
lemma var_fresh_subst:
+ − 640
"atom x \<sharp> s \<Longrightarrow> atom x \<sharp> (t[x ::= s])"
3181
+ − 641
by (induct t x s rule: subst.induct) (auto simp add: lam.supp fresh_at_base)
2841
+ − 642
2834
+ − 643
(* function that evaluates a lambda term *)
+ − 644
nominal_primrec
+ − 645
eval :: "lam \<Rightarrow> lam" and
2860
+ − 646
apply_subst :: "lam \<Rightarrow> lam \<Rightarrow> lam"
2834
+ − 647
where
+ − 648
"eval (Var x) = Var x"
+ − 649
| "eval (Lam [x].t) = Lam [x].(eval t)"
2860
+ − 650
| "eval (App t1 t2) = apply_subst (eval t1) (eval t2)"
+ − 651
| "apply_subst (Var x) t2 = App (Var x) t2"
+ − 652
| "apply_subst (App t0 t1) t2 = App (App t0 t1) t2"
+ − 653
| "atom x \<sharp> t2 \<Longrightarrow> apply_subst (Lam [x].t1) t2 = eval (t1[x::= t2])"
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 654
apply(simp add: eval_apply_subst_graph_def eqvt_def)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 655
apply(rule TrueI)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 656
apply (case_tac x)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 657
apply (case_tac a rule: lam.exhaust)
3192
+ − 658
using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 659
apply simp_all[3]
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 660
apply blast
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 661
apply (case_tac b)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 662
apply (rule_tac y="a" and c="ba" in lam.strong_exhaust)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 663
apply simp_all[3]
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 664
apply blast
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 665
apply blast
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 666
apply (simp add: Abs1_eq_iff fresh_star_def)
3192
+ − 667
using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 668
apply(simp_all)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 669
apply(erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 670
apply (simp add: Abs_fresh_iff)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 671
apply(simp add: fresh_star_def fresh_Unit)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 672
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 673
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 674
apply(erule conjE)
2912
3c363a5070a5
copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 675
apply(erule_tac c="t2a" in Abs_lst1_fcb2')
2902
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 676
apply (erule fresh_eqvt_at)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 677
apply (simp add: finite_supp)
9c3f6a4d95d4
another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 678
apply (simp add: fresh_Inl var_fresh_subst)
2912
3c363a5070a5
copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 679
apply(simp add: fresh_star_def)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 680
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 681
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 682
apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 683
apply(simp only: eqvt_at_def)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 684
apply(perm_simp)
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 685
apply(simp add: fresh_star_Pair perm_supp_eq)
2860
+ − 686
done
+ − 687
+ − 688
+ − 689
(* a small test
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 690
termination (eqvt) sorry
2845
+ − 691
2860
+ − 692
lemma
+ − 693
assumes "x \<noteq> y"
+ − 694
shows "eval (App (Lam [x].App (Var x) (Var x)) (Var y)) = App (Var y) (Var y)"
+ − 695
using assms
+ − 696
apply(simp add: lam.supp fresh_def supp_at_base)
+ − 697
done
+ − 698
*)
+ − 699
2852
+ − 700
+ − 701
text {* TODO: eqvt_at for the other side *}
+ − 702
nominal_primrec q where
+ − 703
"atom c \<sharp> (x, M) \<Longrightarrow> q (Lam [x]. M) (N :: lam) = Lam [x]. (Lam [c]. (App M (q (Var c) N)))"
+ − 704
| "q (Var x) N = Var x"
+ − 705
| "q (App l r) N = App l r"
+ − 706
unfolding eqvt_def q_graph_def
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 707
apply (simp)
2852
+ − 708
apply (rule TrueI)
+ − 709
apply (case_tac x)
+ − 710
apply (rule_tac y="a" in lam.exhaust)
3192
+ − 711
using [[simproc del: alpha_lst]]
2852
+ − 712
apply simp_all
+ − 713
apply blast
+ − 714
apply blast
+ − 715
apply (rule_tac x="(name, lam)" and ?'a="name" in obtain_fresh)
+ − 716
apply blast
+ − 717
apply clarify
+ − 718
apply (rule_tac x="(x, xa, M, Ma, c, ca, Na)" and ?'a="name" in obtain_fresh)
+ − 719
apply (subgoal_tac "eqvt_at q_sumC (Var ca, Na)") --"Could come from nominal_function?"
+ − 720
apply (subgoal_tac "Lam [c]. App M (q_sumC (Var c, Na)) = Lam [a]. App M (q_sumC (Var a, Na))")
+ − 721
apply (subgoal_tac "Lam [ca]. App Ma (q_sumC (Var ca, Na)) = Lam [a]. App Ma (q_sumC (Var a, Na))")
+ − 722
apply (simp only:)
+ − 723
apply (erule Abs_lst1_fcb)
+ − 724
oops
+ − 725
2846
+ − 726
text {* Working Examples *}
+ − 727
+ − 728
nominal_primrec
+ − 729
map_term :: "(lam \<Rightarrow> lam) \<Rightarrow> lam \<Rightarrow> lam"
+ − 730
where
+ − 731
"eqvt f \<Longrightarrow> map_term f (Var x) = f (Var x)"
+ − 732
| "eqvt f \<Longrightarrow> map_term f (App t1 t2) = App (f t1) (f t2)"
+ − 733
| "eqvt f \<Longrightarrow> map_term f (Lam [x].t) = Lam [x].(f t)"
+ − 734
| "\<not>eqvt f \<Longrightarrow> map_term f t = t"
+ − 735
apply (simp add: eqvt_def map_term_graph_def)
+ − 736
apply(rule TrueI)
+ − 737
apply (case_tac x, case_tac "eqvt a", case_tac b rule: lam.exhaust)
3192
+ − 738
using [[simproc del: alpha_lst]]
2846
+ − 739
apply auto
+ − 740
apply (erule Abs_lst1_fcb)
+ − 741
apply (simp_all add: Abs_fresh_iff fresh_fun_eqvt_app)
+ − 742
apply (simp add: eqvt_def permute_fun_app_eq)
+ − 743
done
+ − 744
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 745
termination (eqvt)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 746
by lexicographic_order
2846
+ − 747
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 748
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 749
(*
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 750
abbreviation
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 751
mbind :: "'a option => ('a => 'b option) => 'b option" ("_ \<guillemotright>= _" [65,65] 65)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 752
where
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 753
"c \<guillemotright>= f \<equiv> case c of None => None | (Some v) => f v"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 754
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 755
lemma mbind_eqvt:
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 756
fixes c::"'a::pt option"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 757
shows "(p \<bullet> (c \<guillemotright>= f)) = ((p \<bullet> c) \<guillemotright>= (p \<bullet> f))"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 758
apply(cases c)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 759
apply(simp_all)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 760
apply(perm_simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 761
apply(rule refl)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 762
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 763
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 764
lemma mbind_eqvt_raw[eqvt_raw]:
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 765
shows "(p \<bullet> option_case) \<equiv> option_case"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 766
apply(rule eq_reflection)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 767
apply(rule ext)+
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 768
apply(case_tac xb)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 769
apply(simp_all)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 770
apply(rule_tac p="-p" in permute_boolE)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 771
apply(perm_simp add: permute_minus_cancel)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 772
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 773
apply(rule_tac p="-p" in permute_boolE)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 774
apply(perm_simp add: permute_minus_cancel)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 775
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 776
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 777
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 778
fun
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 779
index :: "atom list \<Rightarrow> nat \<Rightarrow> atom \<Rightarrow> nat option"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 780
where
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 781
"index [] n x = None"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 782
| "index (y # ys) n x = (if x = y then (Some n) else (index ys (n + 1) x))"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 783
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 784
lemma [eqvt]:
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 785
shows "(p \<bullet> index xs n x) = index (p \<bullet> xs) (p \<bullet> n) (p \<bullet> x)"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 786
apply(induct xs arbitrary: n)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 787
apply(simp_all add: permute_pure)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 788
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 789
*)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 790
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 791
(*
2846
+ − 792
nominal_primrec
+ − 793
trans2 :: "lam \<Rightarrow> atom list \<Rightarrow> db option"
+ − 794
where
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 795
"trans2 (Var x) xs = (index xs 0 (atom x) \<guillemotright>= (\<lambda>n::nat. Some (DBVar n)))"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 796
| "trans2 (App t1 t2) xs =
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 797
((trans2 t1 xs) \<guillemotright>= (\<lambda>db1::db. (trans2 t2 xs) \<guillemotright>= (\<lambda>db2::db. Some (DBApp db1 db2))))"
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 798
| "trans2 (Lam [x].t) xs = (trans2 t (atom x # xs) \<guillemotright>= (\<lambda>db::db. Some (DBLam db)))"
2846
+ − 799
oops
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 800
*)
2846
+ − 801
+ − 802
nominal_primrec
+ − 803
CPS :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
+ − 804
where
+ − 805
"CPS (Var x) k = Var x"
+ − 806
| "CPS (App M N) k = CPS M (\<lambda>m. CPS N (\<lambda>n. n))"
+ − 807
oops
+ − 808
+ − 809
consts b :: name
+ − 810
nominal_primrec
+ − 811
Z :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
+ − 812
where
+ − 813
"Z (App M N) k = Z M (%m. (Z N (%n.(App m n))))"
+ − 814
| "Z (App M N) k = Z M (%m. (Z N (%n.(App (App m n) (Abs b (k (Var b)))))))"
+ − 815
unfolding eqvt_def Z_graph_def
+ − 816
apply (rule, perm_simp, rule)
+ − 817
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
+ − 818
2937
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 819
lemma test:
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 820
assumes "t = s"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 821
and "supp p \<sharp>* t" "supp p \<sharp>* x"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 822
and "(p \<bullet> t) = s \<Longrightarrow> (p \<bullet> x) = y"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 823
shows "x = y"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 824
using assms by (simp add: perm_supp_eq)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 825
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 826
lemma test2:
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 827
assumes "cs \<subseteq> as \<union> bs"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 828
and "as \<sharp>* x" "bs \<sharp>* x"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 829
shows "cs \<sharp>* x"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 830
using assms
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 831
by (auto simp add: fresh_star_def)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 832
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 833
lemma test3:
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 834
assumes "cs \<subseteq> as"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 835
and "as \<sharp>* x"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 836
shows "cs \<sharp>* x"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 837
using assms
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 838
by (auto simp add: fresh_star_def)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 839
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 840
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 841
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 842
nominal_primrec (invariant "\<lambda>(_, _, xs) y. atom ` fst ` set xs \<sharp>* y \<and> atom ` snd ` set xs \<sharp>* y")
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 843
aux :: "lam \<Rightarrow> lam \<Rightarrow> (name \<times> name) list \<Rightarrow> bool"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 844
where
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 845
"aux (Var x) (Var y) xs = ((x, y) \<in> set xs)"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 846
| "aux (App t1 t2) (App s1 s2) xs = (aux t1 s1 xs \<and> aux t2 s2 xs)"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 847
| "aux (Var x) (App t1 t2) xs = False"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 848
| "aux (Var x) (Lam [y].t) xs = False"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 849
| "aux (App t1 t2) (Var x) xs = False"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 850
| "aux (App t1 t2) (Lam [x].t) xs = False"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 851
| "aux (Lam [x].t) (Var y) xs = False"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 852
| "aux (Lam [x].t) (App t1 t2) xs = False"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 853
| "\<lbrakk>{atom x} \<sharp>* (s, xs); {atom y} \<sharp>* (t, xs); x \<noteq> y\<rbrakk> \<Longrightarrow>
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 854
aux (Lam [x].t) (Lam [y].s) xs = aux t s ((x, y) # xs)"
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 855
apply (simp add: eqvt_def aux_graph_def)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 856
apply(erule aux_graph.induct)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 857
apply(simp_all add: fresh_star_def pure_fresh)[9]
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 858
apply(case_tac x)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 859
apply(simp)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 860
apply(rule_tac y="a" and c="(b, c)" in lam.strong_exhaust)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 861
apply(simp)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 862
apply(rule_tac y="b" and c="c" in lam.strong_exhaust)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 863
apply(metis)+
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 864
apply(simp)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 865
apply(rule_tac y="b" and c="c" in lam.strong_exhaust)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 866
apply(metis)+
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 867
apply(simp)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 868
apply(rule_tac y="b" and c="(lam, c, name)" in lam.strong_exhaust)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 869
apply(metis)+
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 870
apply(simp)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 871
apply(drule_tac x="name" in meta_spec)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 872
apply(drule_tac x="lama" in meta_spec)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 873
apply(drule_tac x="c" in meta_spec)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 874
apply(drule_tac x="namea" in meta_spec)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 875
apply(drule_tac x="lam" in meta_spec)
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 876
apply(simp add: fresh_star_Pair)
3181
+ − 877
apply(simp add: fresh_star_def fresh_at_base )
2937
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 878
apply(auto)[1]
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 879
apply(simp_all)[44]
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 880
apply(simp del: Product_Type.prod.inject)
2948
+ − 881
oops
2937
a56d422e17f6
added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 882
2941
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 883
lemma abs_same_binder:
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 884
fixes t ta s sa :: "_ :: fs"
3191
0440bc1a2438
streamlined definition of alpha-equivalence for single binders (used flip instead of swap)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 885
and x y::"'a::at"
2941
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 886
shows "[[atom x]]lst. t = [[atom y]]lst. ta \<and> [[atom x]]lst. s = [[atom y]]lst. sa
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 887
\<longleftrightarrow> [[atom x]]lst. (t, s) = [[atom y]]lst. (ta, sa)"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 888
by (cases "atom x = atom y") (auto simp add: Abs1_eq_iff assms fresh_Pair)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 889
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 890
nominal_primrec
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 891
aux2 :: "lam \<Rightarrow> lam \<Rightarrow> bool"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 892
where
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 893
"aux2 (Var x) (Var y) = (x = y)"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 894
| "aux2 (App t1 t2) (App s1 s2) = (aux2 t1 s1 \<and> aux2 t2 s2)"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 895
| "aux2 (Var x) (App t1 t2) = False"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 896
| "aux2 (Var x) (Lam [y].t) = False"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 897
| "aux2 (App t1 t2) (Var x) = False"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 898
| "aux2 (App t1 t2) (Lam [x].t) = False"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 899
| "aux2 (Lam [x].t) (Var y) = False"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 900
| "aux2 (Lam [x].t) (App t1 t2) = False"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 901
| "x = y \<Longrightarrow> aux2 (Lam [x].t) (Lam [y].s) = aux2 t s"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 902
apply(simp add: eqvt_def aux2_graph_def)
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 903
apply(simp)
2941
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 904
apply(case_tac x)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 905
apply(rule_tac y="a" and c="b" in lam.strong_exhaust)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 906
apply(rule_tac y="b" in lam.exhaust)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 907
apply(auto)[3]
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 908
apply(rule_tac y="b" in lam.exhaust)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 909
apply(auto)[3]
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 910
apply(rule_tac y="b" and c="(name, lam)" in lam.strong_exhaust)
3192
+ − 911
using [[simproc del: alpha_lst]]
2941
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 912
apply(auto)[3]
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 913
apply(drule_tac x="name" in meta_spec)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 914
apply(drule_tac x="name" in meta_spec)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 915
apply(drule_tac x="lam" in meta_spec)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 916
apply(drule_tac x="(name \<leftrightarrow> namea) \<bullet> lama" in meta_spec)
3192
+ − 917
using [[simproc del: alpha_lst]]
3181
+ − 918
apply(simp add: Abs1_eq_iff fresh_star_def fresh_Pair_elim fresh_at_base flip_def)
2941
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 919
apply (metis Nominal2_Base.swap_commute fresh_permute_iff sort_of_atom_eq swap_atom_simps(2))
3192
+ − 920
using [[simproc del: alpha_lst]]
2941
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 921
apply simp_all
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 922
apply (simp add: abs_same_binder)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 923
apply (erule_tac c="()" in Abs_lst1_fcb2)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 924
apply (simp_all add: pure_fresh fresh_star_def eqvt_at_def)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 925
done
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 926
2940
+ − 927
text {* tests of functions containing if and case *}
+ − 928
3134
+ − 929
consts P :: "lam \<Rightarrow> bool"
2940
+ − 930
3191
0440bc1a2438
streamlined definition of alpha-equivalence for single binders (used flip instead of swap)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 931
(*
2940
+ − 932
nominal_primrec
+ − 933
A :: "lam => lam"
+ − 934
where
+ − 935
"A (App M N) = (if (True \<or> P M) then (A M) else (A N))"
+ − 936
| "A (Var x) = (Var x)"
+ − 937
| "A (App M N) = (if True then M else A N)"
+ − 938
oops
+ − 939
+ − 940
nominal_primrec
+ − 941
C :: "lam => lam"
+ − 942
where
+ − 943
"C (App M N) = (case (True \<or> P M) of True \<Rightarrow> (A M) | False \<Rightarrow> (A N))"
+ − 944
| "C (Var x) = (Var x)"
+ − 945
| "C (App M N) = (if True then M else C N)"
+ − 946
oops
+ − 947
+ − 948
nominal_primrec
+ − 949
A :: "lam => lam"
+ − 950
where
+ − 951
"A (Lam [x].M) = (Lam [x].M)"
+ − 952
| "A (Var x) = (Var x)"
+ − 953
| "A (App M N) = (if True then M else A N)"
+ − 954
oops
+ − 955
+ − 956
nominal_primrec
+ − 957
B :: "lam => lam"
+ − 958
where
+ − 959
"B (Lam [x].M) = (Lam [x].M)"
+ − 960
| "B (Var x) = (Var x)"
+ − 961
| "B (App M N) = (if True then M else (B N))"
+ − 962
unfolding eqvt_def
+ − 963
unfolding B_graph_def
+ − 964
apply(perm_simp)
+ − 965
apply(rule allI)
+ − 966
apply(rule refl)
3134
+ − 967
oops
3191
0440bc1a2438
streamlined definition of alpha-equivalence for single binders (used flip instead of swap)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 968
*)
1594
+ − 969
end
+ − 970
+ − 971
+ − 972