author | nipkow |
Tue, 17 Nov 2015 11:44:10 +0100 | |
changeset 61692 | cb595e12451d |
parent 60770 | 240563fbf41d |
child 62020 | 5d208fd2507d |
permissions | -rw-r--r-- |
17456 | 1 |
(* Title: CCL/Term.thy |
1474 | 2 |
Author: Martin Coen |
0 | 3 |
Copyright 1993 University of Cambridge |
4 |
*) |
|
5 |
||
60770 | 6 |
section \<open>Definitions of usual program constructs in CCL\<close> |
17456 | 7 |
|
8 |
theory Term |
|
9 |
imports CCL |
|
10 |
begin |
|
0 | 11 |
|
12 |
consts |
|
13 |
||
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
14 |
one :: "i" |
0 | 15 |
|
58977 | 16 |
"if" :: "[i,i,i]\<Rightarrow>i" ("(3if _/ then _/ else _)" [0,0,60] 60) |
0 | 17 |
|
58977 | 18 |
inl :: "i\<Rightarrow>i" |
19 |
inr :: "i\<Rightarrow>i" |
|
60555
51a6997b1384
support 'when' statement, which corresponds to 'presume';
wenzelm
parents:
59498
diff
changeset
|
20 |
"when" :: "[i,i\<Rightarrow>i,i\<Rightarrow>i]\<Rightarrow>i" |
0 | 21 |
|
58977 | 22 |
split :: "[i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
23 |
fst :: "i\<Rightarrow>i" |
|
24 |
snd :: "i\<Rightarrow>i" |
|
25 |
thd :: "i\<Rightarrow>i" |
|
0 | 26 |
|
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
27 |
zero :: "i" |
58977 | 28 |
succ :: "i\<Rightarrow>i" |
29 |
ncase :: "[i,i,i\<Rightarrow>i]\<Rightarrow>i" |
|
30 |
nrec :: "[i,i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
|
0 | 31 |
|
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
32 |
nil :: "i" ("([])") |
58977 | 33 |
cons :: "[i,i]\<Rightarrow>i" (infixr "$" 80) |
34 |
lcase :: "[i,i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
|
35 |
lrec :: "[i,i,[i,i,i]\<Rightarrow>i]\<Rightarrow>i" |
|
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
36 |
|
58977 | 37 |
"let" :: "[i,i\<Rightarrow>i]\<Rightarrow>i" |
38 |
letrec :: "[[i,i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
|
39 |
letrec2 :: "[[i,i,i\<Rightarrow>i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
|
40 |
letrec3 :: "[[i,i,i,i\<Rightarrow>i\<Rightarrow>i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i\<Rightarrow>i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
|
0 | 41 |
|
14765 | 42 |
syntax |
58977 | 43 |
"_let" :: "[id,i,i]\<Rightarrow>i" ("(3let _ be _/ in _)" |
1474 | 44 |
[0,0,60] 60) |
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
45 |
|
58977 | 46 |
"_letrec" :: "[id,id,i,i]\<Rightarrow>i" ("(3letrec _ _ be _/ in _)" |
1474 | 47 |
[0,0,0,60] 60) |
0 | 48 |
|
58977 | 49 |
"_letrec2" :: "[id,id,id,i,i]\<Rightarrow>i" ("(3letrec _ _ _ be _/ in _)" |
1474 | 50 |
[0,0,0,0,60] 60) |
0 | 51 |
|
58977 | 52 |
"_letrec3" :: "[id,id,id,id,i,i]\<Rightarrow>i" ("(3letrec _ _ _ _ be _/ in _)" |
1474 | 53 |
[0,0,0,0,0,60] 60) |
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
54 |
|
60770 | 55 |
ML \<open> |
0 | 56 |
(** Quantifier translations: variable binding **) |
57 |
||
17781 | 58 |
(* FIXME does not handle "_idtdummy" *) |
49660
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
wenzelm
parents:
44241
diff
changeset
|
59 |
(* FIXME should use Syntax_Trans.mark_bound, Syntax_Trans.variant_abs' *) |
2709 | 60 |
|
44241 | 61 |
fun let_tr [Free x, a, b] = Const(@{const_syntax let},dummyT) $ a $ absfree x b; |
0 | 62 |
fun let_tr' [a,Abs(id,T,b)] = |
42284 | 63 |
let val (id',b') = Syntax_Trans.variant_abs(id,T,b) |
35113 | 64 |
in Const(@{syntax_const "_let"},dummyT) $ Free(id',T) $ a $ b' end; |
0 | 65 |
|
44241 | 66 |
fun letrec_tr [Free f, Free x, a, b] = |
67 |
Const(@{const_syntax letrec}, dummyT) $ absfree x (absfree f a) $ absfree f b; |
|
68 |
fun letrec2_tr [Free f, Free x, Free y, a, b] = |
|
69 |
Const(@{const_syntax letrec2}, dummyT) $ absfree x (absfree y (absfree f a)) $ absfree f b; |
|
70 |
fun letrec3_tr [Free f, Free x, Free y, Free z, a, b] = |
|
71 |
Const(@{const_syntax letrec3}, dummyT) $ |
|
72 |
absfree x (absfree y (absfree z (absfree f a))) $ absfree f b; |
|
0 | 73 |
|
74 |
fun letrec_tr' [Abs(x,T,Abs(f,S,a)),Abs(ff,SS,b)] = |
|
42284 | 75 |
let val (f',b') = Syntax_Trans.variant_abs(ff,SS,b) |
76 |
val (_,a'') = Syntax_Trans.variant_abs(f,S,a) |
|
77 |
val (x',a') = Syntax_Trans.variant_abs(x,T,a'') |
|
35113 | 78 |
in Const(@{syntax_const "_letrec"},dummyT) $ Free(f',SS) $ Free(x',T) $ a' $ b' end; |
0 | 79 |
fun letrec2_tr' [Abs(x,T,Abs(y,U,Abs(f,S,a))),Abs(ff,SS,b)] = |
42284 | 80 |
let val (f',b') = Syntax_Trans.variant_abs(ff,SS,b) |
81 |
val ( _,a1) = Syntax_Trans.variant_abs(f,S,a) |
|
82 |
val (y',a2) = Syntax_Trans.variant_abs(y,U,a1) |
|
83 |
val (x',a') = Syntax_Trans.variant_abs(x,T,a2) |
|
35113 | 84 |
in Const(@{syntax_const "_letrec2"},dummyT) $ Free(f',SS) $ Free(x',T) $ Free(y',U) $ a' $ b' |
0 | 85 |
end; |
86 |
fun letrec3_tr' [Abs(x,T,Abs(y,U,Abs(z,V,Abs(f,S,a)))),Abs(ff,SS,b)] = |
|
42284 | 87 |
let val (f',b') = Syntax_Trans.variant_abs(ff,SS,b) |
88 |
val ( _,a1) = Syntax_Trans.variant_abs(f,S,a) |
|
89 |
val (z',a2) = Syntax_Trans.variant_abs(z,V,a1) |
|
90 |
val (y',a3) = Syntax_Trans.variant_abs(y,U,a2) |
|
91 |
val (x',a') = Syntax_Trans.variant_abs(x,T,a3) |
|
35113 | 92 |
in Const(@{syntax_const "_letrec3"},dummyT) $ Free(f',SS) $ Free(x',T) $ Free(y',U) $ Free(z',V) $ a' $ b' |
0 | 93 |
end; |
60770 | 94 |
\<close> |
17456 | 95 |
|
60770 | 96 |
parse_translation \<open> |
52143 | 97 |
[(@{syntax_const "_let"}, K let_tr), |
98 |
(@{syntax_const "_letrec"}, K letrec_tr), |
|
99 |
(@{syntax_const "_letrec2"}, K letrec2_tr), |
|
100 |
(@{syntax_const "_letrec3"}, K letrec3_tr)] |
|
60770 | 101 |
\<close> |
17456 | 102 |
|
60770 | 103 |
print_translation \<open> |
52143 | 104 |
[(@{const_syntax let}, K let_tr'), |
105 |
(@{const_syntax letrec}, K letrec_tr'), |
|
106 |
(@{const_syntax letrec2}, K letrec2_tr'), |
|
107 |
(@{const_syntax letrec3}, K letrec3_tr')] |
|
60770 | 108 |
\<close> |
17456 | 109 |
|
110 |
consts |
|
58977 | 111 |
napply :: "[i\<Rightarrow>i,i,i]\<Rightarrow>i" ("(_ ^ _ ` _)" [56,56,56] 56) |
17456 | 112 |
|
42156 | 113 |
defs |
17456 | 114 |
one_def: "one == true" |
58977 | 115 |
if_def: "if b then t else u == case(b, t, u, \<lambda> x y. bot, \<lambda>v. bot)" |
17456 | 116 |
inl_def: "inl(a) == <true,a>" |
117 |
inr_def: "inr(b) == <false,b>" |
|
58977 | 118 |
when_def: "when(t,f,g) == split(t, \<lambda>b x. if b then f(x) else g(x))" |
119 |
split_def: "split(t,f) == case(t, bot, bot, f, \<lambda>u. bot)" |
|
120 |
fst_def: "fst(t) == split(t, \<lambda>x y. x)" |
|
121 |
snd_def: "snd(t) == split(t, \<lambda>x y. y)" |
|
122 |
thd_def: "thd(t) == split(t, \<lambda>x p. split(p, \<lambda>y z. z))" |
|
17456 | 123 |
zero_def: "zero == inl(one)" |
124 |
succ_def: "succ(n) == inr(n)" |
|
58977 | 125 |
ncase_def: "ncase(n,b,c) == when(n, \<lambda>x. b, \<lambda>y. c(y))" |
126 |
nrec_def: " nrec(n,b,c) == letrec g x be ncase(x, b, \<lambda>y. c(y,g(y))) in g(n)" |
|
17456 | 127 |
nil_def: "[] == inl(one)" |
128 |
cons_def: "h$t == inr(<h,t>)" |
|
58977 | 129 |
lcase_def: "lcase(l,b,c) == when(l, \<lambda>x. b, \<lambda>y. split(y,c))" |
130 |
lrec_def: "lrec(l,b,c) == letrec g x be lcase(x, b, \<lambda>h t. c(h,t,g(t))) in g(l)" |
|
17456 | 131 |
|
58977 | 132 |
let_def: "let x be t in f(x) == case(t,f(true),f(false), \<lambda>x y. f(<x,y>), \<lambda>u. f(lam x. u(x)))" |
17456 | 133 |
letrec_def: |
58977 | 134 |
"letrec g x be h(x,g) in b(g) == b(\<lambda>x. fix(\<lambda>f. lam x. h(x,\<lambda>y. f`y))`x)" |
17456 | 135 |
|
136 |
letrec2_def: "letrec g x y be h(x,y,g) in f(g)== |
|
58977 | 137 |
letrec g' p be split(p,\<lambda>x y. h(x,y,\<lambda>u v. g'(<u,v>))) |
138 |
in f(\<lambda>x y. g'(<x,y>))" |
|
17456 | 139 |
|
140 |
letrec3_def: "letrec g x y z be h(x,y,z,g) in f(g) == |
|
58977 | 141 |
letrec g' p be split(p,\<lambda>x xs. split(xs,\<lambda>y z. h(x,y,z,\<lambda>u v w. g'(<u,<v,w>>)))) |
142 |
in f(\<lambda>x y z. g'(<x,<y,z>>))" |
|
17456 | 143 |
|
58977 | 144 |
napply_def: "f ^n` a == nrec(n,a,\<lambda>x g. f(g))" |
17456 | 145 |
|
20140 | 146 |
|
147 |
lemmas simp_can_defs = one_def inl_def inr_def |
|
148 |
and simp_ncan_defs = if_def when_def split_def fst_def snd_def thd_def |
|
149 |
lemmas simp_defs = simp_can_defs simp_ncan_defs |
|
150 |
||
151 |
lemmas ind_can_defs = zero_def succ_def nil_def cons_def |
|
152 |
and ind_ncan_defs = ncase_def nrec_def lcase_def lrec_def |
|
153 |
lemmas ind_defs = ind_can_defs ind_ncan_defs |
|
154 |
||
155 |
lemmas data_defs = simp_defs ind_defs napply_def |
|
156 |
and genrec_defs = letrec_def letrec2_def letrec3_def |
|
157 |
||
158 |
||
60770 | 159 |
subsection \<open>Beta Rules, including strictness\<close> |
20140 | 160 |
|
58977 | 161 |
lemma letB: "\<not> t=bot \<Longrightarrow> let x be t in f(x) = f(t)" |
20140 | 162 |
apply (unfold let_def) |
163 |
apply (erule rev_mp) |
|
164 |
apply (rule_tac t = "t" in term_case) |
|
165 |
apply (simp_all add: caseBtrue caseBfalse caseBpair caseBlam) |
|
166 |
done |
|
167 |
||
168 |
lemma letBabot: "let x be bot in f(x) = bot" |
|
169 |
apply (unfold let_def) |
|
170 |
apply (rule caseBbot) |
|
171 |
done |
|
172 |
||
173 |
lemma letBbbot: "let x be t in bot = bot" |
|
174 |
apply (unfold let_def) |
|
175 |
apply (rule_tac t = t in term_case) |
|
176 |
apply (rule caseBbot) |
|
177 |
apply (simp_all add: caseBtrue caseBfalse caseBpair caseBlam) |
|
178 |
done |
|
179 |
||
180 |
lemma applyB: "(lam x. b(x)) ` a = b(a)" |
|
181 |
apply (unfold apply_def) |
|
182 |
apply (simp add: caseBtrue caseBfalse caseBpair caseBlam) |
|
183 |
done |
|
184 |
||
185 |
lemma applyBbot: "bot ` a = bot" |
|
186 |
apply (unfold apply_def) |
|
187 |
apply (rule caseBbot) |
|
188 |
done |
|
189 |
||
190 |
lemma fixB: "fix(f) = f(fix(f))" |
|
191 |
apply (unfold fix_def) |
|
192 |
apply (rule applyB [THEN ssubst], rule refl) |
|
193 |
done |
|
194 |
||
195 |
lemma letrecB: |
|
58977 | 196 |
"letrec g x be h(x,g) in g(a) = h(a,\<lambda>y. letrec g x be h(x,g) in g(y))" |
20140 | 197 |
apply (unfold letrec_def) |
198 |
apply (rule fixB [THEN ssubst], rule applyB [THEN ssubst], rule refl) |
|
199 |
done |
|
200 |
||
201 |
lemmas rawBs = caseBs applyB applyBbot |
|
202 |
||
60770 | 203 |
method_setup beta_rl = \<open> |
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
204 |
Scan.succeed (fn ctxt => |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
205 |
SIMPLE_METHOD' (CHANGED o |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58977
diff
changeset
|
206 |
simp_tac (ctxt addsimps @{thms rawBs} setloop (fn _ => stac ctxt @{thm letrecB})))) |
60770 | 207 |
\<close> |
20140 | 208 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
209 |
lemma ifBtrue: "if true then t else u = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
210 |
and ifBfalse: "if false then t else u = u" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
211 |
and ifBbot: "if bot then t else u = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
212 |
unfolding data_defs by beta_rl+ |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
213 |
|
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
214 |
lemma whenBinl: "when(inl(a),t,u) = t(a)" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
215 |
and whenBinr: "when(inr(a),t,u) = u(a)" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
216 |
and whenBbot: "when(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
217 |
unfolding data_defs by beta_rl+ |
20140 | 218 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
219 |
lemma splitB: "split(<a,b>,h) = h(a,b)" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
220 |
and splitBbot: "split(bot,h) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
221 |
unfolding data_defs by beta_rl+ |
17456 | 222 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
223 |
lemma fstB: "fst(<a,b>) = a" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
224 |
and fstBbot: "fst(bot) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
225 |
unfolding data_defs by beta_rl+ |
20140 | 226 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
227 |
lemma sndB: "snd(<a,b>) = b" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
228 |
and sndBbot: "snd(bot) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
229 |
unfolding data_defs by beta_rl+ |
20140 | 230 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
231 |
lemma thdB: "thd(<a,<b,c>>) = c" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
232 |
and thdBbot: "thd(bot) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
233 |
unfolding data_defs by beta_rl+ |
20140 | 234 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
235 |
lemma ncaseBzero: "ncase(zero,t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
236 |
and ncaseBsucc: "ncase(succ(n),t,u) = u(n)" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
237 |
and ncaseBbot: "ncase(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
238 |
unfolding data_defs by beta_rl+ |
20140 | 239 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
240 |
lemma nrecBzero: "nrec(zero,t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
241 |
and nrecBsucc: "nrec(succ(n),t,u) = u(n,nrec(n,t,u))" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
242 |
and nrecBbot: "nrec(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
243 |
unfolding data_defs by beta_rl+ |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
244 |
|
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
245 |
lemma lcaseBnil: "lcase([],t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
246 |
and lcaseBcons: "lcase(x$xs,t,u) = u(x,xs)" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
247 |
and lcaseBbot: "lcase(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
248 |
unfolding data_defs by beta_rl+ |
20140 | 249 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
250 |
lemma lrecBnil: "lrec([],t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
251 |
and lrecBcons: "lrec(x$xs,t,u) = u(x,xs,lrec(xs,t,u))" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
252 |
and lrecBbot: "lrec(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
253 |
unfolding data_defs by beta_rl+ |
20140 | 254 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
255 |
lemma letrec2B: |
58977 | 256 |
"letrec g x y be h(x,y,g) in g(p,q) = h(p,q,\<lambda>u v. letrec g x y be h(x,y,g) in g(u,v))" |
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
257 |
unfolding data_defs letrec2_def by beta_rl+ |
20140 | 258 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
259 |
lemma letrec3B: |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
260 |
"letrec g x y z be h(x,y,z,g) in g(p,q,r) = |
58977 | 261 |
h(p,q,r,\<lambda>u v w. letrec g x y z be h(x,y,z,g) in g(u,v,w))" |
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
262 |
unfolding data_defs letrec3_def by beta_rl+ |
20140 | 263 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
264 |
lemma napplyBzero: "f^zero`a = a" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
265 |
and napplyBsucc: "f^succ(n)`a = f(f^n`a)" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
266 |
unfolding data_defs by beta_rl+ |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
267 |
|
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
268 |
lemmas termBs = letB applyB applyBbot splitB splitBbot fstB fstBbot |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
269 |
sndB sndBbot thdB thdBbot ifBtrue ifBfalse ifBbot whenBinl whenBinr |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
270 |
whenBbot ncaseBzero ncaseBsucc ncaseBbot nrecBzero nrecBsucc |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
271 |
nrecBbot lcaseBnil lcaseBcons lcaseBbot lrecBnil lrecBcons lrecBbot |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
272 |
napplyBzero napplyBsucc |
20140 | 273 |
|
274 |
||
60770 | 275 |
subsection \<open>Constructors are injective\<close> |
20140 | 276 |
|
32154 | 277 |
lemma term_injs: |
58977 | 278 |
"(inl(a) = inl(a')) \<longleftrightarrow> (a=a')" |
279 |
"(inr(a) = inr(a')) \<longleftrightarrow> (a=a')" |
|
280 |
"(succ(a) = succ(a')) \<longleftrightarrow> (a=a')" |
|
281 |
"(a$b = a'$b') \<longleftrightarrow> (a=a' \<and> b=b')" |
|
32154 | 282 |
by (inj_rl applyB splitB whenBinl whenBinr ncaseBsucc lcaseBcons) |
20140 | 283 |
|
284 |
||
60770 | 285 |
subsection \<open>Constructors are distinct\<close> |
20140 | 286 |
|
60770 | 287 |
ML \<open> |
56199 | 288 |
ML_Thms.bind_thms ("term_dstncts", |
51670 | 289 |
mkall_dstnct_thms @{context} @{thms data_defs} (@{thms ccl_injs} @ @{thms term_injs}) |
24825 | 290 |
[["bot","inl","inr"], ["bot","zero","succ"], ["bot","nil","cons"]]); |
60770 | 291 |
\<close> |
20140 | 292 |
|
293 |
||
60770 | 294 |
subsection \<open>Rules for pre-order @{text "[="}\<close> |
20140 | 295 |
|
32154 | 296 |
lemma term_porews: |
58977 | 297 |
"inl(a) [= inl(a') \<longleftrightarrow> a [= a'" |
298 |
"inr(b) [= inr(b') \<longleftrightarrow> b [= b'" |
|
299 |
"succ(n) [= succ(n') \<longleftrightarrow> n [= n'" |
|
300 |
"x$xs [= x'$xs' \<longleftrightarrow> x [= x' \<and> xs [= xs'" |
|
32154 | 301 |
by (simp_all add: data_defs ccl_porews) |
20140 | 302 |
|
303 |
||
60770 | 304 |
subsection \<open>Rewriting and Proving\<close> |
20140 | 305 |
|
60770 | 306 |
ML \<open> |
56199 | 307 |
ML_Thms.bind_thms ("term_injDs", XH_to_Ds @{thms term_injs}); |
60770 | 308 |
\<close> |
20140 | 309 |
|
20917 | 310 |
lemmas term_rews = termBs term_injs term_dstncts ccl_porews term_porews |
311 |
||
20140 | 312 |
lemmas [simp] = term_rews |
20917 | 313 |
lemmas [elim!] = term_dstncts [THEN notE] |
314 |
lemmas [dest!] = term_injDs |
|
20140 | 315 |
|
316 |
end |