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
2436
+ − 10
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
+ − 11
Var "name"
2436
+ − 12
| 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
+ − 13
| 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
+ − 14
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 15
ML {* Method.SIMPLE_METHOD' *}
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 16
ML {* Sign.intern_const *}
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 17
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 18
ML {*
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 19
val test:((Proof.context -> Method.method) context_parser) =
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 20
Scan.succeed (fn ctxt =>
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 21
let
2891
304dfe6cc83a
the simplifier can simplify "sort (atom a)" if a is a concrete atom type declared with atom_decl
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 22
val _ = Inductive.the_inductive ctxt "local.frees_lst_graph"
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 23
in
2948
+ − 24
Method.SIMPLE_METHOD' (K (all_tac))
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 25
end)
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 26
*}
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 27
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 28
method_setup test = {* test *} {* test *}
2868
+ − 29
+ − 30
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
+ − 31
2860
+ − 32
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
+ − 33
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 34
ML Thm.implies_intr
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 35
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
+ − 36
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
+ − 37
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
+ − 38
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
+ − 39
"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
+ − 40
| "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
+ − 41
| "frees_lst (Lam [x]. t) = removeAll (atom x) (frees_lst t)"
2868
+ − 42
unfolding eqvt_def
+ − 43
unfolding frees_lst_graph_def
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
+ − 44
apply (rule, perm_simp, rule)
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
+ − 45
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
+ − 46
apply(rule_tac y="x" in lam.exhaust)
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
+ − 47
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
+ − 48
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
+ − 49
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
+ − 50
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
+ − 51
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
+ − 52
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
+ − 53
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
+ − 54
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
+ − 55
termination
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
+ − 56
by lexicographic_order
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
+ − 57
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
+ − 58
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
+ − 59
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
+ − 60
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
+ − 61
2860
+ − 62
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
+ − 63
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
+ − 64
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
+ − 65
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
+ − 66
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
+ − 67
"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
+ − 68
| "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
+ − 69
| "frees_set (Lam [x]. t) = (frees_set t) - {atom x}"
2845
+ − 70
apply(simp add: eqvt_def frees_set_graph_def)
+ − 71
apply(rule, perm_simp, rule)
+ − 72
apply(erule frees_set_graph.induct)
+ − 73
apply(auto)[9]
+ − 74
apply(rule_tac y="x" in lam.exhaust)
+ − 75
apply(auto)[3]
+ − 76
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
+ − 77
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
+ − 78
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
+ − 79
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
+ − 80
apply(simp add: Diff_eqvt eqvt_at_def, perm_simp, rule refl)
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
+ − 81
apply(simp add: Diff_eqvt eqvt_at_def, perm_simp, rule refl)
2845
+ − 82
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
+ − 83
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
+ − 84
termination
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
+ − 85
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
+ − 86
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
+ − 87
lemma "frees_set t = supp t"
2845
+ − 88
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
+ − 89
2868
+ − 90
section {* height function *}
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 91
2666
+ − 92
nominal_primrec
2678
+ − 93
height :: "lam \<Rightarrow> int"
2666
+ − 94
where
2678
+ − 95
"height (Var x) = 1"
2683
+ − 96
| "height (App t1 t2) = max (height t1) (height t2) + 1"
+ − 97
| "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
+ − 98
apply(simp add: eqvt_def height_graph_def)
2791
+ − 99
apply (rule, perm_simp, rule)
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
+ − 100
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
+ − 101
apply(rule_tac y="x" in lam.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
+ − 102
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
+ − 103
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
+ − 104
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
+ − 105
done
2666
+ − 106
+ − 107
termination
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
+ − 108
by lexicographic_order
2666
+ − 109
2707
+ − 110
thm height.simps
+ − 111
2683
+ − 112
2868
+ − 113
section {* capture-avoiding substitution *}
2683
+ − 114
2675
+ − 115
nominal_primrec
2683
+ − 116
subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_ [_ ::= _]" [90, 90, 90] 90)
2675
+ − 117
where
2683
+ − 118
"(Var x)[y ::= s] = (if x = y then s else (Var x))"
+ − 119
| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
+ − 120
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
2791
+ − 121
unfolding eqvt_def subst_graph_def
+ − 122
apply (rule, perm_simp, rule)
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
+ − 123
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
+ − 124
apply(auto simp add: lam.distinct lam.eq_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
+ − 125
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
+ − 126
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
+ − 127
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
+ − 128
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
+ − 129
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
+ − 130
apply(simp add: fresh_star_def fresh_Pair)
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
+ − 131
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
+ − 132
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
2675
+ − 133
done
+ − 134
2678
+ − 135
termination
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
+ − 136
by lexicographic_order
2683
+ − 137
+ − 138
lemma subst_eqvt[eqvt]:
+ − 139
shows "(p \<bullet> t[x ::= s]) = (p \<bullet> t)[(p \<bullet> x) ::= (p \<bullet> s)]"
+ − 140
by (induct t x s rule: subst.induct) (simp_all)
+ − 141
+ − 142
lemma forget:
+ − 143
shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
2845
+ − 144
by (nominal_induct t avoiding: x s rule: lam.strong_induct)
+ − 145
(auto simp add: lam.fresh fresh_at_base)
2683
+ − 146
+ − 147
text {* same lemma but with subst.induction *}
+ − 148
lemma forget2:
+ − 149
shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
2845
+ − 150
by (induct t x s rule: subst.induct)
+ − 151
(auto simp add: lam.fresh fresh_at_base fresh_Pair)
2683
+ − 152
+ − 153
lemma fresh_fact:
+ − 154
fixes z::"name"
+ − 155
assumes a: "atom z \<sharp> s"
2845
+ − 156
and b: "z = y \<or> atom z \<sharp> t"
2683
+ − 157
shows "atom z \<sharp> t[y ::= s]"
2845
+ − 158
using a b
+ − 159
by (nominal_induct t avoiding: z y s rule: lam.strong_induct)
+ − 160
(auto simp add: lam.fresh fresh_at_base)
2683
+ − 161
+ − 162
lemma substitution_lemma:
+ − 163
assumes a: "x \<noteq> y" "atom x \<sharp> u"
+ − 164
shows "t[x ::= s][y ::= u] = t[y ::= u][x ::= s[y ::= u]]"
+ − 165
using a
+ − 166
by (nominal_induct t avoiding: x y s u rule: lam.strong_induct)
+ − 167
(auto simp add: fresh_fact forget)
+ − 168
+ − 169
lemma subst_rename:
+ − 170
assumes a: "atom y \<sharp> t"
+ − 171
shows "t[x ::= s] = ((y \<leftrightarrow> x) \<bullet>t)[y ::= s]"
+ − 172
using a
+ − 173
apply (nominal_induct t avoiding: x y s rule: lam.strong_induct)
+ − 174
apply (auto simp add: lam.fresh fresh_at_base)
+ − 175
done
+ − 176
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
+ − 177
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
+ − 178
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
+ − 179
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
+ − 180
94f6f70e3067
New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 181
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
+ − 182
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
+ − 183
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
+ − 184
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
+ − 185
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
+ − 186
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
+ − 187
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
+ − 188
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
+ − 189
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
+ − 190
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
+ − 191
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
+ − 192
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
+ − 193
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
+ − 194
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
+ − 195
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
+ − 196
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
+ − 197
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
+ − 198
qed
2683
+ − 199
+ − 200
subsection {* single-step beta-reduction *}
+ − 201
+ − 202
inductive
+ − 203
beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b _" [80,80] 80)
+ − 204
where
+ − 205
b1[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> App t1 s \<longrightarrow>b App t2 s"
+ − 206
| b2[intro]: "s1 \<longrightarrow>b s2 \<Longrightarrow> App t s1 \<longrightarrow>b App t s2"
+ − 207
| b3[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> Lam [x]. t1 \<longrightarrow>b Lam [x]. t2"
+ − 208
| b4[intro]: "atom x \<sharp> s \<Longrightarrow> App (Lam [x]. t) s \<longrightarrow>b t[x ::= s]"
+ − 209
+ − 210
equivariance beta
+ − 211
+ − 212
nominal_inductive beta
+ − 213
avoids b4: "x"
+ − 214
by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
+ − 215
+ − 216
text {* One-Reduction *}
+ − 217
+ − 218
inductive
+ − 219
One :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>1 _" [80,80] 80)
+ − 220
where
+ − 221
o1[intro]: "Var x \<longrightarrow>1 Var x"
+ − 222
| o2[intro]: "\<lbrakk>t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>1 App t2 s2"
+ − 223
| o3[intro]: "t1 \<longrightarrow>1 t2 \<Longrightarrow> Lam [x].t1 \<longrightarrow>1 Lam [x].t2"
+ − 224
| 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]"
+ − 225
+ − 226
equivariance One
+ − 227
+ − 228
nominal_inductive One
+ − 229
avoids o3: "x"
+ − 230
| o4: "x"
+ − 231
by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
+ − 232
+ − 233
lemma One_refl:
+ − 234
shows "t \<longrightarrow>1 t"
+ − 235
by (nominal_induct t rule: lam.strong_induct) (auto)
+ − 236
+ − 237
lemma One_subst:
+ − 238
assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
+ − 239
shows "t1[x ::= s1] \<longrightarrow>1 t2[x ::= s2]"
+ − 240
using a
+ − 241
apply(nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct)
+ − 242
apply(auto simp add: substitution_lemma fresh_at_base fresh_fact fresh_Pair)
+ − 243
done
+ − 244
+ − 245
lemma better_o4_intro:
+ − 246
assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
+ − 247
shows "App (Lam [x]. t1) s1 \<longrightarrow>1 t2[ x ::= s2]"
+ − 248
proof -
2685
+ − 249
obtain y::"name" where fs: "atom y \<sharp> (x, t1, s1, t2, s2)" by (rule obtain_fresh)
2683
+ − 250
have "App (Lam [x]. t1) s1 = App (Lam [y]. ((y \<leftrightarrow> x) \<bullet> t1)) s1" using fs
+ − 251
by (auto simp add: lam.eq_iff Abs1_eq_iff' flip_def fresh_Pair fresh_at_base)
+ − 252
also have "\<dots> \<longrightarrow>1 ((y \<leftrightarrow> x) \<bullet> t2)[y ::= s2]" using fs a by (auto simp add: One.eqvt)
+ − 253
also have "\<dots> = t2[x ::= s2]" using fs by (simp add: subst_rename[symmetric])
+ − 254
finally show "App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]" by simp
+ − 255
qed
+ − 256
+ − 257
section {* Locally Nameless Terms *}
2678
+ − 258
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
+ − 259
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
+ − 260
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
+ − 261
| 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
+ − 262
| 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
+ − 263
| 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
+ − 264
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
+ − 265
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
+ − 266
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
+ − 267
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
+ − 268
"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
+ − 269
| "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
+ − 270
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
+ − 271
lemma supp_lookup:
2824
+ − 272
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
+ − 273
apply(induct arbitrary: n rule: lookup.induct)
2824
+ − 274
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
+ − 275
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
+ − 276
done
2824
+ − 277
+ − 278
lemma supp_lookup_in:
+ − 279
shows "x \<in> set xs \<Longrightarrow> supp (lookup xs n x) = {}"
+ − 280
by (induct arbitrary: n rule: lookup.induct)(auto simp add: ln.supp pure_supp)
+ − 281
+ − 282
lemma supp_lookup_notin:
+ − 283
shows "x \<notin> set xs \<Longrightarrow> supp (lookup xs n x) = {atom x}"
+ − 284
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
+ − 285
2829
+ − 286
lemma supp_lookup_fresh:
+ − 287
shows "atom ` set xs \<sharp>* lookup xs n x"
+ − 288
by (case_tac "x \<in> set xs") (auto simp add: fresh_star_def fresh_def supp_lookup_in supp_lookup_notin)
+ − 289
+ − 290
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
+ − 291
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
+ − 292
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
+ − 293
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
+ − 294
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
+ − 295
2826
+ − 296
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
+ − 297
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
+ − 298
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
+ − 299
"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
+ − 300
| "trans (App t1 t2) xs = LNApp (trans t1 xs) (trans t2 xs)"
2685
+ − 301
| "atom x \<sharp> xs \<Longrightarrow> trans (Lam [x]. t) xs = LNLam (trans t (x # xs))"
2829
+ − 302
apply (simp add: eqvt_def trans_graph_def)
+ − 303
apply (rule, perm_simp, rule)
2824
+ − 304
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
+ − 305
apply (auto simp add: ln.fresh)[3]
2829
+ − 306
apply (simp add: supp_lookup_fresh)
2824
+ − 307
apply (simp add: fresh_star_def ln.fresh)
+ − 308
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
+ − 309
apply(auto)[1]
2829
+ − 310
apply (rule_tac y="a" and c="b" in lam.strong_exhaust)
+ − 311
apply (auto simp add: fresh_star_def)[3]
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
+ − 312
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
+ − 313
apply(erule conjE)+
2948
+ − 314
thm Abs_lst1_fcb2'
+ − 315
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
+ − 316
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
+ − 317
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
+ − 318
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
+ − 319
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
2829
+ − 320
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
+ − 321
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
+ − 322
termination
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
+ − 323
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
+ − 324
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 325
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 326
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
+ − 327
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 328
nominal_primrec
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 329
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
+ − 330
where
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 331
"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
+ − 332
| "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
+ − 333
| "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
+ − 334
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
+ − 335
apply(rule, perm_simp, rule)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 336
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
+ − 337
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
+ − 338
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
+ − 339
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
+ − 340
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 341
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 342
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
+ − 343
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
+ − 344
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
+ − 345
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
+ − 346
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
+ − 347
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 348
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 349
termination
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 350
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
+ − 351
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 352
2860
+ − 353
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
+ − 354
2828
+ − 355
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
+ − 356
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
+ − 357
where
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 358
"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
+ − 359
| "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
+ − 360
| "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
+ − 361
apply(simp add: eqvt_def cntbvs_graph_def)
2828
+ − 362
apply(rule, perm_simp, rule)
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 363
apply(rule TrueI)
2828
+ − 364
apply(case_tac x)
+ − 365
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
+ − 366
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
+ − 367
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
+ − 368
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 369
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 370
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
+ − 371
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
+ − 372
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
+ − 373
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
+ − 374
apply(simp add: 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
+ − 375
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
+ − 376
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
2828
+ − 377
done
2827
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 378
394664816e24
defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 379
termination
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
+ − 380
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
+ − 381
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
+ − 382
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
+ − 383
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
+ − 384
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
+ − 385
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
+ − 386
| 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
+ − 387
| 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
+ − 388
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
+ − 389
lemma option_map_eqvt[eqvt]:
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
+ − 390
"p \<bullet> (Option.map f x) = Option.map (p \<bullet> f) (p \<bullet> x)"
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
+ − 391
by (cases x) (simp_all, simp add: permute_fun_app_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
+ − 392
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
+ − 393
lemma option_bind_eqvt[eqvt]:
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
+ − 394
shows "(p \<bullet> (Option.map f c)) = (Option.map (p \<bullet> f) (p \<bullet> c))"
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
+ − 395
by (cases c) (simp_all, simp add: permute_fun_app_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
+ − 396
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 397
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
+ − 398
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
+ − 399
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
+ − 400
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
+ − 401
done
2795
+ − 402
+ − 403
lemma fresh_at_list: "atom x \<sharp> xs \<longleftrightarrow> x \<notin> set xs"
+ − 404
unfolding fresh_def supp_set[symmetric]
2845
+ − 405
by (induct xs) (auto simp add: supp_of_finite_insert supp_at_base supp_set_empty)
2795
+ − 406
2800
+ − 407
fun
+ − 408
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
+ − 409
where
2800
+ − 410
"vindex [] v n = None"
+ − 411
| "vindex (h # t) v n = (if v = h then (Some (DBVar n)) else (vindex t v (Suc n)))"
+ − 412
+ − 413
lemma vindex_eqvt[eqvt]:
+ − 414
"(p \<bullet> vindex l v n) = vindex (p \<bullet> l) (p \<bullet> v) (p \<bullet> n)"
+ − 415
by (induct l arbitrary: n) (simp_all add: permute_pure)
+ − 416
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 417
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 418
2800
+ − 419
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
+ − 420
transdb :: "lam \<Rightarrow> name list \<Rightarrow> db option"
2800
+ − 421
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
+ − 422
"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
+ − 423
| "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
+ − 424
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
+ − 425
| "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
+ − 426
unfolding eqvt_def transdb_graph_def
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
+ − 427
apply (rule, perm_simp, rule)
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
+ − 428
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
+ − 429
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
+ − 430
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
+ − 431
apply (auto simp add: fresh_star_def fresh_at_list)[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
+ − 432
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
+ − 433
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
+ − 434
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
+ − 435
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
+ − 436
apply(simp add: fresh_star_def fresh_at_list)
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
+ − 437
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq eqvts eqvts_raw)+
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
+ − 438
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
+ − 439
c4ed08a7454a
Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 440
termination
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
+ − 441
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
+ − 442
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
+ − 443
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
+ − 444
"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
+ − 445
apply (nominal_induct t avoiding: l rule: lam.strong_induct)
2800
+ − 446
apply (simp add: vindex_eqvt)
+ − 447
apply (simp_all add: permute_pure)
2797
+ − 448
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
+ − 449
apply (subst transdb.simps)
2797
+ − 450
apply (simp add: fresh_at_list[symmetric])
2800
+ − 451
apply (drule_tac x="name # l" in meta_spec)
+ − 452
apply auto
2797
+ − 453
done
+ − 454
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
+ − 455
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
+ − 456
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
+ − 457
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
+ − 458
Some (DBLam (DBLam (DBApp (DBVar 1) (DBVar 0))))"
2795
+ − 459
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
+ − 460
2841
+ − 461
lemma supp_subst:
+ − 462
"supp (t[x ::= s]) \<subseteq> supp t \<union> supp s"
+ − 463
by (induct t x s rule: subst.induct) (auto simp add: lam.supp)
+ − 464
+ − 465
lemma var_fresh_subst:
+ − 466
"atom x \<sharp> s \<Longrightarrow> atom x \<sharp> (t[x ::= s])"
+ − 467
by (induct t x s rule: subst.induct) (auto simp add: lam.supp lam.fresh fresh_at_base)
+ − 468
2834
+ − 469
(* function that evaluates a lambda term *)
+ − 470
nominal_primrec
+ − 471
eval :: "lam \<Rightarrow> lam" and
2860
+ − 472
apply_subst :: "lam \<Rightarrow> lam \<Rightarrow> lam"
2834
+ − 473
where
+ − 474
"eval (Var x) = Var x"
+ − 475
| "eval (Lam [x].t) = Lam [x].(eval t)"
2860
+ − 476
| "eval (App t1 t2) = apply_subst (eval t1) (eval t2)"
+ − 477
| "apply_subst (Var x) t2 = App (Var x) t2"
+ − 478
| "apply_subst (App t0 t1) t2 = App (App t0 t1) t2"
+ − 479
| "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
+ − 480
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
+ − 481
apply(rule, perm_simp, rule)
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(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
+ − 483
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
+ − 484
apply (case_tac a rule: lam.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
+ − 485
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
+ − 486
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
+ − 487
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
+ − 488
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
+ − 489
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
+ − 490
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
+ − 491
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
+ − 492
apply (simp add: Abs1_eq_iff 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
+ − 493
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
+ − 494
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
+ − 495
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
+ − 496
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
+ − 497
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
+ − 498
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
+ − 499
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
+ − 500
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
+ − 501
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
+ − 502
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
+ − 503
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
+ − 504
apply(simp add: 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
+ − 505
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq subst_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
+ − 506
apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq subst_eqvt)
2860
+ − 507
done
+ − 508
+ − 509
+ − 510
(* a small test
+ − 511
termination sorry
2845
+ − 512
2860
+ − 513
lemma
+ − 514
assumes "x \<noteq> y"
+ − 515
shows "eval (App (Lam [x].App (Var x) (Var x)) (Var y)) = App (Var y) (Var y)"
+ − 516
using assms
+ − 517
apply(simp add: lam.supp fresh_def supp_at_base)
+ − 518
done
+ − 519
*)
+ − 520
2852
+ − 521
+ − 522
text {* TODO: eqvt_at for the other side *}
+ − 523
nominal_primrec q where
+ − 524
"atom c \<sharp> (x, M) \<Longrightarrow> q (Lam [x]. M) (N :: lam) = Lam [x]. (Lam [c]. (App M (q (Var c) N)))"
+ − 525
| "q (Var x) N = Var x"
+ − 526
| "q (App l r) N = App l r"
+ − 527
unfolding eqvt_def q_graph_def
+ − 528
apply (rule, perm_simp, rule)
+ − 529
apply (rule TrueI)
+ − 530
apply (case_tac x)
+ − 531
apply (rule_tac y="a" in lam.exhaust)
+ − 532
apply simp_all
+ − 533
apply blast
+ − 534
apply blast
+ − 535
apply (rule_tac x="(name, lam)" and ?'a="name" in obtain_fresh)
+ − 536
apply blast
+ − 537
apply clarify
+ − 538
apply (rule_tac x="(x, xa, M, Ma, c, ca, Na)" and ?'a="name" in obtain_fresh)
+ − 539
apply (subgoal_tac "eqvt_at q_sumC (Var ca, Na)") --"Could come from nominal_function?"
+ − 540
apply (subgoal_tac "Lam [c]. App M (q_sumC (Var c, Na)) = Lam [a]. App M (q_sumC (Var a, Na))")
+ − 541
apply (subgoal_tac "Lam [ca]. App Ma (q_sumC (Var ca, Na)) = Lam [a]. App Ma (q_sumC (Var a, Na))")
+ − 542
apply (simp only:)
+ − 543
apply (erule Abs_lst1_fcb)
+ − 544
oops
+ − 545
2846
+ − 546
text {* Working Examples *}
+ − 547
+ − 548
nominal_primrec
+ − 549
map_term :: "(lam \<Rightarrow> lam) \<Rightarrow> lam \<Rightarrow> lam"
+ − 550
where
+ − 551
"eqvt f \<Longrightarrow> map_term f (Var x) = f (Var x)"
+ − 552
| "eqvt f \<Longrightarrow> map_term f (App t1 t2) = App (f t1) (f t2)"
+ − 553
| "eqvt f \<Longrightarrow> map_term f (Lam [x].t) = Lam [x].(f t)"
+ − 554
| "\<not>eqvt f \<Longrightarrow> map_term f t = t"
+ − 555
apply (simp add: eqvt_def map_term_graph_def)
+ − 556
apply (rule, perm_simp, rule)
+ − 557
apply(rule TrueI)
+ − 558
apply (case_tac x, case_tac "eqvt a", case_tac b rule: lam.exhaust)
+ − 559
apply auto
+ − 560
apply (erule Abs_lst1_fcb)
+ − 561
apply (simp_all add: Abs_fresh_iff fresh_fun_eqvt_app)
+ − 562
apply (simp add: eqvt_def permute_fun_app_eq)
+ − 563
done
+ − 564
+ − 565
termination
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
+ − 566
by lexicographic_order
2846
+ − 567
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 568
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 569
(*
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 570
abbreviation
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 571
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
+ − 572
where
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 573
"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
+ − 574
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 575
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
+ − 576
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
+ − 577
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
+ − 578
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
+ − 579
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
+ − 580
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
+ − 581
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
+ − 582
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 583
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 584
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
+ − 585
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
+ − 586
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
+ − 587
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
+ − 588
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
+ − 589
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
+ − 590
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
+ − 591
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
+ − 592
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 593
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
+ − 594
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
+ − 595
apply(simp)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 596
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 597
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 598
fun
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 599
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
+ − 600
where
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 601
"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
+ − 602
| "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
+ − 603
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 604
lemma [eqvt]:
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 605
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
+ − 606
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
+ − 607
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
+ − 608
done
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 609
*)
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 610
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 611
(*
2846
+ − 612
nominal_primrec
+ − 613
trans2 :: "lam \<Rightarrow> atom list \<Rightarrow> db option"
+ − 614
where
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 615
"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
+ − 616
| "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
+ − 617
((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
+ − 618
| "trans2 (Lam [x].t) xs = (trans2 t (atom x # xs) \<guillemotright>= (\<lambda>db::db. Some (DBLam db)))"
2846
+ − 619
oops
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 620
*)
2846
+ − 621
+ − 622
nominal_primrec
+ − 623
CPS :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
+ − 624
where
+ − 625
"CPS (Var x) k = Var x"
+ − 626
| "CPS (App M N) k = CPS M (\<lambda>m. CPS N (\<lambda>n. n))"
+ − 627
oops
+ − 628
+ − 629
consts b :: name
+ − 630
nominal_primrec
+ − 631
Z :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
+ − 632
where
+ − 633
"Z (App M N) k = Z M (%m. (Z N (%n.(App m n))))"
+ − 634
| "Z (App M N) k = Z M (%m. (Z N (%n.(App (App m n) (Abs b (k (Var b)))))))"
+ − 635
unfolding eqvt_def Z_graph_def
+ − 636
apply (rule, perm_simp, rule)
+ − 637
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
+ − 638
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
+ − 639
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
+ − 640
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
+ − 641
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
+ − 642
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
+ − 643
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
+ − 644
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
+ − 645
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
+ − 646
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
+ − 647
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
+ − 648
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
+ − 649
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
+ − 650
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
+ − 651
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
+ − 652
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
+ − 653
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
+ − 654
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
+ − 655
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
+ − 656
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
+ − 657
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
+ − 658
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
+ − 659
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
+ − 660
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
+ − 661
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
+ − 662
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
+ − 663
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
+ − 664
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
+ − 665
"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
+ − 666
| "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
+ − 667
| "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
+ − 668
| "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
+ − 669
| "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
+ − 670
| "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
+ − 671
| "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
+ − 672
| "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
+ − 673
| "\<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
+ − 674
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
+ − 675
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
+ − 676
apply (rule, perm_simp, rule)
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
+ − 677
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
+ − 678
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
+ − 679
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
+ − 680
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
+ − 681
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
+ − 682
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
+ − 683
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
+ − 684
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
+ − 685
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
+ − 686
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
+ − 687
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
+ − 688
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
+ − 689
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
+ − 690
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
+ − 691
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
+ − 692
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
+ − 693
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
+ − 694
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
+ − 695
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
+ − 696
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
+ − 697
apply(simp add: fresh_star_Pair)
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
+ − 698
apply(simp add: fresh_star_def fresh_at_base lam.fresh)
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
+ − 699
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
+ − 700
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
+ − 701
apply(simp del: Product_Type.prod.inject)
2948
+ − 702
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
+ − 703
2941
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 704
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
+ − 705
fixes t ta s sa :: "_ :: fs"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 706
assumes "sort_of (atom x) = sort_of (atom y)"
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 707
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
+ − 708
\<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
+ − 709
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
+ − 710
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 711
nominal_primrec
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 712
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
+ − 713
where
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 714
"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
+ − 715
| "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
+ − 716
| "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
+ − 717
| "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
+ − 718
| "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
+ − 719
| "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
+ − 720
| "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
+ − 721
| "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
+ − 722
| "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
+ − 723
apply(simp add: eqvt_def aux2_graph_def)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 724
apply(rule, perm_simp, rule, rule)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 725
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
+ − 726
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
+ − 727
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
+ − 728
apply(auto)[3]
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 729
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
+ − 730
apply(auto)[3]
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 731
apply(rule_tac y="b" and c="(name, lam)" 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
+ − 732
apply(auto)[3]
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 733
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
+ − 734
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
+ − 735
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
+ − 736
apply(drule_tac x="(name \<leftrightarrow> namea) \<bullet> lama" in meta_spec)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 737
apply(simp add: Abs1_eq_iff fresh_star_def fresh_Pair_elim fresh_at_base lam.fresh flip_def)
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 738
apply (metis Nominal2_Base.swap_commute fresh_permute_iff sort_of_atom_eq swap_atom_simps(2))
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 739
apply simp_all
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 740
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
+ − 741
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
+ − 742
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
+ − 743
done
40991ebcda12
Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 744
2940
+ − 745
text {* tests of functions containing if and case *}
+ − 746
+ − 747
consts P :: "lam \<Rightarrow> bool"
+ − 748
+ − 749
nominal_primrec
+ − 750
A :: "lam => lam"
+ − 751
where
+ − 752
"A (App M N) = (if (True \<or> P M) then (A M) else (A N))"
+ − 753
| "A (Var x) = (Var x)"
+ − 754
| "A (App M N) = (if True then M else A N)"
+ − 755
oops
+ − 756
+ − 757
nominal_primrec
+ − 758
C :: "lam => lam"
+ − 759
where
+ − 760
"C (App M N) = (case (True \<or> P M) of True \<Rightarrow> (A M) | False \<Rightarrow> (A N))"
+ − 761
| "C (Var x) = (Var x)"
+ − 762
| "C (App M N) = (if True then M else C N)"
+ − 763
oops
+ − 764
+ − 765
nominal_primrec
+ − 766
A :: "lam => lam"
+ − 767
where
+ − 768
"A (Lam [x].M) = (Lam [x].M)"
+ − 769
| "A (Var x) = (Var x)"
+ − 770
| "A (App M N) = (if True then M else A N)"
+ − 771
oops
+ − 772
+ − 773
nominal_primrec
+ − 774
B :: "lam => lam"
+ − 775
where
+ − 776
"B (Lam [x].M) = (Lam [x].M)"
+ − 777
| "B (Var x) = (Var x)"
+ − 778
| "B (App M N) = (if True then M else (B N))"
+ − 779
unfolding eqvt_def
+ − 780
unfolding B_graph_def
+ − 781
apply(perm_simp)
+ − 782
apply(rule allI)
+ − 783
apply(rule refl)
+ − 784
oops
+ − 785
1594
+ − 786
end
+ − 787
+ − 788
+ − 789