author | wenzelm |
Sun, 25 Aug 2024 15:07:22 +0200 | |
changeset 80761 | bc936d3d8b45 |
parent 80754 | 701912f5645a |
child 80914 | d97fdabd9e2b |
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 |
|
62143 | 12 |
definition one :: "i" |
13 |
where "one == true" |
|
0 | 14 |
|
62143 | 15 |
definition "if" :: "[i,i,i]\<Rightarrow>i" ("(3if _/ then _/ else _)" [0,0,60] 60) |
16 |
where "if b then t else u == case(b, t, u, \<lambda> x y. bot, \<lambda>v. bot)" |
|
0 | 17 |
|
62143 | 18 |
definition inl :: "i\<Rightarrow>i" |
19 |
where "inl(a) == <true,a>" |
|
0 | 20 |
|
62143 | 21 |
definition inr :: "i\<Rightarrow>i" |
22 |
where "inr(b) == <false,b>" |
|
23 |
||
24 |
definition split :: "[i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
|
25 |
where "split(t,f) == case(t, bot, bot, f, \<lambda>u. bot)" |
|
0 | 26 |
|
62143 | 27 |
definition "when" :: "[i,i\<Rightarrow>i,i\<Rightarrow>i]\<Rightarrow>i" |
28 |
where "when(t,f,g) == split(t, \<lambda>b x. if b then f(x) else g(x))" |
|
29 |
||
30 |
definition fst :: "i\<Rightarrow>i" |
|
31 |
where "fst(t) == split(t, \<lambda>x y. x)" |
|
0 | 32 |
|
62143 | 33 |
definition snd :: "i\<Rightarrow>i" |
34 |
where "snd(t) == split(t, \<lambda>x y. y)" |
|
35 |
||
36 |
definition thd :: "i\<Rightarrow>i" |
|
37 |
where "thd(t) == split(t, \<lambda>x p. split(p, \<lambda>y z. z))" |
|
38 |
||
39 |
definition zero :: "i" |
|
40 |
where "zero == inl(one)" |
|
0 | 41 |
|
62143 | 42 |
definition succ :: "i\<Rightarrow>i" |
43 |
where "succ(n) == inr(n)" |
|
44 |
||
45 |
definition ncase :: "[i,i,i\<Rightarrow>i]\<Rightarrow>i" |
|
46 |
where "ncase(n,b,c) == when(n, \<lambda>x. b, \<lambda>y. c(y))" |
|
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
47 |
|
74443
dbf68dbacaff
clarified 'let' syntax: avoid conflict with existing 'let' in FOL;
wenzelm
parents:
74441
diff
changeset
|
48 |
definition "let1" :: "[i,i\<Rightarrow>i]\<Rightarrow>i" |
dbf68dbacaff
clarified 'let' syntax: avoid conflict with existing 'let' in FOL;
wenzelm
parents:
74441
diff
changeset
|
49 |
where let_def: "let1(t, f) == case(t,f(true),f(false), \<lambda>x y. f(<x,y>), \<lambda>u. f(lam x. u(x)))" |
62143 | 50 |
|
74443
dbf68dbacaff
clarified 'let' syntax: avoid conflict with existing 'let' in FOL;
wenzelm
parents:
74441
diff
changeset
|
51 |
syntax "_let1" :: "[idt,i,i]\<Rightarrow>i" ("(3let _ be _/ in _)" [0,0,60] 60) |
80761 | 52 |
syntax_consts "_let1" == let1 |
74443
dbf68dbacaff
clarified 'let' syntax: avoid conflict with existing 'let' in FOL;
wenzelm
parents:
74441
diff
changeset
|
53 |
translations "let x be a in e" == "CONST let1(a, \<lambda>x. e)" |
998
91d09e262799
Gave tighter priorities to if, napply and the let-forms to
lcp
parents:
610
diff
changeset
|
54 |
|
62143 | 55 |
definition letrec :: "[[i,i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
56 |
where "letrec(h, b) == b(\<lambda>x. fix(\<lambda>f. lam x. h(x,\<lambda>y. f`y))`x)" |
|
57 |
||
58 |
definition letrec2 :: "[[i,i,i\<Rightarrow>i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
|
59 |
where "letrec2 (h, f) == |
|
60 |
letrec (\<lambda>p g'. split(p,\<lambda>x y. h(x,y,\<lambda>u v. g'(<u,v>))), \<lambda>g'. f(\<lambda>x y. g'(<x,y>)))" |
|
0 | 61 |
|
62143 | 62 |
definition letrec3 :: "[[i,i,i,i\<Rightarrow>i\<Rightarrow>i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i\<Rightarrow>i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
63 |
where "letrec3 (h, f) == |
|
64 |
letrec (\<lambda>p g'. split(p,\<lambda>x xs. split(xs,\<lambda>y z. h(x,y,z,\<lambda>u v w. g'(<u,<v,w>>)))), |
|
65 |
\<lambda>g'. f(\<lambda>x y z. g'(<x,<y,z>>)))" |
|
0 | 66 |
|
62143 | 67 |
syntax |
74444 | 68 |
"_letrec" :: "[idt,idt,i,i]\<Rightarrow>i" ("(3letrec _ _ be _/ in _)" [0,0,0,60] 60) |
69 |
"_letrec2" :: "[idt,idt,idt,i,i]\<Rightarrow>i" ("(3letrec _ _ _ be _/ in _)" [0,0,0,0,60] 60) |
|
70 |
"_letrec3" :: "[idt,idt,idt,idt,i,i]\<Rightarrow>i" ("(3letrec _ _ _ _ be _/ in _)" [0,0,0,0,0,60] 60) |
|
80761 | 71 |
syntax_consts |
72 |
"_letrec" == letrec and |
|
73 |
"_letrec2" == letrec2 and |
|
74 |
"_letrec3" == letrec3 |
|
74444 | 75 |
parse_translation \<open> |
74441 | 76 |
let |
74444 | 77 |
fun abs_tr t u = Syntax_Trans.abs_tr [t, u]; |
78 |
fun letrec_tr [f, x, a, b] = |
|
79 |
Syntax.const \<^const_syntax>\<open>letrec\<close> $ abs_tr x (abs_tr f a) $ abs_tr f b; |
|
80 |
fun letrec2_tr [f, x, y, a, b] = |
|
81 |
Syntax.const \<^const_syntax>\<open>letrec2\<close> $ abs_tr x (abs_tr y (abs_tr f a)) $ abs_tr f b; |
|
82 |
fun letrec3_tr [f, x, y, z, a, b] = |
|
83 |
Syntax.const \<^const_syntax>\<open>letrec3\<close> $ abs_tr x (abs_tr y (abs_tr z (abs_tr f a))) $ abs_tr f b; |
|
84 |
in |
|
85 |
[(\<^syntax_const>\<open>_letrec\<close>, K letrec_tr), |
|
86 |
(\<^syntax_const>\<open>_letrec2\<close>, K letrec2_tr), |
|
87 |
(\<^syntax_const>\<open>_letrec3\<close>, K letrec3_tr)] |
|
88 |
end |
|
89 |
\<close> |
|
90 |
print_translation \<open> |
|
74441 | 91 |
let |
74444 | 92 |
val bound = Syntax_Trans.mark_bound_abs; |
93 |
||
94 |
fun letrec_tr' [Abs(x,T,Abs(f,S,a)),Abs(ff,SS,b)] = |
|
95 |
let |
|
74448 | 96 |
val (f',b') = Syntax_Trans.print_abs(ff,SS,b) |
97 |
val (_,a'') = Syntax_Trans.print_abs(f,S,a) |
|
98 |
val (x',a') = Syntax_Trans.print_abs(x,T,a'') |
|
74444 | 99 |
in |
100 |
Syntax.const \<^syntax_const>\<open>_letrec\<close> $ bound(f',SS) $ bound(x',T) $ a' $ b' |
|
101 |
end; |
|
74441 | 102 |
|
74444 | 103 |
fun letrec2_tr' [Abs(x,T,Abs(y,U,Abs(f,S,a))),Abs(ff,SS,b)] = |
104 |
let |
|
74448 | 105 |
val (f',b') = Syntax_Trans.print_abs(ff,SS,b) |
106 |
val ( _,a1) = Syntax_Trans.print_abs(f,S,a) |
|
107 |
val (y',a2) = Syntax_Trans.print_abs(y,U,a1) |
|
108 |
val (x',a') = Syntax_Trans.print_abs(x,T,a2) |
|
74444 | 109 |
in |
110 |
Syntax.const \<^syntax_const>\<open>_letrec2\<close> $ bound(f',SS) $ bound(x',T) $ bound(y',U) $ a' $ b' |
|
111 |
end; |
|
112 |
||
113 |
fun letrec3_tr' [Abs(x,T,Abs(y,U,Abs(z,V,Abs(f,S,a)))),Abs(ff,SS,b)] = |
|
114 |
let |
|
74448 | 115 |
val (f',b') = Syntax_Trans.print_abs(ff,SS,b) |
116 |
val ( _,a1) = Syntax_Trans.print_abs(f,S,a) |
|
117 |
val (z',a2) = Syntax_Trans.print_abs(z,V,a1) |
|
118 |
val (y',a3) = Syntax_Trans.print_abs(y,U,a2) |
|
119 |
val (x',a') = Syntax_Trans.print_abs(x,T,a3) |
|
74444 | 120 |
in |
121 |
Syntax.const \<^syntax_const>\<open>_letrec3\<close> $ |
|
122 |
bound(f',SS) $ bound(x',T) $ bound(y',U) $ bound(z',V) $ a' $ b' |
|
123 |
end; |
|
74441 | 124 |
in |
74444 | 125 |
[(\<^const_syntax>\<open>letrec\<close>, K letrec_tr'), |
126 |
(\<^const_syntax>\<open>letrec2\<close>, K letrec2_tr'), |
|
127 |
(\<^const_syntax>\<open>letrec3\<close>, K letrec3_tr')] |
|
128 |
end |
|
60770 | 129 |
\<close> |
17456 | 130 |
|
62143 | 131 |
definition nrec :: "[i,i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
132 |
where "nrec(n,b,c) == letrec g x be ncase(x, b, \<lambda>y. c(y,g(y))) in g(n)" |
|
133 |
||
134 |
definition nil :: "i" ("([])") |
|
135 |
where "[] == inl(one)" |
|
17456 | 136 |
|
62143 | 137 |
definition cons :: "[i,i]\<Rightarrow>i" (infixr "$" 80) |
138 |
where "h$t == inr(<h,t>)" |
|
139 |
||
140 |
definition lcase :: "[i,i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
|
141 |
where "lcase(l,b,c) == when(l, \<lambda>x. b, \<lambda>y. split(y,c))" |
|
17456 | 142 |
|
62143 | 143 |
definition lrec :: "[i,i,[i,i,i]\<Rightarrow>i]\<Rightarrow>i" |
144 |
where "lrec(l,b,c) == letrec g x be lcase(x, b, \<lambda>h t. c(h,t,g(t))) in g(l)" |
|
17456 | 145 |
|
62143 | 146 |
definition napply :: "[i\<Rightarrow>i,i,i]\<Rightarrow>i" ("(_ ^ _ ` _)" [56,56,56] 56) |
147 |
where "f ^n` a == nrec(n,a,\<lambda>x g. f(g))" |
|
20140 | 148 |
|
149 |
lemmas simp_can_defs = one_def inl_def inr_def |
|
150 |
and simp_ncan_defs = if_def when_def split_def fst_def snd_def thd_def |
|
151 |
lemmas simp_defs = simp_can_defs simp_ncan_defs |
|
152 |
||
153 |
lemmas ind_can_defs = zero_def succ_def nil_def cons_def |
|
154 |
and ind_ncan_defs = ncase_def nrec_def lcase_def lrec_def |
|
155 |
lemmas ind_defs = ind_can_defs ind_ncan_defs |
|
156 |
||
157 |
lemmas data_defs = simp_defs ind_defs napply_def |
|
158 |
and genrec_defs = letrec_def letrec2_def letrec3_def |
|
159 |
||
160 |
||
60770 | 161 |
subsection \<open>Beta Rules, including strictness\<close> |
20140 | 162 |
|
58977 | 163 |
lemma letB: "\<not> t=bot \<Longrightarrow> let x be t in f(x) = f(t)" |
20140 | 164 |
apply (unfold let_def) |
165 |
apply (erule rev_mp) |
|
166 |
apply (rule_tac t = "t" in term_case) |
|
74445 | 167 |
apply simp_all |
20140 | 168 |
done |
169 |
||
170 |
lemma letBabot: "let x be bot in f(x) = bot" |
|
74445 | 171 |
unfolding let_def by (rule caseBbot) |
20140 | 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) |
|
74445 | 177 |
apply simp_all |
20140 | 178 |
done |
179 |
||
180 |
lemma applyB: "(lam x. b(x)) ` a = b(a)" |
|
74445 | 181 |
by (simp add: apply_def) |
20140 | 182 |
|
183 |
lemma applyBbot: "bot ` a = bot" |
|
74445 | 184 |
unfolding apply_def by (rule caseBbot) |
20140 | 185 |
|
186 |
lemma fixB: "fix(f) = f(fix(f))" |
|
187 |
apply (unfold fix_def) |
|
188 |
apply (rule applyB [THEN ssubst], rule refl) |
|
189 |
done |
|
190 |
||
74445 | 191 |
lemma letrecB: "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 | 192 |
apply (unfold letrec_def) |
193 |
apply (rule fixB [THEN ssubst], rule applyB [THEN ssubst], rule refl) |
|
194 |
done |
|
195 |
||
196 |
lemmas rawBs = caseBs applyB applyBbot |
|
197 |
||
60770 | 198 |
method_setup beta_rl = \<open> |
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
199 |
Scan.succeed (fn ctxt => |
74445 | 200 |
let val ctxt' = Context_Position.set_visible false ctxt in |
201 |
SIMPLE_METHOD' (CHANGED o |
|
202 |
simp_tac (ctxt' addsimps @{thms rawBs} setloop (fn _ => stac ctxt @{thm letrecB}))) |
|
203 |
end) |
|
60770 | 204 |
\<close> |
20140 | 205 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
206 |
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
|
207 |
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
|
208 |
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
|
209 |
unfolding data_defs by beta_rl+ |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
210 |
|
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
211 |
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
|
212 |
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
|
213 |
and whenBbot: "when(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
214 |
unfolding data_defs by beta_rl+ |
20140 | 215 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
216 |
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
|
217 |
and splitBbot: "split(bot,h) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
218 |
unfolding data_defs by beta_rl+ |
17456 | 219 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
220 |
lemma fstB: "fst(<a,b>) = a" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
221 |
and fstBbot: "fst(bot) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
222 |
unfolding data_defs by beta_rl+ |
20140 | 223 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
224 |
lemma sndB: "snd(<a,b>) = b" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
225 |
and sndBbot: "snd(bot) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
226 |
unfolding data_defs by beta_rl+ |
20140 | 227 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
228 |
lemma thdB: "thd(<a,<b,c>>) = c" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
229 |
and thdBbot: "thd(bot) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
230 |
unfolding data_defs by beta_rl+ |
20140 | 231 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
232 |
lemma ncaseBzero: "ncase(zero,t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
233 |
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
|
234 |
and ncaseBbot: "ncase(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
235 |
unfolding data_defs by beta_rl+ |
20140 | 236 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
237 |
lemma nrecBzero: "nrec(zero,t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
238 |
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
|
239 |
and nrecBbot: "nrec(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
240 |
unfolding data_defs by beta_rl+ |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
241 |
|
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
242 |
lemma lcaseBnil: "lcase([],t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
243 |
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
|
244 |
and lcaseBbot: "lcase(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
245 |
unfolding data_defs by beta_rl+ |
20140 | 246 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
247 |
lemma lrecBnil: "lrec([],t,u) = t" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
248 |
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
|
249 |
and lrecBbot: "lrec(bot,t,u) = bot" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
250 |
unfolding data_defs by beta_rl+ |
20140 | 251 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
252 |
lemma letrec2B: |
58977 | 253 |
"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
|
254 |
unfolding data_defs letrec2_def by beta_rl+ |
20140 | 255 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
256 |
lemma letrec3B: |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
257 |
"letrec g x y z be h(x,y,z,g) in g(p,q,r) = |
58977 | 258 |
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
|
259 |
unfolding data_defs letrec3_def by beta_rl+ |
20140 | 260 |
|
32153
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
261 |
lemma napplyBzero: "f^zero`a = a" |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
262 |
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
|
263 |
unfolding data_defs by beta_rl+ |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
264 |
|
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
265 |
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
|
266 |
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
|
267 |
whenBbot ncaseBzero ncaseBsucc ncaseBbot nrecBzero nrecBsucc |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
268 |
nrecBbot lcaseBnil lcaseBcons lcaseBbot lrecBnil lrecBcons lrecBbot |
a0e57fb1b930
misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents:
32010
diff
changeset
|
269 |
napplyBzero napplyBsucc |
20140 | 270 |
|
271 |
||
60770 | 272 |
subsection \<open>Constructors are injective\<close> |
20140 | 273 |
|
32154 | 274 |
lemma term_injs: |
58977 | 275 |
"(inl(a) = inl(a')) \<longleftrightarrow> (a=a')" |
276 |
"(inr(a) = inr(a')) \<longleftrightarrow> (a=a')" |
|
277 |
"(succ(a) = succ(a')) \<longleftrightarrow> (a=a')" |
|
278 |
"(a$b = a'$b') \<longleftrightarrow> (a=a' \<and> b=b')" |
|
32154 | 279 |
by (inj_rl applyB splitB whenBinl whenBinr ncaseBsucc lcaseBcons) |
20140 | 280 |
|
281 |
||
60770 | 282 |
subsection \<open>Constructors are distinct\<close> |
20140 | 283 |
|
60770 | 284 |
ML \<open> |
56199 | 285 |
ML_Thms.bind_thms ("term_dstncts", |
69593 | 286 |
mkall_dstnct_thms \<^context> @{thms data_defs} (@{thms ccl_injs} @ @{thms term_injs}) |
24825 | 287 |
[["bot","inl","inr"], ["bot","zero","succ"], ["bot","nil","cons"]]); |
60770 | 288 |
\<close> |
20140 | 289 |
|
290 |
||
62020 | 291 |
subsection \<open>Rules for pre-order \<open>[=\<close>\<close> |
20140 | 292 |
|
32154 | 293 |
lemma term_porews: |
58977 | 294 |
"inl(a) [= inl(a') \<longleftrightarrow> a [= a'" |
295 |
"inr(b) [= inr(b') \<longleftrightarrow> b [= b'" |
|
296 |
"succ(n) [= succ(n') \<longleftrightarrow> n [= n'" |
|
297 |
"x$xs [= x'$xs' \<longleftrightarrow> x [= x' \<and> xs [= xs'" |
|
32154 | 298 |
by (simp_all add: data_defs ccl_porews) |
20140 | 299 |
|
300 |
||
60770 | 301 |
subsection \<open>Rewriting and Proving\<close> |
20140 | 302 |
|
60770 | 303 |
ML \<open> |
56199 | 304 |
ML_Thms.bind_thms ("term_injDs", XH_to_Ds @{thms term_injs}); |
60770 | 305 |
\<close> |
20140 | 306 |
|
20917 | 307 |
lemmas term_rews = termBs term_injs term_dstncts ccl_porews term_porews |
308 |
||
20140 | 309 |
lemmas [simp] = term_rews |
20917 | 310 |
lemmas [elim!] = term_dstncts [THEN notE] |
311 |
lemmas [dest!] = term_injDs |
|
20140 | 312 |
|
313 |
end |