432
|
1 |
|
|
2 |
theory SizeBoundStrong
|
|
3 |
imports "Lexer"
|
|
4 |
begin
|
|
5 |
|
|
6 |
section \<open>Bit-Encodings\<close>
|
|
7 |
|
|
8 |
datatype bit = Z | S
|
|
9 |
|
|
10 |
fun code :: "val \<Rightarrow> bit list"
|
|
11 |
where
|
|
12 |
"code Void = []"
|
|
13 |
| "code (Char c) = []"
|
|
14 |
| "code (Left v) = Z # (code v)"
|
|
15 |
| "code (Right v) = S # (code v)"
|
|
16 |
| "code (Seq v1 v2) = (code v1) @ (code v2)"
|
|
17 |
| "code (Stars []) = [S]"
|
|
18 |
| "code (Stars (v # vs)) = (Z # code v) @ code (Stars vs)"
|
|
19 |
|
|
20 |
|
|
21 |
fun
|
|
22 |
Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
|
|
23 |
where
|
|
24 |
"Stars_add v (Stars vs) = Stars (v # vs)"
|
|
25 |
|
|
26 |
function
|
|
27 |
decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)"
|
|
28 |
where
|
|
29 |
"decode' ds ZERO = (Void, [])"
|
|
30 |
| "decode' ds ONE = (Void, ds)"
|
|
31 |
| "decode' ds (CH d) = (Char d, ds)"
|
|
32 |
| "decode' [] (ALT r1 r2) = (Void, [])"
|
|
33 |
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))"
|
|
34 |
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))"
|
|
35 |
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in
|
|
36 |
let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))"
|
|
37 |
| "decode' [] (STAR r) = (Void, [])"
|
|
38 |
| "decode' (S # ds) (STAR r) = (Stars [], ds)"
|
|
39 |
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in
|
|
40 |
let (vs, ds'') = decode' ds' (STAR r)
|
|
41 |
in (Stars_add v vs, ds''))"
|
|
42 |
by pat_completeness auto
|
|
43 |
|
|
44 |
lemma decode'_smaller:
|
|
45 |
assumes "decode'_dom (ds, r)"
|
|
46 |
shows "length (snd (decode' ds r)) \<le> length ds"
|
|
47 |
using assms
|
|
48 |
apply(induct ds r)
|
|
49 |
apply(auto simp add: decode'.psimps split: prod.split)
|
|
50 |
using dual_order.trans apply blast
|
|
51 |
by (meson dual_order.trans le_SucI)
|
|
52 |
|
|
53 |
termination "decode'"
|
|
54 |
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))")
|
|
55 |
apply(auto dest!: decode'_smaller)
|
|
56 |
by (metis less_Suc_eq_le snd_conv)
|
|
57 |
|
|
58 |
definition
|
|
59 |
decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option"
|
|
60 |
where
|
|
61 |
"decode ds r \<equiv> (let (v, ds') = decode' ds r
|
|
62 |
in (if ds' = [] then Some v else None))"
|
|
63 |
|
|
64 |
lemma decode'_code_Stars:
|
|
65 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []"
|
|
66 |
shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)"
|
|
67 |
using assms
|
|
68 |
apply(induct vs)
|
|
69 |
apply(auto)
|
|
70 |
done
|
|
71 |
|
|
72 |
lemma decode'_code:
|
|
73 |
assumes "\<Turnstile> v : r"
|
|
74 |
shows "decode' ((code v) @ ds) r = (v, ds)"
|
|
75 |
using assms
|
|
76 |
apply(induct v r arbitrary: ds)
|
|
77 |
apply(auto)
|
|
78 |
using decode'_code_Stars by blast
|
|
79 |
|
|
80 |
lemma decode_code:
|
|
81 |
assumes "\<Turnstile> v : r"
|
|
82 |
shows "decode (code v) r = Some v"
|
|
83 |
using assms unfolding decode_def
|
|
84 |
by (smt append_Nil2 decode'_code old.prod.case)
|
|
85 |
|
|
86 |
|
|
87 |
section {* Annotated Regular Expressions *}
|
|
88 |
|
|
89 |
datatype arexp =
|
|
90 |
AZERO
|
|
91 |
| AONE "bit list"
|
|
92 |
| ACHAR "bit list" char
|
|
93 |
| ASEQ "bit list" arexp arexp
|
|
94 |
| AALTs "bit list" "arexp list"
|
|
95 |
| ASTAR "bit list" arexp
|
|
96 |
|
|
97 |
abbreviation
|
|
98 |
"AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]"
|
|
99 |
|
|
100 |
fun asize :: "arexp \<Rightarrow> nat" where
|
|
101 |
"asize AZERO = 1"
|
|
102 |
| "asize (AONE cs) = 1"
|
|
103 |
| "asize (ACHAR cs c) = 1"
|
|
104 |
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))"
|
|
105 |
| "asize (ASEQ cs r1 r2) = Suc (asize r1 + asize r2)"
|
|
106 |
| "asize (ASTAR cs r) = Suc (asize r)"
|
|
107 |
|
|
108 |
fun
|
|
109 |
erase :: "arexp \<Rightarrow> rexp"
|
|
110 |
where
|
|
111 |
"erase AZERO = ZERO"
|
|
112 |
| "erase (AONE _) = ONE"
|
|
113 |
| "erase (ACHAR _ c) = CH c"
|
|
114 |
| "erase (AALTs _ []) = ZERO"
|
|
115 |
| "erase (AALTs _ [r]) = (erase r)"
|
|
116 |
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))"
|
|
117 |
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)"
|
|
118 |
| "erase (ASTAR _ r) = STAR (erase r)"
|
|
119 |
|
|
120 |
|
|
121 |
fun nonalt :: "arexp \<Rightarrow> bool"
|
|
122 |
where
|
|
123 |
"nonalt (AALTs bs2 rs) = False"
|
|
124 |
| "nonalt r = True"
|
|
125 |
|
|
126 |
|
|
127 |
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where
|
|
128 |
"fuse bs AZERO = AZERO"
|
|
129 |
| "fuse bs (AONE cs) = AONE (bs @ cs)"
|
|
130 |
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
|
|
131 |
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs"
|
|
132 |
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2"
|
|
133 |
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r"
|
|
134 |
|
|
135 |
lemma fuse_append:
|
|
136 |
shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)"
|
|
137 |
apply(induct r)
|
|
138 |
apply(auto)
|
|
139 |
done
|
|
140 |
|
|
141 |
lemma fuse_Nil:
|
|
142 |
shows "fuse [] r = r"
|
|
143 |
by (induct r)(simp_all)
|
|
144 |
|
|
145 |
lemma map_fuse_Nil:
|
|
146 |
shows "map (fuse []) rs = rs"
|
|
147 |
by (induct rs)(simp_all add: fuse_Nil)
|
|
148 |
|
|
149 |
|
|
150 |
fun intern :: "rexp \<Rightarrow> arexp" where
|
|
151 |
"intern ZERO = AZERO"
|
|
152 |
| "intern ONE = AONE []"
|
|
153 |
| "intern (CH c) = ACHAR [] c"
|
|
154 |
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1))
|
|
155 |
(fuse [S] (intern r2))"
|
|
156 |
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)"
|
|
157 |
| "intern (STAR r) = ASTAR [] (intern r)"
|
|
158 |
|
|
159 |
|
|
160 |
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bit list" where
|
|
161 |
"retrieve (AONE bs) Void = bs"
|
|
162 |
| "retrieve (ACHAR bs c) (Char d) = bs"
|
|
163 |
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v"
|
|
164 |
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v"
|
|
165 |
| "retrieve (AALTs bs (r#rs)) (Right v) = bs @ retrieve (AALTs [] rs) v"
|
|
166 |
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2"
|
|
167 |
| "retrieve (ASTAR bs r) (Stars []) = bs @ [S]"
|
|
168 |
| "retrieve (ASTAR bs r) (Stars (v#vs)) =
|
|
169 |
bs @ [Z] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)"
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
fun
|
|
174 |
bnullable :: "arexp \<Rightarrow> bool"
|
|
175 |
where
|
|
176 |
"bnullable (AZERO) = False"
|
|
177 |
| "bnullable (AONE bs) = True"
|
|
178 |
| "bnullable (ACHAR bs c) = False"
|
|
179 |
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
|
|
180 |
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)"
|
|
181 |
| "bnullable (ASTAR bs r) = True"
|
|
182 |
|
|
183 |
fun
|
|
184 |
bmkeps :: "arexp \<Rightarrow> bit list"
|
|
185 |
where
|
|
186 |
"bmkeps(AONE bs) = bs"
|
|
187 |
| "bmkeps(ASEQ bs r1 r2) = bs @ (bmkeps r1) @ (bmkeps r2)"
|
|
188 |
| "bmkeps(AALTs bs [r]) = bs @ (bmkeps r)"
|
|
189 |
| "bmkeps(AALTs bs (r#rs)) = (if bnullable(r) then bs @ (bmkeps r) else (bmkeps (AALTs bs rs)))"
|
|
190 |
| "bmkeps(ASTAR bs r) = bs @ [S]"
|
|
191 |
|
|
192 |
|
|
193 |
fun
|
|
194 |
bder :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
|
|
195 |
where
|
|
196 |
"bder c (AZERO) = AZERO"
|
|
197 |
| "bder c (AONE bs) = AZERO"
|
|
198 |
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)"
|
|
199 |
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)"
|
|
200 |
| "bder c (ASEQ bs r1 r2) =
|
|
201 |
(if bnullable r1
|
|
202 |
then AALT bs (ASEQ [] (bder c r1) r2) (fuse (bmkeps r1) (bder c r2))
|
|
203 |
else ASEQ bs (bder c r1) r2)"
|
|
204 |
| "bder c (ASTAR bs r) = ASEQ bs (fuse [Z] (bder c r)) (ASTAR [] r)"
|
|
205 |
|
|
206 |
|
|
207 |
fun
|
|
208 |
bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
|
|
209 |
where
|
|
210 |
"bders r [] = r"
|
|
211 |
| "bders r (c#s) = bders (bder c r) s"
|
|
212 |
|
|
213 |
lemma bders_append:
|
|
214 |
"bders r (s1 @ s2) = bders (bders r s1) s2"
|
|
215 |
apply(induct s1 arbitrary: r s2)
|
|
216 |
apply(simp_all)
|
|
217 |
done
|
|
218 |
|
|
219 |
lemma bnullable_correctness:
|
|
220 |
shows "nullable (erase r) = bnullable r"
|
|
221 |
apply(induct r rule: erase.induct)
|
|
222 |
apply(simp_all)
|
|
223 |
done
|
|
224 |
|
|
225 |
lemma erase_fuse:
|
|
226 |
shows "erase (fuse bs r) = erase r"
|
|
227 |
apply(induct r rule: erase.induct)
|
|
228 |
apply(simp_all)
|
|
229 |
done
|
|
230 |
|
|
231 |
lemma erase_intern [simp]:
|
|
232 |
shows "erase (intern r) = r"
|
|
233 |
apply(induct r)
|
|
234 |
apply(simp_all add: erase_fuse)
|
|
235 |
done
|
|
236 |
|
|
237 |
lemma erase_bder [simp]:
|
|
238 |
shows "erase (bder a r) = der a (erase r)"
|
|
239 |
apply(induct r rule: erase.induct)
|
|
240 |
apply(simp_all add: erase_fuse bnullable_correctness)
|
|
241 |
done
|
|
242 |
|
|
243 |
lemma erase_bders [simp]:
|
|
244 |
shows "erase (bders r s) = ders s (erase r)"
|
|
245 |
apply(induct s arbitrary: r )
|
|
246 |
apply(simp_all)
|
|
247 |
done
|
|
248 |
|
|
249 |
lemma bnullable_fuse:
|
|
250 |
shows "bnullable (fuse bs r) = bnullable r"
|
|
251 |
apply(induct r arbitrary: bs)
|
|
252 |
apply(auto)
|
|
253 |
done
|
|
254 |
|
|
255 |
lemma retrieve_encode_STARS:
|
|
256 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v"
|
|
257 |
shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)"
|
|
258 |
using assms
|
|
259 |
apply(induct vs)
|
|
260 |
apply(simp_all)
|
|
261 |
done
|
|
262 |
|
|
263 |
|
|
264 |
lemma retrieve_fuse2:
|
|
265 |
assumes "\<Turnstile> v : (erase r)"
|
|
266 |
shows "retrieve (fuse bs r) v = bs @ retrieve r v"
|
|
267 |
using assms
|
|
268 |
apply(induct r arbitrary: v bs)
|
|
269 |
apply(auto elim: Prf_elims)[4]
|
|
270 |
defer
|
|
271 |
using retrieve_encode_STARS
|
|
272 |
apply(auto elim!: Prf_elims)[1]
|
|
273 |
apply(case_tac vs)
|
|
274 |
apply(simp)
|
|
275 |
apply(simp)
|
|
276 |
(* AALTs case *)
|
|
277 |
apply(simp)
|
|
278 |
apply(case_tac x2a)
|
|
279 |
apply(simp)
|
|
280 |
apply(auto elim!: Prf_elims)[1]
|
|
281 |
apply(simp)
|
|
282 |
apply(case_tac list)
|
|
283 |
apply(simp)
|
|
284 |
apply(auto)
|
|
285 |
apply(auto elim!: Prf_elims)[1]
|
|
286 |
done
|
|
287 |
|
|
288 |
lemma retrieve_fuse:
|
|
289 |
assumes "\<Turnstile> v : r"
|
|
290 |
shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v"
|
|
291 |
using assms
|
|
292 |
by (simp_all add: retrieve_fuse2)
|
|
293 |
|
|
294 |
|
|
295 |
lemma retrieve_code:
|
|
296 |
assumes "\<Turnstile> v : r"
|
|
297 |
shows "code v = retrieve (intern r) v"
|
|
298 |
using assms
|
|
299 |
apply(induct v r )
|
|
300 |
apply(simp_all add: retrieve_fuse retrieve_encode_STARS)
|
|
301 |
done
|
|
302 |
|
|
303 |
|
|
304 |
lemma bnullable_Hdbmkeps_Hd:
|
|
305 |
assumes "bnullable a"
|
|
306 |
shows "bmkeps (AALTs bs (a # rs)) = bs @ (bmkeps a)"
|
|
307 |
using assms
|
|
308 |
by (metis bmkeps.simps(3) bmkeps.simps(4) list.exhaust)
|
|
309 |
|
|
310 |
lemma r1:
|
|
311 |
assumes "\<not> bnullable a" "bnullable (AALTs bs rs)"
|
|
312 |
shows "bmkeps (AALTs bs (a # rs)) = bmkeps (AALTs bs rs)"
|
|
313 |
using assms
|
|
314 |
apply(induct rs)
|
|
315 |
apply(auto)
|
|
316 |
done
|
|
317 |
|
|
318 |
lemma r2:
|
|
319 |
assumes "x \<in> set rs" "bnullable x"
|
|
320 |
shows "bnullable (AALTs bs rs)"
|
|
321 |
using assms
|
|
322 |
apply(induct rs)
|
|
323 |
apply(auto)
|
|
324 |
done
|
|
325 |
|
|
326 |
lemma r3:
|
|
327 |
assumes "\<not> bnullable r"
|
|
328 |
" \<exists> x \<in> set rs. bnullable x"
|
|
329 |
shows "retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs))) =
|
|
330 |
retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs))))"
|
|
331 |
using assms
|
|
332 |
apply(induct rs arbitrary: r bs)
|
|
333 |
apply(auto)[1]
|
|
334 |
apply(auto)
|
|
335 |
using bnullable_correctness apply blast
|
|
336 |
apply(auto simp add: bnullable_correctness mkeps_nullable retrieve_fuse2)
|
|
337 |
apply(subst retrieve_fuse2[symmetric])
|
|
338 |
apply (smt bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable)
|
|
339 |
apply(simp)
|
|
340 |
apply(case_tac "bnullable a")
|
|
341 |
apply (smt append_Nil2 bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) fuse.simps(4) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable retrieve_fuse2)
|
|
342 |
apply(drule_tac x="a" in meta_spec)
|
|
343 |
apply(drule_tac x="bs" in meta_spec)
|
|
344 |
apply(drule meta_mp)
|
|
345 |
apply(simp)
|
|
346 |
apply(drule meta_mp)
|
|
347 |
apply(auto)
|
|
348 |
apply(subst retrieve_fuse2[symmetric])
|
|
349 |
apply(case_tac rs)
|
|
350 |
apply(simp)
|
|
351 |
apply(auto)[1]
|
|
352 |
apply (simp add: bnullable_correctness)
|
|
353 |
apply (metis append_Nil2 bnullable_correctness erase_fuse fuse.simps(4) list.set_intros(1) mkeps.simps(3) mkeps_nullable nullable.simps(4) r2)
|
|
354 |
apply (simp add: bnullable_correctness)
|
|
355 |
apply (metis append_Nil2 bnullable_correctness erase.simps(6) erase_fuse fuse.simps(4) list.set_intros(2) mkeps.simps(3) mkeps_nullable r2)
|
|
356 |
apply(simp)
|
|
357 |
done
|
|
358 |
|
|
359 |
|
|
360 |
lemma t:
|
|
361 |
assumes "\<forall>r \<in> set rs. nullable (erase r) \<longrightarrow> bmkeps r = retrieve r (mkeps (erase r))"
|
|
362 |
"nullable (erase (AALTs bs rs))"
|
|
363 |
shows " bmkeps (AALTs bs rs) = retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))"
|
|
364 |
using assms
|
|
365 |
apply(induct rs arbitrary: bs)
|
|
366 |
apply(simp)
|
|
367 |
apply(auto simp add: bnullable_correctness)
|
|
368 |
apply(case_tac rs)
|
|
369 |
apply(auto simp add: bnullable_correctness)[2]
|
|
370 |
apply(subst r1)
|
|
371 |
apply(simp)
|
|
372 |
apply(rule r2)
|
|
373 |
apply(assumption)
|
|
374 |
apply(simp)
|
|
375 |
apply(drule_tac x="bs" in meta_spec)
|
|
376 |
apply(drule meta_mp)
|
|
377 |
apply(auto)[1]
|
|
378 |
prefer 2
|
|
379 |
apply(case_tac "bnullable a")
|
|
380 |
apply(subst bnullable_Hdbmkeps_Hd)
|
|
381 |
apply blast
|
|
382 |
apply(subgoal_tac "nullable (erase a)")
|
|
383 |
prefer 2
|
|
384 |
using bnullable_correctness apply blast
|
|
385 |
apply (metis (no_types, lifting) erase.simps(5) erase.simps(6) list.exhaust mkeps.simps(3) retrieve.simps(3) retrieve.simps(4))
|
|
386 |
apply(subst r1)
|
|
387 |
apply(simp)
|
|
388 |
using r2 apply blast
|
|
389 |
apply(drule_tac x="bs" in meta_spec)
|
|
390 |
apply(drule meta_mp)
|
|
391 |
apply(auto)[1]
|
|
392 |
apply(simp)
|
|
393 |
using r3 apply blast
|
|
394 |
apply(auto)
|
|
395 |
using r3 by blast
|
|
396 |
|
|
397 |
lemma bmkeps_retrieve:
|
|
398 |
assumes "nullable (erase r)"
|
|
399 |
shows "bmkeps r = retrieve r (mkeps (erase r))"
|
|
400 |
using assms
|
|
401 |
apply(induct r)
|
|
402 |
apply(simp)
|
|
403 |
apply(simp)
|
|
404 |
apply(simp)
|
|
405 |
apply(simp)
|
|
406 |
defer
|
|
407 |
apply(simp)
|
|
408 |
apply(rule t)
|
|
409 |
apply(auto)
|
|
410 |
done
|
|
411 |
|
|
412 |
lemma bder_retrieve:
|
|
413 |
assumes "\<Turnstile> v : der c (erase r)"
|
|
414 |
shows "retrieve (bder c r) v = retrieve r (injval (erase r) c v)"
|
|
415 |
using assms
|
|
416 |
apply(induct r arbitrary: v rule: erase.induct)
|
|
417 |
apply(simp)
|
|
418 |
apply(erule Prf_elims)
|
|
419 |
apply(simp)
|
|
420 |
apply(erule Prf_elims)
|
|
421 |
apply(simp)
|
|
422 |
apply(case_tac "c = ca")
|
|
423 |
apply(simp)
|
|
424 |
apply(erule Prf_elims)
|
|
425 |
apply(simp)
|
|
426 |
apply(simp)
|
|
427 |
apply(erule Prf_elims)
|
|
428 |
apply(simp)
|
|
429 |
apply(erule Prf_elims)
|
|
430 |
apply(simp)
|
|
431 |
apply(simp)
|
|
432 |
apply(rename_tac "r\<^sub>1" "r\<^sub>2" rs v)
|
|
433 |
apply(erule Prf_elims)
|
|
434 |
apply(simp)
|
|
435 |
apply(simp)
|
|
436 |
apply(case_tac rs)
|
|
437 |
apply(simp)
|
|
438 |
apply(simp)
|
|
439 |
apply (smt Prf_elims(3) injval.simps(2) injval.simps(3) retrieve.simps(4) retrieve.simps(5) same_append_eq)
|
|
440 |
apply(simp)
|
|
441 |
apply(case_tac "nullable (erase r1)")
|
|
442 |
apply(simp)
|
|
443 |
apply(erule Prf_elims)
|
|
444 |
apply(subgoal_tac "bnullable r1")
|
|
445 |
prefer 2
|
|
446 |
using bnullable_correctness apply blast
|
|
447 |
apply(simp)
|
|
448 |
apply(erule Prf_elims)
|
|
449 |
apply(simp)
|
|
450 |
apply(subgoal_tac "bnullable r1")
|
|
451 |
prefer 2
|
|
452 |
using bnullable_correctness apply blast
|
|
453 |
apply(simp)
|
|
454 |
apply(simp add: retrieve_fuse2)
|
|
455 |
apply(simp add: bmkeps_retrieve)
|
|
456 |
apply(simp)
|
|
457 |
apply(erule Prf_elims)
|
|
458 |
apply(simp)
|
|
459 |
using bnullable_correctness apply blast
|
|
460 |
apply(rename_tac bs r v)
|
|
461 |
apply(simp)
|
|
462 |
apply(erule Prf_elims)
|
|
463 |
apply(clarify)
|
|
464 |
apply(erule Prf_elims)
|
|
465 |
apply(clarify)
|
|
466 |
apply(subst injval.simps)
|
|
467 |
apply(simp del: retrieve.simps)
|
|
468 |
apply(subst retrieve.simps)
|
|
469 |
apply(subst retrieve.simps)
|
|
470 |
apply(simp)
|
|
471 |
apply(simp add: retrieve_fuse2)
|
|
472 |
done
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
lemma MAIN_decode:
|
|
477 |
assumes "\<Turnstile> v : ders s r"
|
|
478 |
shows "Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r"
|
|
479 |
using assms
|
|
480 |
proof (induct s arbitrary: v rule: rev_induct)
|
|
481 |
case Nil
|
|
482 |
have "\<Turnstile> v : ders [] r" by fact
|
|
483 |
then have "\<Turnstile> v : r" by simp
|
|
484 |
then have "Some v = decode (retrieve (intern r) v) r"
|
|
485 |
using decode_code retrieve_code by auto
|
|
486 |
then show "Some (flex r id [] v) = decode (retrieve (bders (intern r) []) v) r"
|
|
487 |
by simp
|
|
488 |
next
|
|
489 |
case (snoc c s v)
|
|
490 |
have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow>
|
|
491 |
Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" by fact
|
|
492 |
have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact
|
|
493 |
then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r"
|
|
494 |
by (simp add: Prf_injval ders_append)
|
|
495 |
have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))"
|
|
496 |
by (simp add: flex_append)
|
|
497 |
also have "... = decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r"
|
|
498 |
using asm2 IH by simp
|
|
499 |
also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r"
|
|
500 |
using asm by (simp_all add: bder_retrieve ders_append)
|
|
501 |
finally show "Some (flex r id (s @ [c]) v) =
|
|
502 |
decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append)
|
|
503 |
qed
|
|
504 |
|
|
505 |
|
|
506 |
definition blex where
|
|
507 |
"blex a s \<equiv> if bnullable (bders a s) then Some (bmkeps (bders a s)) else None"
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
definition blexer where
|
|
512 |
"blexer r s \<equiv> if bnullable (bders (intern r) s) then
|
|
513 |
decode (bmkeps (bders (intern r) s)) r else None"
|
|
514 |
|
|
515 |
lemma blexer_correctness:
|
|
516 |
shows "blexer r s = lexer r s"
|
|
517 |
proof -
|
|
518 |
{ define bds where "bds \<equiv> bders (intern r) s"
|
|
519 |
define ds where "ds \<equiv> ders s r"
|
|
520 |
assume asm: "nullable ds"
|
|
521 |
have era: "erase bds = ds"
|
|
522 |
unfolding ds_def bds_def by simp
|
|
523 |
have mke: "\<Turnstile> mkeps ds : ds"
|
|
524 |
using asm by (simp add: mkeps_nullable)
|
|
525 |
have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r"
|
|
526 |
using bmkeps_retrieve
|
|
527 |
using asm era by (simp add: bmkeps_retrieve)
|
|
528 |
also have "... = Some (flex r id s (mkeps ds))"
|
|
529 |
using mke by (simp_all add: MAIN_decode ds_def bds_def)
|
|
530 |
finally have "decode (bmkeps bds) r = Some (flex r id s (mkeps ds))"
|
|
531 |
unfolding bds_def ds_def .
|
|
532 |
}
|
|
533 |
then show "blexer r s = lexer r s"
|
|
534 |
unfolding blexer_def lexer_flex
|
|
535 |
apply(subst bnullable_correctness[symmetric])
|
|
536 |
apply(simp)
|
|
537 |
done
|
|
538 |
qed
|
|
539 |
|
|
540 |
|
|
541 |
fun distinctBy :: "'a list \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b set \<Rightarrow> 'a list"
|
|
542 |
where
|
|
543 |
"distinctBy [] f acc = []"
|
|
544 |
| "distinctBy (x#xs) f acc =
|
|
545 |
(if (f x) \<in> acc then distinctBy xs f acc
|
|
546 |
else x # (distinctBy xs f ({f x} \<union> acc)))"
|
|
547 |
|
|
548 |
(*filter (\<lambda>rt. case rt of
|
|
549 |
SEQ r1p r2p \<Rightarrow> r2p = (erase r2)
|
|
550 |
r \<Rightarrow> False ) allowableTerms*)
|
|
551 |
|
|
552 |
|
|
553 |
lemma dB_single_step:
|
|
554 |
shows "distinctBy (a#rs) f {} = a # distinctBy rs f {f a}"
|
|
555 |
by simp
|
|
556 |
|
|
557 |
fun flts :: "arexp list \<Rightarrow> arexp list"
|
|
558 |
where
|
|
559 |
"flts [] = []"
|
|
560 |
| "flts (AZERO # rs) = flts rs"
|
|
561 |
| "flts ((AALTs bs rs1) # rs) = (map (fuse bs) rs1) @ flts rs"
|
|
562 |
| "flts (r1 # rs) = r1 # flts rs"
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
|
|
567 |
where
|
|
568 |
"bsimp_ASEQ _ AZERO _ = AZERO"
|
|
569 |
| "bsimp_ASEQ _ _ AZERO = AZERO"
|
|
570 |
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
|
|
571 |
| "bsimp_ASEQ bs1 r1 r2 = ASEQ bs1 r1 r2"
|
|
572 |
|
|
573 |
|
|
574 |
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
|
|
575 |
where
|
|
576 |
"bsimp_AALTs _ [] = AZERO"
|
|
577 |
| "bsimp_AALTs bs1 [r] = fuse bs1 r"
|
|
578 |
| "bsimp_AALTs bs1 rs = AALTs bs1 rs"
|
|
579 |
|
|
580 |
|
|
581 |
fun bsimp_ASEQ1 :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
|
|
582 |
where
|
|
583 |
"bsimp_ASEQ1 _ AZERO _ = AZERO"
|
|
584 |
| "bsimp_ASEQ1 bs (AONE bs1) r2 = fuse (bs @ bs1) r2"
|
|
585 |
| "bsimp_ASEQ1 bs r1 r2 = ASEQ bs r1 r2"
|
|
586 |
|
|
587 |
|
436
|
588 |
fun collect :: "rexp \<Rightarrow> rexp list \<Rightarrow> rexp list" where
|
432
|
589 |
\<open>collect _ [] = []\<close>
|
436
|
590 |
| \<open>collect erasedR2 ((SEQ r1 r2) # rs) =
|
|
591 |
(if r2 = erasedR2 then r1 # (collect erasedR2 rs) else collect erasedR2 rs)\<close>
|
432
|
592 |
| \<open>collect erasedR2 (r # rs) = collect erasedR2 rs\<close>
|
|
593 |
|
|
594 |
|
|
595 |
fun pruneRexp where
|
436
|
596 |
"pruneRexp (ASEQ bs r1 r2) allowableTerms =
|
|
597 |
(let termsTruncated = (collect (erase r2) allowableTerms) in
|
|
598 |
(let pruned = pruneRexp r1 termsTruncated in
|
|
599 |
(bsimp_ASEQ1 bs pruned r2)))"
|
|
600 |
| \<open>pruneRexp (AALTs bs rs) allowableTerms =
|
|
601 |
(let rsp = (filter (\<lambda>r. r \<noteq> AZERO) (map (\<lambda>r. pruneRexp r allowableTerms) rs) ) in bsimp_AALTs bs rsp )
|
432
|
602 |
\<close>
|
|
603 |
| \<open>pruneRexp r allowableTerms = (if (erase r) \<in> (set allowableTerms) then r else AZERO)\<close>
|
|
604 |
|
|
605 |
|
|
606 |
fun oneSimp :: \<open>rexp \<Rightarrow> rexp\<close> where
|
|
607 |
\<open> oneSimp (SEQ ONE r) = r \<close>
|
|
608 |
| \<open> oneSimp (SEQ r1 r2) = SEQ (oneSimp r1) r2 \<close>
|
|
609 |
| \<open> oneSimp r = r \<close>
|
|
610 |
|
|
611 |
fun breakIntoTerms where
|
|
612 |
\<open>breakIntoTerms (SEQ r1 r2) = map (\<lambda>r1p. SEQ r1p r2) (breakIntoTerms r1)\<close>
|
|
613 |
| \<open>breakIntoTerms (ALT r1 r2) = (breakIntoTerms r1) @ (breakIntoTerms r2)\<close>
|
|
614 |
| \<open>breakIntoTerms r = r # [] \<close>
|
|
615 |
|
|
616 |
fun addToAcc :: "arexp \<Rightarrow> rexp list \<Rightarrow> rexp list"
|
|
617 |
where
|
|
618 |
\<open>addToAcc r acc = filter (\<lambda>r1. oneSimp r1 \<notin> set acc) (breakIntoTerms (erase r)) \<close>
|
|
619 |
|
|
620 |
fun dBStrong :: "arexp list \<Rightarrow> rexp list \<Rightarrow> arexp list"
|
|
621 |
where
|
|
622 |
"dBStrong [] acc = []"
|
|
623 |
| "dBStrong (r # rs) acc = (if (erase r) \<in> (set acc) then dBStrong rs acc
|
|
624 |
else (case (pruneRexp r (addToAcc r acc)) of
|
|
625 |
AZERO \<Rightarrow> dBStrong rs ((addToAcc r acc) @ acc) |
|
|
626 |
r1 \<Rightarrow> r1 # (dBStrong rs ((addToAcc r acc) @ acc))
|
|
627 |
)
|
|
628 |
)
|
|
629 |
"
|
|
630 |
fun bsimpStrong :: "arexp \<Rightarrow> arexp "
|
|
631 |
where
|
|
632 |
"bsimpStrong (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimpStrong r1) (bsimpStrong r2)"
|
|
633 |
| "bsimpStrong (AALTs bs1 rs) = bsimp_AALTs bs1 (dBStrong (flts (map bsimpStrong rs)) []) "
|
|
634 |
| "bsimpStrong r = r"
|
|
635 |
|
|
636 |
|
|
637 |
fun bdersStrong :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
|
|
638 |
where
|
|
639 |
"bdersStrong r [] = r"
|
|
640 |
| "bdersStrong r (c # s) = bdersStrong (bsimpStrong (bder c r)) s"
|
|
641 |
|
|
642 |
|
|
643 |
definition blexerStrong where
|
|
644 |
"blexerStrong r s \<equiv> if bnullable (bdersStrong (intern r) s) then
|
|
645 |
decode (bmkeps (bdersStrong (intern r) s)) r else None"
|
|
646 |
|
|
647 |
|
|
648 |
|
|
649 |
fun bsimp :: "arexp \<Rightarrow> arexp"
|
|
650 |
where
|
|
651 |
"bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)"
|
|
652 |
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (distinctBy (flts (map bsimp rs)) erase {}) "
|
|
653 |
| "bsimp r = r"
|
|
654 |
|
|
655 |
|
|
656 |
fun
|
|
657 |
bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
|
|
658 |
where
|
|
659 |
"bders_simp r [] = r"
|
|
660 |
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s"
|
|
661 |
|
|
662 |
definition blexer_simp where
|
|
663 |
"blexer_simp r s \<equiv> if bnullable (bders_simp (intern r) s) then
|
|
664 |
decode (bmkeps (bders_simp (intern r) s)) r else None"
|
|
665 |
|
|
666 |
export_code bders_simp in Scala module_name Example
|
|
667 |
|
|
668 |
lemma bders_simp_append:
|
|
669 |
shows "bders_simp r (s1 @ s2) = bders_simp (bders_simp r s1) s2"
|
|
670 |
apply(induct s1 arbitrary: r s2)
|
|
671 |
apply(simp_all)
|
|
672 |
done
|
|
673 |
|
|
674 |
lemma L_bsimp_ASEQ:
|
|
675 |
"L (SEQ (erase r1) (erase r2)) = L (erase (bsimp_ASEQ bs r1 r2))"
|
|
676 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
|
|
677 |
apply(simp_all)
|
|
678 |
by (metis erase_fuse fuse.simps(4))
|
|
679 |
|
|
680 |
lemma L_bsimp_AALTs:
|
|
681 |
"L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))"
|
|
682 |
apply(induct bs rs rule: bsimp_AALTs.induct)
|
|
683 |
apply(simp_all add: erase_fuse)
|
|
684 |
done
|
|
685 |
|
|
686 |
lemma L_erase_AALTs:
|
|
687 |
shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))"
|
|
688 |
apply(induct rs)
|
|
689 |
apply(simp)
|
|
690 |
apply(simp)
|
|
691 |
apply(case_tac rs)
|
|
692 |
apply(simp)
|
|
693 |
apply(simp)
|
|
694 |
done
|
|
695 |
|
|
696 |
lemma L_erase_flts:
|
|
697 |
shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))"
|
|
698 |
apply(induct rs rule: flts.induct)
|
|
699 |
apply(simp_all)
|
|
700 |
apply(auto)
|
|
701 |
using L_erase_AALTs erase_fuse apply auto[1]
|
|
702 |
by (simp add: L_erase_AALTs erase_fuse)
|
|
703 |
|
|
704 |
lemma L_erase_dB_acc:
|
|
705 |
shows "( \<Union>(L ` acc) \<union> ( \<Union> (L ` erase ` (set (distinctBy rs erase acc) ) ) )) = \<Union>(L ` acc) \<union> \<Union> (L ` erase ` (set rs))"
|
|
706 |
apply(induction rs arbitrary: acc)
|
|
707 |
apply simp
|
|
708 |
apply simp
|
|
709 |
by (smt (z3) SUP_absorb UN_insert sup_assoc sup_commute)
|
|
710 |
|
|
711 |
lemma L_erase_dB:
|
|
712 |
shows " ( \<Union> (L ` erase ` (set (distinctBy rs erase {}) ) ) ) = \<Union> (L ` erase ` (set rs))"
|
|
713 |
by (metis L_erase_dB_acc Un_commute Union_image_empty)
|
|
714 |
|
|
715 |
lemma L_bsimp_erase:
|
|
716 |
shows "L (erase r) = L (erase (bsimp r))"
|
|
717 |
apply(induct r)
|
|
718 |
apply(simp)
|
|
719 |
apply(simp)
|
|
720 |
apply(simp)
|
|
721 |
apply(auto simp add: Sequ_def)[1]
|
|
722 |
apply(subst L_bsimp_ASEQ[symmetric])
|
|
723 |
apply(auto simp add: Sequ_def)[1]
|
|
724 |
apply(subst (asm) L_bsimp_ASEQ[symmetric])
|
|
725 |
apply(auto simp add: Sequ_def)[1]
|
|
726 |
apply(simp)
|
|
727 |
apply(subst L_bsimp_AALTs[symmetric])
|
|
728 |
defer
|
|
729 |
apply(simp)
|
|
730 |
apply(subst (2)L_erase_AALTs)
|
|
731 |
apply(subst L_erase_dB)
|
|
732 |
apply(subst L_erase_flts)
|
|
733 |
apply(auto)
|
|
734 |
apply (simp add: L_erase_AALTs)
|
|
735 |
using L_erase_AALTs by blast
|
|
736 |
|
|
737 |
|
|
738 |
|
|
739 |
lemma bsimp_ASEQ0:
|
|
740 |
shows "bsimp_ASEQ bs r1 AZERO = AZERO"
|
|
741 |
apply(induct r1)
|
|
742 |
apply(auto)
|
|
743 |
done
|
|
744 |
|
|
745 |
lemma bsimp_ASEQ1:
|
|
746 |
assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
|
|
747 |
shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2"
|
|
748 |
using assms
|
|
749 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
|
|
750 |
apply(auto)
|
|
751 |
done
|
|
752 |
|
|
753 |
lemma bsimp_ASEQ2:
|
|
754 |
shows "bsimp_ASEQ bs (AONE bs1) r2 = fuse (bs @ bs1) r2"
|
|
755 |
apply(induct r2)
|
|
756 |
apply(auto)
|
|
757 |
done
|
|
758 |
|
|
759 |
|
|
760 |
lemma L_bders_simp:
|
|
761 |
shows "L (erase (bders_simp r s)) = L (erase (bders r s))"
|
|
762 |
apply(induct s arbitrary: r rule: rev_induct)
|
|
763 |
apply(simp)
|
|
764 |
apply(simp)
|
|
765 |
apply(simp add: ders_append)
|
|
766 |
apply(simp add: bders_simp_append)
|
|
767 |
apply(simp add: L_bsimp_erase[symmetric])
|
|
768 |
by (simp add: der_correctness)
|
|
769 |
|
|
770 |
|
|
771 |
lemma b2:
|
|
772 |
assumes "bnullable r"
|
|
773 |
shows "bmkeps (fuse bs r) = bs @ bmkeps r"
|
|
774 |
by (simp add: assms bmkeps_retrieve bnullable_correctness erase_fuse mkeps_nullable retrieve_fuse2)
|
|
775 |
|
|
776 |
|
|
777 |
lemma b4:
|
|
778 |
shows "bnullable (bders_simp r s) = bnullable (bders r s)"
|
|
779 |
by (metis L_bders_simp bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1))
|
|
780 |
|
|
781 |
lemma qq1:
|
|
782 |
assumes "\<exists>r \<in> set rs. bnullable r"
|
|
783 |
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs)"
|
|
784 |
using assms
|
|
785 |
apply(induct rs arbitrary: rs1 bs)
|
|
786 |
apply(simp)
|
|
787 |
apply(simp)
|
|
788 |
by (metis Nil_is_append_conv bmkeps.simps(4) neq_Nil_conv bnullable_Hdbmkeps_Hd split_list_last)
|
|
789 |
|
|
790 |
lemma qq2:
|
|
791 |
assumes "\<forall>r \<in> set rs. \<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r"
|
|
792 |
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs1)"
|
|
793 |
using assms
|
|
794 |
apply(induct rs arbitrary: rs1 bs)
|
|
795 |
apply(simp)
|
|
796 |
apply(simp)
|
|
797 |
by (metis append_assoc in_set_conv_decomp r1 r2)
|
|
798 |
|
|
799 |
lemma qq3:
|
|
800 |
assumes "bnullable (AALTs bs (rs @ rs1))"
|
|
801 |
"bnullable (AALTs bs (rs @ rs2))"
|
|
802 |
"\<lbrakk>bnullable (AALTs bs rs1); bnullable (AALTs bs rs2); \<forall>r\<in>set rs. \<not>bnullable r\<rbrakk> \<Longrightarrow>
|
|
803 |
bmkeps (AALTs bs rs1) = bmkeps (AALTs bs rs2)"
|
|
804 |
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs (rs @ rs2))"
|
|
805 |
using assms
|
|
806 |
apply(case_tac "\<exists>r \<in> set rs. bnullable r")
|
|
807 |
using qq1 apply auto[1]
|
|
808 |
by (metis UnE bnullable.simps(4) qq2 set_append)
|
|
809 |
|
|
810 |
|
|
811 |
lemma flts_append:
|
|
812 |
shows "flts (xs1 @ xs2) = flts xs1 @ flts xs2"
|
|
813 |
by (induct xs1 arbitrary: xs2 rule: flts.induct)(auto)
|
|
814 |
|
|
815 |
lemma k0a:
|
|
816 |
shows "flts [AALTs bs rs] = map (fuse bs) rs"
|
|
817 |
apply(simp)
|
|
818 |
done
|
|
819 |
|
|
820 |
|
|
821 |
lemma bbbbs1:
|
|
822 |
shows "nonalt r \<or> (\<exists>bs rs. r = AALTs bs rs)"
|
|
823 |
using nonalt.elims(3) by auto
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
fun nonazero :: "arexp \<Rightarrow> bool"
|
|
828 |
where
|
|
829 |
"nonazero AZERO = False"
|
|
830 |
| "nonazero r = True"
|
|
831 |
|
|
832 |
|
|
833 |
lemma flts_single1:
|
|
834 |
assumes "nonalt r" "nonazero r"
|
|
835 |
shows "flts [r] = [r]"
|
|
836 |
using assms
|
|
837 |
apply(induct r)
|
|
838 |
apply(auto)
|
|
839 |
done
|
|
840 |
|
|
841 |
|
|
842 |
|
|
843 |
lemma q3a:
|
|
844 |
assumes "\<exists>r \<in> set rs. bnullable r"
|
|
845 |
shows "bmkeps (AALTs bs (map (fuse bs1) rs)) = bmkeps (AALTs (bs@bs1) rs)"
|
|
846 |
using assms
|
|
847 |
apply(induct rs arbitrary: bs bs1)
|
|
848 |
apply(simp)
|
|
849 |
apply(simp)
|
|
850 |
apply(auto)
|
|
851 |
apply (metis append_assoc b2 bnullable_correctness erase_fuse bnullable_Hdbmkeps_Hd)
|
|
852 |
apply(case_tac "bnullable a")
|
|
853 |
apply (metis append.assoc b2 bnullable_correctness erase_fuse bnullable_Hdbmkeps_Hd)
|
|
854 |
apply(case_tac rs)
|
|
855 |
apply(simp)
|
|
856 |
apply(simp)
|
|
857 |
apply(auto)[1]
|
|
858 |
apply (metis bnullable_correctness erase_fuse)+
|
|
859 |
done
|
|
860 |
|
|
861 |
lemma qq4:
|
|
862 |
assumes "\<exists>x\<in>set list. bnullable x"
|
|
863 |
shows "\<exists>x\<in>set (flts list). bnullable x"
|
|
864 |
using assms
|
|
865 |
apply(induct list rule: flts.induct)
|
|
866 |
apply(auto)
|
|
867 |
by (metis UnCI bnullable_correctness erase_fuse imageI)
|
|
868 |
|
|
869 |
|
|
870 |
lemma qs3:
|
|
871 |
assumes "\<exists>r \<in> set rs. bnullable r"
|
|
872 |
shows "bmkeps (AALTs bs rs) = bmkeps (AALTs bs (flts rs))"
|
|
873 |
using assms
|
|
874 |
apply(induct rs arbitrary: bs taking: size rule: measure_induct)
|
|
875 |
apply(case_tac x)
|
|
876 |
apply(simp)
|
|
877 |
apply(simp)
|
|
878 |
apply(case_tac a)
|
|
879 |
apply(simp)
|
|
880 |
apply (simp add: r1)
|
|
881 |
apply(simp)
|
|
882 |
apply (simp add: bnullable_Hdbmkeps_Hd)
|
|
883 |
apply(simp)
|
|
884 |
apply(case_tac "flts list")
|
|
885 |
apply(simp)
|
|
886 |
apply (metis L_erase_AALTs L_erase_flts L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(4) mkeps_nullable r2)
|
|
887 |
apply(simp)
|
|
888 |
apply (simp add: r1)
|
|
889 |
prefer 3
|
|
890 |
apply(simp)
|
|
891 |
apply (simp add: bnullable_Hdbmkeps_Hd)
|
|
892 |
prefer 2
|
|
893 |
apply(simp)
|
|
894 |
apply(case_tac "\<exists>x\<in>set x52. bnullable x")
|
|
895 |
apply(case_tac "list")
|
|
896 |
apply(simp)
|
|
897 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
898 |
apply(erule disjE)
|
|
899 |
apply(subst qq1)
|
|
900 |
apply(auto)[1]
|
|
901 |
apply (metis bnullable_correctness erase_fuse)
|
|
902 |
apply(simp)
|
|
903 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
904 |
apply(simp)
|
|
905 |
apply(auto)[1]
|
|
906 |
apply(subst qq1)
|
|
907 |
apply (metis bnullable_correctness erase_fuse image_eqI set_map)
|
|
908 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
909 |
apply(subst qq1)
|
|
910 |
apply (metis bnullable_correctness erase_fuse image_eqI set_map)
|
|
911 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
912 |
apply(simp)
|
|
913 |
apply(subst qq2)
|
|
914 |
apply (metis bnullable_correctness erase_fuse imageE set_map)
|
|
915 |
prefer 2
|
|
916 |
apply(case_tac "list")
|
|
917 |
apply(simp)
|
|
918 |
apply(simp)
|
|
919 |
apply (simp add: qq4)
|
|
920 |
apply(simp)
|
|
921 |
apply(auto)
|
|
922 |
apply(case_tac list)
|
|
923 |
apply(simp)
|
|
924 |
apply(simp)
|
|
925 |
apply (simp add: bnullable_Hdbmkeps_Hd)
|
|
926 |
apply(case_tac "bnullable (ASEQ x41 x42 x43)")
|
|
927 |
apply(case_tac list)
|
|
928 |
apply(simp)
|
|
929 |
apply(simp)
|
|
930 |
apply (simp add: bnullable_Hdbmkeps_Hd)
|
|
931 |
apply(simp)
|
|
932 |
using qq4 r1 r2 by auto
|
|
933 |
|
|
934 |
lemma bder_fuse:
|
|
935 |
shows "bder c (fuse bs a) = fuse bs (bder c a)"
|
|
936 |
apply(induct a arbitrary: bs c)
|
|
937 |
apply(simp_all)
|
|
938 |
done
|
|
939 |
|
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
inductive
|
|
944 |
rrewrite:: "arexp \<Rightarrow> arexp \<Rightarrow> bool" ("_ \<leadsto> _" [99, 99] 99)
|
|
945 |
where
|
|
946 |
"ASEQ bs AZERO r2 \<leadsto> AZERO"
|
|
947 |
| "ASEQ bs r1 AZERO \<leadsto> AZERO"
|
|
948 |
| "ASEQ bs1 (AONE bs2) r \<leadsto> fuse (bs1@bs2) r"
|
|
949 |
| "r1 \<leadsto> r2 \<Longrightarrow> ASEQ bs r1 r3 \<leadsto> ASEQ bs r2 r3"
|
|
950 |
| "r3 \<leadsto> r4 \<Longrightarrow> ASEQ bs r1 r3 \<leadsto> ASEQ bs r1 r4"
|
|
951 |
| "r \<leadsto> r' \<Longrightarrow> (AALTs bs (rs1 @ [r] @ rs2)) \<leadsto> (AALTs bs (rs1 @ [r'] @ rs2))"
|
|
952 |
(*context rule for eliminating 0, alts--corresponds to the recursive call flts r::rs = r::(flts rs)*)
|
|
953 |
| "AALTs bs (rsa@ [AZERO] @ rsb) \<leadsto> AALTs bs (rsa @ rsb)"
|
|
954 |
| "AALTs bs (rsa@ [AALTs bs1 rs1] @ rsb) \<leadsto> AALTs bs (rsa@(map (fuse bs1) rs1)@rsb)"
|
|
955 |
| "AALTs bs [] \<leadsto> AZERO"
|
|
956 |
| "AALTs bs [r] \<leadsto> fuse bs r"
|
|
957 |
| "erase a1 = erase a2 \<Longrightarrow> AALTs bs (rsa@[a1]@rsb@[a2]@rsc) \<leadsto> AALTs bs (rsa@[a1]@rsb@rsc)"
|
|
958 |
|
|
959 |
|
|
960 |
inductive
|
|
961 |
rrewrites:: "arexp \<Rightarrow> arexp \<Rightarrow> bool" ("_ \<leadsto>* _" [100, 100] 100)
|
|
962 |
where
|
|
963 |
rs1[intro, simp]:"r \<leadsto>* r"
|
|
964 |
| rs2[intro]: "\<lbrakk>r1 \<leadsto>* r2; r2 \<leadsto> r3\<rbrakk> \<Longrightarrow> r1 \<leadsto>* r3"
|
|
965 |
|
|
966 |
|
|
967 |
inductive
|
|
968 |
srewrites:: "arexp list \<Rightarrow> arexp list \<Rightarrow> bool" (" _ s\<leadsto>* _" [100, 100] 100)
|
|
969 |
where
|
|
970 |
ss1: "[] s\<leadsto>* []"
|
|
971 |
| ss2: "\<lbrakk>r \<leadsto>* r'; rs s\<leadsto>* rs'\<rbrakk> \<Longrightarrow> (r#rs) s\<leadsto>* (r'#rs')"
|
|
972 |
|
|
973 |
|
|
974 |
(* rewrites for lists *)
|
|
975 |
inductive
|
|
976 |
frewrites:: "arexp list \<Rightarrow> arexp list \<Rightarrow> bool" (" _ f\<leadsto>* _" [100, 100] 100)
|
|
977 |
where
|
|
978 |
fs1: "[] f\<leadsto>* []"
|
|
979 |
| fs2: "\<lbrakk>rs f\<leadsto>* rs'\<rbrakk> \<Longrightarrow> (AZERO#rs) f\<leadsto>* rs'"
|
|
980 |
| fs3: "\<lbrakk>rs f\<leadsto>* rs'\<rbrakk> \<Longrightarrow> ((AALTs bs rs1) # rs) f\<leadsto>* ((map (fuse bs) rs1) @ rs')"
|
|
981 |
| fs4: "\<lbrakk>rs f\<leadsto>* rs'; nonalt r; nonazero r\<rbrakk> \<Longrightarrow> (r#rs) f\<leadsto>* (r#rs')"
|
|
982 |
|
|
983 |
|
|
984 |
lemma r_in_rstar : "r1 \<leadsto> r2 \<Longrightarrow> r1 \<leadsto>* r2"
|
|
985 |
using rrewrites.intros(1) rrewrites.intros(2) by blast
|
|
986 |
|
|
987 |
lemma real_trans[trans]:
|
|
988 |
assumes a1: "r1 \<leadsto>* r2" and a2: "r2 \<leadsto>* r3"
|
|
989 |
shows "r1 \<leadsto>* r3"
|
|
990 |
using a2 a1
|
|
991 |
apply(induct r2 r3 arbitrary: r1 rule: rrewrites.induct)
|
|
992 |
apply(auto)
|
|
993 |
done
|
|
994 |
|
|
995 |
|
|
996 |
lemma many_steps_later: "\<lbrakk>r1 \<leadsto> r2; r2 \<leadsto>* r3 \<rbrakk> \<Longrightarrow> r1 \<leadsto>* r3"
|
|
997 |
by (meson r_in_rstar real_trans)
|
|
998 |
|
|
999 |
|
|
1000 |
lemma contextrewrites1: "r \<leadsto>* r' \<Longrightarrow> (AALTs bs (r#rs)) \<leadsto>* (AALTs bs (r'#rs))"
|
|
1001 |
apply(induct r r' rule: rrewrites.induct)
|
|
1002 |
apply simp
|
|
1003 |
by (metis append_Cons append_Nil rrewrite.intros(6) rs2)
|
|
1004 |
|
|
1005 |
|
|
1006 |
lemma contextrewrites2: "r \<leadsto>* r' \<Longrightarrow> (AALTs bs (rs1@[r]@rs)) \<leadsto>* (AALTs bs (rs1@[r']@rs))"
|
|
1007 |
apply(induct r r' rule: rrewrites.induct)
|
|
1008 |
apply simp
|
|
1009 |
using rrewrite.intros(6) by blast
|
|
1010 |
|
|
1011 |
|
|
1012 |
|
|
1013 |
lemma srewrites_alt: "rs1 s\<leadsto>* rs2 \<Longrightarrow> (AALTs bs (rs@rs1)) \<leadsto>* (AALTs bs (rs@rs2))"
|
|
1014 |
|
|
1015 |
apply(induct rs1 rs2 arbitrary: bs rs rule: srewrites.induct)
|
|
1016 |
apply(rule rs1)
|
|
1017 |
apply(drule_tac x = "bs" in meta_spec)
|
|
1018 |
apply(drule_tac x = "rsa@[r']" in meta_spec)
|
|
1019 |
apply simp
|
|
1020 |
apply(rule real_trans)
|
|
1021 |
prefer 2
|
|
1022 |
apply(assumption)
|
|
1023 |
apply(drule contextrewrites2)
|
|
1024 |
apply auto
|
|
1025 |
done
|
|
1026 |
|
|
1027 |
corollary srewrites_alt1:
|
|
1028 |
assumes "rs1 s\<leadsto>* rs2"
|
|
1029 |
shows "AALTs bs rs1 \<leadsto>* AALTs bs rs2"
|
|
1030 |
using assms
|
|
1031 |
by (metis append.left_neutral srewrites_alt)
|
|
1032 |
|
|
1033 |
|
|
1034 |
lemma star_seq:
|
|
1035 |
assumes "r1 \<leadsto>* r2"
|
|
1036 |
shows "ASEQ bs r1 r3 \<leadsto>* ASEQ bs r2 r3"
|
|
1037 |
using assms
|
|
1038 |
apply(induct r1 r2 arbitrary: r3 rule: rrewrites.induct)
|
|
1039 |
apply(auto intro: rrewrite.intros)
|
|
1040 |
done
|
|
1041 |
|
|
1042 |
lemma star_seq2:
|
|
1043 |
assumes "r3 \<leadsto>* r4"
|
|
1044 |
shows "ASEQ bs r1 r3 \<leadsto>* ASEQ bs r1 r4"
|
|
1045 |
using assms
|
|
1046 |
apply(induct r3 r4 arbitrary: r1 rule: rrewrites.induct)
|
|
1047 |
apply(auto intro: rrewrite.intros)
|
|
1048 |
done
|
|
1049 |
|
|
1050 |
lemma continuous_rewrite:
|
|
1051 |
assumes "r1 \<leadsto>* AZERO"
|
|
1052 |
shows "ASEQ bs1 r1 r2 \<leadsto>* AZERO"
|
|
1053 |
using assms
|
|
1054 |
apply(induction ra\<equiv>"r1" rb\<equiv>"AZERO" arbitrary: bs1 r1 r2 rule: rrewrites.induct)
|
|
1055 |
apply(auto intro: rrewrite.intros r_in_rstar star_seq)
|
|
1056 |
by (meson rrewrite.intros(1) rs2 star_seq)
|
|
1057 |
|
|
1058 |
|
|
1059 |
|
|
1060 |
lemma bsimp_aalts_simpcases:
|
|
1061 |
shows "AONE bs \<leadsto>* bsimp (AONE bs)"
|
|
1062 |
and "AZERO \<leadsto>* bsimp AZERO"
|
|
1063 |
and "ACHAR bs c \<leadsto>* bsimp (ACHAR bs c)"
|
|
1064 |
by (simp_all)
|
|
1065 |
|
|
1066 |
|
|
1067 |
lemma trivialbsimp_srewrites:
|
|
1068 |
"\<lbrakk>\<And>x. x \<in> set rs \<Longrightarrow> x \<leadsto>* f x \<rbrakk> \<Longrightarrow> rs s\<leadsto>* (map f rs)"
|
|
1069 |
|
|
1070 |
apply(induction rs)
|
|
1071 |
apply simp
|
|
1072 |
apply(rule ss1)
|
|
1073 |
by (metis insert_iff list.simps(15) list.simps(9) srewrites.simps)
|
|
1074 |
|
|
1075 |
|
|
1076 |
lemma bsimp_AALTs_rewrites:
|
|
1077 |
"AALTs bs1 rs \<leadsto>* bsimp_AALTs bs1 rs"
|
|
1078 |
apply(induction rs)
|
|
1079 |
apply simp
|
|
1080 |
apply(rule r_in_rstar)
|
|
1081 |
using rrewrite.intros(9) apply blast
|
|
1082 |
by (metis bsimp_AALTs.elims list.discI rrewrite.intros(10) rrewrites.simps)
|
|
1083 |
|
|
1084 |
|
|
1085 |
|
|
1086 |
lemma flts_prepend: "\<lbrakk>nonalt a; nonazero a\<rbrakk> \<Longrightarrow> flts (a#rs) = a # (flts rs)"
|
|
1087 |
by (metis append_Cons append_Nil flts_single1 flts_append)
|
|
1088 |
|
|
1089 |
lemma fltsfrewrites: "rs f\<leadsto>* (flts rs)"
|
|
1090 |
apply(induction rs)
|
|
1091 |
apply simp
|
|
1092 |
apply(rule fs1)
|
|
1093 |
|
|
1094 |
apply(case_tac "a = AZERO")
|
|
1095 |
|
|
1096 |
|
|
1097 |
using fs2 apply auto[1]
|
|
1098 |
apply(case_tac "\<exists>bs rs. a = AALTs bs rs")
|
|
1099 |
apply(erule exE)+
|
|
1100 |
|
|
1101 |
apply (simp add: fs3)
|
|
1102 |
apply(subst flts_prepend)
|
|
1103 |
apply(rule nonalt.elims(2))
|
|
1104 |
prefer 2
|
|
1105 |
thm nonalt.elims
|
|
1106 |
|
|
1107 |
apply blast
|
|
1108 |
|
|
1109 |
using bbbbs1 apply blast
|
|
1110 |
apply(simp)+
|
|
1111 |
|
|
1112 |
apply (meson nonazero.elims(3))
|
|
1113 |
|
|
1114 |
by (meson fs4 nonalt.elims(3) nonazero.elims(3))
|
|
1115 |
|
|
1116 |
|
|
1117 |
lemma rrewrite0away: "AALTs bs (AZERO # rsb) \<leadsto> AALTs bs rsb"
|
|
1118 |
by (metis append_Cons append_Nil rrewrite.intros(7))
|
|
1119 |
|
|
1120 |
|
|
1121 |
lemma frewritesaalts:"rs f\<leadsto>* rs' \<Longrightarrow> (AALTs bs (rs1@rs)) \<leadsto>* (AALTs bs (rs1@rs'))"
|
|
1122 |
apply(induct rs rs' arbitrary: bs rs1 rule:frewrites.induct)
|
|
1123 |
apply(rule rs1)
|
|
1124 |
apply(drule_tac x = "bs" in meta_spec)
|
|
1125 |
apply(drule_tac x = "rs1 @ [AZERO]" in meta_spec)
|
|
1126 |
apply(rule real_trans)
|
|
1127 |
apply simp
|
|
1128 |
using rrewrite.intros(7) apply auto[1]
|
|
1129 |
apply(drule_tac x = "bsa" in meta_spec)
|
|
1130 |
apply(drule_tac x = "rs1a @ [AALTs bs rs1]" in meta_spec)
|
|
1131 |
apply(rule real_trans)
|
|
1132 |
apply simp
|
|
1133 |
using r_in_rstar rrewrite.intros(8) apply auto[1]
|
|
1134 |
apply(drule_tac x = "bs" in meta_spec)
|
|
1135 |
apply(drule_tac x = "rs1@[r]" in meta_spec)
|
|
1136 |
apply(rule real_trans)
|
|
1137 |
apply simp
|
|
1138 |
apply auto
|
|
1139 |
done
|
|
1140 |
|
|
1141 |
lemma flts_rewrites: " AALTs bs1 rs \<leadsto>* AALTs bs1 (flts rs)"
|
|
1142 |
apply(induction rs)
|
|
1143 |
apply simp
|
|
1144 |
apply(case_tac "a = AZERO")
|
|
1145 |
apply (metis flts.simps(2) many_steps_later rrewrite0away)
|
|
1146 |
|
|
1147 |
apply(case_tac "\<exists>bs2 rs2. a = AALTs bs2 rs2")
|
|
1148 |
apply(erule exE)+
|
|
1149 |
apply(simp)
|
|
1150 |
prefer 2
|
|
1151 |
|
|
1152 |
apply(subst flts_prepend)
|
|
1153 |
|
|
1154 |
apply (meson nonalt.elims(3))
|
|
1155 |
|
|
1156 |
apply (meson nonazero.elims(3))
|
|
1157 |
apply(subgoal_tac "(a#rs) f\<leadsto>* (a#flts rs)")
|
|
1158 |
apply (metis append_Nil frewritesaalts)
|
|
1159 |
apply (meson fltsfrewrites fs4 nonalt.elims(3) nonazero.elims(3))
|
|
1160 |
by (metis append_Cons append_Nil fltsfrewrites frewritesaalts flts_append k0a)
|
|
1161 |
|
|
1162 |
(* TEST *)
|
|
1163 |
lemma r:
|
|
1164 |
assumes "AALTs bs rs1 \<leadsto> AALTs bs rs2"
|
|
1165 |
shows "AALTs bs (x # rs1) \<leadsto>* AALTs bs (x # rs2)"
|
|
1166 |
using assms
|
|
1167 |
apply(erule_tac rrewrite.cases)
|
|
1168 |
apply(auto)
|
|
1169 |
apply (metis append_Cons append_Nil rrewrite.intros(6) r_in_rstar)
|
|
1170 |
apply (metis append_Cons append_self_conv2 rrewrite.intros(7) r_in_rstar)
|
|
1171 |
apply (metis Cons_eq_appendI append_eq_append_conv2 rrewrite.intros(8) self_append_conv r_in_rstar)
|
|
1172 |
apply(case_tac rs2)
|
|
1173 |
apply(auto)
|
|
1174 |
apply(case_tac r)
|
|
1175 |
apply(auto)
|
|
1176 |
apply (metis append_Nil2 append_butlast_last_id butlast.simps(2) last.simps list.distinct(1) list.map_disc_iff r_in_rstar rrewrite.intros(8))
|
|
1177 |
apply(case_tac r)
|
|
1178 |
apply(auto)
|
|
1179 |
defer
|
|
1180 |
apply(rule r_in_rstar)
|
|
1181 |
apply (metis append_Cons append_Nil rrewrite.intros(11))
|
|
1182 |
apply(rule real_trans)
|
|
1183 |
apply(rule r_in_rstar)
|
|
1184 |
using rrewrite.intros(8)[where ?rsb = "[]", of "bs" "[x]" "[]" , simplified]
|
|
1185 |
apply(rule_tac rrewrite.intros(8)[where ?rsb = "[]", of "bs" "[x]" "[]" , simplified])
|
|
1186 |
apply(simp add: map_fuse_Nil fuse_Nil)
|
|
1187 |
done
|
|
1188 |
|
|
1189 |
lemma alts_simpalts:
|
|
1190 |
"(\<And>x. x \<in> set rs \<Longrightarrow> x \<leadsto>* bsimp x) \<Longrightarrow>
|
|
1191 |
AALTs bs1 rs \<leadsto>* AALTs bs1 (map bsimp rs)"
|
|
1192 |
apply(induct rs)
|
|
1193 |
apply(auto)[1]
|
|
1194 |
using trivialbsimp_srewrites apply auto[1]
|
|
1195 |
by (simp add: srewrites_alt1 ss2)
|
|
1196 |
|
|
1197 |
lemma threelistsappend: "rsa@a#rsb = (rsa@[a])@rsb"
|
|
1198 |
apply auto
|
|
1199 |
done
|
|
1200 |
|
|
1201 |
|
|
1202 |
lemma somewhereInside: "r \<in> set rs \<Longrightarrow> \<exists>rs1 rs2. rs = rs1@[r]@rs2"
|
|
1203 |
using split_list by fastforce
|
|
1204 |
|
|
1205 |
lemma somewhereMapInside: "f r \<in> f ` set rs \<Longrightarrow> \<exists>rs1 rs2 a. rs = rs1@[a]@rs2 \<and> f a = f r"
|
|
1206 |
apply auto
|
|
1207 |
by (metis split_list)
|
|
1208 |
|
|
1209 |
lemma alts_dBrewrites_withFront:
|
|
1210 |
"AALTs bs (rsa @ rs) \<leadsto>* AALTs bs (rsa @ distinctBy rs erase (erase ` set rsa))"
|
|
1211 |
apply(induction rs arbitrary: rsa)
|
|
1212 |
apply simp
|
|
1213 |
apply(drule_tac x = "rsa@[a]" in meta_spec)
|
|
1214 |
apply(subst threelistsappend)
|
|
1215 |
apply(rule real_trans)
|
|
1216 |
apply simp
|
|
1217 |
apply(case_tac "a \<in> set rsa")
|
|
1218 |
apply simp
|
|
1219 |
apply(drule somewhereInside)
|
|
1220 |
apply(erule exE)+
|
|
1221 |
apply simp
|
|
1222 |
apply(subgoal_tac " AALTs bs
|
|
1223 |
(rs1 @
|
|
1224 |
a #
|
|
1225 |
rs2 @
|
|
1226 |
a #
|
|
1227 |
distinctBy rs erase
|
|
1228 |
(insert (erase a)
|
|
1229 |
(erase `
|
|
1230 |
(set rs1 \<union> set rs2)))) \<leadsto> AALTs bs (rs1@ a # rs2 @ distinctBy rs erase
|
|
1231 |
(insert (erase a)
|
|
1232 |
(erase `
|
|
1233 |
(set rs1 \<union> set rs2)))) ")
|
|
1234 |
prefer 2
|
|
1235 |
using rrewrite.intros(11) apply force
|
|
1236 |
using r_in_rstar apply force
|
|
1237 |
apply(subgoal_tac "erase ` set (rsa @ [a]) = insert (erase a) (erase ` set rsa)")
|
|
1238 |
prefer 2
|
|
1239 |
|
|
1240 |
apply auto[1]
|
|
1241 |
apply(case_tac "erase a \<in> erase `set rsa")
|
|
1242 |
|
|
1243 |
apply simp
|
|
1244 |
apply(subgoal_tac "AALTs bs (rsa @ a # distinctBy rs erase (insert (erase a) (erase ` set rsa))) \<leadsto>
|
|
1245 |
AALTs bs (rsa @ distinctBy rs erase (insert (erase a) (erase ` set rsa)))")
|
|
1246 |
apply force
|
|
1247 |
apply (smt (verit, ccfv_threshold) append_Cons append_assoc append_self_conv2 r_in_rstar rrewrite.intros(11) same_append_eq somewhereMapInside)
|
|
1248 |
by force
|
|
1249 |
|
|
1250 |
|
|
1251 |
|
|
1252 |
lemma alts_dBrewrites: "AALTs bs rs \<leadsto>* AALTs bs (distinctBy rs erase {})"
|
|
1253 |
apply(induction rs)
|
|
1254 |
apply simp
|
|
1255 |
apply simp
|
|
1256 |
using alts_dBrewrites_withFront
|
|
1257 |
by (metis append_Nil dB_single_step empty_set image_empty)
|
|
1258 |
|
|
1259 |
lemma bsimp_rewrite:
|
|
1260 |
shows "r \<leadsto>* bsimp r"
|
|
1261 |
proof (induction r rule: bsimp.induct)
|
|
1262 |
case (1 bs1 r1 r2)
|
|
1263 |
then show "ASEQ bs1 r1 r2 \<leadsto>* bsimp (ASEQ bs1 r1 r2)"
|
|
1264 |
apply(simp)
|
|
1265 |
apply(case_tac "bsimp r1 = AZERO")
|
|
1266 |
apply simp
|
|
1267 |
using continuous_rewrite apply blast
|
|
1268 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
|
|
1269 |
apply(erule exE)
|
|
1270 |
apply simp
|
|
1271 |
apply(subst bsimp_ASEQ2)
|
|
1272 |
apply (meson real_trans rrewrite.intros(3) rrewrites.intros(2) star_seq star_seq2)
|
|
1273 |
apply (smt (verit, best) bsimp_ASEQ0 bsimp_ASEQ1 real_trans rrewrite.intros(2) rs2 star_seq star_seq2)
|
|
1274 |
done
|
|
1275 |
next
|
|
1276 |
case (2 bs1 rs)
|
|
1277 |
then show "AALTs bs1 rs \<leadsto>* bsimp (AALTs bs1 rs)"
|
|
1278 |
by (metis alts_dBrewrites alts_simpalts bsimp.simps(2) bsimp_AALTs_rewrites flts_rewrites real_trans)
|
|
1279 |
next
|
|
1280 |
case "3_1"
|
|
1281 |
then show "AZERO \<leadsto>* bsimp AZERO"
|
|
1282 |
by simp
|
|
1283 |
next
|
|
1284 |
case ("3_2" v)
|
|
1285 |
then show "AONE v \<leadsto>* bsimp (AONE v)"
|
|
1286 |
by simp
|
|
1287 |
next
|
|
1288 |
case ("3_3" v va)
|
|
1289 |
then show "ACHAR v va \<leadsto>* bsimp (ACHAR v va)"
|
|
1290 |
by simp
|
|
1291 |
next
|
|
1292 |
case ("3_4" v va)
|
|
1293 |
then show "ASTAR v va \<leadsto>* bsimp (ASTAR v va)"
|
|
1294 |
by simp
|
|
1295 |
qed
|
|
1296 |
|
|
1297 |
lemma rewrite_non_nullable_strong:
|
|
1298 |
assumes "r1 \<leadsto> r2"
|
|
1299 |
shows "bnullable r1 = bnullable r2"
|
|
1300 |
using assms
|
|
1301 |
apply(induction r1 r2 rule: rrewrite.induct)
|
|
1302 |
apply(auto)
|
|
1303 |
apply(metis bnullable_correctness erase_fuse)+
|
|
1304 |
apply(metis UnCI bnullable_correctness erase_fuse imageI)
|
|
1305 |
apply(metis bnullable_correctness erase_fuse)+
|
|
1306 |
done
|
|
1307 |
|
|
1308 |
lemma rewrite_nullable:
|
|
1309 |
assumes "r1 \<leadsto> r2" "bnullable r1"
|
|
1310 |
shows "bnullable r2"
|
|
1311 |
using assms rewrite_non_nullable_strong
|
|
1312 |
by auto
|
|
1313 |
|
|
1314 |
lemma rewritesnullable:
|
|
1315 |
assumes "r1 \<leadsto>* r2" "bnullable r1"
|
|
1316 |
shows "bnullable r2"
|
|
1317 |
using assms
|
|
1318 |
apply(induction r1 r2 rule: rrewrites.induct)
|
|
1319 |
apply simp
|
|
1320 |
using rewrite_non_nullable_strong by blast
|
|
1321 |
|
|
1322 |
|
|
1323 |
lemma bnullable_segment:
|
|
1324 |
"bnullable (AALTs bs (rs1@[r]@rs2)) \<Longrightarrow> bnullable (AALTs bs rs1) \<or> bnullable (AALTs bs rs2) \<or> bnullable r"
|
|
1325 |
by auto
|
|
1326 |
|
|
1327 |
lemma bnullablewhichbmkeps: "\<lbrakk>bnullable (AALTs bs (rs1@[r]@rs2)); \<not> bnullable (AALTs bs rs1); bnullable r \<rbrakk>
|
|
1328 |
\<Longrightarrow> bmkeps (AALTs bs (rs1@[r]@rs2)) = bs @ (bmkeps r)"
|
|
1329 |
|
|
1330 |
using qq2 bnullable_Hdbmkeps_Hd by force
|
|
1331 |
|
|
1332 |
lemma spillbmkepslistr: "bnullable (AALTs bs1 rs1)
|
|
1333 |
\<Longrightarrow> bmkeps (AALTs bs (AALTs bs1 rs1 # rsb)) = bmkeps (AALTs bs ( map (fuse bs1) rs1 @ rsb))"
|
|
1334 |
apply(subst bnullable_Hdbmkeps_Hd)
|
|
1335 |
|
|
1336 |
apply simp
|
|
1337 |
by (metis bmkeps.simps(3) k0a list.set_intros(1) qq1 qq4 qs3)
|
|
1338 |
|
|
1339 |
lemma third_segment_bnullable:
|
|
1340 |
"\<lbrakk>bnullable (AALTs bs (rs1@rs2@rs3)); \<not>bnullable (AALTs bs rs1); \<not>bnullable (AALTs bs rs2)\<rbrakk> \<Longrightarrow>
|
|
1341 |
bnullable (AALTs bs rs3)"
|
|
1342 |
apply(auto)
|
|
1343 |
done
|
|
1344 |
|
|
1345 |
lemma third_segment_bmkeps:
|
|
1346 |
"\<lbrakk>bnullable (AALTs bs (rs1@rs2@rs3)); \<not>bnullable (AALTs bs rs1); \<not>bnullable (AALTs bs rs2)\<rbrakk> \<Longrightarrow>
|
|
1347 |
bmkeps (AALTs bs (rs1@rs2@rs3) ) = bmkeps (AALTs bs rs3)"
|
|
1348 |
by (metis bnullable.simps(1) bnullable.simps(4) bsimp_AALTs.simps(1) bsimp_AALTs_rewrites qq2 rewritesnullable self_append_conv third_segment_bnullable)
|
|
1349 |
|
|
1350 |
lemma rewrite_bmkepsalt:
|
|
1351 |
"\<lbrakk>bnullable (AALTs bs (rsa @ AALTs bs1 rs1 # rsb)); bnullable (AALTs bs (rsa @ map (fuse bs1) rs1 @ rsb))\<rbrakk>
|
|
1352 |
\<Longrightarrow> bmkeps (AALTs bs (rsa @ AALTs bs1 rs1 # rsb)) = bmkeps (AALTs bs (rsa @ map (fuse bs1) rs1 @ rsb))"
|
|
1353 |
apply(rule qq3)
|
|
1354 |
apply(simp)
|
|
1355 |
apply(simp)
|
|
1356 |
apply(case_tac "bnullable (AALTs bs1 rs1)")
|
|
1357 |
using spillbmkepslistr apply blast
|
|
1358 |
apply(subst qq2)
|
|
1359 |
apply(auto simp add: bnullable_fuse r1)
|
|
1360 |
done
|
|
1361 |
|
|
1362 |
lemma rewrite_bmkeps_aux:
|
|
1363 |
assumes "r1 \<leadsto> r2" "bnullable r1" "bnullable r2"
|
|
1364 |
shows "bmkeps r1 = bmkeps r2"
|
|
1365 |
using assms
|
|
1366 |
proof (induction r1 r2 rule: rrewrite.induct)
|
|
1367 |
case (1 bs r2)
|
|
1368 |
then show ?case by simp
|
|
1369 |
next
|
|
1370 |
case (2 bs r1)
|
|
1371 |
then show ?case by simp
|
|
1372 |
next
|
|
1373 |
case (3 bs bs1 r)
|
|
1374 |
then show ?case by (simp add: b2)
|
|
1375 |
next
|
|
1376 |
case (4 r1 r2 bs r3)
|
|
1377 |
then show ?case by simp
|
|
1378 |
next
|
|
1379 |
case (5 r3 r4 bs r1)
|
|
1380 |
then show ?case by simp
|
|
1381 |
next
|
|
1382 |
case (6 r r' bs rs1 rs2)
|
|
1383 |
then show ?case
|
|
1384 |
by (metis append_Cons append_Nil bnullable.simps(4) bnullable_segment bnullablewhichbmkeps qq3 r1 rewrite_non_nullable_strong)
|
|
1385 |
next
|
|
1386 |
case (7 bs rsa rsb)
|
|
1387 |
then show ?case
|
|
1388 |
by (metis bnullable.simps(1) bnullable.simps(4) bnullable_segment qq1 qq2 rewrite_nullable rrewrite.intros(9) rrewrite0away third_segment_bmkeps)
|
|
1389 |
next
|
|
1390 |
case (8 bs rsa bs1 rs1 rsb)
|
|
1391 |
then show ?case
|
|
1392 |
by (simp add: rewrite_bmkepsalt)
|
|
1393 |
next
|
|
1394 |
case (9 bs)
|
|
1395 |
then show ?case
|
|
1396 |
by fastforce
|
|
1397 |
next
|
|
1398 |
case (10 bs r)
|
|
1399 |
then show ?case
|
|
1400 |
by (simp add: b2)
|
|
1401 |
next
|
|
1402 |
case (11 a1 a2 bs rsa rsb rsc)
|
|
1403 |
then show ?case
|
|
1404 |
by (smt (verit, ccfv_threshold) append_Cons append_eq_appendI append_self_conv2 bnullable_correctness list.set_intros(1) qq3 r1)
|
|
1405 |
qed
|
|
1406 |
|
|
1407 |
|
|
1408 |
lemma rewrite_bmkeps:
|
|
1409 |
assumes "r1 \<leadsto> r2" "bnullable r1"
|
|
1410 |
shows "bmkeps r1 = bmkeps r2"
|
|
1411 |
using assms(1) assms(2) rewrite_bmkeps_aux rewrite_nullable by blast
|
|
1412 |
|
|
1413 |
|
|
1414 |
lemma rewrites_bmkeps:
|
|
1415 |
assumes "r1 \<leadsto>* r2" "bnullable r1"
|
|
1416 |
shows "bmkeps r1 = bmkeps r2"
|
|
1417 |
using assms
|
|
1418 |
proof(induction r1 r2 rule: rrewrites.induct)
|
|
1419 |
case (rs1 r)
|
|
1420 |
then show "bmkeps r = bmkeps r" by simp
|
|
1421 |
next
|
|
1422 |
case (rs2 r1 r2 r3)
|
|
1423 |
then have IH: "bmkeps r1 = bmkeps r2" by simp
|
|
1424 |
have a1: "bnullable r1" by fact
|
|
1425 |
have a2: "r1 \<leadsto>* r2" by fact
|
|
1426 |
have a3: "r2 \<leadsto> r3" by fact
|
|
1427 |
have a4: "bnullable r2" using a1 a2 by (simp add: rewritesnullable)
|
|
1428 |
then have "bmkeps r2 = bmkeps r3" using rewrite_bmkeps a3 a4 by simp
|
|
1429 |
then show "bmkeps r1 = bmkeps r3" using IH by simp
|
|
1430 |
qed
|
|
1431 |
|
|
1432 |
lemma alts_rewrite_front: "r \<leadsto> r' \<Longrightarrow> AALTs bs (r # rs) \<leadsto> AALTs bs (r' # rs)"
|
|
1433 |
by (metis append_Cons append_Nil rrewrite.intros(6))
|
|
1434 |
|
|
1435 |
lemma to_zero_in_alt: " AALT bs (ASEQ [] AZERO r) r2 \<leadsto> AALT bs AZERO r2"
|
|
1436 |
by (simp add: alts_rewrite_front rrewrite.intros(1))
|
|
1437 |
|
|
1438 |
lemma rewrite_fuse:
|
|
1439 |
assumes "r2 \<leadsto> r3"
|
|
1440 |
shows "fuse bs r2 \<leadsto>* fuse bs r3"
|
|
1441 |
using assms
|
|
1442 |
proof(induction r2 r3 arbitrary: bs rule: rrewrite.induct)
|
|
1443 |
case (1 bs r2)
|
|
1444 |
then show ?case
|
|
1445 |
by (simp add: continuous_rewrite)
|
|
1446 |
next
|
|
1447 |
case (2 bs r1)
|
|
1448 |
then show ?case
|
|
1449 |
using rrewrite.intros(2) by force
|
|
1450 |
next
|
|
1451 |
case (3 bs bs1 r)
|
|
1452 |
then show ?case
|
|
1453 |
by (metis fuse.simps(5) fuse_append r_in_rstar rrewrite.intros(3))
|
|
1454 |
next
|
|
1455 |
case (4 r1 r2 bs r3)
|
|
1456 |
then show ?case
|
|
1457 |
by (simp add: r_in_rstar star_seq)
|
|
1458 |
next
|
|
1459 |
case (5 r3 r4 bs r1)
|
|
1460 |
then show ?case
|
|
1461 |
using fuse.simps(5) r_in_rstar star_seq2 by auto
|
|
1462 |
next
|
|
1463 |
case (6 r r' bs rs1 rs2)
|
|
1464 |
then show ?case
|
|
1465 |
using contextrewrites2 r_in_rstar by force
|
|
1466 |
next
|
|
1467 |
case (7 bs rsa rsb)
|
|
1468 |
then show ?case
|
|
1469 |
using rrewrite.intros(7) by force
|
|
1470 |
next
|
|
1471 |
case (8 bs rsa bs1 rs1 rsb)
|
|
1472 |
then show ?case
|
|
1473 |
using rrewrite.intros(8) by force
|
|
1474 |
next
|
|
1475 |
case (9 bs)
|
|
1476 |
then show ?case
|
|
1477 |
by (simp add: r_in_rstar rrewrite.intros(9))
|
|
1478 |
next
|
|
1479 |
case (10 bs r)
|
|
1480 |
then show ?case
|
|
1481 |
by (metis fuse.simps(4) fuse_append r_in_rstar rrewrite.intros(10))
|
|
1482 |
next
|
|
1483 |
case (11 a1 a2 bs rsa rsb rsc)
|
|
1484 |
then show ?case
|
|
1485 |
using fuse.simps(4) r_in_rstar rrewrite.intros(11) by auto
|
|
1486 |
qed
|
|
1487 |
|
|
1488 |
lemma rewrites_fuse:
|
|
1489 |
assumes "r1 \<leadsto>* r2"
|
|
1490 |
shows "fuse bs r1 \<leadsto>* fuse bs r2"
|
|
1491 |
using assms
|
|
1492 |
apply(induction r1 r2 arbitrary: bs rule: rrewrites.induct)
|
|
1493 |
apply(auto intro: rewrite_fuse real_trans)
|
|
1494 |
done
|
|
1495 |
|
|
1496 |
lemma bder_fuse_list:
|
|
1497 |
shows "map (bder c \<circ> fuse bs1) rs1 = map (fuse bs1 \<circ> bder c) rs1"
|
|
1498 |
apply(induction rs1)
|
|
1499 |
apply(simp_all add: bder_fuse)
|
|
1500 |
done
|
|
1501 |
|
|
1502 |
|
|
1503 |
lemma rewrite_der_altmiddle:
|
|
1504 |
"bder c (AALTs bs (rsa @ AALTs bs1 rs1 # rsb)) \<leadsto>* bder c (AALTs bs (rsa @ map (fuse bs1) rs1 @ rsb))"
|
|
1505 |
apply simp
|
|
1506 |
apply(simp add: bder_fuse_list del: append.simps)
|
|
1507 |
by (metis append.assoc map_map r_in_rstar rrewrite.intros(8) threelistsappend)
|
|
1508 |
|
|
1509 |
lemma lock_step_der_removal:
|
|
1510 |
shows " erase a1 = erase a2 \<Longrightarrow>
|
|
1511 |
bder c (AALTs bs (rsa @ [a1] @ rsb @ [a2] @ rsc)) \<leadsto>*
|
|
1512 |
bder c (AALTs bs (rsa @ [a1] @ rsb @ rsc))"
|
|
1513 |
apply(simp)
|
|
1514 |
|
|
1515 |
using rrewrite.intros(11) by auto
|
|
1516 |
|
|
1517 |
lemma rewrite_after_der:
|
|
1518 |
assumes "r1 \<leadsto> r2"
|
|
1519 |
shows "(bder c r1) \<leadsto>* (bder c r2)"
|
|
1520 |
using assms
|
|
1521 |
proof(induction r1 r2 rule: rrewrite.induct)
|
|
1522 |
case (1 bs r2)
|
|
1523 |
then show "bder c (ASEQ bs AZERO r2) \<leadsto>* bder c AZERO"
|
|
1524 |
by (simp add: continuous_rewrite)
|
|
1525 |
next
|
|
1526 |
case (2 bs r1)
|
|
1527 |
then show "bder c (ASEQ bs r1 AZERO) \<leadsto>* bder c AZERO"
|
|
1528 |
apply(simp)
|
|
1529 |
by (meson contextrewrites1 r_in_rstar real_trans rrewrite.intros(9) rrewrite.intros(2) rrewrite0away)
|
|
1530 |
next
|
|
1531 |
case (3 bs bs1 r)
|
|
1532 |
then show "bder c (ASEQ bs (AONE bs1) r) \<leadsto>* bder c (fuse (bs @ bs1) r)"
|
|
1533 |
apply(simp)
|
|
1534 |
by (metis bder_fuse fuse_append rrewrite.intros(10) rrewrite0away rrewrites.simps to_zero_in_alt)
|
|
1535 |
next
|
|
1536 |
case (4 r1 r2 bs r3)
|
|
1537 |
have as: "r1 \<leadsto> r2" by fact
|
|
1538 |
have IH: "bder c r1 \<leadsto>* bder c r2" by fact
|
|
1539 |
from as IH show "bder c (ASEQ bs r1 r3) \<leadsto>* bder c (ASEQ bs r2 r3)"
|
|
1540 |
by (simp add: contextrewrites1 rewrite_bmkeps rewrite_non_nullable_strong star_seq)
|
|
1541 |
next
|
|
1542 |
case (5 r3 r4 bs r1)
|
|
1543 |
have as: "r3 \<leadsto> r4" by fact
|
|
1544 |
have IH: "bder c r3 \<leadsto>* bder c r4" by fact
|
|
1545 |
from as IH show "bder c (ASEQ bs r1 r3) \<leadsto>* bder c (ASEQ bs r1 r4)"
|
|
1546 |
using bder.simps(5) r_in_rstar rewrites_fuse srewrites_alt1 ss1 ss2 star_seq2 by presburger
|
|
1547 |
next
|
|
1548 |
case (6 r r' bs rs1 rs2)
|
|
1549 |
have as: "r \<leadsto> r'" by fact
|
|
1550 |
have IH: "bder c r \<leadsto>* bder c r'" by fact
|
|
1551 |
from as IH show "bder c (AALTs bs (rs1 @ [r] @ rs2)) \<leadsto>* bder c (AALTs bs (rs1 @ [r'] @ rs2))"
|
|
1552 |
apply(simp)
|
|
1553 |
using contextrewrites2 by force
|
|
1554 |
next
|
|
1555 |
case (7 bs rsa rsb)
|
|
1556 |
then show "bder c (AALTs bs (rsa @ [AZERO] @ rsb)) \<leadsto>* bder c (AALTs bs (rsa @ rsb))"
|
|
1557 |
apply(simp)
|
|
1558 |
using rrewrite.intros(7) by auto
|
|
1559 |
next
|
|
1560 |
case (8 bs rsa bs1 rs1 rsb)
|
|
1561 |
then show
|
|
1562 |
"bder c (AALTs bs (rsa @ [AALTs bs1 rs1] @ rsb)) \<leadsto>* bder c (AALTs bs (rsa @ map (fuse bs1) rs1 @ rsb))"
|
|
1563 |
using rewrite_der_altmiddle by auto
|
|
1564 |
next
|
|
1565 |
case (9 bs)
|
|
1566 |
then show "bder c (AALTs bs []) \<leadsto>* bder c AZERO"
|
|
1567 |
by (simp add: r_in_rstar rrewrite.intros(9))
|
|
1568 |
next
|
|
1569 |
case (10 bs r)
|
|
1570 |
then show "bder c (AALTs bs [r]) \<leadsto>* bder c (fuse bs r)"
|
|
1571 |
by (simp add: bder_fuse r_in_rstar rrewrite.intros(10))
|
|
1572 |
next
|
|
1573 |
case (11 a1 a2 bs rsa rsb rsc)
|
|
1574 |
have as: "erase a1 = erase a2" by fact
|
|
1575 |
then show "bder c (AALTs bs (rsa @ [a1] @ rsb @ [a2] @ rsc)) \<leadsto>* bder c (AALTs bs (rsa @ [a1] @ rsb @ rsc))"
|
|
1576 |
using lock_step_der_removal by force
|
|
1577 |
qed
|
|
1578 |
|
|
1579 |
|
|
1580 |
lemma rewrites_after_der:
|
|
1581 |
assumes "r1 \<leadsto>* r2"
|
|
1582 |
shows "bder c r1 \<leadsto>* bder c r2"
|
|
1583 |
using assms
|
|
1584 |
apply(induction r1 r2 rule: rrewrites.induct)
|
|
1585 |
apply(simp_all add: rewrite_after_der real_trans)
|
|
1586 |
done
|
|
1587 |
|
|
1588 |
|
|
1589 |
lemma central:
|
|
1590 |
shows "bders r s \<leadsto>* bders_simp r s"
|
|
1591 |
proof(induct s arbitrary: r rule: rev_induct)
|
|
1592 |
case Nil
|
|
1593 |
then show "bders r [] \<leadsto>* bders_simp r []" by simp
|
|
1594 |
next
|
|
1595 |
case (snoc x xs)
|
|
1596 |
have IH: "\<And>r. bders r xs \<leadsto>* bders_simp r xs" by fact
|
|
1597 |
have "bders r (xs @ [x]) = bders (bders r xs) [x]" by (simp add: bders_append)
|
|
1598 |
also have "... \<leadsto>* bders (bders_simp r xs) [x]" using IH
|
|
1599 |
by (simp add: rewrites_after_der)
|
|
1600 |
also have "... \<leadsto>* bders_simp (bders_simp r xs) [x]" using IH
|
|
1601 |
by (simp add: bsimp_rewrite)
|
|
1602 |
finally show "bders r (xs @ [x]) \<leadsto>* bders_simp r (xs @ [x])"
|
|
1603 |
by (simp add: bders_simp_append)
|
|
1604 |
qed
|
|
1605 |
|
|
1606 |
|
|
1607 |
|
|
1608 |
|
|
1609 |
|
|
1610 |
lemma quasi_main:
|
|
1611 |
assumes "bnullable (bders r s)"
|
|
1612 |
shows "bmkeps (bders r s) = bmkeps (bders_simp r s)"
|
|
1613 |
proof -
|
|
1614 |
have "bders r s \<leadsto>* bders_simp r s" by (rule central)
|
|
1615 |
then
|
|
1616 |
show "bmkeps (bders r s) = bmkeps (bders_simp r s)" using assms
|
|
1617 |
by (rule rewrites_bmkeps)
|
|
1618 |
qed
|
|
1619 |
|
|
1620 |
|
|
1621 |
|
|
1622 |
|
|
1623 |
theorem main_main:
|
|
1624 |
shows "blexer r s = blexer_simp r s"
|
|
1625 |
unfolding blexer_def blexer_simp_def
|
|
1626 |
using b4 quasi_main by simp
|
|
1627 |
|
|
1628 |
|
|
1629 |
theorem blexersimp_correctness:
|
|
1630 |
shows "lexer r s = blexer_simp r s"
|
|
1631 |
using blexer_correctness main_main by simp
|
|
1632 |
|
|
1633 |
|
|
1634 |
|
|
1635 |
export_code blexer_simp blexer lexer bders bders_simp in Scala module_name VerifiedLexers
|
|
1636 |
|
|
1637 |
|
|
1638 |
unused_thms
|
|
1639 |
|
|
1640 |
|
|
1641 |
inductive aggressive:: "arexp \<Rightarrow> arexp \<Rightarrow> bool" ("_ \<leadsto>? _" [99, 99] 99)
|
|
1642 |
where
|
|
1643 |
"ASEQ bs (AALTs bs1 rs) r \<leadsto>? AALTs (bs@bs1) (map (\<lambda>r'. ASEQ [] r' r) rs) "
|
|
1644 |
|
|
1645 |
|
|
1646 |
|
|
1647 |
end
|