365
|
1 |
|
489
|
2 |
theory BitCoded
|
365
|
3 |
imports "Lexer"
|
|
4 |
begin
|
|
5 |
|
|
6 |
section \<open>Bit-Encodings\<close>
|
|
7 |
|
|
8 |
datatype bit = Z | S
|
|
9 |
|
|
10 |
fun
|
|
11 |
code :: "val \<Rightarrow> bit list"
|
|
12 |
where
|
|
13 |
"code Void = []"
|
|
14 |
| "code (Char c) = []"
|
|
15 |
| "code (Left v) = Z # (code v)"
|
|
16 |
| "code (Right v) = S # (code v)"
|
|
17 |
| "code (Seq v1 v2) = (code v1) @ (code v2)"
|
|
18 |
| "code (Stars []) = [S]"
|
|
19 |
| "code (Stars (v # vs)) = (Z # code v) @ code (Stars vs)"
|
|
20 |
|
|
21 |
|
|
22 |
fun
|
|
23 |
Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
|
|
24 |
where
|
|
25 |
"Stars_add v (Stars vs) = Stars (v # vs)"
|
|
26 |
|
|
27 |
function
|
|
28 |
decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)"
|
|
29 |
where
|
|
30 |
"decode' ds ZERO = (Void, [])"
|
|
31 |
| "decode' ds ONE = (Void, ds)"
|
489
|
32 |
| "decode' ds (CH d) = (Char d, ds)"
|
365
|
33 |
| "decode' [] (ALT r1 r2) = (Void, [])"
|
|
34 |
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))"
|
|
35 |
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))"
|
|
36 |
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in
|
|
37 |
let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))"
|
|
38 |
| "decode' [] (STAR r) = (Void, [])"
|
|
39 |
| "decode' (S # ds) (STAR r) = (Stars [], ds)"
|
|
40 |
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in
|
|
41 |
let (vs, ds'') = decode' ds' (STAR r)
|
|
42 |
in (Stars_add v vs, ds''))"
|
|
43 |
by pat_completeness auto
|
|
44 |
|
|
45 |
lemma decode'_smaller:
|
|
46 |
assumes "decode'_dom (ds, r)"
|
|
47 |
shows "length (snd (decode' ds r)) \<le> length ds"
|
|
48 |
using assms
|
|
49 |
apply(induct ds r)
|
|
50 |
apply(auto simp add: decode'.psimps split: prod.split)
|
|
51 |
using dual_order.trans apply blast
|
|
52 |
by (meson dual_order.trans le_SucI)
|
|
53 |
|
|
54 |
termination "decode'"
|
|
55 |
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))")
|
|
56 |
apply(auto dest!: decode'_smaller)
|
|
57 |
by (metis less_Suc_eq_le snd_conv)
|
|
58 |
|
|
59 |
definition
|
|
60 |
decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option"
|
|
61 |
where
|
|
62 |
"decode ds r \<equiv> (let (v, ds') = decode' ds r
|
|
63 |
in (if ds' = [] then Some v else None))"
|
|
64 |
|
|
65 |
lemma decode'_code_Stars:
|
|
66 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []"
|
|
67 |
shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)"
|
|
68 |
using assms
|
|
69 |
apply(induct vs)
|
|
70 |
apply(auto)
|
|
71 |
done
|
|
72 |
|
|
73 |
lemma decode'_code:
|
|
74 |
assumes "\<Turnstile> v : r"
|
|
75 |
shows "decode' ((code v) @ ds) r = (v, ds)"
|
|
76 |
using assms
|
|
77 |
apply(induct v r arbitrary: ds)
|
|
78 |
apply(auto)
|
|
79 |
using decode'_code_Stars by blast
|
|
80 |
|
|
81 |
lemma decode_code:
|
|
82 |
assumes "\<Turnstile> v : r"
|
|
83 |
shows "decode (code v) r = Some v"
|
|
84 |
using assms unfolding decode_def
|
|
85 |
by (smt append_Nil2 decode'_code old.prod.case)
|
|
86 |
|
|
87 |
|
|
88 |
section {* Annotated Regular Expressions *}
|
|
89 |
|
|
90 |
datatype arexp =
|
|
91 |
AZERO
|
|
92 |
| AONE "bit list"
|
|
93 |
| ACHAR "bit list" char
|
|
94 |
| ASEQ "bit list" arexp arexp
|
|
95 |
| AALTs "bit list" "arexp list"
|
|
96 |
| ASTAR "bit list" arexp
|
|
97 |
|
|
98 |
abbreviation
|
|
99 |
"AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]"
|
|
100 |
|
|
101 |
fun asize :: "arexp \<Rightarrow> nat" where
|
|
102 |
"asize AZERO = 1"
|
|
103 |
| "asize (AONE cs) = 1"
|
|
104 |
| "asize (ACHAR cs c) = 1"
|
|
105 |
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))"
|
|
106 |
| "asize (ASEQ cs r1 r2) = Suc (asize r1 + asize r2)"
|
|
107 |
| "asize (ASTAR cs r) = Suc (asize r)"
|
|
108 |
|
|
109 |
fun
|
|
110 |
erase :: "arexp \<Rightarrow> rexp"
|
|
111 |
where
|
|
112 |
"erase AZERO = ZERO"
|
|
113 |
| "erase (AONE _) = ONE"
|
489
|
114 |
| "erase (ACHAR _ c) = CH c"
|
365
|
115 |
| "erase (AALTs _ []) = ZERO"
|
|
116 |
| "erase (AALTs _ [r]) = (erase r)"
|
|
117 |
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))"
|
|
118 |
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)"
|
|
119 |
| "erase (ASTAR _ r) = STAR (erase r)"
|
|
120 |
|
|
121 |
lemma decode_code_erase:
|
|
122 |
assumes "\<Turnstile> v : (erase a)"
|
|
123 |
shows "decode (code v) (erase a) = Some v"
|
|
124 |
using assms
|
|
125 |
by (simp add: decode_code)
|
|
126 |
|
|
127 |
|
|
128 |
fun nonalt :: "arexp \<Rightarrow> bool"
|
|
129 |
where
|
|
130 |
"nonalt (AALTs bs2 rs) = False"
|
|
131 |
| "nonalt r = True"
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where
|
|
136 |
"fuse bs AZERO = AZERO"
|
|
137 |
| "fuse bs (AONE cs) = AONE (bs @ cs)"
|
|
138 |
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
|
|
139 |
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs"
|
|
140 |
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2"
|
|
141 |
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r"
|
|
142 |
|
|
143 |
lemma fuse_append:
|
|
144 |
shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)"
|
|
145 |
apply(induct r)
|
|
146 |
apply(auto)
|
|
147 |
done
|
|
148 |
|
|
149 |
|
|
150 |
fun intern :: "rexp \<Rightarrow> arexp" where
|
|
151 |
"intern ZERO = AZERO"
|
|
152 |
| "intern ONE = AONE []"
|
489
|
153 |
| "intern (CH c) = ACHAR [] c"
|
365
|
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 retrieve_encode_STARS:
|
|
250 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v"
|
|
251 |
shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)"
|
|
252 |
using assms
|
|
253 |
apply(induct vs)
|
|
254 |
apply(simp_all)
|
|
255 |
done
|
|
256 |
|
|
257 |
lemma retrieve_fuse2:
|
|
258 |
assumes "\<Turnstile> v : (erase r)"
|
|
259 |
shows "retrieve (fuse bs r) v = bs @ retrieve r v"
|
|
260 |
using assms
|
|
261 |
apply(induct r arbitrary: v bs)
|
|
262 |
apply(auto elim: Prf_elims)[4]
|
|
263 |
defer
|
|
264 |
using retrieve_encode_STARS
|
|
265 |
apply(auto elim!: Prf_elims)[1]
|
|
266 |
apply(case_tac vs)
|
|
267 |
apply(simp)
|
|
268 |
apply(simp)
|
|
269 |
(* AALTs case *)
|
|
270 |
apply(simp)
|
|
271 |
apply(case_tac x2a)
|
|
272 |
apply(simp)
|
|
273 |
apply(auto elim!: Prf_elims)[1]
|
|
274 |
apply(simp)
|
|
275 |
apply(case_tac list)
|
|
276 |
apply(simp)
|
|
277 |
apply(auto)
|
|
278 |
apply(auto elim!: Prf_elims)[1]
|
|
279 |
done
|
|
280 |
|
|
281 |
lemma retrieve_fuse:
|
|
282 |
assumes "\<Turnstile> v : r"
|
|
283 |
shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v"
|
|
284 |
using assms
|
|
285 |
by (simp_all add: retrieve_fuse2)
|
|
286 |
|
|
287 |
|
|
288 |
lemma retrieve_code:
|
|
289 |
assumes "\<Turnstile> v : r"
|
|
290 |
shows "code v = retrieve (intern r) v"
|
|
291 |
using assms
|
|
292 |
apply(induct v r )
|
|
293 |
apply(simp_all add: retrieve_fuse retrieve_encode_STARS)
|
|
294 |
done
|
|
295 |
|
|
296 |
lemma r:
|
|
297 |
assumes "bnullable (AALTs bs (a # rs))"
|
|
298 |
shows "bnullable a \<or> (\<not> bnullable a \<and> bnullable (AALTs bs rs))"
|
|
299 |
using assms
|
|
300 |
apply(induct rs)
|
|
301 |
apply(auto)
|
|
302 |
done
|
|
303 |
|
|
304 |
lemma r0:
|
|
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 r0)
|
|
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 |
fun flts :: "arexp list \<Rightarrow> arexp list"
|
|
549 |
where
|
|
550 |
"flts [] = []"
|
|
551 |
| "flts (AZERO # rs) = flts rs"
|
|
552 |
| "flts ((AALTs bs rs1) # rs) = (map (fuse bs) rs1) @ flts rs"
|
|
553 |
| "flts (r1 # rs) = r1 # flts rs"
|
|
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
|
558 |
fun li :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
|
|
559 |
where
|
|
560 |
"li _ [] = AZERO"
|
|
561 |
| "li bs [a] = fuse bs a"
|
|
562 |
| "li bs as = AALTs bs as"
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
|
567 |
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
|
|
568 |
where
|
|
569 |
"bsimp_ASEQ _ AZERO _ = AZERO"
|
|
570 |
| "bsimp_ASEQ _ _ AZERO = AZERO"
|
|
571 |
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
|
|
572 |
| "bsimp_ASEQ bs1 r1 r2 = ASEQ bs1 r1 r2"
|
|
573 |
|
|
574 |
|
|
575 |
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
|
|
576 |
where
|
|
577 |
"bsimp_AALTs _ [] = AZERO"
|
|
578 |
| "bsimp_AALTs bs1 [r] = fuse bs1 r"
|
|
579 |
| "bsimp_AALTs bs1 rs = AALTs bs1 rs"
|
|
580 |
|
|
581 |
|
|
582 |
fun bsimp :: "arexp \<Rightarrow> arexp"
|
|
583 |
where
|
|
584 |
"bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)"
|
|
585 |
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (flts (map bsimp rs))"
|
|
586 |
| "bsimp r = r"
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
591 |
fun
|
|
592 |
bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
|
|
593 |
where
|
|
594 |
"bders_simp r [] = r"
|
|
595 |
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s"
|
|
596 |
|
|
597 |
definition blexer_simp where
|
|
598 |
"blexer_simp r s \<equiv> if bnullable (bders_simp (intern r) s) then
|
|
599 |
decode (bmkeps (bders_simp (intern r) s)) r else None"
|
|
600 |
|
|
601 |
|
|
602 |
lemma asize0:
|
|
603 |
shows "0 < asize r"
|
|
604 |
apply(induct r)
|
|
605 |
apply(auto)
|
|
606 |
done
|
|
607 |
|
|
608 |
|
|
609 |
lemma bders_simp_append:
|
|
610 |
shows "bders_simp r (s1 @ s2) = bders_simp (bders_simp r s1) s2"
|
|
611 |
apply(induct s1 arbitrary: r s2)
|
|
612 |
apply(simp)
|
|
613 |
apply(simp)
|
|
614 |
done
|
|
615 |
|
|
616 |
lemma bsimp_ASEQ_size:
|
|
617 |
shows "asize (bsimp_ASEQ bs r1 r2) \<le> Suc (asize r1 + asize r2)"
|
|
618 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
|
|
619 |
apply(auto)
|
|
620 |
done
|
|
621 |
|
|
622 |
lemma fuse_size:
|
|
623 |
shows "asize (fuse bs r) = asize r"
|
|
624 |
apply(induct r)
|
|
625 |
apply(auto)
|
|
626 |
done
|
|
627 |
|
|
628 |
lemma flts_size:
|
|
629 |
shows "sum_list (map asize (flts rs)) \<le> sum_list (map asize rs)"
|
|
630 |
apply(induct rs rule: flts.induct)
|
|
631 |
apply(simp_all)
|
|
632 |
by (metis (mono_tags, lifting) add_mono comp_apply eq_imp_le fuse_size le_SucI map_eq_conv)
|
|
633 |
|
|
634 |
|
|
635 |
lemma bsimp_AALTs_size:
|
|
636 |
shows "asize (bsimp_AALTs bs rs) \<le> Suc (sum_list (map asize rs))"
|
|
637 |
apply(induct rs rule: bsimp_AALTs.induct)
|
|
638 |
apply(auto simp add: fuse_size)
|
|
639 |
done
|
|
640 |
|
|
641 |
|
|
642 |
lemma bsimp_size:
|
|
643 |
shows "asize (bsimp r) \<le> asize r"
|
|
644 |
apply(induct r)
|
|
645 |
apply(simp_all)
|
|
646 |
apply (meson Suc_le_mono add_mono_thms_linordered_semiring(1) bsimp_ASEQ_size le_trans)
|
|
647 |
apply(rule le_trans)
|
|
648 |
apply(rule bsimp_AALTs_size)
|
|
649 |
apply(simp)
|
|
650 |
apply(rule le_trans)
|
|
651 |
apply(rule flts_size)
|
|
652 |
by (simp add: sum_list_mono)
|
|
653 |
|
|
654 |
lemma bsimp_asize0:
|
|
655 |
shows "(\<Sum>x\<leftarrow>rs. asize (bsimp x)) \<le> sum_list (map asize rs)"
|
|
656 |
apply(induct rs)
|
|
657 |
apply(auto)
|
|
658 |
by (simp add: add_mono bsimp_size)
|
|
659 |
|
|
660 |
lemma bsimp_AALTs_size2:
|
|
661 |
assumes "\<forall>r \<in> set rs. nonalt r"
|
|
662 |
shows "asize (bsimp_AALTs bs rs) \<ge> sum_list (map asize rs)"
|
|
663 |
using assms
|
|
664 |
apply(induct rs rule: bsimp_AALTs.induct)
|
|
665 |
apply(simp_all add: fuse_size)
|
|
666 |
done
|
|
667 |
|
|
668 |
|
|
669 |
lemma qq:
|
|
670 |
shows "map (asize \<circ> fuse bs) rs = map asize rs"
|
|
671 |
apply(induct rs)
|
|
672 |
apply(auto simp add: fuse_size)
|
|
673 |
done
|
|
674 |
|
|
675 |
lemma flts_size2:
|
|
676 |
assumes "\<exists>bs rs'. AALTs bs rs' \<in> set rs"
|
|
677 |
shows "sum_list (map asize (flts rs)) < sum_list (map asize rs)"
|
|
678 |
using assms
|
|
679 |
apply(induct rs)
|
|
680 |
apply(auto simp add: qq)
|
|
681 |
apply (simp add: flts_size less_Suc_eq_le)
|
|
682 |
apply(case_tac a)
|
|
683 |
apply(auto simp add: qq)
|
|
684 |
prefer 2
|
|
685 |
apply (simp add: flts_size le_imp_less_Suc)
|
|
686 |
using less_Suc_eq by auto
|
|
687 |
|
|
688 |
lemma bsimp_AALTs_size3:
|
|
689 |
assumes "\<exists>r \<in> set (map bsimp rs). \<not>nonalt r"
|
|
690 |
shows "asize (bsimp (AALTs bs rs)) < asize (AALTs bs rs)"
|
|
691 |
using assms flts_size2
|
|
692 |
apply -
|
|
693 |
apply(clarify)
|
|
694 |
apply(simp)
|
|
695 |
apply(drule_tac x="map bsimp rs" in meta_spec)
|
|
696 |
apply(drule meta_mp)
|
|
697 |
apply (metis list.set_map nonalt.elims(3))
|
|
698 |
apply(simp)
|
|
699 |
apply(rule order_class.order.strict_trans1)
|
|
700 |
apply(rule bsimp_AALTs_size)
|
|
701 |
apply(simp)
|
|
702 |
by (smt Suc_leI bsimp_asize0 comp_def le_imp_less_Suc le_trans map_eq_conv not_less_eq)
|
|
703 |
|
|
704 |
|
|
705 |
|
|
706 |
|
|
707 |
lemma L_bsimp_ASEQ:
|
|
708 |
"L (SEQ (erase r1) (erase r2)) = L (erase (bsimp_ASEQ bs r1 r2))"
|
|
709 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
|
|
710 |
apply(simp_all)
|
|
711 |
by (metis erase_fuse fuse.simps(4))
|
|
712 |
|
|
713 |
lemma L_bsimp_AALTs:
|
|
714 |
"L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))"
|
|
715 |
apply(induct bs rs rule: bsimp_AALTs.induct)
|
|
716 |
apply(simp_all add: erase_fuse)
|
|
717 |
done
|
|
718 |
|
|
719 |
lemma L_erase_AALTs:
|
|
720 |
shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))"
|
|
721 |
apply(induct rs)
|
|
722 |
apply(simp)
|
|
723 |
apply(simp)
|
|
724 |
apply(case_tac rs)
|
|
725 |
apply(simp)
|
|
726 |
apply(simp)
|
|
727 |
done
|
|
728 |
|
|
729 |
lemma L_erase_flts:
|
|
730 |
shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))"
|
|
731 |
apply(induct rs rule: flts.induct)
|
|
732 |
apply(simp_all)
|
|
733 |
apply(auto)
|
|
734 |
using L_erase_AALTs erase_fuse apply auto[1]
|
|
735 |
by (simp add: L_erase_AALTs erase_fuse)
|
|
736 |
|
|
737 |
|
|
738 |
lemma L_bsimp_erase:
|
|
739 |
shows "L (erase r) = L (erase (bsimp r))"
|
|
740 |
apply(induct r)
|
|
741 |
apply(simp)
|
|
742 |
apply(simp)
|
|
743 |
apply(simp)
|
|
744 |
apply(auto simp add: Sequ_def)[1]
|
|
745 |
apply(subst L_bsimp_ASEQ[symmetric])
|
|
746 |
apply(auto simp add: Sequ_def)[1]
|
|
747 |
apply(subst (asm) L_bsimp_ASEQ[symmetric])
|
|
748 |
apply(auto simp add: Sequ_def)[1]
|
|
749 |
apply(simp)
|
|
750 |
apply(subst L_bsimp_AALTs[symmetric])
|
|
751 |
defer
|
|
752 |
apply(simp)
|
|
753 |
apply(subst (2)L_erase_AALTs)
|
|
754 |
apply(subst L_erase_flts)
|
|
755 |
apply(auto)
|
|
756 |
apply (simp add: L_erase_AALTs)
|
|
757 |
using L_erase_AALTs by blast
|
|
758 |
|
|
759 |
lemma bsimp_ASEQ0:
|
|
760 |
shows "bsimp_ASEQ bs r1 AZERO = AZERO"
|
|
761 |
apply(induct r1)
|
|
762 |
apply(auto)
|
|
763 |
done
|
|
764 |
|
|
765 |
|
|
766 |
|
|
767 |
lemma bsimp_ASEQ1:
|
|
768 |
assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
|
|
769 |
shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2"
|
|
770 |
using assms
|
|
771 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
|
|
772 |
apply(auto)
|
|
773 |
done
|
|
774 |
|
|
775 |
lemma bsimp_ASEQ2:
|
|
776 |
shows "bsimp_ASEQ bs (AONE bs1) r2 = fuse (bs @ bs1) r2"
|
|
777 |
apply(induct r2)
|
|
778 |
apply(auto)
|
|
779 |
done
|
|
780 |
|
|
781 |
|
|
782 |
lemma L_bders_simp:
|
|
783 |
shows "L (erase (bders_simp r s)) = L (erase (bders r s))"
|
|
784 |
apply(induct s arbitrary: r rule: rev_induct)
|
|
785 |
apply(simp)
|
|
786 |
apply(simp)
|
|
787 |
apply(simp add: ders_append)
|
|
788 |
apply(simp add: bders_simp_append)
|
|
789 |
apply(simp add: L_bsimp_erase[symmetric])
|
|
790 |
by (simp add: der_correctness)
|
|
791 |
|
|
792 |
lemma b1:
|
|
793 |
"bsimp_ASEQ bs1 (AONE bs) r = fuse (bs1 @ bs) r"
|
|
794 |
apply(induct r)
|
|
795 |
apply(auto)
|
|
796 |
done
|
|
797 |
|
|
798 |
lemma b2:
|
|
799 |
assumes "bnullable r"
|
|
800 |
shows "bmkeps (fuse bs r) = bs @ bmkeps r"
|
|
801 |
by (simp add: assms bmkeps_retrieve bnullable_correctness erase_fuse mkeps_nullable retrieve_fuse2)
|
|
802 |
|
|
803 |
lemma b3:
|
|
804 |
shows "bnullable r = bnullable (bsimp r)"
|
|
805 |
using L_bsimp_erase bnullable_correctness nullable_correctness by auto
|
|
806 |
|
|
807 |
|
|
808 |
lemma b4:
|
|
809 |
shows "bnullable (bders_simp r s) = bnullable (bders r s)"
|
|
810 |
by (metis L_bders_simp bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1))
|
|
811 |
|
|
812 |
lemma q1:
|
|
813 |
assumes "\<forall>r \<in> set rs. bmkeps(bsimp r) = bmkeps r"
|
|
814 |
shows "map (\<lambda>r. bmkeps(bsimp r)) rs = map bmkeps rs"
|
|
815 |
using assms
|
|
816 |
apply(induct rs)
|
|
817 |
apply(simp)
|
|
818 |
apply(simp)
|
|
819 |
done
|
|
820 |
|
|
821 |
lemma q3:
|
|
822 |
assumes "\<exists>r \<in> set rs. bnullable r"
|
|
823 |
shows "bmkeps (AALTs bs rs) = bmkeps (bsimp_AALTs bs rs)"
|
|
824 |
using assms
|
|
825 |
apply(induct bs rs rule: bsimp_AALTs.induct)
|
|
826 |
apply(simp)
|
|
827 |
apply(simp)
|
|
828 |
apply (simp add: b2)
|
|
829 |
apply(simp)
|
|
830 |
done
|
|
831 |
|
|
832 |
lemma qq1:
|
|
833 |
assumes "\<exists>r \<in> set rs. bnullable r"
|
|
834 |
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs)"
|
|
835 |
using assms
|
|
836 |
apply(induct rs arbitrary: rs1 bs)
|
|
837 |
apply(simp)
|
|
838 |
apply(simp)
|
|
839 |
by (metis Nil_is_append_conv bmkeps.simps(4) neq_Nil_conv r0 split_list_last)
|
|
840 |
|
|
841 |
lemma qq2:
|
|
842 |
assumes "\<forall>r \<in> set rs. \<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r"
|
|
843 |
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs1)"
|
|
844 |
using assms
|
|
845 |
apply(induct rs arbitrary: rs1 bs)
|
|
846 |
apply(simp)
|
|
847 |
apply(simp)
|
|
848 |
by (metis append_assoc in_set_conv_decomp r1 r2)
|
|
849 |
|
|
850 |
lemma qq3:
|
|
851 |
shows "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
|
|
852 |
apply(induct rs arbitrary: bs)
|
|
853 |
apply(simp)
|
|
854 |
apply(simp)
|
|
855 |
done
|
|
856 |
|
|
857 |
lemma fuse_empty:
|
|
858 |
shows "fuse [] r = r"
|
|
859 |
apply(induct r)
|
|
860 |
apply(auto)
|
|
861 |
done
|
|
862 |
|
|
863 |
lemma flts_fuse:
|
|
864 |
shows "map (fuse bs) (flts rs) = flts (map (fuse bs) rs)"
|
|
865 |
apply(induct rs arbitrary: bs rule: flts.induct)
|
|
866 |
apply(auto simp add: fuse_append)
|
|
867 |
done
|
|
868 |
|
|
869 |
lemma bsimp_ASEQ_fuse:
|
|
870 |
shows "fuse bs1 (bsimp_ASEQ bs2 r1 r2) = bsimp_ASEQ (bs1 @ bs2) r1 r2"
|
|
871 |
apply(induct r1 r2 arbitrary: bs1 bs2 rule: bsimp_ASEQ.induct)
|
|
872 |
apply(auto)
|
|
873 |
done
|
|
874 |
|
|
875 |
lemma bsimp_AALTs_fuse:
|
|
876 |
assumes "\<forall>r \<in> set rs. fuse bs1 (fuse bs2 r) = fuse (bs1 @ bs2) r"
|
|
877 |
shows "fuse bs1 (bsimp_AALTs bs2 rs) = bsimp_AALTs (bs1 @ bs2) rs"
|
|
878 |
using assms
|
|
879 |
apply(induct bs2 rs arbitrary: bs1 rule: bsimp_AALTs.induct)
|
|
880 |
apply(auto)
|
|
881 |
done
|
|
882 |
|
|
883 |
|
|
884 |
|
|
885 |
lemma bsimp_fuse:
|
|
886 |
shows "fuse bs (bsimp r) = bsimp (fuse bs r)"
|
|
887 |
apply(induct r arbitrary: bs)
|
|
888 |
apply(simp)
|
|
889 |
apply(simp)
|
|
890 |
apply(simp)
|
|
891 |
prefer 3
|
|
892 |
apply(simp)
|
|
893 |
apply(simp)
|
|
894 |
apply (simp add: bsimp_ASEQ_fuse)
|
|
895 |
apply(simp)
|
|
896 |
by (simp add: bsimp_AALTs_fuse fuse_append)
|
|
897 |
|
|
898 |
lemma bsimp_fuse_AALTs:
|
|
899 |
shows "fuse bs (bsimp (AALTs [] rs)) = bsimp (AALTs bs rs)"
|
|
900 |
apply(subst bsimp_fuse)
|
|
901 |
apply(simp)
|
|
902 |
done
|
|
903 |
|
|
904 |
lemma bsimp_fuse_AALTs2:
|
|
905 |
shows "fuse bs (bsimp_AALTs [] rs) = bsimp_AALTs bs rs"
|
|
906 |
using bsimp_AALTs_fuse fuse_append by auto
|
|
907 |
|
|
908 |
|
|
909 |
lemma bsimp_ASEQ_idem:
|
|
910 |
assumes "bsimp (bsimp r1) = bsimp r1" "bsimp (bsimp r2) = bsimp r2"
|
|
911 |
shows "bsimp (bsimp_ASEQ x1 (bsimp r1) (bsimp r2)) = bsimp_ASEQ x1 (bsimp r1) (bsimp r2)"
|
|
912 |
using assms
|
|
913 |
apply(case_tac "bsimp r1 = AZERO")
|
|
914 |
apply(simp)
|
|
915 |
apply(case_tac "bsimp r2 = AZERO")
|
|
916 |
apply(simp)
|
|
917 |
apply (metis bnullable.elims(2) bnullable.elims(3) bsimp.simps(3) bsimp_ASEQ.simps(2) bsimp_ASEQ.simps(3) bsimp_ASEQ.simps(4) bsimp_ASEQ.simps(5) bsimp_ASEQ.simps(6))
|
|
918 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
|
|
919 |
apply(auto)[1]
|
|
920 |
apply(subst bsimp_ASEQ2)
|
|
921 |
apply(subst bsimp_ASEQ2)
|
|
922 |
apply (metis assms(2) bsimp_fuse)
|
|
923 |
apply(subst bsimp_ASEQ1)
|
|
924 |
apply(auto)
|
|
925 |
done
|
|
926 |
|
|
927 |
|
|
928 |
fun nonnested :: "arexp \<Rightarrow> bool"
|
|
929 |
where
|
|
930 |
"nonnested (AALTs bs2 []) = True"
|
|
931 |
| "nonnested (AALTs bs2 ((AALTs bs1 rs1) # rs2)) = False"
|
|
932 |
| "nonnested (AALTs bs2 (r # rs2)) = nonnested (AALTs bs2 rs2)"
|
|
933 |
| "nonnested r = True"
|
|
934 |
|
|
935 |
|
|
936 |
lemma k0:
|
|
937 |
shows "flts (r # rs1) = flts [r] @ flts rs1"
|
|
938 |
apply(induct r arbitrary: rs1)
|
|
939 |
apply(auto)
|
|
940 |
done
|
|
941 |
|
|
942 |
lemma k00:
|
|
943 |
shows "flts (rs1 @ rs2) = flts rs1 @ flts rs2"
|
|
944 |
apply(induct rs1 arbitrary: rs2)
|
|
945 |
apply(auto)
|
|
946 |
by (metis append.assoc k0)
|
|
947 |
|
|
948 |
lemma k0a:
|
|
949 |
shows "flts [AALTs bs rs] = map (fuse bs) rs"
|
|
950 |
apply(simp)
|
|
951 |
done
|
|
952 |
|
|
953 |
|
|
954 |
lemma k0b:
|
|
955 |
assumes "nonalt r" "r \<noteq> AZERO"
|
|
956 |
shows "flts [r] = [r]"
|
|
957 |
using assms
|
|
958 |
apply(case_tac r)
|
|
959 |
apply(simp_all)
|
|
960 |
done
|
|
961 |
|
|
962 |
lemma nn1:
|
|
963 |
assumes "nonnested (AALTs bs rs)"
|
|
964 |
shows "\<nexists>bs1 rs1. flts rs = [AALTs bs1 rs1]"
|
|
965 |
using assms
|
|
966 |
apply(induct rs rule: flts.induct)
|
|
967 |
apply(auto)
|
|
968 |
done
|
|
969 |
|
|
970 |
lemma nn1q:
|
|
971 |
assumes "nonnested (AALTs bs rs)"
|
|
972 |
shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set (flts rs)"
|
|
973 |
using assms
|
|
974 |
apply(induct rs rule: flts.induct)
|
|
975 |
apply(auto)
|
|
976 |
done
|
|
977 |
|
|
978 |
lemma nn1qq:
|
|
979 |
assumes "nonnested (AALTs bs rs)"
|
|
980 |
shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set rs"
|
|
981 |
using assms
|
|
982 |
apply(induct rs rule: flts.induct)
|
|
983 |
apply(auto)
|
|
984 |
done
|
|
985 |
|
|
986 |
lemma nn10:
|
|
987 |
assumes "nonnested (AALTs cs rs)"
|
|
988 |
shows "nonnested (AALTs (bs @ cs) rs)"
|
|
989 |
using assms
|
|
990 |
apply(induct rs arbitrary: cs bs)
|
|
991 |
apply(simp_all)
|
|
992 |
apply(case_tac a)
|
|
993 |
apply(simp_all)
|
|
994 |
done
|
|
995 |
|
|
996 |
lemma nn11a:
|
|
997 |
assumes "nonalt r"
|
|
998 |
shows "nonalt (fuse bs r)"
|
|
999 |
using assms
|
|
1000 |
apply(induct r)
|
|
1001 |
apply(auto)
|
|
1002 |
done
|
|
1003 |
|
|
1004 |
|
|
1005 |
lemma nn1a:
|
|
1006 |
assumes "nonnested r"
|
|
1007 |
shows "nonnested (fuse bs r)"
|
|
1008 |
using assms
|
|
1009 |
apply(induct bs r arbitrary: rule: fuse.induct)
|
|
1010 |
apply(simp_all add: nn10)
|
|
1011 |
done
|
|
1012 |
|
|
1013 |
lemma n0:
|
|
1014 |
shows "nonnested (AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. nonalt r)"
|
|
1015 |
apply(induct rs arbitrary: bs)
|
|
1016 |
apply(auto)
|
|
1017 |
apply (metis list.set_intros(1) nn1qq nonalt.elims(3))
|
|
1018 |
apply (metis list.set_intros(2) nn1qq nonalt.elims(3))
|
|
1019 |
by (metis nonalt.elims(2) nonnested.simps(3) nonnested.simps(4) nonnested.simps(5) nonnested.simps(6) nonnested.simps(7))
|
|
1020 |
|
|
1021 |
|
|
1022 |
|
|
1023 |
|
|
1024 |
lemma nn1c:
|
|
1025 |
assumes "\<forall>r \<in> set rs. nonnested r"
|
|
1026 |
shows "\<forall>r \<in> set (flts rs). nonalt r"
|
|
1027 |
using assms
|
|
1028 |
apply(induct rs rule: flts.induct)
|
|
1029 |
apply(auto)
|
|
1030 |
apply(rule nn11a)
|
|
1031 |
by (metis nn1qq nonalt.elims(3))
|
|
1032 |
|
|
1033 |
lemma nn1bb:
|
|
1034 |
assumes "\<forall>r \<in> set rs. nonalt r"
|
|
1035 |
shows "nonnested (bsimp_AALTs bs rs)"
|
|
1036 |
using assms
|
|
1037 |
apply(induct bs rs rule: bsimp_AALTs.induct)
|
|
1038 |
apply(auto)
|
|
1039 |
apply (metis nn11a nonalt.simps(1) nonnested.elims(3))
|
|
1040 |
using n0 by auto
|
|
1041 |
|
|
1042 |
lemma nn1b:
|
|
1043 |
shows "nonnested (bsimp r)"
|
|
1044 |
apply(induct r)
|
|
1045 |
apply(simp_all)
|
|
1046 |
apply(case_tac "bsimp r1 = AZERO")
|
|
1047 |
apply(simp)
|
|
1048 |
apply(case_tac "bsimp r2 = AZERO")
|
|
1049 |
apply(simp)
|
|
1050 |
apply(subst bsimp_ASEQ0)
|
|
1051 |
apply(simp)
|
|
1052 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
|
|
1053 |
apply(auto)[1]
|
|
1054 |
apply(subst bsimp_ASEQ2)
|
|
1055 |
apply (simp add: nn1a)
|
|
1056 |
apply(subst bsimp_ASEQ1)
|
|
1057 |
apply(auto)
|
|
1058 |
apply(rule nn1bb)
|
|
1059 |
apply(auto)
|
|
1060 |
by (metis (mono_tags, hide_lams) imageE nn1c set_map)
|
|
1061 |
|
|
1062 |
lemma nn1d:
|
|
1063 |
assumes "bsimp r = AALTs bs rs"
|
|
1064 |
shows "\<forall>r1 \<in> set rs. \<forall> bs. r1 \<noteq> AALTs bs rs2"
|
|
1065 |
using nn1b assms
|
|
1066 |
by (metis nn1qq)
|
|
1067 |
|
|
1068 |
lemma nn_flts:
|
|
1069 |
assumes "nonnested (AALTs bs rs)"
|
|
1070 |
shows "\<forall>r \<in> set (flts rs). nonalt r"
|
|
1071 |
using assms
|
|
1072 |
apply(induct rs arbitrary: bs rule: flts.induct)
|
|
1073 |
apply(auto)
|
|
1074 |
done
|
|
1075 |
|
|
1076 |
|
|
1077 |
|
|
1078 |
lemma rt:
|
|
1079 |
shows "sum_list (map asize (flts (map bsimp rs))) \<le> sum_list (map asize rs)"
|
|
1080 |
apply(induct rs)
|
|
1081 |
apply(simp)
|
|
1082 |
apply(simp)
|
|
1083 |
apply(subst k0)
|
|
1084 |
apply(simp)
|
|
1085 |
by (smt add_le_cancel_right add_mono bsimp_size flts.simps(1) flts_size k0 le_iff_add list.simps(9) map_append sum_list.Cons sum_list.append trans_le_add1)
|
|
1086 |
|
|
1087 |
lemma bsimp_AALTs_qq:
|
|
1088 |
assumes "1 < length rs"
|
|
1089 |
shows "bsimp_AALTs bs rs = AALTs bs rs"
|
|
1090 |
using assms
|
|
1091 |
apply(case_tac rs)
|
|
1092 |
apply(simp)
|
|
1093 |
apply(case_tac list)
|
|
1094 |
apply(simp_all)
|
|
1095 |
done
|
|
1096 |
|
|
1097 |
|
|
1098 |
lemma bsimp_AALTs1:
|
|
1099 |
assumes "nonalt r"
|
|
1100 |
shows "bsimp_AALTs bs (flts [r]) = fuse bs r"
|
|
1101 |
using assms
|
|
1102 |
apply(case_tac r)
|
|
1103 |
apply(simp_all)
|
|
1104 |
done
|
|
1105 |
|
489
|
1106 |
fun nonalt :: "arexp \<Rightarrow> bool"
|
|
1107 |
where
|
|
1108 |
"nonalt (AALTs bs2 rs) = False"
|
|
1109 |
| "nonalt r = True"
|
|
1110 |
|
|
1111 |
|
|
1112 |
fun good :: "arexp \<Rightarrow> bool" where
|
|
1113 |
"good AZERO = False"
|
|
1114 |
| "good (AONE cs) = True"
|
|
1115 |
| "good (ACHAR cs c) = True"
|
|
1116 |
| "good (AALTs cs []) = False"
|
|
1117 |
| "good (AALTs cs [r]) = False"
|
|
1118 |
| "good (AALTs cs (r1#r2#rs)) = (\<forall>r' \<in> set (r1#r2#rs). good r' \<and> nonalt r')"
|
|
1119 |
| "good (ASEQ _ AZERO _) = False"
|
|
1120 |
| "good (ASEQ _ (AONE _) _) = False"
|
|
1121 |
| "good (ASEQ _ _ AZERO) = False"
|
|
1122 |
| "good (ASEQ cs r1 r2) = (good r1 \<and> good r2)"
|
|
1123 |
| "good (ASTAR cs r) = True"
|
|
1124 |
|
365
|
1125 |
lemma bbbbs:
|
|
1126 |
assumes "good r" "r = AALTs bs1 rs"
|
|
1127 |
shows "bsimp_AALTs bs (flts [r]) = AALTs bs (map (fuse bs1) rs)"
|
|
1128 |
using assms
|
|
1129 |
by (metis (no_types, lifting) Nil_is_map_conv append.left_neutral append_butlast_last_id bsimp_AALTs.elims butlast.simps(2) good.simps(4) good.simps(5) k0a map_butlast)
|
|
1130 |
|
|
1131 |
lemma bbbbs1:
|
|
1132 |
shows "nonalt r \<or> (\<exists>bs rs. r = AALTs bs rs)"
|
|
1133 |
using nonalt.elims(3) by auto
|
|
1134 |
|
|
1135 |
|
|
1136 |
lemma good_fuse:
|
|
1137 |
shows "good (fuse bs r) = good r"
|
|
1138 |
apply(induct r arbitrary: bs)
|
|
1139 |
apply(auto)
|
|
1140 |
apply(case_tac r1)
|
|
1141 |
apply(simp_all)
|
|
1142 |
apply(case_tac r2)
|
|
1143 |
apply(simp_all)
|
|
1144 |
apply(case_tac r2)
|
|
1145 |
apply(simp_all)
|
|
1146 |
apply(case_tac r2)
|
|
1147 |
apply(simp_all)
|
|
1148 |
apply(case_tac r2)
|
|
1149 |
apply(simp_all)
|
|
1150 |
apply(case_tac r1)
|
|
1151 |
apply(simp_all)
|
|
1152 |
apply(case_tac r2)
|
|
1153 |
apply(simp_all)
|
|
1154 |
apply(case_tac r2)
|
|
1155 |
apply(simp_all)
|
|
1156 |
apply(case_tac r2)
|
|
1157 |
apply(simp_all)
|
|
1158 |
apply(case_tac r2)
|
|
1159 |
apply(simp_all)
|
|
1160 |
apply(case_tac x2a)
|
|
1161 |
apply(simp_all)
|
|
1162 |
apply(case_tac list)
|
|
1163 |
apply(simp_all)
|
|
1164 |
apply(case_tac x2a)
|
|
1165 |
apply(simp_all)
|
|
1166 |
apply(case_tac list)
|
|
1167 |
apply(simp_all)
|
|
1168 |
done
|
|
1169 |
|
|
1170 |
lemma good0:
|
|
1171 |
assumes "rs \<noteq> Nil" "\<forall>r \<in> set rs. nonalt r"
|
|
1172 |
shows "good (bsimp_AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. good r)"
|
|
1173 |
using assms
|
|
1174 |
apply(induct bs rs rule: bsimp_AALTs.induct)
|
|
1175 |
apply(auto simp add: good_fuse)
|
|
1176 |
done
|
|
1177 |
|
|
1178 |
lemma good0a:
|
|
1179 |
assumes "flts (map bsimp rs) \<noteq> Nil" "\<forall>r \<in> set (flts (map bsimp rs)). nonalt r"
|
|
1180 |
shows "good (bsimp (AALTs bs rs)) \<longleftrightarrow> (\<forall>r \<in> set (flts (map bsimp rs)). good r)"
|
|
1181 |
using assms
|
|
1182 |
apply(simp)
|
|
1183 |
apply(auto)
|
|
1184 |
apply(subst (asm) good0)
|
|
1185 |
apply(simp)
|
|
1186 |
apply(auto)
|
|
1187 |
apply(subst good0)
|
|
1188 |
apply(simp)
|
|
1189 |
apply(auto)
|
|
1190 |
done
|
|
1191 |
|
|
1192 |
lemma flts0:
|
|
1193 |
assumes "r \<noteq> AZERO" "nonalt r"
|
|
1194 |
shows "flts [r] \<noteq> []"
|
|
1195 |
using assms
|
|
1196 |
apply(induct r)
|
|
1197 |
apply(simp_all)
|
|
1198 |
done
|
|
1199 |
|
|
1200 |
lemma flts1:
|
|
1201 |
assumes "good r"
|
|
1202 |
shows "flts [r] \<noteq> []"
|
|
1203 |
using assms
|
|
1204 |
apply(induct r)
|
|
1205 |
apply(simp_all)
|
|
1206 |
apply(case_tac x2a)
|
|
1207 |
apply(simp)
|
|
1208 |
apply(simp)
|
|
1209 |
done
|
|
1210 |
|
|
1211 |
lemma flts2:
|
|
1212 |
assumes "good r"
|
|
1213 |
shows "\<forall>r' \<in> set (flts [r]). good r' \<and> nonalt r'"
|
|
1214 |
using assms
|
|
1215 |
apply(induct r)
|
|
1216 |
apply(simp)
|
|
1217 |
apply(simp)
|
|
1218 |
apply(simp)
|
|
1219 |
prefer 2
|
|
1220 |
apply(simp)
|
|
1221 |
apply(auto)[1]
|
|
1222 |
apply (metis bsimp_AALTs.elims good.simps(4) good.simps(5) good.simps(6) good_fuse)
|
|
1223 |
apply (metis bsimp_AALTs.elims good.simps(4) good.simps(5) good.simps(6) nn11a)
|
|
1224 |
apply fastforce
|
|
1225 |
apply(simp)
|
|
1226 |
done
|
|
1227 |
|
|
1228 |
|
|
1229 |
lemma flts3:
|
|
1230 |
assumes "\<forall>r \<in> set rs. good r \<or> r = AZERO"
|
|
1231 |
shows "\<forall>r \<in> set (flts rs). good r"
|
|
1232 |
using assms
|
|
1233 |
apply(induct rs arbitrary: rule: flts.induct)
|
|
1234 |
apply(simp_all)
|
|
1235 |
by (metis UnE flts2 k0a set_map)
|
|
1236 |
|
|
1237 |
lemma flts3b:
|
|
1238 |
assumes "\<exists>r\<in>set rs. good r"
|
|
1239 |
shows "flts rs \<noteq> []"
|
|
1240 |
using assms
|
|
1241 |
apply(induct rs arbitrary: rule: flts.induct)
|
|
1242 |
apply(simp)
|
|
1243 |
apply(simp)
|
|
1244 |
apply(simp)
|
|
1245 |
apply(auto)
|
|
1246 |
done
|
|
1247 |
|
|
1248 |
lemma flts4:
|
|
1249 |
assumes "bsimp_AALTs bs (flts rs) = AZERO"
|
|
1250 |
shows "\<forall>r \<in> set rs. \<not> good r"
|
|
1251 |
using assms
|
|
1252 |
apply(induct rs arbitrary: bs rule: flts.induct)
|
|
1253 |
apply(auto)
|
|
1254 |
defer
|
|
1255 |
apply (metis (no_types, lifting) Nil_is_append_conv append_self_conv2 bsimp_AALTs.elims butlast.simps(2) butlast_append flts3b nonalt.simps(1) nonalt.simps(2))
|
|
1256 |
apply (metis arexp.distinct(7) bsimp_AALTs.elims flts2 good.simps(1) good.simps(2) good0 k0b list.distinct(1) list.inject nonalt.simps(3))
|
|
1257 |
apply (metis arexp.distinct(3) arexp.distinct(7) bsimp_AALTs.elims fuse.simps(3) list.distinct(1) list.inject)
|
|
1258 |
apply (metis arexp.distinct(7) bsimp_AALTs.elims good.simps(1) good_fuse list.distinct(1) list.inject)
|
|
1259 |
apply (metis arexp.distinct(7) bsimp_AALTs.elims list.distinct(1) list.inject)
|
|
1260 |
apply (metis arexp.distinct(7) bsimp_AALTs.elims flts2 good.simps(1) good.simps(33) good0 k0b list.distinct(1) list.inject nonalt.simps(6))
|
|
1261 |
by (metis (no_types, lifting) Nil_is_append_conv append_Nil2 arexp.distinct(7) bsimp_AALTs.elims butlast.simps(2) butlast_append flts1 flts2 good.simps(1) good0 k0a)
|
|
1262 |
|
|
1263 |
|
|
1264 |
lemma flts_nil:
|
|
1265 |
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
|
|
1266 |
good (bsimp y) \<or> bsimp y = AZERO"
|
|
1267 |
and "\<forall>r\<in>set rs. \<not> good (bsimp r)"
|
|
1268 |
shows "flts (map bsimp rs) = []"
|
|
1269 |
using assms
|
|
1270 |
apply(induct rs)
|
|
1271 |
apply(simp)
|
|
1272 |
apply(simp)
|
|
1273 |
apply(subst k0)
|
|
1274 |
apply(simp)
|
|
1275 |
by force
|
|
1276 |
|
|
1277 |
lemma flts_nil2:
|
|
1278 |
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
|
|
1279 |
good (bsimp y) \<or> bsimp y = AZERO"
|
|
1280 |
and "bsimp_AALTs bs (flts (map bsimp rs)) = AZERO"
|
|
1281 |
shows "flts (map bsimp rs) = []"
|
|
1282 |
using assms
|
|
1283 |
apply(induct rs arbitrary: bs)
|
|
1284 |
apply(simp)
|
|
1285 |
apply(simp)
|
|
1286 |
apply(subst k0)
|
|
1287 |
apply(simp)
|
|
1288 |
apply(subst (asm) k0)
|
|
1289 |
apply(auto)
|
|
1290 |
apply (metis flts.simps(1) flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
|
|
1291 |
by (metis flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
|
|
1292 |
|
|
1293 |
|
|
1294 |
|
|
1295 |
lemma good_SEQ:
|
|
1296 |
assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
|
|
1297 |
shows "good (ASEQ bs r1 r2) = (good r1 \<and> good r2)"
|
|
1298 |
using assms
|
|
1299 |
apply(case_tac r1)
|
|
1300 |
apply(simp_all)
|
|
1301 |
apply(case_tac r2)
|
|
1302 |
apply(simp_all)
|
|
1303 |
apply(case_tac r2)
|
|
1304 |
apply(simp_all)
|
|
1305 |
apply(case_tac r2)
|
|
1306 |
apply(simp_all)
|
|
1307 |
apply(case_tac r2)
|
|
1308 |
apply(simp_all)
|
|
1309 |
done
|
|
1310 |
|
|
1311 |
lemma good1:
|
|
1312 |
shows "good (bsimp a) \<or> bsimp a = AZERO"
|
|
1313 |
apply(induct a taking: asize rule: measure_induct)
|
|
1314 |
apply(case_tac x)
|
|
1315 |
apply(simp)
|
|
1316 |
apply(simp)
|
|
1317 |
apply(simp)
|
|
1318 |
prefer 3
|
|
1319 |
apply(simp)
|
|
1320 |
prefer 2
|
|
1321 |
(* AALTs case *)
|
|
1322 |
apply(simp only:)
|
|
1323 |
apply(case_tac "x52")
|
|
1324 |
apply(simp)
|
|
1325 |
thm good0a
|
|
1326 |
(* AALTs list at least one - case *)
|
|
1327 |
apply(simp only: )
|
|
1328 |
apply(frule_tac x="a" in spec)
|
|
1329 |
apply(drule mp)
|
|
1330 |
apply(simp)
|
|
1331 |
(* either first element is good, or AZERO *)
|
|
1332 |
apply(erule disjE)
|
|
1333 |
prefer 2
|
|
1334 |
apply(simp)
|
|
1335 |
(* in the AZERO case, the size is smaller *)
|
|
1336 |
apply(drule_tac x="AALTs x51 list" in spec)
|
|
1337 |
apply(drule mp)
|
|
1338 |
apply(simp add: asize0)
|
|
1339 |
apply(subst (asm) bsimp.simps)
|
|
1340 |
apply(subst (asm) bsimp.simps)
|
|
1341 |
apply(assumption)
|
|
1342 |
(* in the good case *)
|
|
1343 |
apply(frule_tac x="AALTs x51 list" in spec)
|
|
1344 |
apply(drule mp)
|
|
1345 |
apply(simp add: asize0)
|
|
1346 |
apply(erule disjE)
|
|
1347 |
apply(rule disjI1)
|
|
1348 |
apply(simp add: good0)
|
|
1349 |
apply(subst good0)
|
|
1350 |
apply (metis Nil_is_append_conv flts1 k0)
|
|
1351 |
apply (metis ex_map_conv list.simps(9) nn1b nn1c)
|
|
1352 |
apply(simp)
|
|
1353 |
apply(subst k0)
|
|
1354 |
apply(simp)
|
|
1355 |
apply(auto)[1]
|
|
1356 |
using flts2 apply blast
|
|
1357 |
apply(subst (asm) good0)
|
|
1358 |
prefer 3
|
|
1359 |
apply(auto)[1]
|
|
1360 |
apply auto[1]
|
|
1361 |
apply (metis ex_map_conv nn1b nn1c)
|
|
1362 |
(* in the AZERO case *)
|
|
1363 |
apply(simp)
|
|
1364 |
apply(frule_tac x="a" in spec)
|
|
1365 |
apply(drule mp)
|
|
1366 |
apply(simp)
|
|
1367 |
apply(erule disjE)
|
|
1368 |
apply(rule disjI1)
|
|
1369 |
apply(subst good0)
|
|
1370 |
apply(subst k0)
|
|
1371 |
using flts1 apply blast
|
|
1372 |
apply(auto)[1]
|
|
1373 |
apply (metis (no_types, hide_lams) ex_map_conv list.simps(9) nn1b nn1c)
|
|
1374 |
apply(auto)[1]
|
|
1375 |
apply(subst (asm) k0)
|
|
1376 |
apply(auto)[1]
|
|
1377 |
using flts2 apply blast
|
|
1378 |
apply(frule_tac x="AALTs x51 list" in spec)
|
|
1379 |
apply(drule mp)
|
|
1380 |
apply(simp add: asize0)
|
|
1381 |
apply(erule disjE)
|
|
1382 |
apply(simp)
|
|
1383 |
apply(simp)
|
|
1384 |
apply (metis add.left_commute flts_nil2 less_add_Suc1 less_imp_Suc_add list.distinct(1) list.set_cases nat.inject)
|
|
1385 |
apply(subst (2) k0)
|
|
1386 |
apply(simp)
|
|
1387 |
(* SEQ case *)
|
|
1388 |
apply(simp)
|
|
1389 |
apply(case_tac "bsimp x42 = AZERO")
|
|
1390 |
apply(simp)
|
|
1391 |
apply(case_tac "bsimp x43 = AZERO")
|
|
1392 |
apply(simp)
|
|
1393 |
apply(subst (2) bsimp_ASEQ0)
|
|
1394 |
apply(simp)
|
|
1395 |
apply(case_tac "\<exists>bs. bsimp x42 = AONE bs")
|
|
1396 |
apply(auto)[1]
|
|
1397 |
apply(subst bsimp_ASEQ2)
|
|
1398 |
using good_fuse apply force
|
|
1399 |
apply(subst bsimp_ASEQ1)
|
|
1400 |
apply(auto)
|
|
1401 |
apply(subst good_SEQ)
|
|
1402 |
apply(simp)
|
|
1403 |
apply(simp)
|
|
1404 |
apply(simp)
|
|
1405 |
using less_add_Suc1 less_add_Suc2 by blast
|
|
1406 |
|
|
1407 |
lemma good1a:
|
|
1408 |
assumes "L(erase a) \<noteq> {}"
|
|
1409 |
shows "good (bsimp a)"
|
|
1410 |
using good1 assms
|
|
1411 |
using L_bsimp_erase by force
|
|
1412 |
|
|
1413 |
|
|
1414 |
|
|
1415 |
lemma flts_append:
|
|
1416 |
"flts (xs1 @ xs2) = flts xs1 @ flts xs2"
|
|
1417 |
apply(induct xs1 arbitrary: xs2 rule: rev_induct)
|
|
1418 |
apply(auto)
|
|
1419 |
apply(case_tac xs)
|
|
1420 |
apply(auto)
|
|
1421 |
apply(case_tac x)
|
|
1422 |
apply(auto)
|
|
1423 |
apply(case_tac x)
|
|
1424 |
apply(auto)
|
|
1425 |
done
|
|
1426 |
|
|
1427 |
lemma g1:
|
|
1428 |
assumes "good (bsimp_AALTs bs rs)"
|
|
1429 |
shows "bsimp_AALTs bs rs = AALTs bs rs \<or> (\<exists>r. rs = [r] \<and> bsimp_AALTs bs [r] = fuse bs r)"
|
|
1430 |
using assms
|
|
1431 |
apply(induct rs arbitrary: bs)
|
|
1432 |
apply(simp)
|
|
1433 |
apply(case_tac rs)
|
|
1434 |
apply(simp only:)
|
|
1435 |
apply(simp)
|
|
1436 |
apply(case_tac list)
|
|
1437 |
apply(simp)
|
|
1438 |
by simp
|
|
1439 |
|
|
1440 |
lemma flts_0:
|
|
1441 |
assumes "nonnested (AALTs bs rs)"
|
|
1442 |
shows "\<forall>r \<in> set (flts rs). r \<noteq> AZERO"
|
|
1443 |
using assms
|
|
1444 |
apply(induct rs arbitrary: bs rule: flts.induct)
|
|
1445 |
apply(simp)
|
|
1446 |
apply(simp)
|
|
1447 |
defer
|
|
1448 |
apply(simp)
|
|
1449 |
apply(simp)
|
|
1450 |
apply(simp)
|
|
1451 |
apply(simp)
|
|
1452 |
apply(rule ballI)
|
|
1453 |
apply(simp)
|
|
1454 |
done
|
|
1455 |
|
|
1456 |
lemma flts_0a:
|
|
1457 |
assumes "nonnested (AALTs bs rs)"
|
|
1458 |
shows "AZERO \<notin> set (flts rs)"
|
|
1459 |
using assms
|
|
1460 |
using flts_0 by blast
|
|
1461 |
|
|
1462 |
lemma qqq1:
|
|
1463 |
shows "AZERO \<notin> set (flts (map bsimp rs))"
|
|
1464 |
by (metis ex_map_conv flts3 good.simps(1) good1)
|
|
1465 |
|
|
1466 |
|
|
1467 |
fun nonazero :: "arexp \<Rightarrow> bool"
|
|
1468 |
where
|
|
1469 |
"nonazero AZERO = False"
|
|
1470 |
| "nonazero r = True"
|
|
1471 |
|
|
1472 |
lemma flts_concat:
|
|
1473 |
shows "flts rs = concat (map (\<lambda>r. flts [r]) rs)"
|
|
1474 |
apply(induct rs)
|
|
1475 |
apply(auto)
|
|
1476 |
apply(subst k0)
|
|
1477 |
apply(simp)
|
|
1478 |
done
|
|
1479 |
|
|
1480 |
lemma flts_single1:
|
|
1481 |
assumes "nonalt r" "nonazero r"
|
|
1482 |
shows "flts [r] = [r]"
|
|
1483 |
using assms
|
|
1484 |
apply(induct r)
|
|
1485 |
apply(auto)
|
|
1486 |
done
|
|
1487 |
|
|
1488 |
lemma flts_qq:
|
|
1489 |
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> good y \<longrightarrow> bsimp y = y"
|
|
1490 |
"\<forall>r'\<in>set rs. good r' \<and> nonalt r'"
|
|
1491 |
shows "flts (map bsimp rs) = rs"
|
|
1492 |
using assms
|
|
1493 |
apply(induct rs)
|
|
1494 |
apply(simp)
|
|
1495 |
apply(simp)
|
|
1496 |
apply(subst k0)
|
|
1497 |
apply(subgoal_tac "flts [bsimp a] = [a]")
|
|
1498 |
prefer 2
|
|
1499 |
apply(drule_tac x="a" in spec)
|
|
1500 |
apply(drule mp)
|
|
1501 |
apply(simp)
|
|
1502 |
apply(auto)[1]
|
|
1503 |
using good.simps(1) k0b apply blast
|
|
1504 |
apply(auto)[1]
|
|
1505 |
done
|
|
1506 |
|
|
1507 |
lemma test:
|
|
1508 |
assumes "good r"
|
|
1509 |
shows "bsimp r = r"
|
|
1510 |
using assms
|
|
1511 |
apply(induct r taking: "asize" rule: measure_induct)
|
|
1512 |
apply(erule good.elims)
|
|
1513 |
apply(simp_all)
|
|
1514 |
apply(subst k0)
|
|
1515 |
apply(subst (2) k0)
|
|
1516 |
apply(subst flts_qq)
|
|
1517 |
apply(auto)[1]
|
|
1518 |
apply(auto)[1]
|
|
1519 |
apply (metis append_Cons append_Nil bsimp_AALTs.simps(3) good.simps(1) k0b)
|
|
1520 |
apply force+
|
|
1521 |
apply (metis (no_types, lifting) add_Suc add_Suc_right asize.simps(5) bsimp.simps(1) bsimp_ASEQ.simps(19) less_add_Suc1 less_add_Suc2)
|
|
1522 |
apply (metis add_Suc add_Suc_right arexp.distinct(5) arexp.distinct(7) asize.simps(4) asize.simps(5) bsimp.simps(1) bsimp.simps(2) bsimp_ASEQ1 good.simps(21) good.simps(8) less_add_Suc1 less_add_Suc2)
|
|
1523 |
apply force+
|
|
1524 |
apply (metis (no_types, lifting) add_Suc add_Suc_right arexp.distinct(5) arexp.distinct(7) asize.simps(4) asize.simps(5) bsimp.simps(1) bsimp.simps(2) bsimp_ASEQ1 good.simps(25) good.simps(8) less_add_Suc1 less_add_Suc2)
|
|
1525 |
apply (metis add_Suc add_Suc_right arexp.distinct(7) asize.simps(4) bsimp.simps(2) bsimp_ASEQ1 good.simps(26) good.simps(8) less_add_Suc1 less_add_Suc2)
|
|
1526 |
apply force+
|
|
1527 |
done
|
|
1528 |
|
|
1529 |
lemma test2:
|
|
1530 |
assumes "good r"
|
|
1531 |
shows "bsimp r = r"
|
|
1532 |
using assms
|
|
1533 |
apply(induct r taking: "asize" rule: measure_induct)
|
|
1534 |
apply(case_tac x)
|
|
1535 |
apply(simp_all)
|
|
1536 |
defer
|
|
1537 |
(* AALT case *)
|
|
1538 |
apply(subgoal_tac "1 < length x52")
|
|
1539 |
prefer 2
|
|
1540 |
apply(case_tac x52)
|
|
1541 |
apply(simp)
|
|
1542 |
apply(simp)
|
|
1543 |
apply(case_tac list)
|
|
1544 |
apply(simp)
|
|
1545 |
apply(simp)
|
|
1546 |
apply(subst bsimp_AALTs_qq)
|
|
1547 |
prefer 2
|
|
1548 |
apply(subst flts_qq)
|
|
1549 |
apply(auto)[1]
|
|
1550 |
apply(auto)[1]
|
|
1551 |
apply(case_tac x52)
|
|
1552 |
apply(simp)
|
|
1553 |
apply(simp)
|
|
1554 |
apply(case_tac list)
|
|
1555 |
apply(simp)
|
|
1556 |
apply(simp)
|
|
1557 |
apply(auto)[1]
|
|
1558 |
apply (metis (no_types, lifting) bsimp_AALTs.elims good.simps(6) length_Cons length_pos_if_in_set list.size(3) nat_neq_iff)
|
|
1559 |
apply(simp)
|
|
1560 |
apply(case_tac x52)
|
|
1561 |
apply(simp)
|
|
1562 |
apply(simp)
|
|
1563 |
apply(case_tac list)
|
|
1564 |
apply(simp)
|
|
1565 |
apply(simp)
|
|
1566 |
apply(subst k0)
|
|
1567 |
apply(simp)
|
|
1568 |
apply(subst (2) k0)
|
|
1569 |
apply(simp)
|
|
1570 |
apply (simp add: Suc_lessI flts1 one_is_add)
|
|
1571 |
(* SEQ case *)
|
|
1572 |
apply(case_tac "bsimp x42 = AZERO")
|
|
1573 |
apply simp
|
|
1574 |
apply (metis asize.elims good.simps(10) good.simps(11) good.simps(12) good.simps(2) good.simps(7) good.simps(9) good_SEQ less_add_Suc1)
|
|
1575 |
apply(case_tac "\<exists>bs'. bsimp x42 = AONE bs'")
|
|
1576 |
apply(auto)[1]
|
|
1577 |
defer
|
|
1578 |
apply(case_tac "bsimp x43 = AZERO")
|
|
1579 |
apply(simp)
|
|
1580 |
apply (metis bsimp.elims bsimp.simps(3) good.simps(10) good.simps(11) good.simps(12) good.simps(8) good.simps(9) good_SEQ less_add_Suc2)
|
|
1581 |
apply(auto)
|
|
1582 |
apply (subst bsimp_ASEQ1)
|
|
1583 |
apply(auto)[3]
|
|
1584 |
apply(auto)[1]
|
|
1585 |
apply (metis bsimp.simps(3) good.simps(2) good_SEQ less_add_Suc1)
|
|
1586 |
apply (metis bsimp.simps(3) good.simps(2) good_SEQ less_add_Suc1 less_add_Suc2)
|
|
1587 |
apply (subst bsimp_ASEQ2)
|
|
1588 |
apply(drule_tac x="x42" in spec)
|
|
1589 |
apply(drule mp)
|
|
1590 |
apply(simp)
|
|
1591 |
apply(drule mp)
|
|
1592 |
apply (metis bsimp.elims bsimp.simps(3) good.simps(10) good.simps(11) good.simps(2) good_SEQ)
|
|
1593 |
apply(simp)
|
|
1594 |
done
|
|
1595 |
|
|
1596 |
|
|
1597 |
lemma bsimp_idem:
|
|
1598 |
shows "bsimp (bsimp r) = bsimp r"
|
|
1599 |
using test good1
|
|
1600 |
by force
|
|
1601 |
|
|
1602 |
|
|
1603 |
lemma q3a:
|
|
1604 |
assumes "\<exists>r \<in> set rs. bnullable r"
|
|
1605 |
shows "bmkeps (AALTs bs (map (fuse bs1) rs)) = bmkeps (AALTs (bs@bs1) rs)"
|
|
1606 |
using assms
|
|
1607 |
apply(induct rs arbitrary: bs bs1)
|
|
1608 |
apply(simp)
|
|
1609 |
apply(simp)
|
|
1610 |
apply(auto)
|
|
1611 |
apply (metis append_assoc b2 bnullable_correctness erase_fuse r0)
|
|
1612 |
apply(case_tac "bnullable a")
|
|
1613 |
apply (metis append.assoc b2 bnullable_correctness erase_fuse r0)
|
|
1614 |
apply(case_tac rs)
|
|
1615 |
apply(simp)
|
|
1616 |
apply(simp)
|
|
1617 |
apply(auto)[1]
|
|
1618 |
apply (metis bnullable_correctness erase_fuse)+
|
|
1619 |
done
|
|
1620 |
|
|
1621 |
lemma qq4:
|
|
1622 |
assumes "\<exists>x\<in>set list. bnullable x"
|
|
1623 |
shows "\<exists>x\<in>set (flts list). bnullable x"
|
|
1624 |
using assms
|
|
1625 |
apply(induct list rule: flts.induct)
|
|
1626 |
apply(auto)
|
|
1627 |
by (metis UnCI bnullable_correctness erase_fuse imageI)
|
|
1628 |
|
|
1629 |
|
|
1630 |
lemma qs3:
|
|
1631 |
assumes "\<exists>r \<in> set rs. bnullable r"
|
|
1632 |
shows "bmkeps (AALTs bs rs) = bmkeps (AALTs bs (flts rs))"
|
|
1633 |
using assms
|
|
1634 |
apply(induct rs arbitrary: bs taking: size rule: measure_induct)
|
|
1635 |
apply(case_tac x)
|
|
1636 |
apply(simp)
|
|
1637 |
apply(simp)
|
|
1638 |
apply(case_tac a)
|
|
1639 |
apply(simp)
|
|
1640 |
apply (simp add: r1)
|
|
1641 |
apply(simp)
|
|
1642 |
apply (simp add: r0)
|
|
1643 |
apply(simp)
|
|
1644 |
apply(case_tac "flts list")
|
|
1645 |
apply(simp)
|
|
1646 |
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)
|
|
1647 |
apply(simp)
|
|
1648 |
apply (simp add: r1)
|
|
1649 |
prefer 3
|
|
1650 |
apply(simp)
|
|
1651 |
apply (simp add: r0)
|
|
1652 |
prefer 2
|
|
1653 |
apply(simp)
|
|
1654 |
apply(case_tac "\<exists>x\<in>set x52. bnullable x")
|
|
1655 |
apply(case_tac "list")
|
|
1656 |
apply(simp)
|
|
1657 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
1658 |
apply(erule disjE)
|
|
1659 |
apply(subst qq1)
|
|
1660 |
apply(auto)[1]
|
|
1661 |
apply (metis bnullable_correctness erase_fuse)
|
|
1662 |
apply(simp)
|
|
1663 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
1664 |
apply(simp)
|
|
1665 |
apply(auto)[1]
|
|
1666 |
apply(subst qq1)
|
|
1667 |
apply (metis bnullable_correctness erase_fuse image_eqI set_map)
|
|
1668 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
1669 |
apply(subst qq1)
|
|
1670 |
apply (metis bnullable_correctness erase_fuse image_eqI set_map)
|
|
1671 |
apply (metis b2 fuse.simps(4) q3a r2)
|
|
1672 |
apply(simp)
|
|
1673 |
apply(subst qq2)
|
|
1674 |
apply (metis bnullable_correctness erase_fuse imageE set_map)
|
|
1675 |
prefer 2
|
|
1676 |
apply(case_tac "list")
|
|
1677 |
apply(simp)
|
|
1678 |
apply(simp)
|
|
1679 |
apply (simp add: qq4)
|
|
1680 |
apply(simp)
|
|
1681 |
apply(auto)
|
|
1682 |
apply(case_tac list)
|
|
1683 |
apply(simp)
|
|
1684 |
apply(simp)
|
|
1685 |
apply (simp add: r0)
|
|
1686 |
apply(case_tac "bnullable (ASEQ x41 x42 x43)")
|
|
1687 |
apply(case_tac list)
|
|
1688 |
apply(simp)
|
|
1689 |
apply(simp)
|
|
1690 |
apply (simp add: r0)
|
|
1691 |
apply(simp)
|
|
1692 |
using qq4 r1 r2 by auto
|
|
1693 |
|
|
1694 |
|
|
1695 |
|
|
1696 |
lemma k1:
|
|
1697 |
assumes "\<And>x2aa. \<lbrakk>x2aa \<in> set x2a; bnullable x2aa\<rbrakk> \<Longrightarrow> bmkeps x2aa = bmkeps (bsimp x2aa)"
|
|
1698 |
"\<exists>x\<in>set x2a. bnullable x"
|
|
1699 |
shows "bmkeps (AALTs x1 (flts x2a)) = bmkeps (AALTs x1 (flts (map bsimp x2a)))"
|
|
1700 |
using assms
|
|
1701 |
apply(induct x2a)
|
|
1702 |
apply fastforce
|
|
1703 |
apply(simp)
|
|
1704 |
apply(subst k0)
|
|
1705 |
apply(subst (2) k0)
|
|
1706 |
apply(auto)[1]
|
|
1707 |
apply (metis b3 k0 list.set_intros(1) qs3 r0)
|
|
1708 |
by (smt b3 imageI insert_iff k0 list.set(2) qq3 qs3 r0 r1 set_map)
|
|
1709 |
|
|
1710 |
|
|
1711 |
|
|
1712 |
lemma bmkeps_simp:
|
|
1713 |
assumes "bnullable r"
|
|
1714 |
shows "bmkeps r = bmkeps (bsimp r)"
|
|
1715 |
using assms
|
|
1716 |
apply(induct r)
|
|
1717 |
apply(simp)
|
|
1718 |
apply(simp)
|
|
1719 |
apply(simp)
|
|
1720 |
apply(simp)
|
|
1721 |
prefer 3
|
|
1722 |
apply(simp)
|
|
1723 |
apply(case_tac "bsimp r1 = AZERO")
|
|
1724 |
apply(simp)
|
|
1725 |
apply(auto)[1]
|
|
1726 |
apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
|
|
1727 |
apply(case_tac "bsimp r2 = AZERO")
|
|
1728 |
apply(simp)
|
|
1729 |
apply(auto)[1]
|
|
1730 |
apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
|
|
1731 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
|
|
1732 |
apply(auto)[1]
|
|
1733 |
apply(subst b1)
|
|
1734 |
apply(subst b2)
|
|
1735 |
apply(simp add: b3[symmetric])
|
|
1736 |
apply(simp)
|
|
1737 |
apply(subgoal_tac "bsimp_ASEQ x1 (bsimp r1) (bsimp r2) = ASEQ x1 (bsimp r1) (bsimp r2)")
|
|
1738 |
prefer 2
|
|
1739 |
apply (smt b3 bnullable.elims(2) bsimp_ASEQ.simps(17) bsimp_ASEQ.simps(19) bsimp_ASEQ.simps(20) bsimp_ASEQ.simps(21) bsimp_ASEQ.simps(22) bsimp_ASEQ.simps(24) bsimp_ASEQ.simps(25) bsimp_ASEQ.simps(26) bsimp_ASEQ.simps(27) bsimp_ASEQ.simps(29) bsimp_ASEQ.simps(30) bsimp_ASEQ.simps(31))
|
|
1740 |
apply(simp)
|
|
1741 |
apply(simp)
|
|
1742 |
thm q3
|
|
1743 |
apply(subst q3[symmetric])
|
|
1744 |
apply simp
|
|
1745 |
using b3 qq4 apply auto[1]
|
|
1746 |
apply(subst qs3)
|
|
1747 |
apply simp
|
|
1748 |
using k1 by blast
|
|
1749 |
|
|
1750 |
thm bmkeps_retrieve bmkeps_simp bder_retrieve
|
|
1751 |
|
|
1752 |
lemma bmkeps_bder_AALTs:
|
|
1753 |
assumes "\<exists>r \<in> set rs. bnullable (bder c r)"
|
|
1754 |
shows "bmkeps (bder c (bsimp_AALTs bs rs)) = bmkeps (bsimp_AALTs bs (map (bder c) rs))"
|
|
1755 |
using assms
|
|
1756 |
apply(induct rs)
|
|
1757 |
apply(simp)
|
|
1758 |
apply(simp)
|
|
1759 |
apply(auto)
|
|
1760 |
apply(case_tac rs)
|
|
1761 |
apply(simp)
|
|
1762 |
apply (metis (full_types) Prf_injval bder_retrieve bmkeps_retrieve bnullable_correctness erase_bder erase_fuse mkeps_nullable retrieve_fuse2)
|
|
1763 |
apply(simp)
|
|
1764 |
apply(case_tac rs)
|
|
1765 |
apply(simp_all)
|
|
1766 |
done
|
|
1767 |
|
|
1768 |
lemma bbs0:
|
|
1769 |
shows "blexer_simp r [] = blexer r []"
|
|
1770 |
apply(simp add: blexer_def blexer_simp_def)
|
|
1771 |
done
|
|
1772 |
|
|
1773 |
lemma bbs1:
|
|
1774 |
shows "blexer_simp r [c] = blexer r [c]"
|
|
1775 |
apply(simp add: blexer_def blexer_simp_def)
|
|
1776 |
apply(auto)
|
|
1777 |
defer
|
|
1778 |
using b3 apply auto[1]
|
|
1779 |
using b3 apply auto[1]
|
|
1780 |
apply(subst bmkeps_simp[symmetric])
|
|
1781 |
apply(simp)
|
|
1782 |
apply(simp)
|
|
1783 |
done
|
|
1784 |
|
|
1785 |
lemma oo:
|
|
1786 |
shows "(case (blexer (der c r) s) of None \<Rightarrow> None | Some v \<Rightarrow> Some (injval r c v)) = blexer r (c # s)"
|
|
1787 |
apply(simp add: blexer_correctness)
|
|
1788 |
done
|
|
1789 |
|
|
1790 |
|
|
1791 |
lemma bder_fuse:
|
|
1792 |
shows "bder c (fuse bs a) = fuse bs (bder c a)"
|
|
1793 |
apply(induct a arbitrary: bs c)
|
|
1794 |
apply(simp_all)
|
|
1795 |
done
|
|
1796 |
|
|
1797 |
|
|
1798 |
fun flts2 :: "char \<Rightarrow> arexp list \<Rightarrow> arexp list"
|
|
1799 |
where
|
|
1800 |
"flts2 _ [] = []"
|
|
1801 |
| "flts2 c (AZERO # rs) = flts2 c rs"
|
|
1802 |
| "flts2 c (AONE _ # rs) = flts2 c rs"
|
|
1803 |
| "flts2 c (ACHAR bs d # rs) = (if c = d then (ACHAR bs d # flts2 c rs) else flts2 c rs)"
|
|
1804 |
| "flts2 c ((AALTs bs rs1) # rs) = (map (fuse bs) rs1) @ flts2 c rs"
|
|
1805 |
| "flts2 c (ASEQ bs r1 r2 # rs) = (if (bnullable(r1) \<and> r2 = AZERO) then
|
|
1806 |
flts2 c rs
|
|
1807 |
else ASEQ bs r1 r2 # flts2 c rs)"
|
|
1808 |
| "flts2 c (r1 # rs) = r1 # flts2 c rs"
|
|
1809 |
|
|
1810 |
lemma flts2_k0:
|
|
1811 |
shows "flts2 c (r # rs1) = flts2 c [r] @ flts2 c rs1"
|
|
1812 |
apply(induct r arbitrary: c rs1)
|
|
1813 |
apply(auto)
|
|
1814 |
done
|
|
1815 |
|
|
1816 |
lemma flts2_k00:
|
|
1817 |
shows "flts2 c (rs1 @ rs2) = flts2 c rs1 @ flts2 c rs2"
|
|
1818 |
apply(induct rs1 arbitrary: rs2 c)
|
|
1819 |
apply(auto)
|
|
1820 |
by (metis append.assoc flts2_k0)
|
|
1821 |
|
|
1822 |
|
|
1823 |
lemma
|
|
1824 |
shows "flts (map (bder c) rs) = (map (bder c) (flts2 c rs))"
|
|
1825 |
apply(induct c rs rule: flts2.induct)
|
|
1826 |
apply(simp)
|
|
1827 |
apply(simp)
|
|
1828 |
apply(simp)
|
|
1829 |
apply(simp)
|
|
1830 |
apply(simp)
|
|
1831 |
apply(auto simp add: bder_fuse)[1]
|
|
1832 |
defer
|
|
1833 |
apply(simp)
|
|
1834 |
apply(simp del: flts2.simps)
|
|
1835 |
apply(rule conjI)
|
|
1836 |
prefer 2
|
|
1837 |
apply(auto)[1]
|
|
1838 |
apply(rule impI)
|
|
1839 |
apply(subst flts2_k0)
|
|
1840 |
apply(subst map_append)
|
|
1841 |
apply(subst flts2.simps)
|
|
1842 |
apply(simp only: flts2.simps)
|
|
1843 |
apply(auto)
|
|
1844 |
|
|
1845 |
|
|
1846 |
|
|
1847 |
lemma XXX2_helper:
|
|
1848 |
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> good y \<longrightarrow> bsimp y = y"
|
|
1849 |
"\<forall>r'\<in>set rs. good r' \<and> nonalt r'"
|
|
1850 |
shows "flts (map (bsimp \<circ> bder c) (flts (map bsimp rs))) = flts (map (bsimp \<circ> bder c) rs)"
|
|
1851 |
using assms
|
|
1852 |
apply(induct rs arbitrary: c)
|
|
1853 |
apply(simp)
|
|
1854 |
apply(simp)
|
|
1855 |
apply(subst k0)
|
|
1856 |
apply(simp add: flts_append)
|
|
1857 |
apply(subst (2) k0)
|
|
1858 |
apply(simp add: flts_append)
|
|
1859 |
apply(subgoal_tac "flts [a] = [a]")
|
|
1860 |
prefer 2
|
|
1861 |
using good.simps(1) k0b apply blast
|
|
1862 |
apply(simp)
|
|
1863 |
done
|
|
1864 |
|
|
1865 |
lemma bmkeps_good:
|
|
1866 |
assumes "good a"
|
|
1867 |
shows "bmkeps (bsimp a) = bmkeps a"
|
|
1868 |
using assms
|
|
1869 |
using test2 by auto
|
|
1870 |
|
|
1871 |
|
|
1872 |
lemma xxx_bder:
|
|
1873 |
assumes "good r"
|
|
1874 |
shows "L (erase r) \<noteq> {}"
|
|
1875 |
using assms
|
|
1876 |
apply(induct r rule: good.induct)
|
|
1877 |
apply(auto simp add: Sequ_def)
|
|
1878 |
done
|
|
1879 |
|
|
1880 |
lemma xxx_bder2:
|
|
1881 |
assumes "L (erase (bsimp r)) = {}"
|
|
1882 |
shows "bsimp r = AZERO"
|
|
1883 |
using assms xxx_bder test2 good1
|
|
1884 |
by blast
|
|
1885 |
|
|
1886 |
lemma XXX2aa:
|
|
1887 |
assumes "good a"
|
|
1888 |
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
|
|
1889 |
using assms
|
|
1890 |
by (simp add: test2)
|
|
1891 |
|
|
1892 |
lemma XXX2aa_ders:
|
|
1893 |
assumes "good a"
|
|
1894 |
shows "bsimp (bders (bsimp a) s) = bsimp (bders a s)"
|
|
1895 |
using assms
|
|
1896 |
by (simp add: test2)
|
|
1897 |
|
|
1898 |
lemma XXX4a:
|
|
1899 |
shows "good (bders_simp (bsimp r) s) \<or> bders_simp (bsimp r) s = AZERO"
|
|
1900 |
apply(induct s arbitrary: r rule: rev_induct)
|
|
1901 |
apply(simp)
|
|
1902 |
apply (simp add: good1)
|
|
1903 |
apply(simp add: bders_simp_append)
|
|
1904 |
apply (simp add: good1)
|
|
1905 |
done
|
|
1906 |
|
|
1907 |
lemma XXX4a_good:
|
|
1908 |
assumes "good a"
|
|
1909 |
shows "good (bders_simp a s) \<or> bders_simp a s = AZERO"
|
|
1910 |
using assms
|
|
1911 |
apply(induct s arbitrary: a rule: rev_induct)
|
|
1912 |
apply(simp)
|
|
1913 |
apply(simp add: bders_simp_append)
|
|
1914 |
apply (simp add: good1)
|
|
1915 |
done
|
|
1916 |
|
|
1917 |
lemma XXX4a_good_cons:
|
|
1918 |
assumes "s \<noteq> []"
|
|
1919 |
shows "good (bders_simp a s) \<or> bders_simp a s = AZERO"
|
|
1920 |
using assms
|
|
1921 |
apply(case_tac s)
|
|
1922 |
apply(auto)
|
|
1923 |
using XXX4a by blast
|
|
1924 |
|
|
1925 |
lemma XXX4b:
|
|
1926 |
assumes "good a" "L (erase (bders_simp a s)) \<noteq> {}"
|
|
1927 |
shows "good (bders_simp a s)"
|
|
1928 |
using assms
|
|
1929 |
apply(induct s arbitrary: a)
|
|
1930 |
apply(simp)
|
|
1931 |
apply(simp)
|
|
1932 |
apply(subgoal_tac "L (erase (bder a aa)) = {} \<or> L (erase (bder a aa)) \<noteq> {}")
|
|
1933 |
prefer 2
|
|
1934 |
apply(auto)[1]
|
|
1935 |
apply(erule disjE)
|
|
1936 |
apply(subgoal_tac "bsimp (bder a aa) = AZERO")
|
|
1937 |
prefer 2
|
|
1938 |
using L_bsimp_erase xxx_bder2 apply auto[1]
|
|
1939 |
apply(simp)
|
|
1940 |
apply (metis L.simps(1) XXX4a erase.simps(1))
|
|
1941 |
apply(drule_tac x="bsimp (bder a aa)" in meta_spec)
|
|
1942 |
apply(drule meta_mp)
|
|
1943 |
apply simp
|
|
1944 |
apply(rule good1a)
|
|
1945 |
apply(auto)
|
|
1946 |
done
|
|
1947 |
|
|
1948 |
lemma bders_AZERO:
|
|
1949 |
shows "bders AZERO s = AZERO"
|
|
1950 |
and "bders_simp AZERO s = AZERO"
|
|
1951 |
apply (induct s)
|
|
1952 |
apply(auto)
|
|
1953 |
done
|
|
1954 |
|
|
1955 |
lemma LA:
|
|
1956 |
assumes "\<Turnstile> v : ders s (erase r)"
|
|
1957 |
shows "retrieve (bders r s) v = retrieve r (flex (erase r) id s v)"
|
|
1958 |
using assms
|
|
1959 |
apply(induct s arbitrary: r v rule: rev_induct)
|
|
1960 |
apply(simp)
|
|
1961 |
apply(simp add: bders_append ders_append)
|
|
1962 |
apply(subst bder_retrieve)
|
|
1963 |
apply(simp)
|
|
1964 |
apply(drule Prf_injval)
|
|
1965 |
by (simp add: flex_append)
|
|
1966 |
|
|
1967 |
|
|
1968 |
lemma LB:
|
|
1969 |
assumes "s \<in> (erase r) \<rightarrow> v"
|
|
1970 |
shows "retrieve r v = retrieve r (flex (erase r) id s (mkeps (ders s (erase r))))"
|
|
1971 |
using assms
|
|
1972 |
apply(induct s arbitrary: r v rule: rev_induct)
|
|
1973 |
apply(simp)
|
|
1974 |
apply(subgoal_tac "v = mkeps (erase r)")
|
|
1975 |
prefer 2
|
|
1976 |
apply (simp add: Posix1(1) Posix_determ Posix_mkeps nullable_correctness)
|
|
1977 |
apply(simp)
|
|
1978 |
apply(simp add: flex_append ders_append)
|
|
1979 |
by (metis Posix_determ Posix_flex Posix_injval Posix_mkeps ders_snoc lexer_correctness(2) lexer_flex)
|
|
1980 |
|
|
1981 |
lemma LB_sym:
|
|
1982 |
assumes "s \<in> (erase r) \<rightarrow> v"
|
|
1983 |
shows "retrieve r v = retrieve r (flex (erase r) id s (mkeps (erase (bders r s))))"
|
|
1984 |
using assms
|
|
1985 |
by (simp add: LB)
|
|
1986 |
|
|
1987 |
|
|
1988 |
lemma LC:
|
|
1989 |
assumes "s \<in> (erase r) \<rightarrow> v"
|
|
1990 |
shows "retrieve r v = retrieve (bders r s) (mkeps (erase (bders r s)))"
|
|
1991 |
apply(simp)
|
|
1992 |
by (metis LA LB Posix1(1) assms lexer_correct_None lexer_flex mkeps_nullable)
|
|
1993 |
|
|
1994 |
|
|
1995 |
lemma L0:
|
|
1996 |
assumes "bnullable a"
|
|
1997 |
shows "retrieve (bsimp a) (mkeps (erase (bsimp a))) = retrieve a (mkeps (erase a))"
|
|
1998 |
using assms
|
|
1999 |
by (metis b3 bmkeps_retrieve bmkeps_simp bnullable_correctness)
|
|
2000 |
|
|
2001 |
thm bmkeps_retrieve
|
|
2002 |
|
|
2003 |
lemma L0a:
|
|
2004 |
assumes "s \<in> L(erase a)"
|
|
2005 |
shows "retrieve (bsimp (bders a s)) (mkeps (erase (bsimp (bders a s)))) =
|
|
2006 |
retrieve (bders a s) (mkeps (erase (bders a s)))"
|
|
2007 |
using assms
|
|
2008 |
by (metis L0 bnullable_correctness erase_bders lexer_correct_None lexer_flex)
|
|
2009 |
|
|
2010 |
lemma L0aa:
|
|
2011 |
assumes "s \<in> L (erase a)"
|
|
2012 |
shows "[] \<in> erase (bsimp (bders a s)) \<rightarrow> mkeps (erase (bsimp (bders a s)))"
|
|
2013 |
using assms
|
|
2014 |
by (metis Posix_mkeps b3 bnullable_correctness erase_bders lexer_correct_None lexer_flex)
|
|
2015 |
|
|
2016 |
lemma L0aaa:
|
|
2017 |
assumes "[c] \<in> L (erase a)"
|
|
2018 |
shows "[c] \<in> (erase a) \<rightarrow> flex (erase a) id [c] (mkeps (erase (bder c a)))"
|
|
2019 |
using assms
|
|
2020 |
by (metis bders.simps(1) bders.simps(2) erase_bders lexer_correct_None lexer_correct_Some lexer_flex option.inject)
|
|
2021 |
|
|
2022 |
lemma L0aaaa:
|
|
2023 |
assumes "[c] \<in> L (erase a)"
|
|
2024 |
shows "[c] \<in> (erase a) \<rightarrow> flex (erase a) id [c] (mkeps (erase (bders a [c])))"
|
|
2025 |
using assms
|
|
2026 |
using L0aaa by auto
|
|
2027 |
|
|
2028 |
|
|
2029 |
lemma L02:
|
|
2030 |
assumes "bnullable (bder c a)"
|
|
2031 |
shows "retrieve (bsimp a) (flex (erase (bsimp a)) id [c] (mkeps (erase (bder c (bsimp a))))) =
|
|
2032 |
retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a))))"
|
|
2033 |
using assms
|
|
2034 |
apply(simp)
|
|
2035 |
using bder_retrieve L0 bmkeps_simp bmkeps_retrieve L0 LA LB
|
|
2036 |
apply(subst bder_retrieve[symmetric])
|
|
2037 |
apply (metis L_bsimp_erase bnullable_correctness der_correctness erase_bder mkeps_nullable nullable_correctness)
|
|
2038 |
apply(simp)
|
|
2039 |
done
|
|
2040 |
|
|
2041 |
lemma L02_bders:
|
|
2042 |
assumes "bnullable (bders a s)"
|
|
2043 |
shows "retrieve (bsimp a) (flex (erase (bsimp a)) id s (mkeps (erase (bders (bsimp a) s)))) =
|
|
2044 |
retrieve (bders (bsimp a) s) (mkeps (erase (bders (bsimp a) s)))"
|
|
2045 |
using assms
|
|
2046 |
by (metis LA L_bsimp_erase bnullable_correctness ders_correctness erase_bders mkeps_nullable nullable_correctness)
|
|
2047 |
|
|
2048 |
|
|
2049 |
|
|
2050 |
|
|
2051 |
lemma L03:
|
|
2052 |
assumes "bnullable (bder c a)"
|
|
2053 |
shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
|
|
2054 |
bmkeps (bsimp (bder c (bsimp a)))"
|
|
2055 |
using assms
|
|
2056 |
by (metis L0 L_bsimp_erase bmkeps_retrieve bnullable_correctness der_correctness erase_bder nullable_correctness)
|
|
2057 |
|
|
2058 |
lemma L04:
|
|
2059 |
assumes "bnullable (bder c a)"
|
|
2060 |
shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
|
|
2061 |
retrieve (bsimp (bder c (bsimp a))) (mkeps (erase (bsimp (bder c (bsimp a)))))"
|
|
2062 |
using assms
|
|
2063 |
by (metis L0 L_bsimp_erase bnullable_correctness der_correctness erase_bder nullable_correctness)
|
|
2064 |
|
|
2065 |
lemma L05:
|
|
2066 |
assumes "bnullable (bder c a)"
|
|
2067 |
shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
|
|
2068 |
retrieve (bsimp (bder c (bsimp a))) (mkeps (erase (bsimp (bder c (bsimp a)))))"
|
|
2069 |
using assms
|
|
2070 |
using L04 by auto
|
|
2071 |
|
|
2072 |
lemma L06:
|
|
2073 |
assumes "bnullable (bder c a)"
|
|
2074 |
shows "bmkeps (bder c (bsimp a)) = bmkeps (bsimp (bder c (bsimp a)))"
|
|
2075 |
using assms
|
|
2076 |
by (metis L03 L_bsimp_erase bmkeps_retrieve bnullable_correctness der_correctness erase_bder nullable_correctness)
|
|
2077 |
|
|
2078 |
lemma L07:
|
|
2079 |
assumes "s \<in> L (erase r)"
|
|
2080 |
shows "retrieve r (flex (erase r) id s (mkeps (ders s (erase r))))
|
|
2081 |
= retrieve (bders r s) (mkeps (erase (bders r s)))"
|
|
2082 |
using assms
|
|
2083 |
using LB LC lexer_correct_Some by auto
|
|
2084 |
|
|
2085 |
lemma LXXX:
|
|
2086 |
assumes "s \<in> (erase r) \<rightarrow> v" "s \<in> (erase (bsimp r)) \<rightarrow> v'"
|
|
2087 |
shows "retrieve r v = retrieve (bsimp r) v'"
|
|
2088 |
using assms
|
|
2089 |
apply -
|
|
2090 |
thm LC
|
|
2091 |
apply(subst LC)
|
|
2092 |
apply(assumption)
|
|
2093 |
apply(subst L0[symmetric])
|
|
2094 |
using bnullable_correctness lexer_correctness(2) lexer_flex apply fastforce
|
|
2095 |
apply(subst (2) LC)
|
|
2096 |
apply(assumption)
|
|
2097 |
apply(subst (2) L0[symmetric])
|
|
2098 |
using bnullable_correctness lexer_correctness(2) lexer_flex apply fastforce
|
|
2099 |
|
|
2100 |
oops
|
|
2101 |
|
|
2102 |
|
|
2103 |
lemma L07a:
|
|
2104 |
assumes "s \<in> L (erase r)"
|
|
2105 |
shows "retrieve (bsimp r) (flex (erase (bsimp r)) id s (mkeps (ders s (erase (bsimp r)))))
|
|
2106 |
= retrieve r (flex (erase r) id s (mkeps (ders s (erase r))))"
|
|
2107 |
using assms
|
|
2108 |
apply(induct s arbitrary: r)
|
|
2109 |
apply(simp)
|
|
2110 |
using L0a apply force
|
|
2111 |
apply(drule_tac x="(bder a r)" in meta_spec)
|
|
2112 |
apply(drule meta_mp)
|
|
2113 |
apply (metis L_bsimp_erase erase_bder lexer.simps(2) lexer_correct_None option.case(1))
|
|
2114 |
apply(drule sym)
|
|
2115 |
apply(simp)
|
|
2116 |
apply(subst (asm) bder_retrieve)
|
|
2117 |
apply (metis Posix_Prf Posix_flex Posix_mkeps ders.simps(2) lexer_correct_None lexer_flex)
|
|
2118 |
apply(simp only: flex_fun_apply)
|
|
2119 |
apply(simp)
|
|
2120 |
using L0[no_vars] bder_retrieve[no_vars] LA[no_vars] LC[no_vars] L07[no_vars]
|
|
2121 |
oops
|
|
2122 |
|
|
2123 |
lemma L08:
|
|
2124 |
assumes "s \<in> L (erase r)"
|
|
2125 |
shows "retrieve (bders (bsimp r) s) (mkeps (erase (bders (bsimp r) s)))
|
|
2126 |
= retrieve (bders r s) (mkeps (erase (bders r s)))"
|
|
2127 |
using assms
|
|
2128 |
apply(induct s arbitrary: r)
|
|
2129 |
apply(simp)
|
|
2130 |
using L0 bnullable_correctness nullable_correctness apply blast
|
|
2131 |
apply(simp add: bders_append)
|
|
2132 |
apply(drule_tac x="(bder a (bsimp r))" in meta_spec)
|
|
2133 |
apply(drule meta_mp)
|
|
2134 |
apply (metis L_bsimp_erase erase_bder lexer.simps(2) lexer_correct_None option.case(1))
|
|
2135 |
apply(drule sym)
|
|
2136 |
apply(simp)
|
|
2137 |
apply(subst LA)
|
|
2138 |
apply (metis L0aa L_bsimp_erase Posix1(1) ders.simps(2) ders_correctness erase_bder erase_bders mkeps_nullable nullable_correctness)
|
|
2139 |
apply(subst LA)
|
|
2140 |
using lexer_correct_None lexer_flex mkeps_nullable apply force
|
|
2141 |
|
|
2142 |
using L0[no_vars] bder_retrieve[no_vars] LA[no_vars] LC[no_vars] L07[no_vars]
|
|
2143 |
|
|
2144 |
thm L0[no_vars] bder_retrieve[no_vars] LA[no_vars] LC[no_vars] L07[no_vars]
|
|
2145 |
oops
|
|
2146 |
|
|
2147 |
lemma test:
|
|
2148 |
assumes "s = [c]"
|
|
2149 |
shows "retrieve (bders r s) v = XXX" and "YYY = retrieve r (flex (erase r) id s v)"
|
|
2150 |
using assms
|
|
2151 |
apply(simp only: bders.simps)
|
|
2152 |
defer
|
|
2153 |
using assms
|
|
2154 |
apply(simp only: flex.simps id_simps)
|
|
2155 |
using L0[no_vars] bder_retrieve[no_vars] LA[no_vars] LC[no_vars]
|
|
2156 |
find_theorems "retrieve (bders _ _) _"
|
|
2157 |
find_theorems "retrieve _ (mkeps _)"
|
|
2158 |
oops
|
|
2159 |
|
|
2160 |
lemma L06X:
|
|
2161 |
assumes "bnullable (bder c a)"
|
|
2162 |
shows "bmkeps (bder c (bsimp a)) = bmkeps (bder c a)"
|
|
2163 |
using assms
|
|
2164 |
apply(induct a arbitrary: c)
|
|
2165 |
apply(simp)
|
|
2166 |
apply(simp)
|
|
2167 |
apply(simp)
|
|
2168 |
prefer 3
|
|
2169 |
apply(simp)
|
|
2170 |
prefer 2
|
|
2171 |
apply(simp)
|
|
2172 |
|
|
2173 |
defer
|
|
2174 |
oops
|
|
2175 |
|
|
2176 |
lemma L06_2:
|
|
2177 |
assumes "bnullable (bders a [c,d])"
|
|
2178 |
shows "bmkeps (bders (bsimp a) [c,d]) = bmkeps (bsimp (bders (bsimp a) [c,d]))"
|
|
2179 |
using assms
|
|
2180 |
apply(simp)
|
|
2181 |
by (metis L_bsimp_erase bmkeps_simp bnullable_correctness der_correctness erase_bder nullable_correctness)
|
|
2182 |
|
|
2183 |
lemma L06_bders:
|
|
2184 |
assumes "bnullable (bders a s)"
|
|
2185 |
shows "bmkeps (bders (bsimp a) s) = bmkeps (bsimp (bders (bsimp a) s))"
|
|
2186 |
using assms
|
|
2187 |
by (metis L_bsimp_erase bmkeps_simp bnullable_correctness ders_correctness erase_bders nullable_correctness)
|
|
2188 |
|
|
2189 |
lemma LLLL:
|
|
2190 |
shows "L (erase a) = L (erase (bsimp a))"
|
|
2191 |
and "L (erase a) = {flat v | v. \<Turnstile> v: (erase a)}"
|
|
2192 |
and "L (erase a) = {flat v | v. \<Turnstile> v: (erase (bsimp a))}"
|
|
2193 |
using L_bsimp_erase apply(blast)
|
|
2194 |
apply (simp add: L_flat_Prf)
|
|
2195 |
using L_bsimp_erase L_flat_Prf apply(auto)[1]
|
|
2196 |
done
|
|
2197 |
|
|
2198 |
|
|
2199 |
|
|
2200 |
lemma L07XX:
|
|
2201 |
assumes "s \<in> L (erase a)"
|
|
2202 |
shows "s \<in> erase a \<rightarrow> flex (erase a) id s (mkeps (ders s (erase a)))"
|
|
2203 |
using assms
|
|
2204 |
by (meson lexer_correct_None lexer_correctness(1) lexer_flex)
|
|
2205 |
|
|
2206 |
lemma LX0:
|
|
2207 |
assumes "s \<in> L r"
|
|
2208 |
shows "decode (bmkeps (bders (intern r) s)) r = Some(flex r id s (mkeps (ders s r)))"
|
|
2209 |
by (metis assms blexer_correctness blexer_def lexer_correct_None lexer_flex)
|
|
2210 |
|
|
2211 |
|
|
2212 |
lemma L02_bders2:
|
|
2213 |
assumes "bnullable (bders a s)" "s = [c]"
|
|
2214 |
shows "retrieve (bders (bsimp a) s) (mkeps (erase (bders (bsimp a) s))) =
|
|
2215 |
retrieve (bders a s) (mkeps (erase (bders a s)))"
|
|
2216 |
using assms
|
|
2217 |
apply(simp)
|
|
2218 |
|
|
2219 |
apply(induct s arbitrary: a)
|
|
2220 |
apply(simp)
|
|
2221 |
using L0 apply auto[1]
|
|
2222 |
oops
|
|
2223 |
|
|
2224 |
thm bmkeps_retrieve bmkeps_simp Posix_mkeps
|
|
2225 |
|
|
2226 |
lemma WQ1:
|
|
2227 |
assumes "s \<in> L (der c r)"
|
|
2228 |
shows "s \<in> der c r \<rightarrow> mkeps (ders s (der c r))"
|
|
2229 |
using assms
|
|
2230 |
oops
|
|
2231 |
|
|
2232 |
lemma L02_bsimp:
|
|
2233 |
assumes "bnullable (bders a s)"
|
|
2234 |
shows "retrieve (bsimp a) (flex (erase (bsimp a)) id s (mkeps (erase (bders (bsimp a) s)))) =
|
|
2235 |
retrieve a (flex (erase a) id s (mkeps (erase (bders a s))))"
|
|
2236 |
using assms
|
|
2237 |
apply(induct s arbitrary: a)
|
|
2238 |
apply(simp)
|
|
2239 |
apply (simp add: L0)
|
|
2240 |
apply(simp)
|
|
2241 |
apply(drule_tac x="bder a aa" in meta_spec)
|
|
2242 |
apply(simp)
|
|
2243 |
apply(subst (asm) bder_retrieve)
|
|
2244 |
using Posix_Prf Posix_flex Posix_mkeps bnullable_correctness apply fastforce
|
|
2245 |
apply(simp add: flex_fun_apply)
|
|
2246 |
apply(drule sym)
|
|
2247 |
apply(simp)
|
|
2248 |
apply(subst flex_injval)
|
|
2249 |
apply(subst bder_retrieve[symmetric])
|
|
2250 |
apply (metis L_bsimp_erase Posix_Prf Posix_flex Posix_mkeps bders.simps(2) bnullable_correctness ders.simps(2) erase_bders lexer_correct_None lexer_flex option.distinct(1))
|
|
2251 |
apply(simp only: erase_bder[symmetric] erase_bders[symmetric])
|
|
2252 |
apply(subst LB_sym[symmetric])
|
|
2253 |
apply(simp)
|
|
2254 |
oops
|
|
2255 |
|
|
2256 |
lemma L1:
|
|
2257 |
assumes "s \<in> r \<rightarrow> v"
|
|
2258 |
shows "decode (bmkeps (bders (intern r) s)) r = Some v"
|
|
2259 |
using assms
|
|
2260 |
by (metis blexer_correctness blexer_def lexer_correctness(1) option.distinct(1))
|
|
2261 |
|
|
2262 |
lemma L2:
|
|
2263 |
assumes "s \<in> (der c r) \<rightarrow> v"
|
|
2264 |
shows "decode (bmkeps (bders (intern r) (c # s))) r = Some (injval r c v)"
|
|
2265 |
using assms
|
|
2266 |
apply(subst bmkeps_retrieve)
|
|
2267 |
using Posix1(1) lexer_correct_None lexer_flex apply fastforce
|
|
2268 |
using MAIN_decode
|
|
2269 |
apply(subst MAIN_decode[symmetric])
|
|
2270 |
apply(simp)
|
|
2271 |
apply (meson Posix1(1) lexer_correct_None lexer_flex mkeps_nullable)
|
|
2272 |
apply(simp)
|
|
2273 |
apply(subgoal_tac "v = flex (der c r) id s (mkeps (ders s (der c r)))")
|
|
2274 |
prefer 2
|
|
2275 |
apply (metis Posix_determ lexer_correctness(1) lexer_flex option.distinct(1))
|
|
2276 |
apply(simp)
|
|
2277 |
apply(subgoal_tac "injval r c (flex (der c r) id s (mkeps (ders s (der c r)))) =
|
|
2278 |
(flex (der c r) ((\<lambda>v. injval r c v) o id) s (mkeps (ders s (der c r))))")
|
|
2279 |
apply(simp)
|
|
2280 |
using flex_fun_apply by blast
|
|
2281 |
|
|
2282 |
lemma L3:
|
|
2283 |
assumes "s2 \<in> (ders s1 r) \<rightarrow> v"
|
|
2284 |
shows "decode (bmkeps (bders (intern r) (s1 @ s2))) r = Some (flex r id s1 v)"
|
|
2285 |
using assms
|
|
2286 |
apply(induct s1 arbitrary: r s2 v rule: rev_induct)
|
|
2287 |
apply(simp)
|
|
2288 |
using L1 apply blast
|
|
2289 |
apply(simp add: ders_append)
|
|
2290 |
apply(drule_tac x="r" in meta_spec)
|
|
2291 |
apply(drule_tac x="x # s2" in meta_spec)
|
|
2292 |
apply(drule_tac x="injval (ders xs r) x v" in meta_spec)
|
|
2293 |
apply(drule meta_mp)
|
|
2294 |
defer
|
|
2295 |
apply(simp)
|
|
2296 |
apply(simp add: flex_append)
|
|
2297 |
by (simp add: Posix_injval)
|
|
2298 |
|
|
2299 |
|
|
2300 |
|
|
2301 |
lemma bders_snoc:
|
|
2302 |
"bder c (bders a s) = bders a (s @ [c])"
|
|
2303 |
apply(simp add: bders_append)
|
|
2304 |
done
|
|
2305 |
|
|
2306 |
|
|
2307 |
lemma QQ1:
|
|
2308 |
shows "bsimp (bders (bsimp a) []) = bders_simp (bsimp a) []"
|
|
2309 |
apply(simp)
|
|
2310 |
apply(simp add: bsimp_idem)
|
|
2311 |
done
|
|
2312 |
|
|
2313 |
lemma QQ2:
|
|
2314 |
shows "bsimp (bders (bsimp a) [c]) = bders_simp (bsimp a) [c]"
|
|
2315 |
apply(simp)
|
|
2316 |
done
|
|
2317 |
|
|
2318 |
lemma XXX2a_long:
|
|
2319 |
assumes "good a"
|
|
2320 |
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
|
|
2321 |
using assms
|
|
2322 |
apply(induct a arbitrary: c taking: asize rule: measure_induct)
|
|
2323 |
apply(case_tac x)
|
|
2324 |
apply(simp)
|
|
2325 |
apply(simp)
|
|
2326 |
apply(simp)
|
|
2327 |
prefer 3
|
|
2328 |
apply(simp)
|
|
2329 |
apply(simp)
|
|
2330 |
apply(auto)[1]
|
|
2331 |
apply(case_tac "x42 = AZERO")
|
|
2332 |
apply(simp)
|
|
2333 |
apply(case_tac "x43 = AZERO")
|
|
2334 |
apply(simp)
|
|
2335 |
using test2 apply force
|
|
2336 |
apply(case_tac "\<exists>bs. x42 = AONE bs")
|
|
2337 |
apply(clarify)
|
|
2338 |
apply(simp)
|
|
2339 |
apply(subst bsimp_ASEQ1)
|
|
2340 |
apply(simp)
|
|
2341 |
using b3 apply force
|
|
2342 |
using bsimp_ASEQ0 test2 apply force
|
|
2343 |
thm good_SEQ test2
|
|
2344 |
apply (simp add: good_SEQ test2)
|
|
2345 |
apply (simp add: good_SEQ test2)
|
|
2346 |
apply(case_tac "x42 = AZERO")
|
|
2347 |
apply(simp)
|
|
2348 |
apply(case_tac "x43 = AZERO")
|
|
2349 |
apply(simp)
|
|
2350 |
apply (simp add: bsimp_ASEQ0)
|
|
2351 |
apply(case_tac "\<exists>bs. x42 = AONE bs")
|
|
2352 |
apply(clarify)
|
|
2353 |
apply(simp)
|
|
2354 |
apply(subst bsimp_ASEQ1)
|
|
2355 |
apply(simp)
|
|
2356 |
using bsimp_ASEQ0 test2 apply force
|
|
2357 |
apply (simp add: good_SEQ test2)
|
|
2358 |
apply (simp add: good_SEQ test2)
|
|
2359 |
apply (simp add: good_SEQ test2)
|
|
2360 |
(* AALTs case *)
|
|
2361 |
apply(simp)
|
|
2362 |
using test2 by fastforce
|
|
2363 |
|
|
2364 |
lemma XXX2a_long_without_good:
|
|
2365 |
assumes "a = AALTs bs0 [AALTs bs1 [AALTs bs2 [ASTAR [] (AONE bs7), AONE bs6, ASEQ bs3 (ACHAR bs4 d) (AONE bs5)]]]"
|
|
2366 |
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
|
|
2367 |
"bsimp (bder c (bsimp a)) = XXX"
|
|
2368 |
"bsimp (bder c a) = YYY"
|
|
2369 |
using assms
|
|
2370 |
apply(simp)
|
|
2371 |
using assms
|
|
2372 |
apply(simp)
|
|
2373 |
prefer 2
|
|
2374 |
using assms
|
|
2375 |
apply(simp)
|
|
2376 |
oops
|
|
2377 |
|
|
2378 |
lemma bder_bsimp_AALTs:
|
|
2379 |
shows "bder c (bsimp_AALTs bs rs) = bsimp_AALTs bs (map (bder c) rs)"
|
|
2380 |
apply(induct bs rs rule: bsimp_AALTs.induct)
|
|
2381 |
apply(simp)
|
|
2382 |
apply(simp)
|
|
2383 |
apply (simp add: bder_fuse)
|
|
2384 |
apply(simp)
|
|
2385 |
done
|
|
2386 |
|
|
2387 |
lemma flts_nothing:
|
|
2388 |
assumes "\<forall>r \<in> set rs. r \<noteq> AZERO" "\<forall>r \<in> set rs. nonalt r"
|
|
2389 |
shows "flts rs = rs"
|
|
2390 |
using assms
|
|
2391 |
apply(induct rs rule: flts.induct)
|
|
2392 |
apply(auto)
|
|
2393 |
done
|
|
2394 |
|
|
2395 |
lemma flts_flts:
|
|
2396 |
assumes "\<forall>r \<in> set rs. good r"
|
|
2397 |
shows "flts (flts rs) = flts rs"
|
|
2398 |
using assms
|
|
2399 |
apply(induct rs taking: "\<lambda>rs. sum_list (map asize rs)" rule: measure_induct)
|
|
2400 |
apply(case_tac x)
|
|
2401 |
apply(simp)
|
|
2402 |
apply(simp)
|
|
2403 |
apply(case_tac a)
|
|
2404 |
apply(simp_all add: bder_fuse flts_append)
|
|
2405 |
apply(subgoal_tac "\<forall>r \<in> set x52. r \<noteq> AZERO")
|
|
2406 |
prefer 2
|
|
2407 |
apply (metis Nil_is_append_conv bsimp_AALTs.elims good.simps(1) good.simps(5) good0 list.distinct(1) n0 nn1b split_list_last test2)
|
|
2408 |
apply(subgoal_tac "\<forall>r \<in> set x52. nonalt r")
|
|
2409 |
prefer 2
|
|
2410 |
apply (metis n0 nn1b test2)
|
|
2411 |
by (metis flts_fuse flts_nothing)
|
|
2412 |
|
|
2413 |
|
|
2414 |
lemma PP:
|
|
2415 |
assumes "bnullable (bders r s)"
|
|
2416 |
shows "bmkeps (bders (bsimp r) s) = bmkeps (bders r s)"
|
|
2417 |
using assms
|
|
2418 |
apply(induct s arbitrary: r)
|
|
2419 |
apply(simp)
|
|
2420 |
using bmkeps_simp apply auto[1]
|
|
2421 |
apply(simp add: bders_append bders_simp_append)
|
|
2422 |
oops
|
|
2423 |
|
|
2424 |
lemma PP:
|
|
2425 |
assumes "bnullable (bders r s)"
|
|
2426 |
shows "bmkeps (bders_simp (bsimp r) s) = bmkeps (bders r s)"
|
|
2427 |
using assms
|
|
2428 |
apply(induct s arbitrary: r rule: rev_induct)
|
|
2429 |
apply(simp)
|
|
2430 |
using bmkeps_simp apply auto[1]
|
|
2431 |
apply(simp add: bders_append bders_simp_append)
|
|
2432 |
apply(drule_tac x="bder a (bsimp r)" in meta_spec)
|
|
2433 |
apply(drule_tac meta_mp)
|
|
2434 |
defer
|
|
2435 |
oops
|
|
2436 |
|
|
2437 |
|
|
2438 |
lemma
|
|
2439 |
assumes "asize (bsimp a) = asize a" "a = AALTs bs [AALTs bs2 [], AZERO, AONE bs3]"
|
|
2440 |
shows "bsimp a = a"
|
|
2441 |
using assms
|
|
2442 |
apply(simp)
|
|
2443 |
oops
|
|
2444 |
|
|
2445 |
|
|
2446 |
lemma iii:
|
|
2447 |
assumes "bsimp_AALTs bs rs \<noteq> AZERO"
|
|
2448 |
shows "rs \<noteq> []"
|
|
2449 |
using assms
|
|
2450 |
apply(induct bs rs rule: bsimp_AALTs.induct)
|
|
2451 |
apply(auto)
|
|
2452 |
done
|
|
2453 |
|
|
2454 |
lemma CT1_SEQ:
|
|
2455 |
shows "bsimp (ASEQ bs a1 a2) = bsimp (ASEQ bs (bsimp a1) (bsimp a2))"
|
|
2456 |
apply(simp add: bsimp_idem)
|
|
2457 |
done
|
|
2458 |
|
|
2459 |
lemma CT1:
|
|
2460 |
shows "bsimp (AALTs bs as) = bsimp (AALTs bs (map bsimp as))"
|
|
2461 |
apply(induct as arbitrary: bs)
|
|
2462 |
apply(simp)
|
|
2463 |
apply(simp)
|
|
2464 |
by (simp add: bsimp_idem comp_def)
|
|
2465 |
|
|
2466 |
lemma CT1a:
|
|
2467 |
shows "bsimp (AALT bs a1 a2) = bsimp(AALT bs (bsimp a1) (bsimp a2))"
|
|
2468 |
by (metis CT1 list.simps(8) list.simps(9))
|
|
2469 |
|
|
2470 |
lemma WWW2:
|
|
2471 |
shows "bsimp (bsimp_AALTs bs1 (flts (map bsimp as1))) =
|
|
2472 |
bsimp_AALTs bs1 (flts (map bsimp as1))"
|
|
2473 |
by (metis bsimp.simps(2) bsimp_idem)
|
|
2474 |
|
|
2475 |
lemma CT1b:
|
|
2476 |
shows "bsimp (bsimp_AALTs bs as) = bsimp (bsimp_AALTs bs (map bsimp as))"
|
|
2477 |
apply(induct bs as rule: bsimp_AALTs.induct)
|
|
2478 |
apply(auto simp add: bsimp_idem)
|
|
2479 |
apply (simp add: bsimp_fuse bsimp_idem)
|
|
2480 |
by (metis bsimp_idem comp_apply)
|
|
2481 |
|
|
2482 |
|
|
2483 |
|
|
2484 |
|
|
2485 |
(* CT *)
|
|
2486 |
|
|
2487 |
lemma CTU:
|
|
2488 |
shows "bsimp_AALTs bs as = li bs as"
|
|
2489 |
apply(induct bs as rule: li.induct)
|
|
2490 |
apply(auto)
|
|
2491 |
done
|
|
2492 |
|
|
2493 |
find_theorems "bder _ (bsimp_AALTs _ _)"
|
|
2494 |
|
|
2495 |
lemma CTa:
|
|
2496 |
assumes "\<forall>r \<in> set as. nonalt r \<and> r \<noteq> AZERO"
|
|
2497 |
shows "flts as = as"
|
|
2498 |
using assms
|
|
2499 |
apply(induct as)
|
|
2500 |
apply(simp)
|
|
2501 |
apply(case_tac as)
|
|
2502 |
apply(simp)
|
|
2503 |
apply (simp add: k0b)
|
|
2504 |
using flts_nothing by auto
|
|
2505 |
|
|
2506 |
lemma CT0:
|
|
2507 |
assumes "\<forall>r \<in> set as1. nonalt r \<and> r \<noteq> AZERO"
|
|
2508 |
shows "flts [bsimp_AALTs bs1 as1] = flts (map (fuse bs1) as1)"
|
|
2509 |
using assms CTa
|
|
2510 |
apply(induct as1 arbitrary: bs1)
|
|
2511 |
apply(simp)
|
|
2512 |
apply(simp)
|
|
2513 |
apply(case_tac as1)
|
|
2514 |
apply(simp)
|
|
2515 |
apply(simp)
|
|
2516 |
proof -
|
|
2517 |
fix a :: arexp and as1a :: "arexp list" and bs1a :: "bit list" and aa :: arexp and list :: "arexp list"
|
|
2518 |
assume a1: "nonalt a \<and> a \<noteq> AZERO \<and> nonalt aa \<and> aa \<noteq> AZERO \<and> (\<forall>r\<in>set list. nonalt r \<and> r \<noteq> AZERO)"
|
|
2519 |
assume a2: "\<And>as. \<forall>r\<in>set as. nonalt r \<and> r \<noteq> AZERO \<Longrightarrow> flts as = as"
|
|
2520 |
assume a3: "as1a = aa # list"
|
|
2521 |
have "flts [a] = [a]"
|
|
2522 |
using a1 k0b by blast
|
|
2523 |
then show "fuse bs1a a # fuse bs1a aa # map (fuse bs1a) list = flts (fuse bs1a a # fuse bs1a aa # map (fuse bs1a) list)"
|
|
2524 |
using a3 a2 a1 by (metis (no_types) append.left_neutral append_Cons flts_fuse k00 k0b list.simps(9))
|
|
2525 |
qed
|
|
2526 |
|
|
2527 |
|
|
2528 |
lemma CT01:
|
|
2529 |
assumes "\<forall>r \<in> set as1. nonalt r \<and> r \<noteq> AZERO" "\<forall>r \<in> set as2. nonalt r \<and> r \<noteq> AZERO"
|
|
2530 |
shows "flts [bsimp_AALTs bs1 as1, bsimp_AALTs bs2 as2] = flts ((map (fuse bs1) as1) @ (map (fuse bs2) as2))"
|
|
2531 |
using assms CT0
|
|
2532 |
by (metis k0 k00)
|
|
2533 |
|
|
2534 |
|
|
2535 |
|
|
2536 |
lemma CT_exp:
|
|
2537 |
assumes "\<forall>a \<in> set as. bsimp (bder c (bsimp a)) = bsimp (bder c a)"
|
|
2538 |
shows "map bsimp (map (bder c) as) = map bsimp (map (bder c) (map bsimp as))"
|
|
2539 |
using assms
|
|
2540 |
apply(induct as)
|
|
2541 |
apply(auto)
|
|
2542 |
done
|
|
2543 |
|
|
2544 |
lemma asize_set:
|
|
2545 |
assumes "a \<in> set as"
|
|
2546 |
shows "asize a < Suc (sum_list (map asize as))"
|
|
2547 |
using assms
|
|
2548 |
apply(induct as arbitrary: a)
|
|
2549 |
apply(auto)
|
|
2550 |
using le_add2 le_less_trans not_less_eq by blast
|
|
2551 |
|
|
2552 |
|
|
2553 |
lemma XXX2a_long_without_good:
|
|
2554 |
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
|
|
2555 |
apply(induct a arbitrary: c taking: "\<lambda>a. asize a" rule: measure_induct)
|
|
2556 |
apply(case_tac x)
|
|
2557 |
apply(simp)
|
|
2558 |
apply(simp)
|
|
2559 |
apply(simp)
|
|
2560 |
prefer 3
|
|
2561 |
apply(simp)
|
|
2562 |
(* AALT case *)
|
|
2563 |
prefer 2
|
|
2564 |
apply(simp del: bsimp.simps)
|
|
2565 |
apply(subst (2) CT1)
|
|
2566 |
apply(subst CT_exp)
|
|
2567 |
apply(auto)[1]
|
|
2568 |
using asize_set apply blast
|
|
2569 |
apply(subst CT1[symmetric])
|
|
2570 |
apply(simp)
|
|
2571 |
oops
|
|
2572 |
|
|
2573 |
lemma YY:
|
|
2574 |
assumes "flts (map bsimp as1) = xs"
|
|
2575 |
shows "flts (map bsimp (map (fuse bs1) as1)) = map (fuse bs1) xs"
|
|
2576 |
using assms
|
|
2577 |
apply(induct as1 arbitrary: bs1 xs)
|
|
2578 |
apply(simp)
|
|
2579 |
apply(auto)
|
|
2580 |
by (metis bsimp_fuse flts_fuse k0 list.simps(9))
|
|
2581 |
|
|
2582 |
|
|
2583 |
lemma flts_nonalt:
|
|
2584 |
assumes "flts (map bsimp xs) = ys"
|
|
2585 |
shows "\<forall>y \<in> set ys. nonalt y"
|
|
2586 |
using assms
|
|
2587 |
apply(induct xs arbitrary: ys)
|
|
2588 |
apply(auto)
|
|
2589 |
apply(case_tac xs)
|
|
2590 |
apply(auto)
|
|
2591 |
using flts2 good1 apply fastforce
|
|
2592 |
by (smt ex_map_conv list.simps(9) nn1b nn1c)
|
|
2593 |
|
|
2594 |
|
|
2595 |
lemma WWW3:
|
|
2596 |
shows "flts [bsimp_AALTs bs1 (flts (map bsimp as1))] =
|
|
2597 |
flts (map bsimp (map (fuse bs1) as1))"
|
|
2598 |
by (metis CT0 YY flts_nonalt flts_nothing qqq1)
|
|
2599 |
|
|
2600 |
lemma WWW4:
|
|
2601 |
shows "map (bder c \<circ> fuse bs1) as1 = map (fuse bs1) (map (bder c) as1)"
|
|
2602 |
apply(induct as1)
|
|
2603 |
apply(auto)
|
|
2604 |
using bder_fuse by blast
|
|
2605 |
|
|
2606 |
lemma WWW5:
|
|
2607 |
shows "map (bsimp \<circ> bder c) as1 = map bsimp (map (bder c) as1)"
|
|
2608 |
apply(induct as1)
|
|
2609 |
apply(auto)
|
|
2610 |
done
|
|
2611 |
|
|
2612 |
lemma WWW6:
|
|
2613 |
shows "bsimp (bder c (bsimp_AALTs x51 (flts [bsimp a1, bsimp a2]) ) ) =
|
|
2614 |
bsimp(bsimp_AALTs x51 (map (bder c) (flts [bsimp a1, bsimp a2]))) "
|
|
2615 |
using bder_bsimp_AALTs by auto
|
|
2616 |
|
|
2617 |
lemma WWW7:
|
|
2618 |
shows "bsimp (bsimp_AALTs x51 (map (bder c) (flts [bsimp a1, bsimp a2]))) =
|
|
2619 |
bsimp(bsimp_AALTs x51 (flts (map (bder c) [bsimp a1, bsimp a2])))"
|
|
2620 |
sorry
|
|
2621 |
|
|
2622 |
|
|
2623 |
lemma stupid:
|
|
2624 |
assumes "a = b"
|
|
2625 |
shows "bsimp(a) = bsimp(b)"
|
|
2626 |
using assms
|
|
2627 |
apply(auto)
|
|
2628 |
done
|
|
2629 |
(*
|
|
2630 |
proving idea:
|
|
2631 |
bsimp_AALTs x51 (map (bder c) (flts [a1, a2])) = bsimp_AALTs x51 (map (bder c) (flts [a1]++[a2]))
|
|
2632 |
= bsimp_AALTs x51 (map (bder c) ((flts [a1])++(flts [a2]))) =
|
|
2633 |
bsimp_AALTs x51 (map (bder c) (flts [a1]))++(map (bder c) (flts [a2])) = A
|
|
2634 |
and then want to prove that
|
|
2635 |
map (bder c) (flts [a]) = flts [bder c a] under the condition
|
|
2636 |
that a is either a seq with the first elem being not nullable, or a character equal to c,
|
|
2637 |
or an AALTs, or a star
|
|
2638 |
Then, A = bsimp_AALTs x51 (flts [bder c a]) ++ (map (bder c) (flts [a2])) = A1
|
|
2639 |
Using the same condition for a2, we get
|
|
2640 |
A1 = bsimp_AALTs x51 (flts [bder c a1]) ++ (flts [bder c a2])
|
|
2641 |
=bsimp_AALTs x51 flts ([bder c a1] ++ [bder c a2])
|
|
2642 |
=bsimp_AALTs x51 flts ([bder c a1, bder c a2])
|
|
2643 |
*)
|
|
2644 |
lemma manipulate_flts:
|
|
2645 |
shows "bsimp_AALTs x51 (map (bder c) (flts [a1, a2])) =
|
|
2646 |
bsimp_AALTs x51 ((map (bder c) (flts [a1])) @ (map (bder c) (flts [a2])))"
|
|
2647 |
by (metis k0 map_append)
|
|
2648 |
|
|
2649 |
lemma go_inside_flts:
|
|
2650 |
assumes " (bder c a1 \<noteq> AZERO) "
|
|
2651 |
"\<not>(\<exists> a01 a02 x02. ( (a1 = ASEQ x02 a01 a02) \<and> bnullable(a01) ) )"
|
|
2652 |
shows "map (bder c) (flts [a1]) = flts [bder c a1]"
|
|
2653 |
using assms
|
|
2654 |
apply -
|
|
2655 |
apply(case_tac a1)
|
|
2656 |
apply(simp)
|
|
2657 |
apply(simp)
|
|
2658 |
apply(case_tac "x32 = c")
|
|
2659 |
prefer 2
|
|
2660 |
apply(simp)
|
|
2661 |
apply(simp)
|
|
2662 |
apply(simp)
|
|
2663 |
apply (simp add: WWW4)
|
|
2664 |
apply(simp add: bder_fuse)
|
|
2665 |
done
|
|
2666 |
|
|
2667 |
lemma medium010:
|
|
2668 |
assumes " (bder c a1 = AZERO) "
|
|
2669 |
shows "map (bder c) (flts [a1]) = [AZERO] \<or> map (bder c) (flts [a1]) = []"
|
|
2670 |
using assms
|
|
2671 |
apply -
|
|
2672 |
apply(case_tac a1)
|
|
2673 |
apply(simp)
|
|
2674 |
apply(simp)
|
|
2675 |
apply(simp)
|
|
2676 |
apply(simp)
|
|
2677 |
apply(simp)
|
|
2678 |
apply(simp)
|
|
2679 |
done
|
|
2680 |
|
|
2681 |
lemma medium011:
|
|
2682 |
assumes " (bder c a1 = AZERO) "
|
|
2683 |
shows "flts (map (bder c) [a1, a2]) = flts [bder c a2]"
|
|
2684 |
using assms
|
|
2685 |
apply -
|
|
2686 |
apply(simp)
|
|
2687 |
done
|
|
2688 |
|
|
2689 |
lemma medium01central:
|
|
2690 |
shows "bsimp(bsimp_AALTs x51 (map (bder c) (flts [a2])) ) = bsimp(bsimp_AALTs x51 (flts [bder c a2]))"
|
|
2691 |
sorry
|
|
2692 |
|
|
2693 |
|
|
2694 |
lemma plus_bsimp:
|
|
2695 |
assumes "bsimp( bsimp a) = bsimp (bsimp b)"
|
|
2696 |
shows "bsimp a = bsimp b"
|
|
2697 |
using assms
|
|
2698 |
apply -
|
|
2699 |
by (simp add: bsimp_idem)
|
|
2700 |
lemma patience_good5:
|
|
2701 |
assumes "bsimp r = AALTs x y"
|
|
2702 |
shows " \<exists> a aa list. y = a#aa#list"
|
|
2703 |
by (metis Nil_is_map_conv arexp.simps(13) assms bsimp_AALTs.elims flts1 good.simps(5) good1 k0a)
|
|
2704 |
|
|
2705 |
(*SAD*)
|
|
2706 |
(*this does not hold actually
|
|
2707 |
lemma bsimp_equiv0:
|
|
2708 |
shows "bsimp(bsimp r) = bsimp(bsimp (AALTs [] [r]))"
|
|
2709 |
apply(simp)
|
|
2710 |
apply(case_tac "bsimp r")
|
|
2711 |
apply(simp)
|
|
2712 |
apply(simp)
|
|
2713 |
apply(simp)
|
|
2714 |
apply(simp)
|
|
2715 |
thm good1
|
|
2716 |
using good1
|
|
2717 |
apply -
|
|
2718 |
apply(drule_tac x="r" in meta_spec)
|
|
2719 |
apply(erule disjE)
|
|
2720 |
|
|
2721 |
apply(simp only: bsimp_AALTs.simps)
|
|
2722 |
apply(simp only:flts.simps)
|
|
2723 |
apply(drule patience_good5)
|
|
2724 |
apply(clarify)
|
|
2725 |
apply(subst bsimp_AALTs_qq)
|
|
2726 |
apply simp
|
|
2727 |
prefer 2
|
|
2728 |
sorry*)
|
|
2729 |
|
|
2730 |
(*exercise: try multiple ways of proving this*)
|
|
2731 |
(*this lemma does not hold.........
|
|
2732 |
lemma bsimp_equiv1:
|
|
2733 |
shows "bsimp r = bsimp (AALTs [] [r])"
|
|
2734 |
using plus_bsimp
|
|
2735 |
apply -
|
|
2736 |
using bsimp_equiv0 by blast
|
|
2737 |
(*apply(simp)
|
|
2738 |
apply(case_tac "bsimp r")
|
|
2739 |
apply(simp)
|
|
2740 |
apply(simp)
|
|
2741 |
apply(simp)
|
|
2742 |
apply(simp)
|
|
2743 |
(*use lemma good1*)
|
|
2744 |
thm good1
|
|
2745 |
using good1
|
|
2746 |
apply -
|
|
2747 |
apply(drule_tac x="r" in meta_spec)
|
|
2748 |
apply(erule disjE)
|
|
2749 |
|
|
2750 |
apply(subst flts_single1)
|
|
2751 |
apply(simp only: bsimp_AALTs.simps)
|
|
2752 |
prefer 2
|
|
2753 |
|
|
2754 |
thm flts_single1
|
|
2755 |
|
|
2756 |
find_theorems "flts _ = _"*)
|
|
2757 |
*)
|
|
2758 |
lemma bsimp_equiv2:
|
|
2759 |
shows "bsimp (AALTs x51 [r]) = bsimp (AALT x51 AZERO r)"
|
|
2760 |
sorry
|
|
2761 |
|
|
2762 |
lemma medium_stupid_isabelle:
|
|
2763 |
assumes "rs = a # list"
|
|
2764 |
shows "bsimp_AALTs x51 (AZERO # rs) = AALTs x51 (AZERO#rs)"
|
|
2765 |
using assms
|
|
2766 |
apply -
|
|
2767 |
apply(simp)
|
|
2768 |
done
|
|
2769 |
(*
|
|
2770 |
lemma mediumlittle:
|
|
2771 |
shows "bsimp(bsimp_AALTs x51 rs) = bsimp(bsimp_AALTs x51 (AZERO # rs))"
|
|
2772 |
apply(case_tac rs)
|
|
2773 |
apply(simp)
|
|
2774 |
apply(case_tac list)
|
|
2775 |
apply(subst medium_stupid_isabelle)
|
|
2776 |
apply(simp)
|
|
2777 |
prefer 2
|
|
2778 |
apply simp
|
|
2779 |
apply(rule_tac s="a#list" and t="rs" in subst)
|
|
2780 |
apply(simp)
|
|
2781 |
apply(rule_tac t="list" and s= "[]" in subst)
|
|
2782 |
apply(simp)
|
|
2783 |
(*dunno what is the rule for x#nil = x*)
|
|
2784 |
apply(case_tac a)
|
|
2785 |
apply(simp)
|
|
2786 |
apply(simp)
|
|
2787 |
apply(simp)
|
|
2788 |
prefer 3
|
|
2789 |
apply simp
|
|
2790 |
apply(simp only:bsimp_AALTs.simps)
|
|
2791 |
|
|
2792 |
apply simp
|
|
2793 |
apply(case_tac "bsimp x42")
|
|
2794 |
apply(simp)
|
|
2795 |
apply simp
|
|
2796 |
apply(case_tac "bsimp x43")
|
|
2797 |
apply simp
|
|
2798 |
apply simp
|
|
2799 |
apply simp
|
|
2800 |
apply simp
|
|
2801 |
apply(simp only:bsimp_ASEQ.simps)
|
|
2802 |
using good1
|
|
2803 |
apply -
|
|
2804 |
apply(drule_tac x="x43" in meta_spec)
|
|
2805 |
apply(erule disjE)
|
|
2806 |
apply(subst bsimp_AALTs_qq)
|
|
2807 |
using patience_good5 apply force
|
|
2808 |
apply(simp only:bsimp_AALTs.simps)
|
|
2809 |
apply(simp only:fuse.simps)
|
|
2810 |
apply(simp only:flts.simps)
|
|
2811 |
(*OK from here you actually realize this lemma doesnt hold*)
|
|
2812 |
apply(simp)
|
|
2813 |
apply(simp)
|
|
2814 |
apply(rule_tac t="rs" and s="a#list" in subst)
|
|
2815 |
apply(simp)
|
|
2816 |
apply(rule_tac t="list" and s="[]" in subst)
|
|
2817 |
apply(simp)
|
|
2818 |
(*apply(simp only:bsimp_AALTs.simps)*)
|
|
2819 |
(*apply(simp only:fuse.simps)*)
|
|
2820 |
sorry
|
|
2821 |
*)
|
|
2822 |
lemma singleton_list_map:
|
|
2823 |
shows"map f [a] = [f a]"
|
|
2824 |
apply simp
|
|
2825 |
done
|
|
2826 |
lemma map_application2:
|
|
2827 |
shows"map f [a,b] = [f a, f b]"
|
|
2828 |
apply simp
|
|
2829 |
done
|
|
2830 |
(*SAD*)
|
|
2831 |
(* bsimp (bder c (bsimp_AALTs x51 (flts [bsimp a1, bsimp a2]))) =
|
|
2832 |
bsimp (AALT x51 (bder c (bsimp a1)) (bder c (bsimp a2)))*)
|
|
2833 |
(*This equality does not hold*)
|
|
2834 |
lemma medium01:
|
|
2835 |
assumes " (bder c a1 = AZERO) "
|
|
2836 |
shows "bsimp(bsimp_AALTs x51 (map (bder c) (flts [ a1, a2]))) =
|
|
2837 |
bsimp(bsimp_AALTs x51 (flts (map (bder c) [ a1, a2])))"
|
|
2838 |
apply(subst manipulate_flts)
|
|
2839 |
using assms
|
|
2840 |
apply -
|
|
2841 |
apply(subst medium011)
|
|
2842 |
apply(simp)
|
|
2843 |
apply(case_tac "map (bder c) (flts [a1]) = []")
|
|
2844 |
apply(simp)
|
|
2845 |
using medium01central apply blast
|
|
2846 |
apply(frule medium010)
|
|
2847 |
apply(erule disjE)
|
|
2848 |
prefer 2
|
|
2849 |
apply(simp)
|
|
2850 |
apply(simp)
|
|
2851 |
apply(case_tac a2)
|
|
2852 |
apply simp
|
|
2853 |
apply simp
|
|
2854 |
apply simp
|
|
2855 |
apply(simp only:flts.simps)
|
|
2856 |
(*HOW do i say here to replace ASEQ ..... back into a2*)
|
|
2857 |
(*how do i say here to use the definition of map function
|
|
2858 |
without lemma, of course*)
|
|
2859 |
(*how do i say here that AZERO#map (bder c) [ASEQ x41 x42 x43]'s list.len >1
|
|
2860 |
without a lemma, of course*)
|
|
2861 |
apply(subst singleton_list_map)
|
|
2862 |
apply(simp only: bsimp_AALTs.simps)
|
|
2863 |
apply(case_tac "bder c (ASEQ x41 x42 x43)")
|
|
2864 |
apply simp
|
|
2865 |
apply simp
|
|
2866 |
apply simp
|
|
2867 |
prefer 3
|
|
2868 |
apply simp
|
|
2869 |
apply(rule_tac t="bder c (ASEQ x41 x42 x43)"
|
|
2870 |
and s="ASEQ x41a x42a x43a" in subst)
|
|
2871 |
apply simp
|
|
2872 |
apply(simp only: flts.simps)
|
|
2873 |
apply(simp only: bsimp_AALTs.simps)
|
|
2874 |
apply(simp only: fuse.simps)
|
|
2875 |
apply(subst (2) bsimp_idem[symmetric])
|
|
2876 |
apply(subst (1) bsimp_idem[symmetric])
|
|
2877 |
apply(simp only:bsimp.simps)
|
|
2878 |
apply(subst map_application2)
|
|
2879 |
apply(simp only: bsimp.simps)
|
|
2880 |
apply(simp only:flts.simps)
|
|
2881 |
(*want to happily change between a2 and ASEQ x41 42 43, and eliminate now
|
|
2882 |
redundant conditions such as map (bder c) (flts [a1]) = [AZERO] *)
|
|
2883 |
apply(case_tac "bsimp x42a")
|
|
2884 |
apply(simp)
|
|
2885 |
apply(case_tac "bsimp x43a")
|
|
2886 |
apply(simp)
|
|
2887 |
apply(simp)
|
|
2888 |
apply(simp)
|
|
2889 |
apply(simp)
|
|
2890 |
prefer 2
|
|
2891 |
apply(simp)
|
|
2892 |
apply(rule_tac t="bsimp x43a"
|
|
2893 |
and s="AALTs x51a x52" in subst)
|
|
2894 |
apply simp
|
|
2895 |
apply(simp only:bsimp_ASEQ.simps)
|
|
2896 |
apply(simp only:fuse.simps)
|
|
2897 |
apply(simp only:flts.simps)
|
|
2898 |
|
|
2899 |
using medium01central mediumlittle by auto
|
|
2900 |
|
|
2901 |
|
|
2902 |
|
|
2903 |
lemma medium1:
|
|
2904 |
assumes " (bder c a1 \<noteq> AZERO) "
|
|
2905 |
"\<not>(\<exists> a01 a02 x02. ( (a1 = ASEQ x02 a01 a02) \<and> bnullable(a01) ) )"
|
|
2906 |
" (bder c a2 \<noteq> AZERO)"
|
|
2907 |
"\<not>(\<exists> a11 a12 x12. ( (a2 = ASEQ x12 a11 a12) \<and> bnullable(a11) ) )"
|
|
2908 |
shows "bsimp_AALTs x51 (map (bder c) (flts [ a1, a2])) =
|
|
2909 |
bsimp_AALTs x51 (flts (map (bder c) [ a1, a2]))"
|
|
2910 |
using assms
|
|
2911 |
apply -
|
|
2912 |
apply(subst manipulate_flts)
|
|
2913 |
apply(case_tac "a1")
|
|
2914 |
apply(simp)
|
|
2915 |
apply(simp)
|
|
2916 |
apply(case_tac "x32 = c")
|
|
2917 |
prefer 2
|
|
2918 |
apply(simp)
|
|
2919 |
prefer 2
|
|
2920 |
apply(case_tac "bnullable x42")
|
|
2921 |
apply(simp)
|
|
2922 |
apply(simp)
|
|
2923 |
|
|
2924 |
apply(case_tac "a2")
|
|
2925 |
apply(simp)
|
|
2926 |
apply(simp)
|
|
2927 |
apply(case_tac "x32 = c")
|
|
2928 |
prefer 2
|
|
2929 |
apply(simp)
|
|
2930 |
apply(simp)
|
|
2931 |
apply(case_tac "bnullable x42a")
|
|
2932 |
apply(simp)
|
|
2933 |
apply(subst go_inside_flts)
|
|
2934 |
apply(simp)
|
|
2935 |
apply(simp)
|
|
2936 |
apply(simp)
|
|
2937 |
apply(simp)
|
|
2938 |
apply (simp add: WWW4)
|
|
2939 |
apply(simp)
|
|
2940 |
apply (simp add: WWW4)
|
|
2941 |
apply (simp add: go_inside_flts)
|
|
2942 |
apply (metis (no_types, lifting) go_inside_flts k0 list.simps(8) list.simps(9))
|
|
2943 |
by (smt bder.simps(6) flts.simps(1) flts.simps(6) flts.simps(7) go_inside_flts k0 list.inject list.simps(9))
|
|
2944 |
|
|
2945 |
lemma big0:
|
|
2946 |
shows "bsimp (AALT x51 (AALTs bs1 as1) (AALTs bs2 as2)) =
|
|
2947 |
bsimp (AALTs x51 ((map (fuse bs1) as1) @ (map (fuse bs2) as2)))"
|
|
2948 |
by (smt WWW3 bsimp.simps(2) k0 k00 list.simps(8) list.simps(9) map_append)
|
|
2949 |
|
|
2950 |
lemma bignA:
|
|
2951 |
shows "bsimp (AALTs x51 (AALTs bs1 as1 # as2)) =
|
|
2952 |
bsimp (AALTs x51 ((map (fuse bs1) as1) @ as2))"
|
|
2953 |
apply(simp)
|
|
2954 |
apply(subst k0)
|
|
2955 |
apply(subst WWW3)
|
|
2956 |
apply(simp add: flts_append)
|
|
2957 |
done
|
|
2958 |
|
|
2959 |
lemma XXX2a_long_without_good:
|
|
2960 |
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
|
|
2961 |
apply(induct a arbitrary: c taking: "\<lambda>a. asize a" rule: measure_induct)
|
|
2962 |
apply(case_tac x)
|
|
2963 |
apply(simp)
|
|
2964 |
apply(simp)
|
|
2965 |
apply(simp)
|
|
2966 |
prefer 3
|
|
2967 |
apply(simp)
|
|
2968 |
(* SEQ case *)
|
|
2969 |
apply(simp only:)
|
|
2970 |
apply(subst CT1_SEQ)
|
|
2971 |
apply(simp only: bsimp.simps)
|
|
2972 |
|
|
2973 |
(* AALT case *)
|
|
2974 |
prefer 2
|
|
2975 |
apply(simp only:)
|
|
2976 |
apply(case_tac "\<exists>a1 a2. x52 = [a1, a2]")
|
|
2977 |
apply(clarify)
|
|
2978 |
apply(simp del: bsimp.simps)
|
|
2979 |
apply(subst (2) CT1)
|
|
2980 |
apply(simp del: bsimp.simps)
|
|
2981 |
apply(rule_tac t="bsimp (bder c a1)" and s="bsimp (bder c (bsimp a1))" in subst)
|
|
2982 |
apply(simp del: bsimp.simps)
|
|
2983 |
apply(rule_tac t="bsimp (bder c a2)" and s="bsimp (bder c (bsimp a2))" in subst)
|
|
2984 |
apply(simp del: bsimp.simps)
|
|
2985 |
apply(subst CT1a[symmetric])
|
|
2986 |
(* \<rightarrow> *)
|
|
2987 |
apply(rule_tac t="AALT x51 (bder c (bsimp a1)) (bder c (bsimp a2))"
|
|
2988 |
and s="bder c (AALT x51 (bsimp a1) (bsimp a2))" in subst)
|
|
2989 |
apply(simp)
|
|
2990 |
apply(subst bsimp.simps)
|
|
2991 |
apply(simp del: bsimp.simps bder.simps)
|
|
2992 |
|
|
2993 |
apply(subst bder_bsimp_AALTs)
|
|
2994 |
apply(subst bsimp.simps)
|
|
2995 |
apply(subst WWW2[symmetric])
|
|
2996 |
apply(subst bsimp_AALTs_qq)
|
|
2997 |
defer
|
|
2998 |
apply(subst bsimp.simps)
|
|
2999 |
|
|
3000 |
(* <- *)
|
|
3001 |
apply(subst bsimp.simps)
|
|
3002 |
apply(simp del: bsimp.simps)
|
|
3003 |
(*bsimp_AALTs x51 (map (bder c) (flts [a1, a2])) =
|
|
3004 |
bsimp_AALTs x51 (flts (map (bder c) [a1, a2]))*)
|
|
3005 |
apply(case_tac "\<exists>bs1 as1. bsimp a1 = AALTs bs1 as1")
|
|
3006 |
apply(case_tac "\<exists>bs2 as2. bsimp a2 = AALTs bs2 as2")
|
|
3007 |
apply(clarify)
|
|
3008 |
apply(simp only:)
|
|
3009 |
apply(simp del: bsimp.simps bder.simps)
|
|
3010 |
apply(subst bsimp_AALTs_qq)
|
|
3011 |
prefer 2
|
|
3012 |
apply(simp del: bsimp.simps)
|
|
3013 |
apply(subst big0)
|
|
3014 |
apply(simp add: WWW4)
|
|
3015 |
apply (m etis One_nat_def Suc_eq_plus1 Suc_lessI arexp.distinct(7) bsimp.simps(2) bsimp_AALTs.simps(1) bsimp_idem flts.simps(1) length_append length_greater_0_conv length_map not_add_less2 not_less_eq)
|
|
3016 |
oops
|
|
3017 |
|
|
3018 |
lemma XXX2a_long_without_good:
|
|
3019 |
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
|
|
3020 |
apply(induct a arbitrary: c taking: "\<lambda>a. asize a" rule: measure_induct)
|
|
3021 |
apply(case_tac x)
|
|
3022 |
apply(simp)
|
|
3023 |
apply(simp)
|
|
3024 |
apply(simp)
|
|
3025 |
prefer 3
|
|
3026 |
apply(simp)
|
|
3027 |
(* AALT case *)
|
|
3028 |
prefer 2
|
|
3029 |
apply(subgoal_tac "nonnested (bsimp x)")
|
|
3030 |
prefer 2
|
|
3031 |
using nn1b apply blast
|
|
3032 |
apply(simp only:)
|
|
3033 |
apply(drule_tac x="AALTs x51 (flts x52)" in spec)
|
|
3034 |
apply(drule mp)
|
|
3035 |
defer
|
|
3036 |
apply(drule_tac x="c" in spec)
|
|
3037 |
apply(simp)
|
|
3038 |
apply(rotate_tac 2)
|
|
3039 |
|
|
3040 |
apply(drule sym)
|
|
3041 |
apply(simp)
|
|
3042 |
|
|
3043 |
apply(simp only: bder.simps)
|
|
3044 |
apply(simp only: bsimp.simps)
|
|
3045 |
apply(subst bder_bsimp_AALTs)
|
|
3046 |
apply(case_tac x52)
|
|
3047 |
apply(simp)
|
|
3048 |
apply(simp)
|
|
3049 |
apply(case_tac list)
|
|
3050 |
apply(simp)
|
|
3051 |
apply(case_tac a)
|
|
3052 |
apply(simp)
|
|
3053 |
apply(simp)
|
|
3054 |
apply(simp)
|
|
3055 |
defer
|
|
3056 |
apply(simp)
|
|
3057 |
|
|
3058 |
|
|
3059 |
(* case AALTs list is not empty *)
|
|
3060 |
apply(simp)
|
|
3061 |
apply(subst k0)
|
|
3062 |
apply(subst (2) k0)
|
|
3063 |
apply(simp)
|
|
3064 |
apply(case_tac "bsimp a = AZERO")
|
|
3065 |
apply(subgoal_tac "bsimp (bder c a) = AZERO")
|
|
3066 |
prefer 2
|
|
3067 |
using less_iff_Suc_add apply auto[1]
|
|
3068 |
apply(simp)
|
|
3069 |
apply(drule_tac x="AALTs x51 list" in spec)
|
|
3070 |
apply(drule mp)
|
|
3071 |
apply(simp add: asize0)
|
|
3072 |
apply(drule_tac x="c" in spec)
|
|
3073 |
apply(simp add: bder_bsimp_AALTs)
|
|
3074 |
apply(case_tac "nonalt (bsimp a)")
|
|
3075 |
prefer 2
|
|
3076 |
apply(drule_tac x="bsimp (AALTs x51 (a#list))" in spec)
|
|
3077 |
apply(drule mp)
|
|
3078 |
apply(rule order_class.order.strict_trans2)
|
|
3079 |
apply(rule bsimp_AALTs_size3)
|
|
3080 |
apply(auto)[1]
|
|
3081 |
apply(simp)
|
|
3082 |
apply(subst (asm) bsimp_idem)
|
|
3083 |
apply(drule_tac x="c" in spec)
|
|
3084 |
apply(simp)
|
|
3085 |
find_theorems "_ < _ \<Longrightarrow> _ \<le> _ \<Longrightarrow>_ < _"
|
|
3086 |
apply(rule le_trans)
|
|
3087 |
apply(subgoal_tac "flts [bsimp a] = [bsimp a]")
|
|
3088 |
prefer 2
|
|
3089 |
using k0b apply blast
|
|
3090 |
apply(simp)
|
|
3091 |
find_theorems "asize _ < asize _"
|
|
3092 |
|
|
3093 |
using bder_bsimp_AALTs
|
|
3094 |
apply(case_tac list)
|
|
3095 |
apply(simp)
|
|
3096 |
sledgeha mmer [timeout=6000]
|
|
3097 |
|
|
3098 |
apply(case_tac "\<exists>r \<in> set (map bsimp x52). \<not>nonalt r")
|
|
3099 |
apply(drule_tac x="bsimp (AALTs x51 x52)" in spec)
|
|
3100 |
apply(drule mp)
|
|
3101 |
using bsimp_AALTs_size3 apply blast
|
|
3102 |
apply(drule_tac x="c" in spec)
|
|
3103 |
apply(subst (asm) (2) test)
|
|
3104 |
|
|
3105 |
apply(case_tac x52)
|
|
3106 |
apply(simp)
|
|
3107 |
apply(simp)
|
|
3108 |
apply(case_tac "bsimp a = AZERO")
|
|
3109 |
apply(simp)
|
|
3110 |
apply(subgoal_tac "bsimp (bder c a) = AZERO")
|
|
3111 |
prefer 2
|
|
3112 |
apply auto[1]
|
|
3113 |
apply (metis L.simps(1) L_bsimp_erase der.simps(1) der_correctness erase.simps(1) erase_bder xxx_bder2)
|
|
3114 |
apply(simp)
|
|
3115 |
apply(drule_tac x="AALTs x51 list" in spec)
|
|
3116 |
apply(drule mp)
|
|
3117 |
apply(simp add: asize0)
|
|
3118 |
apply(simp)
|
|
3119 |
apply(case_tac list)
|
|
3120 |
prefer 2
|
|
3121 |
apply(simp)
|
|
3122 |
apply(case_tac "bsimp aa = AZERO")
|
|
3123 |
apply(simp)
|
|
3124 |
apply(subgoal_tac "bsimp (bder c aa) = AZERO")
|
|
3125 |
prefer 2
|
|
3126 |
apply auto[1]
|
|
3127 |
apply (metis add.left_commute bder.simps(1) bsimp.simps(3) less_add_Suc1)
|
|
3128 |
apply(simp)
|
|
3129 |
apply(drule_tac x="AALTs x51 (a#lista)" in spec)
|
|
3130 |
apply(drule mp)
|
|
3131 |
apply(simp add: asize0)
|
|
3132 |
apply(simp)
|
|
3133 |
apply (metis flts.simps(2) k0)
|
|
3134 |
apply(subst k0)
|
|
3135 |
apply(subst (2) k0)
|
|
3136 |
|
|
3137 |
|
|
3138 |
using less_add_Suc1 apply fastforce
|
|
3139 |
apply(subst k0)
|
|
3140 |
|
|
3141 |
|
|
3142 |
apply(simp)
|
|
3143 |
apply(case_tac "bsimp a = AZERO")
|
|
3144 |
apply(simp)
|
|
3145 |
apply(subgoal_tac "bsimp (bder c a) = AZERO")
|
|
3146 |
prefer 2
|
|
3147 |
apply auto[1]
|
|
3148 |
apply(simp)
|
|
3149 |
apply(case_tac "nonalt (bsimp a)")
|
|
3150 |
apply(subst bsimp_AALTs1)
|
|
3151 |
apply(simp)
|
|
3152 |
using less_add_Suc1 apply fastforce
|
|
3153 |
|
|
3154 |
apply(subst bsimp_AALTs1)
|
|
3155 |
|
|
3156 |
using nn11a apply b last
|
|
3157 |
|
|
3158 |
(* SEQ case *)
|
|
3159 |
apply(clarify)
|
|
3160 |
apply(subst bsimp.simps)
|
|
3161 |
apply(simp del: bsimp.simps)
|
|
3162 |
apply(auto simp del: bsimp.simps)[1]
|
|
3163 |
apply(subgoal_tac "bsimp x42 \<noteq> AZERO")
|
|
3164 |
prefer 2
|
|
3165 |
using b3 apply force
|
|
3166 |
apply(case_tac "bsimp x43 = AZERO")
|
|
3167 |
apply(simp)
|
|
3168 |
apply (simp add: bsimp_ASEQ0)
|
|
3169 |
apply (metis bder.simps(1) bsimp.simps(3) bsimp_AALTs.simps(1) bsimp_fuse flts.simps(1) flts.simps(2) fuse.simps(1) less_add_Suc2)
|
|
3170 |
apply(case_tac "\<exists>bs. bsimp x42 = AONE bs")
|
|
3171 |
apply(clarify)
|
|
3172 |
apply(simp)
|
|
3173 |
apply(subst bsimp_ASEQ2)
|
|
3174 |
apply(subgoal_tac "bsimp (bder c x42) = AZERO")
|
|
3175 |
prefer 2
|
|
3176 |
using less_add_Suc1 apply fastforce
|
|
3177 |
apply(simp)
|
|
3178 |
apply(frule_tac x="x43" in spec)
|
|
3179 |
apply(drule mp)
|
|
3180 |
apply(simp)
|
|
3181 |
apply(drule_tac x="c" in spec)
|
|
3182 |
apply(subst bder_fuse)
|
|
3183 |
apply(subst bsimp_fuse[symmetric])
|
|
3184 |
apply(simp)
|
|
3185 |
apply(subgoal_tac "bmkeps x42 = bs")
|
|
3186 |
prefer 2
|
|
3187 |
apply (simp add: bmkeps_simp)
|
|
3188 |
apply(simp)
|
|
3189 |
apply(subst bsimp_fuse[symmetric])
|
|
3190 |
apply(case_tac "nonalt (bsimp (bder c x43))")
|
|
3191 |
apply(subst bsimp_AALTs1)
|
|
3192 |
using nn11a apply blast
|
|
3193 |
using fuse_append apply blast
|
|
3194 |
apply(subgoal_tac "\<exists>bs rs. bsimp (bder c x43) = AALTs bs rs")
|
|
3195 |
prefer 2
|
|
3196 |
using bbbbs1 apply blast
|
|
3197 |
apply(clarify)
|
|
3198 |
apply(simp)
|
|
3199 |
apply(case_tac rs)
|
|
3200 |
apply(simp)
|
|
3201 |
apply (metis arexp.distinct(7) good.simps(4) good1)
|
|
3202 |
apply(simp)
|
|
3203 |
apply(case_tac list)
|
|
3204 |
apply(simp)
|
|
3205 |
apply (metis arexp.distinct(7) good.simps(5) good1)
|
|
3206 |
apply(simp del: bsimp_AALTs.simps)
|
|
3207 |
apply(simp only: bsimp_AALTs.simps)
|
|
3208 |
apply(simp)
|
|
3209 |
|
|
3210 |
|
|
3211 |
|
|
3212 |
|
|
3213 |
(* HERE *)
|
|
3214 |
apply(case_tac "x42 = AZERO")
|
|
3215 |
apply(simp)
|
|
3216 |
apply(case_tac "bsimp x43 = AZERO")
|
|
3217 |
apply(simp)
|
|
3218 |
apply (simp add: bsimp_ASEQ0)
|
|
3219 |
apply(subgoal_tac "bsimp (fuse (bmkeps x42) (bder c x43)) = AZERO")
|
|
3220 |
apply(simp)
|
|
3221 |
apply (met is bder.simps(1) bsimp.simps(3) bsimp_fuse fuse.simps(1) less_add_Suc2)
|
|
3222 |
apply(case_tac "\<exists>bs. bsimp x42 = AONE bs")
|
|
3223 |
apply(clarify)
|
|
3224 |
apply(simp)
|
|
3225 |
apply(subst bsimp_ASEQ2)
|
|
3226 |
apply(subgoal_tac "bsimp (bder c x42) = AZERO")
|
|
3227 |
apply(simp)
|
|
3228 |
prefer 2
|
|
3229 |
using less_add_Suc1 apply fastforce
|
|
3230 |
apply(subgoal_tac "bmkeps x42 = bs")
|
|
3231 |
prefer 2
|
|
3232 |
apply (simp add: bmkeps_simp)
|
|
3233 |
apply(simp)
|
|
3234 |
apply(case_tac "nonalt (bsimp (bder c x43))")
|
|
3235 |
apply (metis bder_fuse bsimp_AALTs.simps(1) bsimp_AALTs.simps(2) bsimp_fuse flts.simps(1) flts.simps(2) fuse.simps(1) fuse_append k0b less_add_Suc2 nn11a)
|
|
3236 |
apply(subgoal_tac "nonnested (bsimp (bder c x43))")
|
|
3237 |
prefer 2
|
|
3238 |
using nn1b apply blast
|
|
3239 |
apply(case_tac x43)
|
|
3240 |
apply(simp)
|
|
3241 |
apply(simp)
|
|
3242 |
apply(simp)
|
|
3243 |
prefer 3
|
|
3244 |
apply(simp)
|
|
3245 |
apply (metis arexp.distinct(25) arexp.distinct(7) arexp.distinct(9) bsimp_ASEQ.simps(1) bsimp_ASEQ.simps(11) bsimp_ASEQ1 nn11a nonalt.elims(3) nonalt.simps(6))
|
|
3246 |
apply(simp)
|
|
3247 |
apply(auto)[1]
|
|
3248 |
apply(case_tac "(bsimp (bder c x42a)) = AZERO")
|
|
3249 |
apply(simp)
|
|
3250 |
|
|
3251 |
apply(simp)
|
|
3252 |
|
|
3253 |
|
|
3254 |
|
|
3255 |
apply(subgoal_tac "(\<exists>bs1 rs1. 1 < length rs1 \<and> bsimp (bder c x43) = AALTs bs1 rs1 ) \<or>
|
|
3256 |
(\<exists>bs1 r. bsimp (bder c x43) = fuse bs1 r)")
|
|
3257 |
prefer 2
|
|
3258 |
apply (metis fuse_empty)
|
|
3259 |
apply(erule disjE)
|
|
3260 |
prefer 2
|
|
3261 |
apply(clarify)
|
|
3262 |
apply(simp only:)
|
|
3263 |
apply(simp)
|
|
3264 |
apply(simp add: fuse_append)
|
|
3265 |
apply(subst bder_fuse)
|
|
3266 |
apply(subst bsimp_fuse[symmetric])
|
|
3267 |
apply(subst bder_fuse)
|
|
3268 |
apply(subst bsimp_fuse[symmetric])
|
|
3269 |
apply(subgoal_tac "bsimp (bder c (bsimp x43)) = bsimp (bder c x43)")
|
|
3270 |
prefer 2
|
|
3271 |
using less_add_Suc2 apply bl ast
|
|
3272 |
apply(simp only: )
|
|
3273 |
apply(subst bsimp_fuse[symmetric])
|
|
3274 |
apply(simp only: )
|
|
3275 |
|
|
3276 |
apply(simp only: fuse.simps)
|
|
3277 |
apply(simp)
|
|
3278 |
apply(case_tac rs1)
|
|
3279 |
apply(simp)
|
|
3280 |
apply (me tis arexp.distinct(7) fuse.simps(1) good.simps(4) good1 good_fuse)
|
|
3281 |
apply(simp)
|
|
3282 |
apply(case_tac list)
|
|
3283 |
apply(simp)
|
|
3284 |
apply (me tis arexp.distinct(7) fuse.simps(1) good.simps(5) good1 good_fuse)
|
|
3285 |
apply(simp only: bsimp_AALTs.simps map_cons.simps)
|
|
3286 |
apply(auto)[1]
|
|
3287 |
|
|
3288 |
|
|
3289 |
|
|
3290 |
apply(subst bsimp_fuse[symmetric])
|
|
3291 |
apply(subgoal_tac "bmkeps x42 = bs")
|
|
3292 |
prefer 2
|
|
3293 |
apply (simp add: bmkeps_simp)
|
|
3294 |
|
|
3295 |
|
|
3296 |
apply(simp)
|
|
3297 |
|
|
3298 |
using b3 apply force
|
|
3299 |
using bsimp_ASEQ0 test2 apply fo rce
|
|
3300 |
thm good_SEQ test2
|
|
3301 |
apply (simp add: good_SEQ test2)
|
|
3302 |
apply (simp add: good_SEQ test2)
|
|
3303 |
apply(case_tac "x42 = AZERO")
|
|
3304 |
apply(simp)
|
|
3305 |
apply(case_tac "x43 = AZERO")
|
|
3306 |
apply(simp)
|
|
3307 |
apply (simp add: bsimp_ASEQ0)
|
|
3308 |
apply(case_tac "\<exists>bs. x42 = AONE bs")
|
|
3309 |
apply(clarify)
|
|
3310 |
apply(simp)
|
|
3311 |
apply(subst bsimp_ASEQ1)
|
|
3312 |
apply(simp)
|
|
3313 |
using bsimp_ASEQ0 test2 apply fo rce
|
|
3314 |
apply (simp add: good_SEQ test2)
|
|
3315 |
apply (simp add: good_SEQ test2)
|
|
3316 |
apply (simp add: good_SEQ test2)
|
|
3317 |
(* AALTs case *)
|
|
3318 |
apply(simp)
|
|
3319 |
using test2 by fa st force
|
|
3320 |
|
|
3321 |
|
|
3322 |
lemma XXX4ab:
|
|
3323 |
shows "good (bders_simp (bsimp r) s) \<or> bders_simp (bsimp r) s = AZERO"
|
|
3324 |
apply(induct s arbitrary: r rule: rev_induct)
|
|
3325 |
apply(simp)
|
|
3326 |
apply (simp add: good1)
|
|
3327 |
apply(simp add: bders_simp_append)
|
|
3328 |
apply (simp add: good1)
|
|
3329 |
done
|
|
3330 |
|
|
3331 |
lemma XXX4:
|
|
3332 |
assumes "good a"
|
|
3333 |
shows "bders_simp a s = bsimp (bders a s)"
|
|
3334 |
using assms
|
|
3335 |
apply(induct s arbitrary: a rule: rev_induct)
|
|
3336 |
apply(simp)
|
|
3337 |
apply (simp add: test2)
|
|
3338 |
apply(simp add: bders_append bders_simp_append)
|
|
3339 |
oops
|
|
3340 |
|
|
3341 |
|
|
3342 |
lemma MAINMAIN:
|
|
3343 |
"blexer r s = blexer_simp r s"
|
|
3344 |
apply(induct s arbitrary: r)
|
|
3345 |
apply(simp add: blexer_def blexer_simp_def)
|
|
3346 |
apply(simp add: blexer_def blexer_simp_def del: bders.simps bders_simp.simps)
|
|
3347 |
apply(auto simp del: bders.simps bders_simp.simps)
|
|
3348 |
prefer 2
|
|
3349 |
apply (metis b4 bders.simps(2) bders_simp.simps(2))
|
|
3350 |
prefer 2
|
|
3351 |
apply (metis b4 bders.simps(2))
|
|
3352 |
apply(subst bmkeps_simp)
|
|
3353 |
apply(simp)
|
|
3354 |
apply(case_tac s)
|
|
3355 |
apply(simp only: bders.simps)
|
|
3356 |
apply(subst bders_simp.simps)
|
|
3357 |
apply(simp)
|
|
3358 |
oops
|
|
3359 |
|
|
3360 |
|
|
3361 |
lemma
|
|
3362 |
fixes n :: nat
|
|
3363 |
shows "(\<Sum>i \<in> {0..n}. i) = n * (n + 1) div 2"
|
|
3364 |
apply(induct n)
|
|
3365 |
apply(simp)
|
|
3366 |
apply(simp)
|
|
3367 |
done
|
|
3368 |
|
|
3369 |
|
|
3370 |
|
|
3371 |
|
|
3372 |
|
|
3373 |
end |