433
|
1 |
|
|
2 |
theory SizeBound6CT
|
|
3 |
imports "Lexer" "PDerivs"
|
|
4 |
begin
|
|
5 |
|
|
6 |
section \<open>Bit-Encodings\<close>
|
|
7 |
|
|
8 |
fun orderedSufAux :: "nat \<Rightarrow> char list \<Rightarrow> char list list"
|
|
9 |
where
|
|
10 |
"orderedSufAux (Suc i) ss = (drop i ss) # (orderedSufAux i ss)"
|
|
11 |
|"orderedSufAux 0 ss = Nil"
|
|
12 |
|
|
13 |
fun
|
|
14 |
orderedSuf :: "char list \<Rightarrow> char list list"
|
|
15 |
where
|
|
16 |
"orderedSuf s = orderedSufAux (length s) s"
|
|
17 |
|
|
18 |
fun orderedPrefAux :: "nat \<Rightarrow> char list \<Rightarrow> char list list"
|
|
19 |
where
|
|
20 |
"orderedPrefAux (Suc i) ss = (take i ss) # (orderedPrefAux i ss)"
|
|
21 |
|"orderedPrefAux 0 ss = Nil"
|
|
22 |
|
|
23 |
|
438
|
24 |
fun ordsuf :: "char list \<Rightarrow> char list list"
|
|
25 |
where
|
|
26 |
"ordsuf [] = []"
|
|
27 |
| "ordsuf (x # xs) = (ordsuf xs) @ [(x # xs)]"
|
|
28 |
|
|
29 |
|
433
|
30 |
fun orderedPref :: "char list \<Rightarrow> char list list"
|
|
31 |
where
|
|
32 |
"orderedPref s = orderedPrefAux (length s) s"
|
|
33 |
|
|
34 |
lemma shape_of_pref_1list:
|
|
35 |
shows "orderedPref [c] = [[]]"
|
|
36 |
apply auto
|
|
37 |
done
|
|
38 |
|
|
39 |
lemma shape_of_suf_1list:
|
|
40 |
shows "orderedSuf [c] = [[c]]"
|
|
41 |
by auto
|
|
42 |
|
|
43 |
lemma shape_of_suf_2list:
|
|
44 |
shows "orderedSuf [c2, c3] = [[c3], [c2,c3]]"
|
|
45 |
by auto
|
|
46 |
|
|
47 |
lemma shape_of_prf_2list:
|
|
48 |
shows "orderedPref [c1, c2] = [[c1], []]"
|
|
49 |
by auto
|
|
50 |
|
|
51 |
|
|
52 |
lemma shape_of_suf_3list:
|
|
53 |
shows "orderedSuf [c1, c2, c3] = [[c3], [c2, c3], [c1, c2, c3]]"
|
|
54 |
by auto
|
|
55 |
|
436
|
56 |
|
|
57 |
lemma ordsuf_last:
|
|
58 |
shows "ordsuf (xs @ [x]) = [x] # (map (\<lambda>s. s @ [x]) (ordsuf xs))"
|
|
59 |
apply(induct xs)
|
|
60 |
apply(auto)
|
|
61 |
done
|
|
62 |
|
|
63 |
lemma ordsuf_append:
|
|
64 |
shows "ordsuf (s1 @ s) = (ordsuf s) @ (map (\<lambda>s11. s11 @ s) (ordsuf s1))"
|
|
65 |
apply(induct s1 arbitrary: s rule: rev_induct)
|
|
66 |
apply(simp)
|
|
67 |
apply(drule_tac x="[x] @ s" in meta_spec)
|
|
68 |
apply(simp)
|
|
69 |
apply(subst ordsuf_last)
|
|
70 |
apply(simp)
|
|
71 |
done
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
(*
|
433
|
76 |
lemma throwing_elem_around:
|
|
77 |
shows "orderedSuf (s1 @ [a] @ s) = (orderedSuf s) @ (map (\<lambda>s11. s11 @ s) (orderedSuf ( s1 @ [a]) ))"
|
|
78 |
and "orderedSuf (s1 @ [a] @ s) = (orderedSuf ([a] @ s) @ (map (\<lambda>s11. s11 @ ([a] @ s))) (orderedSuf s1) )"
|
|
79 |
sorry
|
|
80 |
|
|
81 |
|
|
82 |
lemma suf_cons:
|
|
83 |
shows "orderedSuf (s1 @ s) = (orderedSuf s) @ (map (\<lambda>s11. s11 @ s) (orderedSuf s1))"
|
|
84 |
apply(induct s arbitrary: s1)
|
|
85 |
apply simp
|
|
86 |
apply(subgoal_tac "s1 @ a # s = (s1 @ [a]) @ s")
|
|
87 |
prefer 2
|
|
88 |
apply simp
|
|
89 |
apply(subgoal_tac "orderedSuf (s1 @ a # s) = orderedSuf ((s1 @ [a]) @ s)")
|
|
90 |
prefer 2
|
|
91 |
apply presburger
|
|
92 |
apply(drule_tac x="s1 @ [a]" in meta_spec)
|
|
93 |
sorry
|
435
|
94 |
*)
|
433
|
95 |
|
|
96 |
|
|
97 |
lemma shape_of_prf_3list:
|
|
98 |
shows "orderedPref [c1, c2, c3] = [[c1, c2], [c1], []]"
|
|
99 |
by auto
|
|
100 |
|
|
101 |
fun zip_concat :: "char list list \<Rightarrow> char list list \<Rightarrow> char list list"
|
|
102 |
where
|
|
103 |
"zip_concat (s1#ss1) (s2#ss2) = (s1@s2) # (zip_concat ss1 ss2)"
|
|
104 |
| "zip_concat [] [] = []"
|
|
105 |
| "zip_concat [] (s2#ss2) = s2 # (zip_concat [] ss2)"
|
|
106 |
| "zip_concat (s1#ss1) [] = s1 # (zip_concat ss1 [])"
|
|
107 |
|
|
108 |
|
434
|
109 |
(*
|
433
|
110 |
lemma compliment_pref_suf:
|
|
111 |
shows "zip_concat (orderedPref s) (orderedSuf s) = replicate (length s) s "
|
|
112 |
apply(induct s)
|
|
113 |
apply auto[1]
|
|
114 |
sorry
|
|
115 |
|
|
116 |
|
434
|
117 |
*)
|
433
|
118 |
|
438
|
119 |
|
433
|
120 |
datatype rrexp =
|
|
121 |
RZERO
|
|
122 |
| RONE
|
441
|
123 |
| RCHAR char
|
433
|
124 |
| RSEQ rrexp rrexp
|
|
125 |
| RALTS "rrexp list"
|
|
126 |
| RSTAR rrexp
|
|
127 |
|
|
128 |
abbreviation
|
|
129 |
"RALT r1 r2 \<equiv> RALTS [r1, r2]"
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
fun
|
|
134 |
rnullable :: "rrexp \<Rightarrow> bool"
|
|
135 |
where
|
|
136 |
"rnullable (RZERO) = False"
|
|
137 |
| "rnullable (RONE ) = True"
|
|
138 |
| "rnullable (RCHAR c) = False"
|
|
139 |
| "rnullable (RALTS rs) = (\<exists>r \<in> set rs. rnullable r)"
|
|
140 |
| "rnullable (RSEQ r1 r2) = (rnullable r1 \<and> rnullable r2)"
|
|
141 |
| "rnullable (RSTAR r) = True"
|
|
142 |
|
|
143 |
|
|
144 |
fun
|
|
145 |
rder :: "char \<Rightarrow> rrexp \<Rightarrow> rrexp"
|
|
146 |
where
|
|
147 |
"rder c (RZERO) = RZERO"
|
|
148 |
| "rder c (RONE) = RZERO"
|
441
|
149 |
| "rder c (RCHAR d) = (if c = d then RONE else RZERO)"
|
433
|
150 |
| "rder c (RALTS rs) = RALTS (map (rder c) rs)"
|
|
151 |
| "rder c (RSEQ r1 r2) =
|
|
152 |
(if rnullable r1
|
|
153 |
then RALT (RSEQ (rder c r1) r2) (rder c r2)
|
|
154 |
else RSEQ (rder c r1) r2)"
|
|
155 |
| "rder c (RSTAR r) = RSEQ (rder c r) (RSTAR r)"
|
|
156 |
|
|
157 |
|
|
158 |
fun
|
|
159 |
rders :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
|
|
160 |
where
|
|
161 |
"rders r [] = r"
|
|
162 |
| "rders r (c#s) = rders (rder c r) s"
|
|
163 |
|
|
164 |
fun rdistinct :: "'a list \<Rightarrow>'a set \<Rightarrow> 'a list"
|
|
165 |
where
|
|
166 |
"rdistinct [] acc = []"
|
|
167 |
| "rdistinct (x#xs) acc =
|
|
168 |
(if x \<in> acc then rdistinct xs acc
|
|
169 |
else x # (rdistinct xs ({x} \<union> acc)))"
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
fun rflts :: "rrexp list \<Rightarrow> rrexp list"
|
|
176 |
where
|
|
177 |
"rflts [] = []"
|
|
178 |
| "rflts (RZERO # rs) = rflts rs"
|
|
179 |
| "rflts ((RALTS rs1) # rs) = rs1 @ rflts rs"
|
|
180 |
| "rflts (r1 # rs) = r1 # rflts rs"
|
|
181 |
|
|
182 |
|
|
183 |
fun rsimp_ALTs :: " rrexp list \<Rightarrow> rrexp"
|
|
184 |
where
|
|
185 |
"rsimp_ALTs [] = RZERO"
|
|
186 |
| "rsimp_ALTs [r] = r"
|
|
187 |
| "rsimp_ALTs rs = RALTS rs"
|
|
188 |
|
|
189 |
fun rsimp_SEQ :: " rrexp \<Rightarrow> rrexp \<Rightarrow> rrexp"
|
|
190 |
where
|
|
191 |
"rsimp_SEQ RZERO _ = RZERO"
|
|
192 |
| "rsimp_SEQ _ RZERO = RZERO"
|
|
193 |
| "rsimp_SEQ RONE r2 = r2"
|
|
194 |
| "rsimp_SEQ r1 r2 = RSEQ r1 r2"
|
|
195 |
|
|
196 |
|
|
197 |
fun rsimp :: "rrexp \<Rightarrow> rrexp"
|
|
198 |
where
|
|
199 |
"rsimp (RSEQ r1 r2) = rsimp_SEQ (rsimp r1) (rsimp r2)"
|
|
200 |
| "rsimp (RALTS rs) = rsimp_ALTs (rdistinct (rflts (map rsimp rs)) {}) "
|
|
201 |
| "rsimp r = r"
|
|
202 |
|
|
203 |
|
|
204 |
fun
|
|
205 |
rders_simp :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
|
|
206 |
where
|
|
207 |
"rders_simp r [] = r"
|
|
208 |
| "rders_simp r (c#s) = rders_simp (rsimp (rder c r)) s"
|
|
209 |
|
|
210 |
fun rsize :: "rrexp \<Rightarrow> nat" where
|
|
211 |
"rsize RZERO = 1"
|
|
212 |
| "rsize (RONE) = 1"
|
|
213 |
| "rsize (RCHAR c) = 1"
|
|
214 |
| "rsize (RALTS rs) = Suc (sum_list (map rsize rs))"
|
|
215 |
| "rsize (RSEQ r1 r2) = Suc (rsize r1 + rsize r2)"
|
|
216 |
| "rsize (RSTAR r) = Suc (rsize r)"
|
|
217 |
|
|
218 |
|
|
219 |
fun rlist_size :: "rrexp list \<Rightarrow> nat" where
|
|
220 |
"rlist_size (r # rs) = rsize r + rlist_size rs"
|
|
221 |
| "rlist_size [] = 0"
|
|
222 |
|
|
223 |
thm neq_Nil_conv
|
435
|
224 |
lemma hand_made_def_rlist_size:
|
|
225 |
shows "rlist_size rs = sum_list (map rsize rs)"
|
|
226 |
proof (induct rs)
|
|
227 |
case Nil show ?case by simp
|
|
228 |
next
|
|
229 |
case (Cons a rs) thus ?case
|
|
230 |
by simp
|
|
231 |
qed
|
433
|
232 |
|
|
233 |
lemma rsimp_aalts_smaller:
|
|
234 |
shows "rsize (rsimp_ALTs rs) \<le> rsize (RALTS rs)"
|
|
235 |
apply(induct rs)
|
|
236 |
apply simp
|
|
237 |
apply simp
|
|
238 |
apply(case_tac "rs = []")
|
|
239 |
apply simp
|
|
240 |
apply(subgoal_tac "\<exists>rsp ap. rs = ap # rsp")
|
|
241 |
apply(erule exE)+
|
|
242 |
apply simp
|
|
243 |
apply simp
|
|
244 |
by(meson neq_Nil_conv)
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
(*
|
|
252 |
lemma rders_shape:
|
|
253 |
shows "s \<noteq> [] \<Longrightarrow> rders_simp (RSEQ r1 r2) s =
|
|
254 |
rsimp (RALTS ((RSEQ (rders r1 s) r2) #
|
|
255 |
(map (rders r2) (orderedSuf s))) )"
|
|
256 |
apply(induct s arbitrary: r1 r2 rule: rev_induct)
|
|
257 |
apply simp
|
|
258 |
apply simp
|
|
259 |
|
|
260 |
sorry
|
|
261 |
*)
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
fun rders_cond_list :: "rrexp \<Rightarrow> bool list \<Rightarrow> char list list \<Rightarrow> rrexp list"
|
|
266 |
where
|
|
267 |
"rders_cond_list r2 (True # bs) (s # strs) = (rders_simp r2 s) # (rders_cond_list r2 bs strs)"
|
|
268 |
| "rders_cond_list r2 (False # bs) (s # strs) = rders_cond_list r2 bs strs"
|
|
269 |
| "rders_cond_list r2 [] s = []"
|
|
270 |
| "rders_cond_list r2 bs [] = []"
|
|
271 |
|
|
272 |
fun nullable_bools :: "rrexp \<Rightarrow> char list list \<Rightarrow> bool list"
|
|
273 |
where
|
|
274 |
"nullable_bools r (s#strs) = (rnullable (rders r s)) # (nullable_bools r strs) "
|
|
275 |
|"nullable_bools r [] = []"
|
|
276 |
|
|
277 |
fun cond_list :: "rrexp \<Rightarrow> rrexp \<Rightarrow> char list \<Rightarrow> rrexp list"
|
|
278 |
where
|
|
279 |
"cond_list r1 r2 s = rders_cond_list r2 (nullable_bools r1 (orderedPref s) ) (orderedSuf s)"
|
|
280 |
|
435
|
281 |
|
438
|
282 |
fun seq_update :: " char \<Rightarrow> rrexp \<Rightarrow> char list list \<Rightarrow> char list list"
|
|
283 |
where
|
|
284 |
"seq_update c r Ss = (if (rnullable r) then ([c] # (map (\<lambda>s1. s1 @ [c]) Ss)) else (map (\<lambda>s1. s1 @ [c]) Ss))"
|
|
285 |
|
|
286 |
|
|
287 |
|
433
|
288 |
lemma rSEQ_mono:
|
|
289 |
shows "rsize (rsimp_SEQ r1 r2) \<le>rsize ( RSEQ r1 r2)"
|
|
290 |
apply auto
|
|
291 |
apply(induct r1)
|
|
292 |
apply auto
|
|
293 |
apply(case_tac "r2")
|
|
294 |
apply simp_all
|
|
295 |
apply(case_tac r2)
|
|
296 |
apply simp_all
|
|
297 |
apply(case_tac r2)
|
|
298 |
apply simp_all
|
|
299 |
apply(case_tac r2)
|
|
300 |
apply simp_all
|
|
301 |
apply(case_tac r2)
|
|
302 |
apply simp_all
|
|
303 |
done
|
|
304 |
|
435
|
305 |
lemma ralts_cap_mono:
|
|
306 |
shows "rsize (RALTS rs) \<le> Suc ( sum_list (map rsize rs)) "
|
|
307 |
by simp
|
|
308 |
|
|
309 |
lemma rflts_def_idiot:
|
|
310 |
shows "\<lbrakk> a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1\<rbrakk>
|
|
311 |
\<Longrightarrow> rflts (a # rs) = a # rflts rs"
|
|
312 |
apply(case_tac a)
|
|
313 |
apply simp_all
|
|
314 |
done
|
|
315 |
|
|
316 |
|
|
317 |
lemma rflts_mono:
|
|
318 |
shows "sum_list (map rsize (rflts rs))\<le> sum_list (map rsize rs)"
|
|
319 |
apply(induct rs)
|
|
320 |
apply simp
|
|
321 |
apply(case_tac "a = RZERO")
|
|
322 |
apply simp
|
|
323 |
apply(case_tac "\<exists>rs1. a = RALTS rs1")
|
|
324 |
apply(erule exE)
|
|
325 |
apply simp
|
|
326 |
apply(subgoal_tac "rflts (a # rs) = a # (rflts rs)")
|
|
327 |
prefer 2
|
|
328 |
using rflts_def_idiot apply blast
|
|
329 |
apply simp
|
|
330 |
done
|
|
331 |
|
|
332 |
lemma rdistinct_smaller: shows "sum_list (map rsize (rdistinct rs ss)) \<le>
|
|
333 |
sum_list (map rsize rs )"
|
|
334 |
apply (induct rs arbitrary: ss)
|
|
335 |
apply simp
|
|
336 |
by (simp add: trans_le_add2)
|
|
337 |
|
|
338 |
lemma rdistinct_phi_smaller: "sum_list (map rsize (rdistinct rs {})) \<le> sum_list (map rsize rs)"
|
|
339 |
by (simp add: rdistinct_smaller)
|
|
340 |
|
|
341 |
|
|
342 |
lemma rsimp_alts_mono :
|
|
343 |
shows "\<And>x. (\<And>xa. xa \<in> set x \<Longrightarrow> rsize (rsimp xa) \<le> rsize xa) \<Longrightarrow>
|
|
344 |
rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {})) \<le> Suc (sum_list (map rsize x))"
|
|
345 |
apply(subgoal_tac "rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {} ))
|
|
346 |
\<le> rsize (RALTS (rdistinct (rflts (map rsimp x)) {} ))")
|
|
347 |
prefer 2
|
|
348 |
using rsimp_aalts_smaller apply auto[1]
|
|
349 |
apply(subgoal_tac "rsize (RALTS (rdistinct (rflts (map rsimp x)) {})) \<le>Suc( sum_list (map rsize (rdistinct (rflts (map rsimp x)) {})))")
|
|
350 |
prefer 2
|
|
351 |
using ralts_cap_mono apply blast
|
|
352 |
apply(subgoal_tac "sum_list (map rsize (rdistinct (rflts (map rsimp x)) {})) \<le>
|
|
353 |
sum_list (map rsize ( (rflts (map rsimp x))))")
|
|
354 |
prefer 2
|
|
355 |
using rdistinct_smaller apply presburger
|
|
356 |
apply(subgoal_tac "sum_list (map rsize (rflts (map rsimp x))) \<le>
|
|
357 |
sum_list (map rsize (map rsimp x))")
|
|
358 |
prefer 2
|
|
359 |
using rflts_mono apply blast
|
|
360 |
apply(subgoal_tac "sum_list (map rsize (map rsimp x)) \<le> sum_list (map rsize x)")
|
|
361 |
prefer 2
|
|
362 |
|
|
363 |
apply (simp add: sum_list_mono)
|
|
364 |
by linarith
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
433
|
370 |
lemma rsimp_mono:
|
|
371 |
shows "rsize (rsimp r) \<le> rsize r"
|
435
|
372 |
|
433
|
373 |
apply(induct r)
|
435
|
374 |
apply simp_all
|
|
375 |
|
433
|
376 |
apply(subgoal_tac "rsize (rsimp_SEQ (rsimp r1) (rsimp r2)) \<le> rsize (RSEQ (rsimp r1) (rsimp r2))")
|
|
377 |
|
|
378 |
apply force
|
|
379 |
using rSEQ_mono
|
435
|
380 |
apply presburger
|
|
381 |
using rsimp_alts_mono by auto
|
433
|
382 |
|
|
383 |
lemma idiot:
|
|
384 |
shows "rsimp_SEQ RONE r = r"
|
|
385 |
apply(case_tac r)
|
|
386 |
apply simp_all
|
|
387 |
done
|
|
388 |
|
435
|
389 |
lemma no_alt_short_list_after_simp:
|
|
390 |
shows "RALTS rs = rsimp r \<Longrightarrow> rsimp_ALTs rs = RALTS rs"
|
433
|
391 |
sorry
|
|
392 |
|
|
393 |
lemma no_further_dB_after_simp:
|
|
394 |
shows "RALTS rs = rsimp r \<Longrightarrow> rdistinct rs {} = rs"
|
435
|
395 |
|
433
|
396 |
sorry
|
|
397 |
|
|
398 |
|
|
399 |
lemma idiot2:
|
|
400 |
shows " \<lbrakk>r1 \<noteq> RZERO; r1 \<noteq> RONE;r2 \<noteq> RZERO\<rbrakk>
|
|
401 |
\<Longrightarrow> rsimp_SEQ r1 r2 = RSEQ r1 r2"
|
|
402 |
apply(case_tac r1)
|
|
403 |
apply(case_tac r2)
|
|
404 |
apply simp_all
|
|
405 |
apply(case_tac r2)
|
|
406 |
apply simp_all
|
|
407 |
apply(case_tac r2)
|
|
408 |
apply simp_all
|
|
409 |
apply(case_tac r2)
|
|
410 |
apply simp_all
|
|
411 |
apply(case_tac r2)
|
|
412 |
apply simp_all
|
|
413 |
done
|
438
|
414 |
(*
|
433
|
415 |
lemma rsimp_aalts_another:
|
|
416 |
shows "\<forall>r \<in> (set (map rsimp ((RSEQ (rders r1 s) r2) #
|
|
417 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) )) ). (rsize r) < N "
|
|
418 |
sorry
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
lemma shape_derssimpseq_onechar:
|
|
423 |
shows " (rders_simp r [c]) = (rsimp (rders r [c]))"
|
|
424 |
and "rders_simp (RSEQ r1 r2) [c] =
|
|
425 |
rsimp (RALTS ((RSEQ (rders r1 [c]) r2) #
|
|
426 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref [c])) (orderedSuf [c]))) )"
|
|
427 |
apply simp
|
|
428 |
apply(simp add: rders.simps)
|
|
429 |
apply(case_tac "rsimp (rder c r1) = RZERO")
|
|
430 |
apply auto
|
|
431 |
apply(case_tac "rsimp (rder c r1) = RONE")
|
|
432 |
apply auto
|
|
433 |
apply(subgoal_tac "rsimp_SEQ RONE (rsimp r2) = rsimp r2")
|
|
434 |
prefer 2
|
|
435 |
using idiot
|
|
436 |
apply simp
|
|
437 |
apply(subgoal_tac "rsimp_SEQ RONE (rsimp r2) = rsimp_ALTs (rdistinct (rflts [rsimp r2]) {})")
|
|
438 |
prefer 2
|
|
439 |
apply auto
|
|
440 |
apply(case_tac "rsimp r2")
|
|
441 |
apply auto
|
|
442 |
apply(subgoal_tac "rdistinct x5 {} = x5")
|
|
443 |
prefer 2
|
|
444 |
using no_further_dB_after_simp
|
|
445 |
apply metis
|
|
446 |
apply(subgoal_tac "rsimp_ALTs (rdistinct x5 {}) = rsimp_ALTs x5")
|
|
447 |
prefer 2
|
|
448 |
apply fastforce
|
|
449 |
apply auto
|
|
450 |
apply (metis no_alt_short_list_after_simp)
|
|
451 |
apply (case_tac "rsimp r2 = RZERO")
|
|
452 |
apply(subgoal_tac "rsimp_SEQ (rsimp (rder c r1)) (rsimp r2) = RZERO")
|
|
453 |
prefer 2
|
|
454 |
apply(case_tac "rsimp ( rder c r1)")
|
|
455 |
apply auto
|
|
456 |
apply(subgoal_tac "rsimp_SEQ (rsimp (rder c r1)) (rsimp r2) = RSEQ (rsimp (rder c r1)) (rsimp r2)")
|
|
457 |
prefer 2
|
|
458 |
apply auto
|
|
459 |
sorry
|
438
|
460 |
*)
|
433
|
461 |
|
438
|
462 |
(*
|
|
463 |
lemma shape_derssimpseq_onechar2:
|
|
464 |
shows "rders_simp (RSEQ r1 r2) [c] =
|
|
465 |
rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) #
|
|
466 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref [c])) (orderedSuf [c]))) )"
|
|
467 |
sorry
|
433
|
468 |
|
438
|
469 |
*)
|
|
470 |
|
|
471 |
lemma shape_derssimpseq_onechar:
|
|
472 |
shows " (rders_simp r [c]) = (rsimp (rders r [c]))"
|
|
473 |
and "rders_simp (RSEQ r1 r2) [c] =
|
|
474 |
rsimp (RALTS ((RSEQ (rders r1 [c]) r2) #
|
|
475 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref [c])) (orderedSuf [c]))) )"
|
|
476 |
apply simp
|
|
477 |
apply(simp add: rders.simps)
|
|
478 |
apply(case_tac "rsimp (rder c r1) = RZERO")
|
|
479 |
apply auto
|
|
480 |
apply(case_tac "rsimp (rder c r1) = RONE")
|
|
481 |
apply auto
|
|
482 |
apply(subgoal_tac "rsimp_SEQ RONE (rsimp r2) = rsimp r2")
|
|
483 |
prefer 2
|
|
484 |
using idiot
|
|
485 |
apply simp
|
|
486 |
apply(subgoal_tac "rsimp_SEQ RONE (rsimp r2) = rsimp_ALTs (rdistinct (rflts [rsimp r2]) {})")
|
|
487 |
prefer 2
|
|
488 |
apply auto
|
|
489 |
apply(case_tac "rsimp r2")
|
|
490 |
apply auto
|
|
491 |
apply(subgoal_tac "rdistinct x5 {} = x5")
|
|
492 |
prefer 2
|
|
493 |
using no_further_dB_after_simp
|
|
494 |
apply metis
|
|
495 |
apply(subgoal_tac "rsimp_ALTs (rdistinct x5 {}) = rsimp_ALTs x5")
|
|
496 |
prefer 2
|
|
497 |
apply fastforce
|
|
498 |
apply auto
|
|
499 |
apply (metis no_alt_short_list_after_simp)
|
|
500 |
apply (case_tac "rsimp r2 = RZERO")
|
|
501 |
apply(subgoal_tac "rsimp_SEQ (rsimp (rder c r1)) (rsimp r2) = RZERO")
|
|
502 |
prefer 2
|
|
503 |
apply(case_tac "rsimp ( rder c r1)")
|
|
504 |
apply auto
|
|
505 |
apply(subgoal_tac "rsimp_SEQ (rsimp (rder c r1)) (rsimp r2) = RSEQ (rsimp (rder c r1)) (rsimp r2)")
|
|
506 |
prefer 2
|
|
507 |
apply auto
|
|
508 |
sorry
|
433
|
509 |
|
|
510 |
lemma shape_derssimpseq_onechar2:
|
|
511 |
shows "rders_simp (RSEQ r1 r2) [c] =
|
|
512 |
rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) #
|
|
513 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref [c])) (orderedSuf [c]))) )"
|
|
514 |
sorry
|
|
515 |
|
438
|
516 |
(*
|
|
517 |
lemma simp_helps_der_pierce_dB:
|
|
518 |
shows " rsimp
|
|
519 |
(rsimp_ALTs
|
|
520 |
(map (rder x)
|
|
521 |
(rdistinct rs {}))) =
|
|
522 |
rsimp (rsimp_ALTs (rdistinct (map (rder x) rs) {}))"
|
|
523 |
|
|
524 |
sorry
|
|
525 |
*)
|
|
526 |
(*
|
|
527 |
lemma simp_helps_der_pierce_flts:
|
|
528 |
shows " rsimp
|
|
529 |
(rsimp_ALTs
|
|
530 |
(rdistinct
|
|
531 |
(map (rder x)
|
|
532 |
(rflts rs )
|
|
533 |
) {}
|
|
534 |
)
|
|
535 |
) =
|
|
536 |
rsimp (rsimp_ALTs (rdistinct (rflts (map (rder x) rs)) {}) )"
|
|
537 |
|
|
538 |
sorry
|
|
539 |
|
|
540 |
*)
|
433
|
541 |
|
|
542 |
lemma rders__onechar:
|
|
543 |
shows " (rders_simp r [c]) = (rsimp (rders r [c]))"
|
|
544 |
by simp
|
|
545 |
|
|
546 |
lemma rders_append:
|
|
547 |
"rders c (s1 @ s2) = rders (rders c s1) s2"
|
|
548 |
apply(induct s1 arbitrary: c s2)
|
|
549 |
apply(simp_all)
|
|
550 |
done
|
|
551 |
|
|
552 |
lemma rders_simp_append:
|
|
553 |
"rders_simp c (s1 @ s2) = rders_simp (rders_simp c s1) s2"
|
|
554 |
apply(induct s1 arbitrary: c s2)
|
|
555 |
apply(simp_all)
|
|
556 |
done
|
|
557 |
|
|
558 |
lemma inside_simp_removal:
|
|
559 |
shows " rsimp (rder x (rsimp r)) = rsimp (rder x r)"
|
|
560 |
|
|
561 |
sorry
|
|
562 |
|
|
563 |
lemma set_related_list:
|
|
564 |
shows "distinct rs \<Longrightarrow> length rs = card (set rs)"
|
|
565 |
by (simp add: distinct_card)
|
|
566 |
(*this section deals with the property of distinctBy: creates a list without duplicates*)
|
|
567 |
lemma rdistinct_never_added_twice:
|
|
568 |
shows "rdistinct (a # rs) {a} = rdistinct rs {a}"
|
|
569 |
by force
|
|
570 |
|
|
571 |
|
|
572 |
lemma rdistinct_does_the_job:
|
|
573 |
shows "distinct (rdistinct rs s)"
|
|
574 |
apply(induct rs arbitrary: s)
|
|
575 |
apply simp
|
|
576 |
apply simp
|
|
577 |
sorry
|
|
578 |
|
|
579 |
|
|
580 |
lemma simp_helps_der_pierce:
|
|
581 |
shows " rsimp
|
|
582 |
(rder x
|
|
583 |
(rsimp_ALTs rs)) =
|
|
584 |
rsimp
|
|
585 |
(rsimp_ALTs
|
|
586 |
(map (rder x )
|
|
587 |
rs
|
|
588 |
)
|
|
589 |
)"
|
|
590 |
sorry
|
|
591 |
|
|
592 |
lemma unfold_ders_simp_inside_only:
|
|
593 |
shows " (rders_simp (RSEQ r1 r2) xs =
|
|
594 |
rsimp (RALTS (RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))
|
|
595 |
\<Longrightarrow> rsimp (rder x (rders_simp (RSEQ r1 r2) xs)) = rsimp (rder x (rsimp (RALTS(RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs)))))"
|
|
596 |
by presburger
|
|
597 |
|
|
598 |
|
|
599 |
|
|
600 |
lemma unfold_ders_simp_inside_only_nosimp:
|
|
601 |
shows " (rders_simp (RSEQ r1 r2) xs =
|
|
602 |
rsimp (RALTS (RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))
|
|
603 |
\<Longrightarrow> rsimp (rder x (rders_simp (RSEQ r1 r2) xs)) = rsimp (rder x (RALTS(RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))"
|
|
604 |
using inside_simp_removal by presburger
|
|
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
lemma rders_simp_one_char:
|
|
610 |
shows "rders_simp r [c] = rsimp (rder c r)"
|
|
611 |
apply auto
|
|
612 |
done
|
|
613 |
|
|
614 |
lemma rsimp_idem:
|
|
615 |
shows "rsimp (rsimp r) = rsimp r"
|
|
616 |
sorry
|
|
617 |
|
434
|
618 |
corollary rsimp_inner_idem1:
|
|
619 |
shows "rsimp r = RSEQ r1 r2 \<Longrightarrow> rsimp r1 = r1 \<and> rsimp r2 = r2"
|
|
620 |
|
|
621 |
sorry
|
|
622 |
|
|
623 |
corollary rsimp_inner_idem2:
|
|
624 |
shows "rsimp r = RALTS rs \<Longrightarrow> \<forall>r' \<in> (set rs). rsimp r' = r'"
|
|
625 |
sorry
|
|
626 |
|
|
627 |
corollary rsimp_inner_idem3:
|
|
628 |
shows "rsimp r = RALTS rs \<Longrightarrow> map rsimp rs = rs"
|
|
629 |
by (meson map_idI rsimp_inner_idem2)
|
|
630 |
|
|
631 |
corollary rsimp_inner_idem4:
|
|
632 |
shows "rsimp r = RALTS rs \<Longrightarrow> flts rs = rs"
|
|
633 |
sorry
|
|
634 |
|
|
635 |
|
433
|
636 |
lemma head_one_more_simp:
|
|
637 |
shows "map rsimp (r # rs) = map rsimp (( rsimp r) # rs)"
|
|
638 |
by (simp add: rsimp_idem)
|
|
639 |
|
|
640 |
lemma head_one_more_dersimp:
|
|
641 |
shows "map rsimp ((rder x (rders_simp r s) # rs)) = map rsimp ((rders_simp r (s@[x]) ) # rs)"
|
|
642 |
using head_one_more_simp rders_simp_append rders_simp_one_char by presburger
|
|
643 |
|
|
644 |
thm cond_list.simps
|
|
645 |
|
|
646 |
lemma suffix_plus1char:
|
|
647 |
shows "\<not> (rnullable (rders r1 s)) \<Longrightarrow> cond_list r1 r2 (s@[c]) = map (rder c) (cond_list r1 r2 s)"
|
|
648 |
apply simp
|
|
649 |
sorry
|
|
650 |
|
|
651 |
lemma suffix_plus1charn:
|
|
652 |
shows "rnullable (rders r1 s) \<Longrightarrow> cond_list r1 r2 (s@[c]) = (rder c r2) # (map (rder c) (cond_list r1 r2 s))"
|
|
653 |
sorry
|
|
654 |
|
|
655 |
lemma ders_simp_nullability:
|
|
656 |
shows "rnullable (rders r s) = rnullable (rders_simp r s)"
|
|
657 |
sorry
|
|
658 |
|
|
659 |
lemma first_elem_seqder:
|
|
660 |
shows "\<not>rnullable r1p \<Longrightarrow> map rsimp (rder x (RSEQ r1p r2)
|
|
661 |
# rs) = map rsimp ((RSEQ (rder x r1p) r2) # rs) "
|
|
662 |
by auto
|
|
663 |
|
|
664 |
lemma first_elem_seqder1:
|
|
665 |
shows "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) =
|
|
666 |
map rsimp ( (RSEQ (rsimp (rder x (rders_simp r xs))) r2) # rs)"
|
|
667 |
by (simp add: rsimp_idem)
|
|
668 |
|
|
669 |
lemma first_elem_seqdersimps:
|
|
670 |
shows "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) =
|
|
671 |
map rsimp ( (RSEQ (rders_simp r (xs @ [x])) r2) # rs)"
|
|
672 |
using first_elem_seqder1 rders_simp_append by auto
|
|
673 |
|
|
674 |
lemma first_elem_seqder_nullable:
|
|
675 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow> cond_list r1 r2 (xs @ [x]) = rder x r2 # map (rder x) (cond_list r1 r2 xs)"
|
|
676 |
sorry
|
|
677 |
|
|
678 |
|
438
|
679 |
|
|
680 |
|
|
681 |
lemma seq_update_seq_ders:
|
|
682 |
shows "rsimp (rder c ( rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
683 |
(map (rders_simp r2) Ss))))) =
|
|
684 |
rsimp (RALTS ((RSEQ (rders_simp r1 (s @ [c])) r2) #
|
|
685 |
(map (rders_simp r2) (seq_update c (rders_simp r1 s) Ss)))) "
|
|
686 |
sorry
|
|
687 |
|
|
688 |
lemma seq_ders_closed_form1:
|
|
689 |
shows "\<exists>Ss. rders_simp (RSEQ r1 r2) [c] = rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) #
|
|
690 |
(map ( rders_simp r2 ) Ss)))"
|
|
691 |
apply(case_tac "rnullable r1")
|
|
692 |
apply(subgoal_tac " rders_simp (RSEQ r1 r2) [c] =
|
|
693 |
rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) # (map (rders_simp r2) [[c]])))")
|
|
694 |
prefer 2
|
|
695 |
apply (simp add: rsimp_idem)
|
|
696 |
apply(rule_tac x = "[[c]]" in exI)
|
|
697 |
apply simp
|
|
698 |
apply(subgoal_tac " rders_simp (RSEQ r1 r2) [c] =
|
|
699 |
rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) # (map (rders_simp r2) [])))")
|
|
700 |
apply blast
|
|
701 |
apply(simp add: rsimp_idem)
|
|
702 |
sorry
|
|
703 |
|
|
704 |
|
|
705 |
|
|
706 |
lemma seq_ders_closed_form:
|
|
707 |
shows "s \<noteq> [] \<Longrightarrow> \<exists>Ss. rders_simp (RSEQ r1 r2) s = rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
708 |
(map ( rders_simp r2 ) Ss)))"
|
|
709 |
apply(induct s rule: rev_induct)
|
|
710 |
apply simp
|
|
711 |
apply(case_tac xs)
|
|
712 |
using seq_ders_closed_form1 apply auto[1]
|
|
713 |
apply(subgoal_tac "\<exists>Ss. rders_simp (RSEQ r1 r2) xs = rsimp (RALTS (RSEQ (rders_simp r1 xs) r2 # map (rders_simp r2) Ss))")
|
|
714 |
prefer 2
|
|
715 |
|
|
716 |
apply blast
|
|
717 |
apply(erule exE)
|
|
718 |
apply(rule_tac x = "seq_update x (rders_simp r1 xs) Ss" in exI)
|
|
719 |
apply(subst rders_simp_append)
|
|
720 |
apply(subgoal_tac "rders_simp (rders_simp (RSEQ r1 r2) xs) [x] = rsimp (rder x (rders_simp (RSEQ r1 r2) xs))")
|
|
721 |
apply(simp only:)
|
|
722 |
apply(subst seq_update_seq_ders)
|
|
723 |
apply blast
|
|
724 |
using rders_simp_one_char by presburger
|
|
725 |
|
|
726 |
|
|
727 |
|
433
|
728 |
(*nullable_seq_with_list1 related *)
|
|
729 |
lemma LHS0_def_der_alt:
|
|
730 |
shows "rsimp (rder x (RALTS ( (RSEQ (rders_simp r1 xs) r2) # (cond_list r1 r2 xs)))) =
|
|
731 |
rsimp (RALTS ((rder x (RSEQ (rders_simp r1 xs) r2)) # (map (rder x) (cond_list r1 r2 xs))))"
|
|
732 |
by fastforce
|
|
733 |
|
|
734 |
lemma LHS1_def_der_seq:
|
|
735 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow>
|
|
736 |
rsimp (rder x (RALTS ( (RSEQ (rders_simp r1 xs) r2) # (cond_list r1 r2 xs)))) =
|
|
737 |
rsimp(RALTS ((RALTS ((RSEQ (rders_simp r1 (xs @ [x])) r2) # [rder x r2]) ) # (map (rder x ) (cond_list r1 r2 xs))))"
|
|
738 |
by (simp add: rders_simp_append rsimp_idem)
|
|
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
lemma cond_list_head_last:
|
|
745 |
shows "rnullable (rders r1 s) \<Longrightarrow>
|
|
746 |
RALTS (r # (cond_list r1 r2 (s @ [c]))) = RALTS (r # ((rder c r2) # (map (rder c) (cond_list r1 r2 s))))"
|
|
747 |
using suffix_plus1charn by blast
|
|
748 |
|
435
|
749 |
lemma simp_flatten2:
|
|
750 |
shows "rsimp (RALTS (r # [RALTS rs])) = rsimp (RALTS (r # rs))"
|
|
751 |
sorry
|
|
752 |
|
433
|
753 |
|
|
754 |
lemma simp_flatten:
|
|
755 |
shows "rsimp (RALTS ((RALTS rsa) # rsb)) = rsimp (RALTS (rsa @ rsb))"
|
|
756 |
|
|
757 |
sorry
|
|
758 |
|
|
759 |
lemma RHS1:
|
|
760 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow>
|
|
761 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs @ [x])) r2) #
|
|
762 |
(cond_list r1 r2 (xs @[x])))) =
|
|
763 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs @ [x])) r2) #
|
|
764 |
( ((rder x r2) # (map (rder x) (cond_list r1 r2 xs)))))) "
|
|
765 |
using first_elem_seqder_nullable by presburger
|
|
766 |
|
|
767 |
|
|
768 |
lemma nullable_seq_with_list1:
|
|
769 |
shows " rnullable (rders_simp r1 s) \<Longrightarrow>
|
|
770 |
rsimp (rder c (RALTS ( (RSEQ (rders_simp r1 s) r2) # (cond_list r1 r2 s)) )) =
|
|
771 |
rsimp (RALTS ( (RSEQ (rders_simp r1 (s @ [c])) r2) # (cond_list r1 r2 (s @ [c])) ) )"
|
434
|
772 |
using RHS1 LHS1_def_der_seq cond_list_head_last simp_flatten
|
|
773 |
by (metis append.left_neutral append_Cons)
|
|
774 |
|
|
775 |
|
|
776 |
(*^^^^^^^^^nullable_seq_with_list1 related ^^^^^^^^^^^^^^^^*)
|
|
777 |
|
|
778 |
|
|
779 |
|
|
780 |
|
|
781 |
|
|
782 |
|
433
|
783 |
|
|
784 |
|
|
785 |
|
|
786 |
|
|
787 |
lemma nullable_seq_with_list:
|
|
788 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow> rsimp (rder x (RALTS ((RSEQ (rders_simp r1 xs) r2) #
|
|
789 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs)) ))) =
|
|
790 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs@[x])) r2) #
|
|
791 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref (xs@[x]))) (orderedSuf (xs@[x]))) ) )
|
|
792 |
"
|
|
793 |
apply(subgoal_tac "rsimp (rder x (RALTS ((RSEQ (rders_simp r1 xs) r2) # (cond_list r1 r2 xs)))) =
|
|
794 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs@[x])) r2) # (cond_list r1 r2 (xs@[x]))))")
|
|
795 |
apply auto[1]
|
|
796 |
using nullable_seq_with_list1 by auto
|
|
797 |
|
|
798 |
|
|
799 |
|
|
800 |
|
|
801 |
lemma r1r2ders_whole:
|
|
802 |
"rsimp
|
|
803 |
(RALTS
|
|
804 |
(rder x (RSEQ (rders_simp r1 xs) r2) #
|
|
805 |
map (rder x) (rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs)))) =
|
|
806 |
rsimp( RALTS( ( (RSEQ (rders_simp r1 (xs@[x])) r2)
|
|
807 |
# (rders_cond_list r2 (nullable_bools r1 (orderedPref (xs @ [x]))) (orderedSuf (xs @ [x])))))) "
|
|
808 |
using ders_simp_nullability first_elem_seqdersimps nullable_seq_with_list1 suffix_plus1char by auto
|
|
809 |
|
|
810 |
lemma rders_simp_same_simpders:
|
|
811 |
shows "s \<noteq> [] \<Longrightarrow> rders_simp r s = rsimp (rders r s)"
|
|
812 |
apply(induct s rule: rev_induct)
|
|
813 |
apply simp
|
|
814 |
apply(case_tac "xs = []")
|
|
815 |
apply simp
|
|
816 |
apply(simp add: rders_append rders_simp_append)
|
|
817 |
using inside_simp_removal by blast
|
|
818 |
|
|
819 |
lemma shape_derssimp_seq:
|
|
820 |
shows "\<lbrakk>s \<noteq> []\<rbrakk> \<Longrightarrow> rders_simp (RSEQ r1 r2) s =
|
|
821 |
rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
822 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )"
|
|
823 |
|
|
824 |
apply(induct s arbitrary: r1 r2 rule: rev_induct)
|
|
825 |
apply simp
|
|
826 |
apply(case_tac "xs = []")
|
|
827 |
using shape_derssimpseq_onechar2 apply force
|
|
828 |
apply(simp only: rders_simp_append)
|
|
829 |
apply(simp only: rders_simp_one_char)
|
|
830 |
|
|
831 |
apply(subgoal_tac "rsimp (rder x (rders_simp (RSEQ r1 r2) xs))
|
|
832 |
= rsimp (rder x (RALTS(RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))")
|
|
833 |
prefer 2
|
|
834 |
using unfold_ders_simp_inside_only_nosimp apply presburger
|
|
835 |
apply(subgoal_tac "rsimp (rder x (RALTS (RSEQ (rders_simp r1 xs) r2
|
|
836 |
# rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs)))) =
|
|
837 |
rsimp ( (RALTS (rder x (RSEQ (rders_simp r1 xs) r2)
|
|
838 |
# (map (rder x) (rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))))
|
|
839 |
")
|
|
840 |
prefer 2
|
|
841 |
apply simp
|
|
842 |
using r1r2ders_whole rders_simp_append rders_simp_one_char by presburger
|
|
843 |
|
|
844 |
|
|
845 |
lemma shape_derssimp_alts:
|
|
846 |
shows "s \<noteq> [] \<Longrightarrow> rders_simp (RALTS rs) s = rsimp (RALTS (map (\<lambda>r. rders r s) rs))"
|
|
847 |
apply(case_tac "s")
|
|
848 |
apply simp
|
|
849 |
apply simp
|
|
850 |
sorry
|
|
851 |
(*
|
|
852 |
fun rexp_encode :: "rrexp \<Rightarrow> nat"
|
|
853 |
where
|
|
854 |
"rexp_encode RZERO = 0"
|
|
855 |
|"rexp_encode RONE = 1"
|
|
856 |
|"rexp_encode (RCHAR c) = 2"
|
|
857 |
|"rexp_encode (RSEQ r1 r2) = ( 2 ^ (rexp_encode r1)) "
|
|
858 |
*)
|
438
|
859 |
|
433
|
860 |
|
438
|
861 |
|
|
862 |
|
433
|
863 |
(*
|
|
864 |
fun rexp_enum :: "nat \<Rightarrow> rrexp list"
|
|
865 |
where
|
|
866 |
"rexp_enum 0 = []"
|
|
867 |
|"rexp_enum (Suc 0) = RALTS [] # RZERO # (RONE # (map RCHAR (all_chars 255)))"
|
|
868 |
|"rexp_enum (Suc n) = [(RSEQ r1 r2). r1 \<in> set (rexp_enum i) \<and> r2 \<in> set (rexp_enum j) \<and> i + j = n]"
|
|
869 |
|
|
870 |
*)
|
438
|
871 |
|
|
872 |
lemma non_zero_size:
|
|
873 |
shows "rsize r \<ge> Suc 0"
|
|
874 |
apply(induct r)
|
|
875 |
apply auto done
|
|
876 |
|
|
877 |
corollary size_geq1:
|
|
878 |
shows "rsize r \<ge> 1"
|
|
879 |
by (simp add: non_zero_size)
|
|
880 |
|
|
881 |
|
|
882 |
lemma rexp_size_induct:
|
|
883 |
shows "\<And>N r x5 a list.
|
|
884 |
\<lbrakk> rsize r = Suc N; r = RALTS x5;
|
|
885 |
x5 = a # list\<rbrakk> \<Longrightarrow>\<exists>i j. rsize a = i \<and> rsize (RALTS list) = j \<and> i + j = Suc N \<and> i \<le> N \<and> j \<le> N"
|
|
886 |
apply(rule_tac x = "rsize a" in exI)
|
|
887 |
apply(rule_tac x = "rsize (RALTS list)" in exI)
|
|
888 |
apply(subgoal_tac "rsize a \<ge> 1")
|
|
889 |
prefer 2
|
|
890 |
using One_nat_def non_zero_size apply presburger
|
|
891 |
apply(subgoal_tac "rsize (RALTS list) \<ge> 1 ")
|
|
892 |
prefer 2
|
|
893 |
using size_geq1 apply blast
|
|
894 |
apply simp
|
|
895 |
done
|
433
|
896 |
|
442
|
897 |
definition SEQ_set where
|
|
898 |
"SEQ_set A n \<equiv> {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A \<and> rsize r1 + rsize r2 \<le> n}"
|
438
|
899 |
|
442
|
900 |
definition SEQ_set_cartesian where
|
|
901 |
"SEQ_set_cartesian A n = {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A}"
|
441
|
902 |
|
442
|
903 |
definition ALT_set where
|
|
904 |
"ALT_set A n \<equiv> {RALTS rs | rs. set rs \<subseteq> A \<and> sum_list (map rsize rs) \<le> n}"
|
441
|
905 |
|
|
906 |
|
|
907 |
definition
|
|
908 |
"sizeNregex N \<equiv> {r. rsize r \<le> N}"
|
|
909 |
|
442
|
910 |
lemma sizenregex_induct:
|
|
911 |
shows "sizeNregex (Suc n) = sizeNregex n \<union> {RZERO, RONE, RALTS []} \<union> {RCHAR c| c. True} \<union>
|
|
912 |
SEQ_set ( sizeNregex n) n \<union> ALT_set (sizeNregex n) n \<union> (RSTAR ` (sizeNregex n))"
|
|
913 |
sorry
|
441
|
914 |
|
438
|
915 |
|
442
|
916 |
lemma chars_finite:
|
|
917 |
shows "finite (RCHAR ` (UNIV::(char set)))"
|
|
918 |
apply(simp)
|
|
919 |
done
|
|
920 |
|
|
921 |
thm full_SetCompr_eq
|
441
|
922 |
|
442
|
923 |
lemma size1finite:
|
|
924 |
shows "finite (sizeNregex (Suc 0))"
|
|
925 |
apply(subst sizenregex_induct)
|
|
926 |
apply(subst finite_Un)+
|
|
927 |
apply(subgoal_tac "sizeNregex 0 = {}")
|
|
928 |
apply(rule conjI)+
|
|
929 |
apply (metis Collect_empty_eq finite.emptyI non_zero_size not_less_eq_eq sizeNregex_def)
|
|
930 |
apply simp
|
|
931 |
apply (simp add: full_SetCompr_eq)
|
|
932 |
apply (simp add: SEQ_set_def)
|
|
933 |
apply (simp add: ALT_set_def)
|
|
934 |
apply(simp add: full_SetCompr_eq)
|
|
935 |
using non_zero_size not_less_eq_eq sizeNregex_def by fastforce
|
|
936 |
|
|
937 |
lemma seq_included_in_cart:
|
|
938 |
shows "SEQ_set A n \<subseteq> SEQ_set_cartesian A n"
|
|
939 |
sledgehammer
|
|
940 |
|
|
941 |
lemma finite_seq:
|
|
942 |
shows " finite (sizeNregex n) \<Longrightarrow> finite (SEQ_set (sizeNregex n) n)"
|
|
943 |
apply(rule finite_subset)
|
|
944 |
sorry
|
441
|
945 |
|
|
946 |
|
442
|
947 |
lemma finite_size_n:
|
|
948 |
shows "finite (sizeNregex n)"
|
|
949 |
apply(induct n)
|
|
950 |
apply (metis Collect_empty_eq finite.emptyI non_zero_size not_less_eq_eq sizeNregex_def)
|
|
951 |
apply(subst sizenregex_induct)
|
|
952 |
apply(subst finite_Un)+
|
|
953 |
apply(rule conjI)+
|
|
954 |
apply simp
|
|
955 |
apply simp
|
|
956 |
apply (simp add: full_SetCompr_eq)
|
|
957 |
|
|
958 |
sorry
|
433
|
959 |
|
|
960 |
(*below probably needs proved concurrently*)
|
|
961 |
|
|
962 |
lemma finite_r1r2_ders_list:
|
|
963 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
964 |
\<Longrightarrow> \<exists>l. \<forall>s.
|
|
965 |
(length (rdistinct (map rsimp (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) {}) ) < l "
|
|
966 |
sorry
|
|
967 |
|
|
968 |
(*
|
|
969 |
\<lbrakk>s \<noteq> []\<rbrakk> \<Longrightarrow> rders_simp (RSEQ r1 r2) s =
|
|
970 |
rsimp (RALTS ((RSEQ (rders r1 s) r2) #
|
|
971 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )
|
|
972 |
*)
|
|
973 |
|
|
974 |
|
|
975 |
lemma sum_list_size2:
|
|
976 |
shows "\<forall>z \<in>set rs. (rsize z ) \<le> Nr \<Longrightarrow> rlist_size rs \<le> (length rs) * Nr"
|
|
977 |
apply(induct rs)
|
|
978 |
apply simp
|
|
979 |
by simp
|
|
980 |
|
|
981 |
lemma sum_list_size:
|
|
982 |
fixes rs
|
|
983 |
shows " \<forall>r \<in> (set rs). (rsize r) \<le> Nr \<and> (length rs) \<le> l \<Longrightarrow> rlist_size rs \<le> l * Nr"
|
|
984 |
by (metis dual_order.trans mult.commute mult_le_mono2 mult_zero_right sum_list_size2 zero_le)
|
|
985 |
|
|
986 |
lemma seq_second_term_chain1:
|
|
987 |
shows " \<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) \<le>
|
|
988 |
rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))"
|
|
989 |
|
|
990 |
sorry
|
|
991 |
|
|
992 |
|
|
993 |
lemma seq_second_term_chain2:
|
|
994 |
shows "\<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) =
|
|
995 |
rlist_size (map rsimp (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)))"
|
|
996 |
|
|
997 |
oops
|
|
998 |
|
|
999 |
lemma seq_second_term_bounded:
|
|
1000 |
fixes r2 r1
|
|
1001 |
assumes "\<forall>s. rsize (rders_simp r2 s) < N2"
|
|
1002 |
shows "\<exists>N3. \<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) < N3"
|
|
1003 |
|
|
1004 |
sorry
|
|
1005 |
|
|
1006 |
|
|
1007 |
lemma seq_first_term_bounded:
|
|
1008 |
fixes r1 r2
|
|
1009 |
shows "\<exists>Nr. \<forall>s. rsize (rders_simp r1 s) \<le> Nr \<Longrightarrow> \<exists>Nr'. \<forall>s. rsize (RSEQ (rders_simp r1 s) r2) \<le> Nr'"
|
|
1010 |
apply(erule exE)
|
|
1011 |
apply(rule_tac x = "Nr + (rsize r2) + 1" in exI)
|
|
1012 |
by simp
|
|
1013 |
|
|
1014 |
|
|
1015 |
lemma alts_triangle_inequality:
|
|
1016 |
shows "rsize (RALTS (r # rs)) \<le> rsize r + rlist_size rs + 1 "
|
|
1017 |
apply(subgoal_tac "rsize (RALTS (r # rs) ) = rsize r + rlist_size rs + 1")
|
|
1018 |
apply auto[1]
|
|
1019 |
apply(induct rs)
|
|
1020 |
apply simp
|
|
1021 |
apply auto
|
|
1022 |
done
|
|
1023 |
|
|
1024 |
lemma seq_equal_term_nosimp_entire_bounded:
|
|
1025 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
1026 |
\<Longrightarrow> \<exists>N3. \<forall>s. rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1027 |
(rdistinct ((rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) ) {}) ) ) \<le> N3"
|
|
1028 |
apply(subgoal_tac "\<exists>N3. \<forall>s. rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1029 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) ) \<le>
|
|
1030 |
rsize (RSEQ (rders_simp r1 s) r2) +
|
|
1031 |
rlist_size (map rsimp (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) + 1")
|
|
1032 |
prefer 2
|
|
1033 |
using alts_triangle_inequality apply presburger
|
|
1034 |
using seq_first_term_bounded
|
|
1035 |
using seq_second_term_bounded
|
|
1036 |
apply(subgoal_tac "\<exists>N3. \<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) < N3")
|
|
1037 |
prefer 2
|
|
1038 |
apply meson
|
|
1039 |
apply(subgoal_tac "\<exists>Nr'. \<forall>s. rsize (RSEQ (rders_simp r1 s) r2) \<le> Nr'")
|
|
1040 |
prefer 2
|
|
1041 |
apply (meson order_le_less)
|
|
1042 |
apply(erule exE)
|
|
1043 |
apply(erule exE)
|
|
1044 |
sorry
|
|
1045 |
|
|
1046 |
lemma alts_simp_bounded_by_sloppy1_version:
|
|
1047 |
shows "\<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1048 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le>
|
|
1049 |
rsize (RALTS (rdistinct ((RSEQ (rders_simp r1 s) r2) #
|
|
1050 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
1051 |
)
|
|
1052 |
{}
|
|
1053 |
)
|
|
1054 |
) "
|
|
1055 |
sorry
|
|
1056 |
|
|
1057 |
lemma alts_simp_bounded_by_sloppy1:
|
|
1058 |
shows "rsize (rsimp (RALTS (rdistinct ((RSEQ (rders_simp r1 s) r2) #
|
|
1059 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
1060 |
)
|
|
1061 |
{}
|
|
1062 |
)
|
|
1063 |
)) \<le>
|
|
1064 |
rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1065 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
1066 |
)
|
|
1067 |
)"
|
|
1068 |
sorry
|
|
1069 |
|
435
|
1070 |
|
433
|
1071 |
|
|
1072 |
(*this section deals with the property of distinctBy: creates a list without duplicates*)
|
|
1073 |
lemma distinct_mono:
|
|
1074 |
shows "rlist_size (rdistinct (a # s) {}) \<le> rlist_size (a # (rdistinct s {}) )"
|
|
1075 |
sorry
|
|
1076 |
|
|
1077 |
lemma distinct_acc_mono:
|
|
1078 |
shows "A \<subseteq> B \<Longrightarrow> rlist_size (rdistinct s A) \<ge> rlist_size (rdistinct s B)"
|
|
1079 |
apply(induct s arbitrary: A B)
|
|
1080 |
apply simp
|
|
1081 |
apply(case_tac "a \<in> A")
|
|
1082 |
apply(subgoal_tac "a \<in> B")
|
|
1083 |
|
|
1084 |
apply simp
|
|
1085 |
|
|
1086 |
apply blast
|
|
1087 |
apply(subgoal_tac "rlist_size (rdistinct (a # s) A) = rlist_size (a # (rdistinct s (A \<union> {a})))")
|
|
1088 |
apply(case_tac "a \<in> B")
|
|
1089 |
apply(subgoal_tac "rlist_size (rdistinct (a # s) B) = rlist_size ( (rdistinct s B))")
|
|
1090 |
apply (metis Un_insert_right dual_order.trans insert_subset le_add_same_cancel2 rlist_size.simps(1) sup_bot_right zero_order(1))
|
|
1091 |
apply simp
|
|
1092 |
apply auto
|
|
1093 |
by (meson insert_mono)
|
|
1094 |
|
|
1095 |
|
|
1096 |
lemma distinct_mono2:
|
|
1097 |
shows " rlist_size (rdistinct s {a}) \<le> rlist_size (rdistinct s {})"
|
|
1098 |
apply(induct s)
|
|
1099 |
apply simp
|
|
1100 |
apply simp
|
|
1101 |
using distinct_acc_mono by auto
|
|
1102 |
|
|
1103 |
|
|
1104 |
|
|
1105 |
lemma distinct_mono_spares_first_elem:
|
|
1106 |
shows "rsize (RALTS (rdistinct (a # s) {})) \<le> rsize (RALTS (a # (rdistinct s {})))"
|
|
1107 |
apply simp
|
|
1108 |
apply (subgoal_tac "rlist_size ( (rdistinct s {a})) \<le> rlist_size ( (rdistinct s {})) ")
|
|
1109 |
using hand_made_def_rlist_size apply auto[1]
|
|
1110 |
using distinct_mono2 by auto
|
|
1111 |
|
|
1112 |
lemma sloppy1_bounded_by_sloppiest:
|
|
1113 |
shows "rsize (RALTS (rdistinct ((RSEQ (rders_simp r1 s) r2) #
|
|
1114 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
1115 |
)
|
|
1116 |
{}
|
|
1117 |
)
|
|
1118 |
) \<le> rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1119 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {})
|
|
1120 |
|
|
1121 |
|
|
1122 |
)
|
|
1123 |
)"
|
|
1124 |
|
|
1125 |
sorry
|
|
1126 |
|
|
1127 |
|
|
1128 |
lemma alts_simp_bounded_by_sloppiest_version:
|
|
1129 |
shows "\<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1130 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le>
|
|
1131 |
rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1132 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}) ) ) "
|
|
1133 |
by (meson alts_simp_bounded_by_sloppy1_version order_trans sloppy1_bounded_by_sloppiest)
|
|
1134 |
|
|
1135 |
|
|
1136 |
lemma seq_equal_term_entire_bounded:
|
|
1137 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
1138 |
\<Longrightarrow> \<exists>N3. \<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1139 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le> N3"
|
|
1140 |
using seq_equal_term_nosimp_entire_bounded
|
|
1141 |
apply(subgoal_tac " \<exists>N3. \<forall>s. rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1142 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}) ) ) \<le> N3")
|
|
1143 |
apply(erule exE)
|
|
1144 |
prefer 2
|
|
1145 |
apply blast
|
|
1146 |
apply(subgoal_tac "\<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1147 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le>
|
|
1148 |
rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
1149 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}) ) ) ")
|
|
1150 |
prefer 2
|
|
1151 |
using alts_simp_bounded_by_sloppiest_version apply blast
|
|
1152 |
apply(rule_tac x = "Suc N3 " in exI)
|
|
1153 |
apply(rule allI)
|
|
1154 |
|
|
1155 |
apply(subgoal_tac " rsize
|
|
1156 |
(rsimp
|
|
1157 |
(RALTS
|
|
1158 |
(RSEQ (rders_simp r1 s) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))))
|
|
1159 |
\<le> rsize
|
|
1160 |
(RALTS
|
|
1161 |
(RSEQ (rders_simp r1 s) r2 #
|
|
1162 |
rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}))")
|
|
1163 |
prefer 2
|
|
1164 |
apply presburger
|
|
1165 |
apply(subgoal_tac " rsize
|
|
1166 |
(RALTS
|
|
1167 |
(RSEQ (rders_simp r1 s) r2 #
|
|
1168 |
rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {})) \<le> N3")
|
|
1169 |
|
|
1170 |
apply linarith
|
|
1171 |
apply simp
|
|
1172 |
done
|
|
1173 |
|
|
1174 |
|
|
1175 |
|
|
1176 |
lemma M1seq:
|
|
1177 |
fixes r1 r2
|
|
1178 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
1179 |
\<Longrightarrow> \<exists>N3.\<forall>s.(rsize (rders_simp (RSEQ r1 r2) s)) < N3"
|
|
1180 |
apply(frule seq_equal_term_entire_bounded)
|
|
1181 |
apply(erule exE)
|
|
1182 |
apply(rule_tac x = "max (N3+2) (Suc (Suc (rsize r1) + (rsize r2)))" in exI)
|
|
1183 |
apply(rule allI)
|
|
1184 |
apply(case_tac "s = []")
|
|
1185 |
prefer 2
|
434
|
1186 |
apply (metis add_2_eq_Suc' le_imp_less_Suc less_SucI max.strict_coboundedI1 shape_derssimp_seq)
|
|
1187 |
by (metis add.assoc less_Suc_eq less_max_iff_disj plus_1_eq_Suc rders_simp.simps(1) rsize.simps(5))
|
|
1188 |
|
433
|
1189 |
(* apply (simp add: less_SucI shape_derssimp_seq(2))
|
|
1190 |
apply (meson less_SucI less_max_iff_disj)
|
|
1191 |
apply simp
|
|
1192 |
done*)
|
|
1193 |
|
|
1194 |
(*lemma empty_diff:
|
|
1195 |
shows "s = [] \<Longrightarrow>
|
|
1196 |
(rsize (rders_simp (RSEQ r1 r2) s)) \<le>
|
|
1197 |
(max
|
|
1198 |
(rsize (rsimp (RALTS (RSEQ (rders r1 s) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)))))
|
|
1199 |
(Suc (rsize r1 + rsize r2)) ) "
|
|
1200 |
apply simp
|
|
1201 |
done*)
|
|
1202 |
(*For star related bound*)
|
|
1203 |
|
|
1204 |
lemma star_is_a_singleton_list_derc:
|
434
|
1205 |
shows " \<exists>Ss. rders_simp (RSTAR r) [c] = rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))"
|
433
|
1206 |
apply simp
|
|
1207 |
apply(rule_tac x = "[[c]]" in exI)
|
|
1208 |
apply auto
|
434
|
1209 |
apply(case_tac "rsimp (rder c r)")
|
|
1210 |
apply simp
|
|
1211 |
apply auto
|
|
1212 |
apply(subgoal_tac "rsimp (RSEQ x41 x42) = RSEQ x41 x42")
|
|
1213 |
prefer 2
|
|
1214 |
apply (metis rsimp_idem)
|
|
1215 |
apply(subgoal_tac "rsimp x41 = x41")
|
|
1216 |
prefer 2
|
|
1217 |
using rsimp_inner_idem1 apply blast
|
|
1218 |
apply(subgoal_tac "rsimp x42 = x42")
|
|
1219 |
prefer 2
|
|
1220 |
using rsimp_inner_idem1 apply blast
|
|
1221 |
apply simp
|
|
1222 |
apply(subgoal_tac "map rsimp x5 = x5")
|
|
1223 |
prefer 2
|
|
1224 |
using rsimp_inner_idem3 apply blast
|
|
1225 |
apply simp
|
|
1226 |
apply(subgoal_tac "rflts x5 = x5")
|
|
1227 |
prefer 2
|
|
1228 |
using rsimp_inner_idem4 apply blast
|
|
1229 |
apply simp
|
|
1230 |
using rsimp_inner_idem4 by auto
|
|
1231 |
|
|
1232 |
|
433
|
1233 |
|
|
1234 |
lemma rder_rsimp_ALTs_commute:
|
|
1235 |
shows " (rder x (rsimp_ALTs rs)) = rsimp_ALTs (map (rder x) rs)"
|
|
1236 |
apply(induct rs)
|
|
1237 |
apply simp
|
|
1238 |
apply(case_tac rs)
|
|
1239 |
apply simp
|
|
1240 |
apply auto
|
|
1241 |
done
|
|
1242 |
|
434
|
1243 |
|
433
|
1244 |
|
|
1245 |
fun star_update :: "char \<Rightarrow> rrexp \<Rightarrow> char list list => char list list" where
|
|
1246 |
"star_update c r [] = []"
|
|
1247 |
|"star_update c r (s # Ss) = (if (rnullable (rders_simp r s))
|
|
1248 |
then (s@[c]) # [c] # (star_update c r Ss)
|
435
|
1249 |
else (s@[c]) # (star_update c r Ss) )"
|
433
|
1250 |
|
434
|
1251 |
lemma star_update_case1:
|
|
1252 |
shows "rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # [c] # (star_update c r Ss)"
|
|
1253 |
|
|
1254 |
by force
|
|
1255 |
|
|
1256 |
lemma star_update_case2:
|
435
|
1257 |
shows "\<not>rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # (star_update c r Ss)"
|
|
1258 |
by simp
|
|
1259 |
|
|
1260 |
lemma bubble_break: shows "rflts [r, RZERO] = rflts [r]"
|
|
1261 |
apply(case_tac r)
|
|
1262 |
apply simp+
|
|
1263 |
done
|
|
1264 |
|
|
1265 |
lemma rsimp_alts_idem_aux1:
|
|
1266 |
shows "rsimp_ALTs (rdistinct (rflts [rsimp a]) {}) = rsimp (RALTS [a])"
|
|
1267 |
by force
|
|
1268 |
|
|
1269 |
|
|
1270 |
|
|
1271 |
lemma rsimp_alts_idem_aux2:
|
|
1272 |
shows "rsimp a = rsimp (RALTS [a])"
|
|
1273 |
apply(simp)
|
|
1274 |
apply(case_tac "rsimp a")
|
|
1275 |
apply simp+
|
|
1276 |
apply (metis no_alt_short_list_after_simp no_further_dB_after_simp)
|
434
|
1277 |
by simp
|
|
1278 |
|
|
1279 |
lemma rsimp_alts_idem:
|
|
1280 |
shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs (a # [(rsimp (rsimp_ALTs as))] ))"
|
435
|
1281 |
apply(induct as)
|
|
1282 |
apply(subgoal_tac "rsimp (rsimp_ALTs [a, rsimp (rsimp_ALTs [])]) = rsimp (rsimp_ALTs [a, RZERO])")
|
|
1283 |
prefer 2
|
|
1284 |
apply simp
|
|
1285 |
using bubble_break rsimp_alts_idem_aux2 apply auto[1]
|
|
1286 |
apply(case_tac as)
|
|
1287 |
apply(subgoal_tac "rsimp_ALTs( aa # as) = aa")
|
|
1288 |
prefer 2
|
|
1289 |
apply simp
|
|
1290 |
using head_one_more_simp apply fastforce
|
|
1291 |
apply(subgoal_tac "rsimp_ALTs (aa # as) = RALTS (aa # as)")
|
|
1292 |
prefer 2
|
|
1293 |
|
|
1294 |
using rsimp_ALTs.simps(3) apply presburger
|
|
1295 |
|
|
1296 |
apply(simp only:)
|
|
1297 |
apply(subgoal_tac "rsimp_ALTs (a # aa # aaa # list) = RALTS (a # aa # aaa # list)")
|
|
1298 |
prefer 2
|
|
1299 |
using rsimp_ALTs.simps(3) apply presburger
|
|
1300 |
apply(simp only:)
|
|
1301 |
apply(subgoal_tac "rsimp_ALTs [a, rsimp (RALTS (aa # aaa # list))] = RALTS (a # [rsimp (RALTS (aa # aaa # list))])")
|
|
1302 |
prefer 2
|
|
1303 |
|
|
1304 |
using rsimp_ALTs.simps(3) apply presburger
|
|
1305 |
apply(simp only:)
|
|
1306 |
using simp_flatten2
|
|
1307 |
apply(subgoal_tac " rsimp (RALT a (rsimp (RALTS (aa # aaa # list)))) = rsimp (RALT a ((RALTS (aa # aaa # list)))) ")
|
|
1308 |
prefer 2
|
|
1309 |
|
|
1310 |
apply (metis head_one_more_simp list.simps(9) rsimp.simps(2))
|
|
1311 |
apply (simp only:)
|
|
1312 |
done
|
|
1313 |
|
434
|
1314 |
|
|
1315 |
lemma rsimp_alts_idem2:
|
|
1316 |
shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs ((rsimp a) # [(rsimp (rsimp_ALTs as))] ))"
|
435
|
1317 |
using head_one_more_simp rsimp_alts_idem by auto
|
|
1318 |
|
434
|
1319 |
|
|
1320 |
lemma evolution_step1:
|
|
1321 |
shows "rsimp
|
|
1322 |
(rsimp_ALTs
|
|
1323 |
(rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1324 |
rsimp
|
|
1325 |
(rsimp_ALTs
|
|
1326 |
(rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # [(rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)))])) "
|
|
1327 |
using rsimp_alts_idem by auto
|
|
1328 |
|
|
1329 |
lemma evolution_step2:
|
|
1330 |
assumes " rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1331 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))"
|
|
1332 |
shows "rsimp
|
|
1333 |
(rsimp_ALTs
|
|
1334 |
(rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1335 |
rsimp
|
|
1336 |
(rsimp_ALTs
|
|
1337 |
(rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # [ rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))])) "
|
|
1338 |
by (simp add: assms rsimp_alts_idem)
|
|
1339 |
|
435
|
1340 |
lemma rsimp_seq_aux1:
|
|
1341 |
shows "r = RONE \<and> r2 = RSTAR r0 \<Longrightarrow> rsimp_SEQ r r2 = r2"
|
|
1342 |
apply simp
|
|
1343 |
done
|
|
1344 |
|
|
1345 |
lemma multiple_alts_simp_flatten:
|
|
1346 |
shows "rsimp (RALT (RALT r1 r2) (rsimp_ALTs rs)) = rsimp (RALTS (r1 # r2 # rs))"
|
|
1347 |
by (metis Cons_eq_appendI append_self_conv2 rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) rsimp_alts_idem simp_flatten)
|
|
1348 |
|
|
1349 |
|
|
1350 |
lemma evo3_main_aux1:
|
|
1351 |
shows "rsimp
|
|
1352 |
(RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
|
|
1353 |
(rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) =
|
|
1354 |
rsimp
|
|
1355 |
(RALTS
|
|
1356 |
(RSEQ (rders_simp r (a @ [x])) (RSTAR r) #
|
|
1357 |
RSEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))"
|
|
1358 |
apply(subgoal_tac "rsimp
|
|
1359 |
(RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
|
|
1360 |
(rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) =
|
|
1361 |
rsimp
|
|
1362 |
(RALT (RALT (RSEQ ( (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
|
|
1363 |
(rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) ")
|
|
1364 |
prefer 2
|
|
1365 |
apply (simp add: rsimp_idem)
|
|
1366 |
apply (simp only:)
|
|
1367 |
apply(subst multiple_alts_simp_flatten)
|
|
1368 |
by simp
|
|
1369 |
|
|
1370 |
|
|
1371 |
lemma evo3_main_nullable:
|
|
1372 |
shows "
|
|
1373 |
\<And>a Ss.
|
|
1374 |
\<lbrakk>rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1375 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)));
|
|
1376 |
rders_simp r a \<noteq> RONE; rders_simp r a \<noteq> RZERO; rnullable (rders_simp r a)\<rbrakk>
|
|
1377 |
\<Longrightarrow> rsimp
|
|
1378 |
(rsimp_ALTs
|
|
1379 |
[rder x (RSEQ (rders_simp r a) (RSTAR r)),
|
|
1380 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
|
|
1381 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
|
|
1382 |
apply(subgoal_tac "rder x (RSEQ (rders_simp r a) (RSTAR r))
|
|
1383 |
= RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r))")
|
|
1384 |
prefer 2
|
|
1385 |
apply simp
|
|
1386 |
apply(simp only:)
|
|
1387 |
apply(subgoal_tac "star_update x r (a # Ss) = (a @ [x]) # [x] # (star_update x r Ss)")
|
|
1388 |
prefer 2
|
|
1389 |
using star_update_case1 apply presburger
|
|
1390 |
apply(simp only:)
|
|
1391 |
apply(subst List.list.map(2))+
|
|
1392 |
apply(subgoal_tac "rsimp
|
|
1393 |
(rsimp_ALTs
|
|
1394 |
[RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r)),
|
|
1395 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
|
|
1396 |
rsimp
|
|
1397 |
(RALTS
|
|
1398 |
[RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r)),
|
|
1399 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))])")
|
|
1400 |
prefer 2
|
|
1401 |
using rsimp_ALTs.simps(3) apply presburger
|
|
1402 |
apply(simp only:)
|
|
1403 |
apply(subgoal_tac " rsimp
|
|
1404 |
(rsimp_ALTs
|
|
1405 |
(rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
|
|
1406 |
rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))
|
|
1407 |
=
|
|
1408 |
rsimp
|
|
1409 |
(RALTS
|
|
1410 |
(rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
|
|
1411 |
rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))")
|
|
1412 |
|
|
1413 |
prefer 2
|
|
1414 |
using rsimp_ALTs.simps(3) apply presburger
|
|
1415 |
apply (simp only:)
|
|
1416 |
apply(subgoal_tac " rsimp
|
|
1417 |
(RALT (RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ ( (rder x r)) (RSTAR r)))
|
|
1418 |
(rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) =
|
|
1419 |
rsimp
|
|
1420 |
(RALT (RALT (RSEQ (rsimp (rder x (rders_simp r a))) (RSTAR r)) (RSEQ (rsimp (rder x r)) (RSTAR r)))
|
|
1421 |
(rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))")
|
|
1422 |
prefer 2
|
|
1423 |
apply (simp add: rsimp_idem)
|
|
1424 |
apply(simp only:)
|
|
1425 |
apply(subgoal_tac " rsimp
|
|
1426 |
(RALT (RALT (RSEQ (rsimp (rder x (rders_simp r a))) (RSTAR r)) (RSEQ (rsimp (rder x r)) (RSTAR r)))
|
|
1427 |
(rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) =
|
|
1428 |
rsimp
|
|
1429 |
(RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
|
|
1430 |
(rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))")
|
|
1431 |
prefer 2
|
|
1432 |
using rders_simp_append rders_simp_one_char rsimp_idem apply presburger
|
|
1433 |
apply(simp only:)
|
|
1434 |
apply(subgoal_tac " rsimp
|
|
1435 |
(RALTS
|
|
1436 |
(rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
|
|
1437 |
rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) =
|
|
1438 |
rsimp
|
|
1439 |
(RALTS
|
|
1440 |
(RSEQ (rders_simp r (a @ [x])) (RSTAR r) #
|
|
1441 |
RSEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))")
|
|
1442 |
prefer 2
|
|
1443 |
apply (smt (z3) idiot2 list.simps(9) rrexp.distinct(9) rsimp.simps(1) rsimp.simps(2) rsimp.simps(3) rsimp.simps(4) rsimp.simps(6) rsimp_idem)
|
|
1444 |
apply(simp only:)
|
|
1445 |
apply(subgoal_tac " rsimp
|
|
1446 |
(RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
|
|
1447 |
(rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) =
|
|
1448 |
rsimp
|
|
1449 |
(RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
|
|
1450 |
( (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) ")
|
|
1451 |
prefer 2
|
|
1452 |
using rsimp_idem apply force
|
|
1453 |
apply(simp only:)
|
|
1454 |
using evo3_main_aux1 by blast
|
|
1455 |
|
|
1456 |
|
|
1457 |
lemma evo3_main_not1:
|
|
1458 |
shows " \<not>rnullable (rders_simp r a) \<Longrightarrow> rder x (RSEQ (rders_simp r a) (RSTAR r)) = RSEQ (rder x (rders_simp r a)) (RSTAR r)"
|
|
1459 |
by fastforce
|
|
1460 |
|
|
1461 |
|
|
1462 |
lemma evo3_main_not2:
|
|
1463 |
shows "\<not>rnullable (rders_simp r a) \<Longrightarrow> rsimp
|
|
1464 |
(rsimp_ALTs
|
|
1465 |
(rder x (RSEQ (rders_simp r a) (RSTAR r)) # rs)) = rsimp
|
|
1466 |
(rsimp_ALTs
|
|
1467 |
((RSEQ (rders_simp r (a @ [x])) (RSTAR r)) # rs))"
|
|
1468 |
by (simp add: rders_simp_append rsimp_alts_idem2 rsimp_idem)
|
|
1469 |
|
|
1470 |
lemma evo3_main_not3:
|
|
1471 |
shows "rsimp
|
|
1472 |
(rsimp_ALTs
|
|
1473 |
(rsimp_SEQ r1 (RSTAR r) # rs)) =
|
|
1474 |
rsimp (rsimp_ALTs
|
|
1475 |
(RSEQ r1 (RSTAR r) # rs))"
|
|
1476 |
by (metis idiot2 rrexp.distinct(9) rsimp.simps(1) rsimp.simps(3) rsimp.simps(4) rsimp.simps(6) rsimp_alts_idem rsimp_alts_idem2)
|
|
1477 |
|
|
1478 |
|
|
1479 |
lemma evo3_main_notnullable:
|
|
1480 |
shows "\<And>a Ss.
|
|
1481 |
\<lbrakk>rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1482 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)));
|
|
1483 |
rders_simp r a \<noteq> RONE; rders_simp r a \<noteq> RZERO; \<not>rnullable (rders_simp r a)\<rbrakk>
|
|
1484 |
\<Longrightarrow> rsimp
|
|
1485 |
(rsimp_ALTs
|
|
1486 |
[rder x (RSEQ (rders_simp r a) (RSTAR r)),
|
|
1487 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
|
|
1488 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
|
|
1489 |
apply(subst star_update_case2)
|
|
1490 |
apply simp
|
|
1491 |
apply(subst List.list.map(2))
|
|
1492 |
apply(subst evo3_main_not2)
|
|
1493 |
apply simp
|
|
1494 |
apply(subst evo3_main_not3)
|
|
1495 |
using rsimp_alts_idem by presburger
|
|
1496 |
|
|
1497 |
|
|
1498 |
lemma evo3_aux2:
|
|
1499 |
shows "rders_simp r a = RONE \<Longrightarrow> rsimp_SEQ (rders_simp (rders_simp r a) [x]) (RSTAR r) = RZERO"
|
|
1500 |
by simp
|
|
1501 |
lemma evo3_aux3:
|
|
1502 |
shows "rsimp (rsimp_ALTs (RZERO # rs)) = rsimp (rsimp_ALTs rs)"
|
|
1503 |
by (metis list.simps(8) list.simps(9) rdistinct.simps(1) rflts.simps(1) rflts.simps(2) rsimp.simps(2) rsimp_ALTs.simps(1) rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) rsimp_alts_idem)
|
|
1504 |
|
|
1505 |
lemma evo3_aux4:
|
|
1506 |
shows " rsimp
|
|
1507 |
(rsimp_ALTs
|
|
1508 |
[RSEQ (rder x r) (RSTAR r),
|
|
1509 |
rsimp (rsimp_ALTs rs)]) =
|
|
1510 |
rsimp
|
|
1511 |
(rsimp_ALTs
|
|
1512 |
(rsimp_SEQ (rders_simp r [x]) (RSTAR r) # rs))"
|
|
1513 |
by (metis rders_simp_one_char rsimp.simps(1) rsimp.simps(6) rsimp_alts_idem rsimp_alts_idem2)
|
|
1514 |
|
|
1515 |
lemma evo3_aux5:
|
|
1516 |
shows "rders_simp r a \<noteq> RONE \<and> rders_simp r a \<noteq> RZERO \<Longrightarrow> rsimp_SEQ (rders_simp r a) (RSTAR r) = RSEQ (rders_simp r a) (RSTAR r)"
|
|
1517 |
using idiot2 by blast
|
|
1518 |
|
|
1519 |
|
|
1520 |
lemma evolution_step3:
|
|
1521 |
shows" \<And>a Ss.
|
|
1522 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1523 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) \<Longrightarrow>
|
|
1524 |
rsimp
|
|
1525 |
(rsimp_ALTs
|
|
1526 |
[rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)),
|
|
1527 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
|
|
1528 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
|
|
1529 |
apply(case_tac "rders_simp r a = RONE")
|
|
1530 |
apply(subst rsimp_seq_aux1)
|
|
1531 |
apply simp
|
|
1532 |
apply(subst rder.simps(6))
|
|
1533 |
apply(subgoal_tac "rnullable (rders_simp r a)")
|
|
1534 |
prefer 2
|
|
1535 |
using rnullable.simps(2) apply presburger
|
|
1536 |
apply(subst star_update_case1)
|
|
1537 |
apply simp
|
|
1538 |
|
|
1539 |
apply(subst List.list.map)+
|
|
1540 |
apply(subst rders_simp_append)
|
|
1541 |
apply(subst evo3_aux2)
|
|
1542 |
apply simp
|
|
1543 |
apply(subst evo3_aux3)
|
|
1544 |
apply(subst evo3_aux4)
|
|
1545 |
apply simp
|
|
1546 |
apply(case_tac "rders_simp r a = RZERO")
|
|
1547 |
|
|
1548 |
apply (simp add: rsimp_alts_idem2)
|
|
1549 |
apply(subgoal_tac "rders_simp r (a @ [x]) = RZERO")
|
|
1550 |
prefer 2
|
|
1551 |
using rder.simps(1) rders_simp_append rders_simp_one_char rsimp.simps(3) apply presburger
|
|
1552 |
using rflts.simps(2) rsimp.simps(3) rsimp_SEQ.simps(1) apply presburger
|
|
1553 |
apply(subst evo3_aux5)
|
|
1554 |
apply simp
|
|
1555 |
apply(case_tac "rnullable (rders_simp r a) ")
|
|
1556 |
using evo3_main_nullable apply blast
|
|
1557 |
using evo3_main_notnullable apply blast
|
|
1558 |
done
|
434
|
1559 |
|
|
1560 |
(*
|
|
1561 |
proof (prove)
|
|
1562 |
goal (1 subgoal):
|
|
1563 |
1. map f (a # s) = f a # map f s
|
|
1564 |
Auto solve_direct: the current goal can be solved directly with
|
|
1565 |
HOL.nitpick_simp(115): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
|
|
1566 |
List.list.map(2): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
|
|
1567 |
List.list.simps(9): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
|
|
1568 |
*)
|
433
|
1569 |
lemma starseq_list_evolution:
|
|
1570 |
fixes r :: rrexp and Ss :: "char list list" and x :: char
|
|
1571 |
shows "rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss) ) =
|
|
1572 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)) )"
|
|
1573 |
apply(induct Ss)
|
434
|
1574 |
apply simp
|
|
1575 |
apply(subst List.list.map(2))
|
|
1576 |
apply(subst evolution_step2)
|
|
1577 |
apply simp
|
435
|
1578 |
|
|
1579 |
|
433
|
1580 |
sorry
|
|
1581 |
|
|
1582 |
|
|
1583 |
lemma star_seqs_produce_star_seqs:
|
|
1584 |
shows "rsimp (rsimp_ALTs (map (rder x \<circ> (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss))
|
|
1585 |
= rsimp (rsimp_ALTs (map ( (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss))"
|
|
1586 |
by (meson comp_apply)
|
|
1587 |
|
434
|
1588 |
lemma map_der_lambda_composition:
|
|
1589 |
shows "map (rder x) (map (\<lambda>s. f s) Ss) = map (\<lambda>s. (rder x (f s))) Ss"
|
|
1590 |
by force
|
|
1591 |
|
|
1592 |
lemma ralts_vs_rsimpalts:
|
|
1593 |
shows "rsimp (RALTS rs) = rsimp (rsimp_ALTs rs)"
|
435
|
1594 |
by (metis evo3_aux3 rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) simp_flatten2)
|
|
1595 |
|
433
|
1596 |
|
|
1597 |
lemma linearity_of_list_of_star_or_starseqs:
|
|
1598 |
fixes r::rrexp and Ss::"char list list" and x::char
|
|
1599 |
shows "\<exists>Ssa. rsimp (rder x (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))) =
|
434
|
1600 |
rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ssa)))"
|
|
1601 |
apply(subst rder_rsimp_ALTs_commute)
|
|
1602 |
apply(subst map_der_lambda_composition)
|
|
1603 |
using starseq_list_evolution
|
|
1604 |
apply(rule_tac x = "star_update x r Ss" in exI)
|
|
1605 |
apply(subst ralts_vs_rsimpalts)
|
|
1606 |
by simp
|
|
1607 |
|
433
|
1608 |
|
|
1609 |
|
434
|
1610 |
(*certified correctness---does not depend on any previous sorry*)
|
|
1611 |
lemma star_list_push_der: shows " \<lbrakk>xs \<noteq> [] \<Longrightarrow> \<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss));
|
|
1612 |
xs @ [x] \<noteq> []; xs \<noteq> []\<rbrakk> \<Longrightarrow>
|
|
1613 |
\<exists>Ss. rders_simp (RSTAR r ) (xs @ [x]) =
|
|
1614 |
rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) )"
|
|
1615 |
apply(subgoal_tac "\<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))")
|
|
1616 |
prefer 2
|
|
1617 |
apply blast
|
|
1618 |
apply(erule exE)
|
|
1619 |
apply(subgoal_tac "rders_simp (RSTAR r) (xs @ [x]) = rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
|
|
1620 |
prefer 2
|
|
1621 |
using rders_simp_append
|
|
1622 |
using rders_simp_one_char apply presburger
|
|
1623 |
apply(rule_tac x= "Ss" in exI)
|
|
1624 |
apply(subgoal_tac " rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
|
|
1625 |
rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
|
|
1626 |
prefer 2
|
|
1627 |
using inside_simp_removal rsimp_idem apply presburger
|
|
1628 |
apply(subgoal_tac "rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
|
|
1629 |
rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
|
|
1630 |
prefer 2
|
|
1631 |
using rder.simps(4) apply presburger
|
|
1632 |
apply(subgoal_tac "rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
|
|
1633 |
rsimp (rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss)))")
|
|
1634 |
apply (metis rsimp_idem)
|
|
1635 |
by (metis map_der_lambda_composition)
|
|
1636 |
|
|
1637 |
lemma simp_in_lambdas :
|
|
1638 |
shows "
|
|
1639 |
rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) ) =
|
|
1640 |
rsimp (RALTS (map (\<lambda>s1. (rsimp (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))))) Ss))"
|
|
1641 |
by (metis (no_types, lifting) comp_apply list.map_comp map_eq_conv rsimp.simps(2) rsimp_idem)
|
|
1642 |
|
433
|
1643 |
|
|
1644 |
lemma starder_is_a_list_of_stars_or_starseqs:
|
434
|
1645 |
shows "s \<noteq> [] \<Longrightarrow> \<exists>Ss. rders_simp (RSTAR r) s = rsimp (RALTS( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))"
|
433
|
1646 |
apply(induct s rule: rev_induct)
|
|
1647 |
apply simp
|
|
1648 |
apply(case_tac "xs = []")
|
|
1649 |
using star_is_a_singleton_list_derc
|
434
|
1650 |
apply(simp)
|
|
1651 |
apply(subgoal_tac "\<exists>Ss. rders_simp (RSTAR r) (xs @ [x]) =
|
|
1652 |
rsimp (RALTS (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss))")
|
|
1653 |
prefer 2
|
|
1654 |
using star_list_push_der apply presburger
|
|
1655 |
|
|
1656 |
|
435
|
1657 |
by (metis ralts_vs_rsimpalts starseq_list_evolution)
|
|
1658 |
|
|
1659 |
|
|
1660 |
lemma starder_is_a_list:
|
|
1661 |
shows " \<exists>Ss. rders_simp (RSTAR r) s = rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))) \<or> rders_simp (RSTAR r) s = RSTAR r"
|
|
1662 |
apply(case_tac s)
|
|
1663 |
prefer 2
|
|
1664 |
apply (metis neq_Nil_conv starder_is_a_list_of_stars_or_starseqs)
|
|
1665 |
apply simp
|
|
1666 |
done
|
|
1667 |
|
|
1668 |
|
|
1669 |
(** start about bounds here**)
|
|
1670 |
|
|
1671 |
|
|
1672 |
lemma list_simp_size:
|
|
1673 |
shows "rlist_size (map rsimp rs) \<le> rlist_size rs"
|
|
1674 |
apply(induct rs)
|
|
1675 |
apply simp
|
|
1676 |
apply simp
|
|
1677 |
apply (subgoal_tac "rsize (rsimp a) \<le> rsize a")
|
|
1678 |
prefer 2
|
|
1679 |
using rsimp_mono apply fastforce
|
|
1680 |
using add_le_mono by presburger
|
|
1681 |
|
|
1682 |
lemma inside_list_simp_inside_list:
|
|
1683 |
shows "r \<in> set rs \<Longrightarrow> rsimp r \<in> set (map rsimp rs)"
|
|
1684 |
apply (induct rs)
|
|
1685 |
apply simp
|
|
1686 |
apply auto
|
|
1687 |
done
|
|
1688 |
|
|
1689 |
|
|
1690 |
lemma rsize_star_seq_list:
|
|
1691 |
shows "(\<forall>s. rsize (rders_simp r0 s) < N0 ) \<Longrightarrow> \<exists>N3.\<forall>Ss.
|
|
1692 |
rlist_size (rdistinct (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss) {}) < N3"
|
434
|
1693 |
sorry
|
433
|
1694 |
|
|
1695 |
|
435
|
1696 |
lemma rdistinct_bound_by_no_simp:
|
|
1697 |
shows "
|
|
1698 |
|
|
1699 |
rlist_size (rdistinct (map rsimp rs) (set (map rsimp ss)))
|
|
1700 |
\<le> (rlist_size (rdistinct rs (set ss)))
|
|
1701 |
"
|
|
1702 |
apply(induct rs arbitrary: ss)
|
|
1703 |
apply simp
|
|
1704 |
apply(case_tac "a \<in> set ss")
|
|
1705 |
apply(subgoal_tac "rsimp a \<in> set (map rsimp ss)")
|
|
1706 |
prefer 2
|
|
1707 |
using inside_list_simp_inside_list apply blast
|
|
1708 |
|
|
1709 |
apply simp
|
|
1710 |
apply simp
|
|
1711 |
by (metis List.set_insert add_le_mono image_insert insert_absorb rsimp_mono trans_le_add2)
|
|
1712 |
|
|
1713 |
|
|
1714 |
lemma starder_closed_form_bound_aux1:
|
|
1715 |
shows
|
|
1716 |
"\<forall>Ss. rsize (rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss)))) \<le>
|
|
1717 |
Suc (rlist_size ( (rdistinct ( ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss))) {}))) "
|
|
1718 |
|
|
1719 |
sorry
|
|
1720 |
|
|
1721 |
lemma starder_closed_form_bound:
|
|
1722 |
shows "(\<forall>s. rsize (rders_simp r0 s) < N0 ) \<Longrightarrow> \<exists>N3.\<forall>Ss.
|
|
1723 |
rsize(rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss)))) < N3"
|
|
1724 |
apply(subgoal_tac " \<exists>N3.\<forall>Ss.
|
|
1725 |
rlist_size (rdistinct (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss) {}) < N3")
|
|
1726 |
prefer 2
|
|
1727 |
|
|
1728 |
using rsize_star_seq_list apply auto[1]
|
|
1729 |
apply(erule exE)
|
|
1730 |
apply(rule_tac x = "Suc N3" in exI)
|
|
1731 |
apply(subgoal_tac "\<forall>Ss. rsize (rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss)))) \<le>
|
|
1732 |
Suc (rlist_size ( (rdistinct ( ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss))) {})))")
|
|
1733 |
prefer 2
|
|
1734 |
using starder_closed_form_bound_aux1 apply blast
|
|
1735 |
by (meson less_trans_Suc linorder_not_le not_less_eq)
|
|
1736 |
|
|
1737 |
|
|
1738 |
thm starder_closed_form_bound_aux1
|
|
1739 |
|
|
1740 |
(*
|
|
1741 |
"ralts_vs_rsimpalts", , and "starder_closed_form_bound_aux1", which could be due to a bug in Sledgehammer or to inconsistent axioms (including "sorry"s)
|
|
1742 |
*)
|
|
1743 |
|
|
1744 |
lemma starder_size_bound:
|
|
1745 |
shows "(\<forall>s. rsize (rders_simp r0 s) < N0 ) \<Longrightarrow> \<exists>N3.\<forall>Ss.
|
|
1746 |
rsize(rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss)))) < N3 \<and>
|
|
1747 |
rsize (RSTAR r0) < N3"
|
|
1748 |
apply(subgoal_tac " \<exists>N3.\<forall>Ss.
|
|
1749 |
rsize(rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss)))) < N3")
|
|
1750 |
prefer 2
|
|
1751 |
using starder_closed_form_bound apply blast
|
|
1752 |
apply(erule exE)
|
|
1753 |
apply(rule_tac x = "max N3 (Suc (rsize (RSTAR r0)))" in exI)
|
|
1754 |
using less_max_iff_disj by blast
|
|
1755 |
|
|
1756 |
|
|
1757 |
|
|
1758 |
|
433
|
1759 |
lemma finite_star:
|
|
1760 |
shows "(\<forall>s. rsize (rders_simp r0 s) < N0 )
|
|
1761 |
\<Longrightarrow> \<exists>N3. \<forall>s.(rsize (rders_simp (RSTAR r0) s)) < N3"
|
435
|
1762 |
apply(subgoal_tac " \<exists>N3. \<forall>Ss.
|
|
1763 |
rsize(rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r0 s1) (RSTAR r0)) Ss)))) < N3 \<and>
|
|
1764 |
rsize (RSTAR r0) < N3")
|
|
1765 |
prefer 2
|
|
1766 |
using starder_size_bound apply blast
|
|
1767 |
apply(erule exE)
|
|
1768 |
apply(rule_tac x = N3 in exI)
|
|
1769 |
by (metis starder_is_a_list)
|
433
|
1770 |
|
|
1771 |
|
|
1772 |
lemma rderssimp_zero:
|
|
1773 |
shows"rders_simp RZERO s = RZERO"
|
|
1774 |
apply(induction s)
|
|
1775 |
apply simp
|
|
1776 |
by simp
|
|
1777 |
|
|
1778 |
lemma rderssimp_one:
|
|
1779 |
shows"rders_simp RONE (a # s) = RZERO"
|
|
1780 |
apply(induction s)
|
|
1781 |
apply simp
|
|
1782 |
by simp
|
|
1783 |
|
|
1784 |
lemma rderssimp_char:
|
|
1785 |
shows "rders_simp (RCHAR c) s = RONE \<or> rders_simp (RCHAR c) s = RZERO \<or> rders_simp (RCHAR c) s = (RCHAR c)"
|
|
1786 |
apply auto
|
|
1787 |
by (metis rder.simps(2) rder.simps(3) rders_simp.elims rders_simp.simps(2) rderssimp_one rsimp.simps(4))
|
|
1788 |
|
|
1789 |
lemma finite_size_ders:
|
|
1790 |
fixes r
|
|
1791 |
shows " \<exists>Nr. \<forall>s. rsize (rders_simp r s) < Nr"
|
|
1792 |
apply(induct r rule: rrexp.induct)
|
|
1793 |
apply auto
|
|
1794 |
apply(rule_tac x = "2" in exI)
|
|
1795 |
using rderssimp_zero rsize.simps(1) apply presburger
|
|
1796 |
apply(rule_tac x = "2" in exI)
|
|
1797 |
apply (metis Suc_1 lessI rders_simp.elims rderssimp_one rsize.simps(1) rsize.simps(2))
|
|
1798 |
apply(rule_tac x = "2" in meta_spec)
|
|
1799 |
apply (metis lessI rderssimp_char rsize.simps(1) rsize.simps(2) rsize.simps(3))
|
|
1800 |
|
|
1801 |
using M1seq apply blast
|
|
1802 |
prefer 2
|
|
1803 |
|
|
1804 |
apply (simp add: finite_star)
|
|
1805 |
sorry
|
|
1806 |
|
434
|
1807 |
lemma finite_list_of_ders:
|
|
1808 |
fixes r
|
|
1809 |
shows"\<exists>dersset. ( (finite dersset) \<and> (\<forall>s. (rders_simp r s) \<in> dersset) )"
|
|
1810 |
sorry
|
|
1811 |
|
|
1812 |
|
433
|
1813 |
|
|
1814 |
unused_thms
|
|
1815 |
lemma seq_ders_shape:
|
|
1816 |
shows "E"
|
|
1817 |
|
|
1818 |
oops
|
|
1819 |
|
|
1820 |
(*rsimp (rders (RSEQ r1 r2) s) =
|
|
1821 |
rsimp RALT [RSEQ (rders r1 s) r2, rders r2 si, ...]
|
|
1822 |
where si is the i-th shortest suffix of s such that si \<in> L r2"
|
|
1823 |
*)
|
|
1824 |
|
|
1825 |
|
|
1826 |
end
|