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 |
|
|
24 |
fun orderedPref :: "char list \<Rightarrow> char list list"
|
|
25 |
where
|
|
26 |
"orderedPref s = orderedPrefAux (length s) s"
|
|
27 |
|
|
28 |
lemma shape_of_pref_1list:
|
|
29 |
shows "orderedPref [c] = [[]]"
|
|
30 |
apply auto
|
|
31 |
done
|
|
32 |
|
|
33 |
lemma shape_of_suf_1list:
|
|
34 |
shows "orderedSuf [c] = [[c]]"
|
|
35 |
by auto
|
|
36 |
|
|
37 |
lemma shape_of_suf_2list:
|
|
38 |
shows "orderedSuf [c2, c3] = [[c3], [c2,c3]]"
|
|
39 |
by auto
|
|
40 |
|
|
41 |
lemma shape_of_prf_2list:
|
|
42 |
shows "orderedPref [c1, c2] = [[c1], []]"
|
|
43 |
by auto
|
|
44 |
|
|
45 |
|
|
46 |
lemma shape_of_suf_3list:
|
|
47 |
shows "orderedSuf [c1, c2, c3] = [[c3], [c2, c3], [c1, c2, c3]]"
|
|
48 |
by auto
|
|
49 |
|
|
50 |
lemma throwing_elem_around:
|
|
51 |
shows "orderedSuf (s1 @ [a] @ s) = (orderedSuf s) @ (map (\<lambda>s11. s11 @ s) (orderedSuf ( s1 @ [a]) ))"
|
|
52 |
and "orderedSuf (s1 @ [a] @ s) = (orderedSuf ([a] @ s) @ (map (\<lambda>s11. s11 @ ([a] @ s))) (orderedSuf s1) )"
|
|
53 |
sorry
|
|
54 |
|
|
55 |
|
|
56 |
lemma suf_cons:
|
|
57 |
shows "orderedSuf (s1 @ s) = (orderedSuf s) @ (map (\<lambda>s11. s11 @ s) (orderedSuf s1))"
|
|
58 |
apply(induct s arbitrary: s1)
|
|
59 |
apply simp
|
|
60 |
apply(subgoal_tac "s1 @ a # s = (s1 @ [a]) @ s")
|
|
61 |
prefer 2
|
|
62 |
apply simp
|
|
63 |
apply(subgoal_tac "orderedSuf (s1 @ a # s) = orderedSuf ((s1 @ [a]) @ s)")
|
|
64 |
prefer 2
|
|
65 |
apply presburger
|
|
66 |
apply(drule_tac x="s1 @ [a]" in meta_spec)
|
|
67 |
sorry
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
lemma shape_of_prf_3list:
|
|
72 |
shows "orderedPref [c1, c2, c3] = [[c1, c2], [c1], []]"
|
|
73 |
by auto
|
|
74 |
|
|
75 |
fun zip_concat :: "char list list \<Rightarrow> char list list \<Rightarrow> char list list"
|
|
76 |
where
|
|
77 |
"zip_concat (s1#ss1) (s2#ss2) = (s1@s2) # (zip_concat ss1 ss2)"
|
|
78 |
| "zip_concat [] [] = []"
|
|
79 |
| "zip_concat [] (s2#ss2) = s2 # (zip_concat [] ss2)"
|
|
80 |
| "zip_concat (s1#ss1) [] = s1 # (zip_concat ss1 [])"
|
|
81 |
|
|
82 |
|
434
|
83 |
(*
|
433
|
84 |
lemma compliment_pref_suf:
|
|
85 |
shows "zip_concat (orderedPref s) (orderedSuf s) = replicate (length s) s "
|
|
86 |
apply(induct s)
|
|
87 |
apply auto[1]
|
|
88 |
sorry
|
|
89 |
|
|
90 |
|
434
|
91 |
*)
|
433
|
92 |
|
|
93 |
datatype rrexp =
|
|
94 |
RZERO
|
|
95 |
| RONE
|
|
96 |
| RCHAR char
|
|
97 |
| RSEQ rrexp rrexp
|
|
98 |
| RALTS "rrexp list"
|
|
99 |
| RSTAR rrexp
|
|
100 |
|
|
101 |
abbreviation
|
|
102 |
"RALT r1 r2 \<equiv> RALTS [r1, r2]"
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
fun
|
|
107 |
rnullable :: "rrexp \<Rightarrow> bool"
|
|
108 |
where
|
|
109 |
"rnullable (RZERO) = False"
|
|
110 |
| "rnullable (RONE ) = True"
|
|
111 |
| "rnullable (RCHAR c) = False"
|
|
112 |
| "rnullable (RALTS rs) = (\<exists>r \<in> set rs. rnullable r)"
|
|
113 |
| "rnullable (RSEQ r1 r2) = (rnullable r1 \<and> rnullable r2)"
|
|
114 |
| "rnullable (RSTAR r) = True"
|
|
115 |
|
|
116 |
|
|
117 |
fun
|
|
118 |
rder :: "char \<Rightarrow> rrexp \<Rightarrow> rrexp"
|
|
119 |
where
|
|
120 |
"rder c (RZERO) = RZERO"
|
|
121 |
| "rder c (RONE) = RZERO"
|
|
122 |
| "rder c (RCHAR d) = (if c = d then RONE else RZERO)"
|
|
123 |
| "rder c (RALTS rs) = RALTS (map (rder c) rs)"
|
|
124 |
| "rder c (RSEQ r1 r2) =
|
|
125 |
(if rnullable r1
|
|
126 |
then RALT (RSEQ (rder c r1) r2) (rder c r2)
|
|
127 |
else RSEQ (rder c r1) r2)"
|
|
128 |
| "rder c (RSTAR r) = RSEQ (rder c r) (RSTAR r)"
|
|
129 |
|
|
130 |
|
|
131 |
fun
|
|
132 |
rders :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
|
|
133 |
where
|
|
134 |
"rders r [] = r"
|
|
135 |
| "rders r (c#s) = rders (rder c r) s"
|
|
136 |
|
|
137 |
fun rdistinct :: "'a list \<Rightarrow>'a set \<Rightarrow> 'a list"
|
|
138 |
where
|
|
139 |
"rdistinct [] acc = []"
|
|
140 |
| "rdistinct (x#xs) acc =
|
|
141 |
(if x \<in> acc then rdistinct xs acc
|
|
142 |
else x # (rdistinct xs ({x} \<union> acc)))"
|
|
143 |
|
|
144 |
lemma rdistinct_idem:
|
|
145 |
shows "rdistinct (x # (rdistinct rs {x})) {} = x # (rdistinct rs {x})"
|
|
146 |
|
|
147 |
sorry
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
fun rflts :: "rrexp list \<Rightarrow> rrexp list"
|
|
154 |
where
|
|
155 |
"rflts [] = []"
|
|
156 |
| "rflts (RZERO # rs) = rflts rs"
|
|
157 |
| "rflts ((RALTS rs1) # rs) = rs1 @ rflts rs"
|
|
158 |
| "rflts (r1 # rs) = r1 # rflts rs"
|
|
159 |
|
|
160 |
|
|
161 |
fun rsimp_ALTs :: " rrexp list \<Rightarrow> rrexp"
|
|
162 |
where
|
|
163 |
"rsimp_ALTs [] = RZERO"
|
|
164 |
| "rsimp_ALTs [r] = r"
|
|
165 |
| "rsimp_ALTs rs = RALTS rs"
|
|
166 |
|
|
167 |
fun rsimp_SEQ :: " rrexp \<Rightarrow> rrexp \<Rightarrow> rrexp"
|
|
168 |
where
|
|
169 |
"rsimp_SEQ RZERO _ = RZERO"
|
|
170 |
| "rsimp_SEQ _ RZERO = RZERO"
|
|
171 |
| "rsimp_SEQ RONE r2 = r2"
|
|
172 |
| "rsimp_SEQ r1 r2 = RSEQ r1 r2"
|
|
173 |
|
|
174 |
|
|
175 |
fun rsimp :: "rrexp \<Rightarrow> rrexp"
|
|
176 |
where
|
|
177 |
"rsimp (RSEQ r1 r2) = rsimp_SEQ (rsimp r1) (rsimp r2)"
|
|
178 |
| "rsimp (RALTS rs) = rsimp_ALTs (rdistinct (rflts (map rsimp rs)) {}) "
|
|
179 |
| "rsimp r = r"
|
|
180 |
|
|
181 |
|
|
182 |
fun
|
|
183 |
rders_simp :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
|
|
184 |
where
|
|
185 |
"rders_simp r [] = r"
|
|
186 |
| "rders_simp r (c#s) = rders_simp (rsimp (rder c r)) s"
|
|
187 |
|
|
188 |
fun rsize :: "rrexp \<Rightarrow> nat" where
|
|
189 |
"rsize RZERO = 1"
|
|
190 |
| "rsize (RONE) = 1"
|
|
191 |
| "rsize (RCHAR c) = 1"
|
|
192 |
| "rsize (RALTS rs) = Suc (sum_list (map rsize rs))"
|
|
193 |
| "rsize (RSEQ r1 r2) = Suc (rsize r1 + rsize r2)"
|
|
194 |
| "rsize (RSTAR r) = Suc (rsize r)"
|
|
195 |
|
|
196 |
|
|
197 |
fun rlist_size :: "rrexp list \<Rightarrow> nat" where
|
|
198 |
"rlist_size (r # rs) = rsize r + rlist_size rs"
|
|
199 |
| "rlist_size [] = 0"
|
|
200 |
|
|
201 |
thm neq_Nil_conv
|
|
202 |
|
|
203 |
|
|
204 |
lemma rsimp_aalts_smaller:
|
|
205 |
shows "rsize (rsimp_ALTs rs) \<le> rsize (RALTS rs)"
|
|
206 |
apply(induct rs)
|
|
207 |
apply simp
|
|
208 |
apply simp
|
|
209 |
apply(case_tac "rs = []")
|
|
210 |
apply simp
|
|
211 |
apply(subgoal_tac "\<exists>rsp ap. rs = ap # rsp")
|
|
212 |
apply(erule exE)+
|
|
213 |
apply simp
|
|
214 |
apply simp
|
|
215 |
by(meson neq_Nil_conv)
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
(*
|
|
223 |
lemma rders_shape:
|
|
224 |
shows "s \<noteq> [] \<Longrightarrow> rders_simp (RSEQ r1 r2) s =
|
|
225 |
rsimp (RALTS ((RSEQ (rders r1 s) r2) #
|
|
226 |
(map (rders r2) (orderedSuf s))) )"
|
|
227 |
apply(induct s arbitrary: r1 r2 rule: rev_induct)
|
|
228 |
apply simp
|
|
229 |
apply simp
|
|
230 |
|
|
231 |
sorry
|
|
232 |
*)
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
fun rders_cond_list :: "rrexp \<Rightarrow> bool list \<Rightarrow> char list list \<Rightarrow> rrexp list"
|
|
237 |
where
|
|
238 |
"rders_cond_list r2 (True # bs) (s # strs) = (rders_simp r2 s) # (rders_cond_list r2 bs strs)"
|
|
239 |
| "rders_cond_list r2 (False # bs) (s # strs) = rders_cond_list r2 bs strs"
|
|
240 |
| "rders_cond_list r2 [] s = []"
|
|
241 |
| "rders_cond_list r2 bs [] = []"
|
|
242 |
|
|
243 |
fun nullable_bools :: "rrexp \<Rightarrow> char list list \<Rightarrow> bool list"
|
|
244 |
where
|
|
245 |
"nullable_bools r (s#strs) = (rnullable (rders r s)) # (nullable_bools r strs) "
|
|
246 |
|"nullable_bools r [] = []"
|
|
247 |
|
|
248 |
fun cond_list :: "rrexp \<Rightarrow> rrexp \<Rightarrow> char list \<Rightarrow> rrexp list"
|
|
249 |
where
|
|
250 |
"cond_list r1 r2 s = rders_cond_list r2 (nullable_bools r1 (orderedPref s) ) (orderedSuf s)"
|
|
251 |
|
|
252 |
thm rsimp_SEQ.simps
|
|
253 |
lemma rSEQ_mono:
|
|
254 |
shows "rsize (rsimp_SEQ r1 r2) \<le>rsize ( RSEQ r1 r2)"
|
|
255 |
apply auto
|
|
256 |
apply(induct r1)
|
|
257 |
apply auto
|
|
258 |
apply(case_tac "r2")
|
|
259 |
apply simp_all
|
|
260 |
apply(case_tac r2)
|
|
261 |
apply simp_all
|
|
262 |
apply(case_tac r2)
|
|
263 |
apply simp_all
|
|
264 |
apply(case_tac r2)
|
|
265 |
apply simp_all
|
|
266 |
apply(case_tac r2)
|
|
267 |
apply simp_all
|
|
268 |
done
|
|
269 |
|
|
270 |
lemma rsimp_mono:
|
|
271 |
shows "rsize (rsimp r) \<le> rsize r"
|
|
272 |
apply(induct r)
|
|
273 |
apply simp_all
|
|
274 |
apply(subgoal_tac "rsize (rsimp_SEQ (rsimp r1) (rsimp r2)) \<le> rsize (RSEQ (rsimp r1) (rsimp r2))")
|
|
275 |
|
|
276 |
apply force
|
|
277 |
using rSEQ_mono
|
|
278 |
apply presburger
|
|
279 |
sorry
|
|
280 |
|
|
281 |
lemma idiot:
|
|
282 |
shows "rsimp_SEQ RONE r = r"
|
|
283 |
apply(case_tac r)
|
|
284 |
apply simp_all
|
|
285 |
done
|
|
286 |
|
|
287 |
lemma no_dup_after_simp:
|
|
288 |
shows "RALTS rs = rsimp r \<Longrightarrow> distinct rs"
|
|
289 |
sorry
|
|
290 |
|
|
291 |
lemma no_further_dB_after_simp:
|
|
292 |
shows "RALTS rs = rsimp r \<Longrightarrow> rdistinct rs {} = rs"
|
|
293 |
sorry
|
|
294 |
|
|
295 |
lemma longlist_withstands_rsimp_alts:
|
|
296 |
shows "length rs \<ge> 2 \<Longrightarrow> rsimp_ALTs rs = RALTS rs"
|
|
297 |
sorry
|
|
298 |
|
|
299 |
lemma no_alt_short_list_after_simp:
|
|
300 |
shows "RALTS rs = rsimp r \<Longrightarrow> rsimp_ALTs rs = RALTS rs"
|
|
301 |
sorry
|
|
302 |
|
|
303 |
lemma idiot2:
|
|
304 |
shows " \<lbrakk>r1 \<noteq> RZERO; r1 \<noteq> RONE;r2 \<noteq> RZERO\<rbrakk>
|
|
305 |
\<Longrightarrow> rsimp_SEQ r1 r2 = RSEQ r1 r2"
|
|
306 |
apply(case_tac r1)
|
|
307 |
apply(case_tac r2)
|
|
308 |
apply simp_all
|
|
309 |
apply(case_tac r2)
|
|
310 |
apply simp_all
|
|
311 |
apply(case_tac r2)
|
|
312 |
apply simp_all
|
|
313 |
apply(case_tac r2)
|
|
314 |
apply simp_all
|
|
315 |
apply(case_tac r2)
|
|
316 |
apply simp_all
|
|
317 |
done
|
|
318 |
|
|
319 |
lemma rsimp_aalts_another:
|
|
320 |
shows "\<forall>r \<in> (set (map rsimp ((RSEQ (rders r1 s) r2) #
|
|
321 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) )) ). (rsize r) < N "
|
|
322 |
sorry
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
lemma shape_derssimpseq_onechar:
|
|
327 |
shows " (rders_simp r [c]) = (rsimp (rders r [c]))"
|
|
328 |
and "rders_simp (RSEQ r1 r2) [c] =
|
|
329 |
rsimp (RALTS ((RSEQ (rders r1 [c]) r2) #
|
|
330 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref [c])) (orderedSuf [c]))) )"
|
|
331 |
apply simp
|
|
332 |
apply(simp add: rders.simps)
|
|
333 |
apply(case_tac "rsimp (rder c r1) = RZERO")
|
|
334 |
apply auto
|
|
335 |
apply(case_tac "rsimp (rder c r1) = RONE")
|
|
336 |
apply auto
|
|
337 |
apply(subgoal_tac "rsimp_SEQ RONE (rsimp r2) = rsimp r2")
|
|
338 |
prefer 2
|
|
339 |
using idiot
|
|
340 |
apply simp
|
|
341 |
apply(subgoal_tac "rsimp_SEQ RONE (rsimp r2) = rsimp_ALTs (rdistinct (rflts [rsimp r2]) {})")
|
|
342 |
prefer 2
|
|
343 |
apply auto
|
|
344 |
apply(case_tac "rsimp r2")
|
|
345 |
apply auto
|
|
346 |
apply(subgoal_tac "rdistinct x5 {} = x5")
|
|
347 |
prefer 2
|
|
348 |
using no_further_dB_after_simp
|
|
349 |
apply metis
|
|
350 |
apply(subgoal_tac "rsimp_ALTs (rdistinct x5 {}) = rsimp_ALTs x5")
|
|
351 |
prefer 2
|
|
352 |
apply fastforce
|
|
353 |
apply auto
|
|
354 |
apply (metis no_alt_short_list_after_simp)
|
|
355 |
apply (case_tac "rsimp r2 = RZERO")
|
|
356 |
apply(subgoal_tac "rsimp_SEQ (rsimp (rder c r1)) (rsimp r2) = RZERO")
|
|
357 |
prefer 2
|
|
358 |
apply(case_tac "rsimp ( rder c r1)")
|
|
359 |
apply auto
|
|
360 |
apply(subgoal_tac "rsimp_SEQ (rsimp (rder c r1)) (rsimp r2) = RSEQ (rsimp (rder c r1)) (rsimp r2)")
|
|
361 |
prefer 2
|
|
362 |
apply auto
|
|
363 |
sorry
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
lemma shape_derssimpseq_onechar2:
|
|
368 |
shows "rders_simp (RSEQ r1 r2) [c] =
|
|
369 |
rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) #
|
|
370 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref [c])) (orderedSuf [c]))) )"
|
|
371 |
sorry
|
|
372 |
|
|
373 |
|
|
374 |
lemma rders__onechar:
|
|
375 |
shows " (rders_simp r [c]) = (rsimp (rders r [c]))"
|
|
376 |
by simp
|
|
377 |
|
|
378 |
lemma rders_append:
|
|
379 |
"rders c (s1 @ s2) = rders (rders c s1) s2"
|
|
380 |
apply(induct s1 arbitrary: c s2)
|
|
381 |
apply(simp_all)
|
|
382 |
done
|
|
383 |
|
|
384 |
lemma rders_simp_append:
|
|
385 |
"rders_simp c (s1 @ s2) = rders_simp (rders_simp c s1) s2"
|
|
386 |
apply(induct s1 arbitrary: c s2)
|
|
387 |
apply(simp_all)
|
|
388 |
done
|
|
389 |
|
|
390 |
lemma inside_simp_removal:
|
|
391 |
shows " rsimp (rder x (rsimp r)) = rsimp (rder x r)"
|
|
392 |
|
|
393 |
sorry
|
|
394 |
|
|
395 |
lemma set_related_list:
|
|
396 |
shows "distinct rs \<Longrightarrow> length rs = card (set rs)"
|
|
397 |
by (simp add: distinct_card)
|
|
398 |
(*this section deals with the property of distinctBy: creates a list without duplicates*)
|
|
399 |
lemma rdistinct_never_added_twice:
|
|
400 |
shows "rdistinct (a # rs) {a} = rdistinct rs {a}"
|
|
401 |
by force
|
|
402 |
|
|
403 |
|
|
404 |
lemma rdistinct_does_the_job:
|
|
405 |
shows "distinct (rdistinct rs s)"
|
|
406 |
apply(induct rs arbitrary: s)
|
|
407 |
apply simp
|
|
408 |
apply simp
|
|
409 |
sorry
|
|
410 |
|
|
411 |
|
|
412 |
lemma simp_helps_der_pierce:
|
|
413 |
shows " rsimp
|
|
414 |
(rder x
|
|
415 |
(rsimp_ALTs rs)) =
|
|
416 |
rsimp
|
|
417 |
(rsimp_ALTs
|
|
418 |
(map (rder x )
|
|
419 |
rs
|
|
420 |
)
|
|
421 |
)"
|
|
422 |
sorry
|
|
423 |
|
|
424 |
lemma simp_helps_der_pierce_dB:
|
|
425 |
shows " rsimp
|
|
426 |
(rsimp_ALTs
|
|
427 |
(map (rder x)
|
|
428 |
(rdistinct rs {}))) =
|
|
429 |
rsimp (rsimp_ALTs (rdistinct (map (rder x) rs) {}))"
|
|
430 |
|
|
431 |
sorry
|
|
432 |
|
|
433 |
lemma simp_helps_der_pierce_flts:
|
|
434 |
shows " rsimp
|
|
435 |
(rsimp_ALTs
|
|
436 |
(rdistinct
|
|
437 |
(map (rder x)
|
|
438 |
(rflts rs )
|
|
439 |
) {}
|
|
440 |
)
|
|
441 |
) =
|
|
442 |
rsimp (rsimp_ALTs (rdistinct (rflts (map (rder x) rs)) {}) )"
|
|
443 |
|
|
444 |
sorry
|
|
445 |
|
|
446 |
|
|
447 |
lemma unfold_ders_simp_inside_only:
|
|
448 |
shows " (rders_simp (RSEQ r1 r2) xs =
|
|
449 |
rsimp (RALTS (RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))
|
|
450 |
\<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)))))"
|
|
451 |
by presburger
|
|
452 |
|
|
453 |
|
|
454 |
|
|
455 |
lemma unfold_ders_simp_inside_only_nosimp:
|
|
456 |
shows " (rders_simp (RSEQ r1 r2) xs =
|
|
457 |
rsimp (RALTS (RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))
|
|
458 |
\<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))))"
|
|
459 |
using inside_simp_removal by presburger
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
lemma rders_simp_one_char:
|
|
465 |
shows "rders_simp r [c] = rsimp (rder c r)"
|
|
466 |
apply auto
|
|
467 |
done
|
|
468 |
|
|
469 |
lemma rsimp_idem:
|
|
470 |
shows "rsimp (rsimp r) = rsimp r"
|
|
471 |
sorry
|
|
472 |
|
434
|
473 |
corollary rsimp_inner_idem1:
|
|
474 |
shows "rsimp r = RSEQ r1 r2 \<Longrightarrow> rsimp r1 = r1 \<and> rsimp r2 = r2"
|
|
475 |
|
|
476 |
sorry
|
|
477 |
|
|
478 |
corollary rsimp_inner_idem2:
|
|
479 |
shows "rsimp r = RALTS rs \<Longrightarrow> \<forall>r' \<in> (set rs). rsimp r' = r'"
|
|
480 |
sorry
|
|
481 |
|
|
482 |
corollary rsimp_inner_idem3:
|
|
483 |
shows "rsimp r = RALTS rs \<Longrightarrow> map rsimp rs = rs"
|
|
484 |
by (meson map_idI rsimp_inner_idem2)
|
|
485 |
|
|
486 |
corollary rsimp_inner_idem4:
|
|
487 |
shows "rsimp r = RALTS rs \<Longrightarrow> flts rs = rs"
|
|
488 |
sorry
|
|
489 |
|
|
490 |
|
433
|
491 |
lemma head_one_more_simp:
|
|
492 |
shows "map rsimp (r # rs) = map rsimp (( rsimp r) # rs)"
|
|
493 |
by (simp add: rsimp_idem)
|
|
494 |
|
|
495 |
lemma head_one_more_dersimp:
|
|
496 |
shows "map rsimp ((rder x (rders_simp r s) # rs)) = map rsimp ((rders_simp r (s@[x]) ) # rs)"
|
|
497 |
using head_one_more_simp rders_simp_append rders_simp_one_char by presburger
|
|
498 |
|
|
499 |
thm cond_list.simps
|
|
500 |
|
|
501 |
lemma suffix_plus1char:
|
|
502 |
shows "\<not> (rnullable (rders r1 s)) \<Longrightarrow> cond_list r1 r2 (s@[c]) = map (rder c) (cond_list r1 r2 s)"
|
|
503 |
apply simp
|
|
504 |
sorry
|
|
505 |
|
|
506 |
lemma suffix_plus1charn:
|
|
507 |
shows "rnullable (rders r1 s) \<Longrightarrow> cond_list r1 r2 (s@[c]) = (rder c r2) # (map (rder c) (cond_list r1 r2 s))"
|
|
508 |
sorry
|
|
509 |
|
|
510 |
lemma ders_simp_nullability:
|
|
511 |
shows "rnullable (rders r s) = rnullable (rders_simp r s)"
|
|
512 |
sorry
|
|
513 |
|
|
514 |
lemma first_elem_seqder:
|
|
515 |
shows "\<not>rnullable r1p \<Longrightarrow> map rsimp (rder x (RSEQ r1p r2)
|
|
516 |
# rs) = map rsimp ((RSEQ (rder x r1p) r2) # rs) "
|
|
517 |
by auto
|
|
518 |
|
|
519 |
lemma first_elem_seqder1:
|
|
520 |
shows "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) =
|
|
521 |
map rsimp ( (RSEQ (rsimp (rder x (rders_simp r xs))) r2) # rs)"
|
|
522 |
by (simp add: rsimp_idem)
|
|
523 |
|
|
524 |
lemma first_elem_seqdersimps:
|
|
525 |
shows "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) =
|
|
526 |
map rsimp ( (RSEQ (rders_simp r (xs @ [x])) r2) # rs)"
|
|
527 |
using first_elem_seqder1 rders_simp_append by auto
|
|
528 |
|
|
529 |
lemma first_elem_seqder_nullable:
|
|
530 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow> cond_list r1 r2 (xs @ [x]) = rder x r2 # map (rder x) (cond_list r1 r2 xs)"
|
|
531 |
sorry
|
|
532 |
|
|
533 |
|
|
534 |
(*nullable_seq_with_list1 related *)
|
|
535 |
lemma LHS0_def_der_alt:
|
|
536 |
shows "rsimp (rder x (RALTS ( (RSEQ (rders_simp r1 xs) r2) # (cond_list r1 r2 xs)))) =
|
|
537 |
rsimp (RALTS ((rder x (RSEQ (rders_simp r1 xs) r2)) # (map (rder x) (cond_list r1 r2 xs))))"
|
|
538 |
by fastforce
|
|
539 |
|
|
540 |
lemma LHS1_def_der_seq:
|
|
541 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow>
|
|
542 |
rsimp (rder x (RALTS ( (RSEQ (rders_simp r1 xs) r2) # (cond_list r1 r2 xs)))) =
|
|
543 |
rsimp(RALTS ((RALTS ((RSEQ (rders_simp r1 (xs @ [x])) r2) # [rder x r2]) ) # (map (rder x ) (cond_list r1 r2 xs))))"
|
|
544 |
by (simp add: rders_simp_append rsimp_idem)
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
lemma cond_list_head_last:
|
|
551 |
shows "rnullable (rders r1 s) \<Longrightarrow>
|
|
552 |
RALTS (r # (cond_list r1 r2 (s @ [c]))) = RALTS (r # ((rder c r2) # (map (rder c) (cond_list r1 r2 s))))"
|
|
553 |
using suffix_plus1charn by blast
|
|
554 |
|
|
555 |
|
|
556 |
lemma simp_flatten:
|
|
557 |
shows "rsimp (RALTS ((RALTS rsa) # rsb)) = rsimp (RALTS (rsa @ rsb))"
|
|
558 |
|
|
559 |
sorry
|
|
560 |
|
|
561 |
lemma RHS1:
|
|
562 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow>
|
|
563 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs @ [x])) r2) #
|
|
564 |
(cond_list r1 r2 (xs @[x])))) =
|
|
565 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs @ [x])) r2) #
|
|
566 |
( ((rder x r2) # (map (rder x) (cond_list r1 r2 xs)))))) "
|
|
567 |
using first_elem_seqder_nullable by presburger
|
|
568 |
|
|
569 |
|
|
570 |
lemma nullable_seq_with_list1:
|
|
571 |
shows " rnullable (rders_simp r1 s) \<Longrightarrow>
|
|
572 |
rsimp (rder c (RALTS ( (RSEQ (rders_simp r1 s) r2) # (cond_list r1 r2 s)) )) =
|
|
573 |
rsimp (RALTS ( (RSEQ (rders_simp r1 (s @ [c])) r2) # (cond_list r1 r2 (s @ [c])) ) )"
|
434
|
574 |
using RHS1 LHS1_def_der_seq cond_list_head_last simp_flatten
|
|
575 |
by (metis append.left_neutral append_Cons)
|
|
576 |
|
|
577 |
|
|
578 |
(*^^^^^^^^^nullable_seq_with_list1 related ^^^^^^^^^^^^^^^^*)
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
433
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
lemma nullable_seq_with_list:
|
|
590 |
shows "rnullable (rders_simp r1 xs) \<Longrightarrow> rsimp (rder x (RALTS ((RSEQ (rders_simp r1 xs) r2) #
|
|
591 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs)) ))) =
|
|
592 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs@[x])) r2) #
|
|
593 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref (xs@[x]))) (orderedSuf (xs@[x]))) ) )
|
|
594 |
"
|
|
595 |
apply(subgoal_tac "rsimp (rder x (RALTS ((RSEQ (rders_simp r1 xs) r2) # (cond_list r1 r2 xs)))) =
|
|
596 |
rsimp (RALTS ((RSEQ (rders_simp r1 (xs@[x])) r2) # (cond_list r1 r2 (xs@[x]))))")
|
|
597 |
apply auto[1]
|
|
598 |
using nullable_seq_with_list1 by auto
|
|
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
lemma r1r2ders_whole:
|
|
604 |
"rsimp
|
|
605 |
(RALTS
|
|
606 |
(rder x (RSEQ (rders_simp r1 xs) r2) #
|
|
607 |
map (rder x) (rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs)))) =
|
|
608 |
rsimp( RALTS( ( (RSEQ (rders_simp r1 (xs@[x])) r2)
|
|
609 |
# (rders_cond_list r2 (nullable_bools r1 (orderedPref (xs @ [x]))) (orderedSuf (xs @ [x])))))) "
|
|
610 |
using ders_simp_nullability first_elem_seqdersimps nullable_seq_with_list1 suffix_plus1char by auto
|
|
611 |
|
|
612 |
lemma rders_simp_same_simpders:
|
|
613 |
shows "s \<noteq> [] \<Longrightarrow> rders_simp r s = rsimp (rders r s)"
|
|
614 |
apply(induct s rule: rev_induct)
|
|
615 |
apply simp
|
|
616 |
apply(case_tac "xs = []")
|
|
617 |
apply simp
|
|
618 |
apply(simp add: rders_append rders_simp_append)
|
|
619 |
using inside_simp_removal by blast
|
|
620 |
|
|
621 |
lemma shape_derssimp_seq:
|
|
622 |
shows "\<lbrakk>s \<noteq> []\<rbrakk> \<Longrightarrow> rders_simp (RSEQ r1 r2) s =
|
|
623 |
rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
624 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )"
|
|
625 |
|
|
626 |
apply(induct s arbitrary: r1 r2 rule: rev_induct)
|
|
627 |
apply simp
|
|
628 |
apply(case_tac "xs = []")
|
|
629 |
using shape_derssimpseq_onechar2 apply force
|
|
630 |
apply(simp only: rders_simp_append)
|
|
631 |
apply(simp only: rders_simp_one_char)
|
|
632 |
|
|
633 |
apply(subgoal_tac "rsimp (rder x (rders_simp (RSEQ r1 r2) xs))
|
|
634 |
= rsimp (rder x (RALTS(RSEQ (rders_simp r1 xs) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))")
|
|
635 |
prefer 2
|
|
636 |
using unfold_ders_simp_inside_only_nosimp apply presburger
|
|
637 |
apply(subgoal_tac "rsimp (rder x (RALTS (RSEQ (rders_simp r1 xs) r2
|
|
638 |
# rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs)))) =
|
|
639 |
rsimp ( (RALTS (rder x (RSEQ (rders_simp r1 xs) r2)
|
|
640 |
# (map (rder x) (rders_cond_list r2 (nullable_bools r1 (orderedPref xs)) (orderedSuf xs))))))
|
|
641 |
")
|
|
642 |
prefer 2
|
|
643 |
apply simp
|
|
644 |
using r1r2ders_whole rders_simp_append rders_simp_one_char by presburger
|
|
645 |
|
|
646 |
(*
|
|
647 |
|
|
648 |
apply(subgoal_tac " rsimp
|
|
649 |
(rder x
|
|
650 |
(rsimp_ALTs
|
|
651 |
(rdistinct
|
|
652 |
(rflts
|
|
653 |
(rsimp_SEQ (rsimp (rders_simp r1 xs)) (rsimp r2) #
|
|
654 |
map rsimp
|
|
655 |
(rders_cond_list r2 (nullable_bools r1 (orderedPrefAux (length xs) xs)) (orderedSufAux (length xs) xs))))
|
|
656 |
{}))) =
|
|
657 |
rsimp
|
|
658 |
(
|
|
659 |
(rsimp_ALTs
|
|
660 |
(map (rder x)
|
|
661 |
(rdistinct
|
|
662 |
(rflts
|
|
663 |
(rsimp_SEQ (rsimp (rders_simp r1 xs)) (rsimp r2) #
|
|
664 |
map rsimp
|
|
665 |
(rders_cond_list r2 (nullable_bools r1 (orderedPrefAux (length xs) xs)) (orderedSufAux (length xs) xs))))
|
|
666 |
{})
|
|
667 |
)
|
|
668 |
)
|
|
669 |
) ")
|
|
670 |
prefer 2
|
|
671 |
*)
|
|
672 |
|
|
673 |
lemma shape_derssimp_alts:
|
|
674 |
shows "s \<noteq> [] \<Longrightarrow> rders_simp (RALTS rs) s = rsimp (RALTS (map (\<lambda>r. rders r s) rs))"
|
|
675 |
apply(case_tac "s")
|
|
676 |
apply simp
|
|
677 |
apply simp
|
|
678 |
sorry
|
|
679 |
(*
|
|
680 |
fun rexp_encode :: "rrexp \<Rightarrow> nat"
|
|
681 |
where
|
|
682 |
"rexp_encode RZERO = 0"
|
|
683 |
|"rexp_encode RONE = 1"
|
|
684 |
|"rexp_encode (RCHAR c) = 2"
|
|
685 |
|"rexp_encode (RSEQ r1 r2) = ( 2 ^ (rexp_encode r1)) "
|
|
686 |
*)
|
|
687 |
lemma finite_chars:
|
|
688 |
shows " \<exists>N. ( (\<forall>r \<in> (set rs). \<exists>c. r = RCHAR c) \<and> (distinct rs) \<longrightarrow> length rs < N)"
|
|
689 |
apply(rule_tac x = "Suc 256" in exI)
|
|
690 |
sorry
|
|
691 |
|
|
692 |
definition all_chars :: "int \<Rightarrow> char list"
|
|
693 |
where "all_chars n = map char_of [0..n]"
|
|
694 |
(*
|
|
695 |
fun rexp_enum :: "nat \<Rightarrow> rrexp list"
|
|
696 |
where
|
|
697 |
"rexp_enum 0 = []"
|
|
698 |
|"rexp_enum (Suc 0) = RALTS [] # RZERO # (RONE # (map RCHAR (all_chars 255)))"
|
|
699 |
|"rexp_enum (Suc n) = [(RSEQ r1 r2). r1 \<in> set (rexp_enum i) \<and> r2 \<in> set (rexp_enum j) \<and> i + j = n]"
|
|
700 |
|
|
701 |
*)
|
|
702 |
|
|
703 |
fun rexp_enum :: "nat \<Rightarrow> rrexp set"
|
|
704 |
where
|
|
705 |
"rexp_enum 0 = {}"
|
|
706 |
|"rexp_enum (Suc 0) = {RALTS []} \<union> {RZERO} \<union> {RONE} \<union> { (RCHAR c) |c. c \<in> set (all_chars 255)}"
|
|
707 |
|"rexp_enum (Suc n) = {(RSEQ r1 r2)|r1 r2 i j. r1 \<in> (rexp_enum i) \<and> r2 \<in> (rexp_enum j) \<and> i + j = n}"
|
|
708 |
|
434
|
709 |
|
433
|
710 |
lemma finite_sized_rexp_forms_finite_set:
|
|
711 |
shows " \<exists>SN. ( \<forall>r.( rsize r < N \<longrightarrow> r \<in> SN)) \<and> (finite SN)"
|
|
712 |
apply(induct N)
|
|
713 |
apply simp
|
|
714 |
apply auto
|
|
715 |
(*\<lbrakk>\<forall>r. rsize r < N \<longrightarrow> r \<in> SN; finite SN\<rbrakk> \<Longrightarrow> \<exists>SN. (\<forall>r. rsize r < Suc N \<longrightarrow> r \<in> SN) \<and> finite SN*)
|
|
716 |
(* \<And>N. \<exists>SN. (\<forall>r. rsize r < N \<longrightarrow> r \<in> SN) \<and> finite SN \<Longrightarrow> \<exists>SN. (\<forall>r. rsize r < Suc N \<longrightarrow> r \<in> SN) \<and> finite SN*)
|
|
717 |
sorry
|
|
718 |
|
|
719 |
|
|
720 |
lemma finite_size_finite_regx:
|
|
721 |
shows " \<exists>l. \<forall>rs. ((\<forall>r \<in> (set rs). rsize r < N) \<and> (distinct rs) \<longrightarrow> (length rs) < l) "
|
|
722 |
sorry
|
|
723 |
|
|
724 |
(*below probably needs proved concurrently*)
|
|
725 |
|
|
726 |
lemma finite_r1r2_ders_list:
|
|
727 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
728 |
\<Longrightarrow> \<exists>l. \<forall>s.
|
|
729 |
(length (rdistinct (map rsimp (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) {}) ) < l "
|
|
730 |
sorry
|
|
731 |
|
|
732 |
(*
|
|
733 |
\<lbrakk>s \<noteq> []\<rbrakk> \<Longrightarrow> rders_simp (RSEQ r1 r2) s =
|
|
734 |
rsimp (RALTS ((RSEQ (rders r1 s) r2) #
|
|
735 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )
|
|
736 |
*)
|
|
737 |
|
|
738 |
|
|
739 |
lemma sum_list_size2:
|
|
740 |
shows "\<forall>z \<in>set rs. (rsize z ) \<le> Nr \<Longrightarrow> rlist_size rs \<le> (length rs) * Nr"
|
|
741 |
apply(induct rs)
|
|
742 |
apply simp
|
|
743 |
by simp
|
|
744 |
|
|
745 |
lemma sum_list_size:
|
|
746 |
fixes rs
|
|
747 |
shows " \<forall>r \<in> (set rs). (rsize r) \<le> Nr \<and> (length rs) \<le> l \<Longrightarrow> rlist_size rs \<le> l * Nr"
|
|
748 |
by (metis dual_order.trans mult.commute mult_le_mono2 mult_zero_right sum_list_size2 zero_le)
|
|
749 |
|
|
750 |
lemma seq_second_term_chain1:
|
|
751 |
shows " \<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) \<le>
|
|
752 |
rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))"
|
|
753 |
|
|
754 |
sorry
|
|
755 |
|
|
756 |
|
|
757 |
lemma seq_second_term_chain2:
|
|
758 |
shows "\<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) =
|
|
759 |
rlist_size (map rsimp (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)))"
|
|
760 |
|
|
761 |
oops
|
|
762 |
|
|
763 |
lemma seq_second_term_bounded:
|
|
764 |
fixes r2 r1
|
|
765 |
assumes "\<forall>s. rsize (rders_simp r2 s) < N2"
|
|
766 |
shows "\<exists>N3. \<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) < N3"
|
|
767 |
|
|
768 |
sorry
|
|
769 |
|
|
770 |
|
|
771 |
lemma seq_first_term_bounded:
|
|
772 |
fixes r1 r2
|
|
773 |
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'"
|
|
774 |
apply(erule exE)
|
|
775 |
apply(rule_tac x = "Nr + (rsize r2) + 1" in exI)
|
|
776 |
by simp
|
|
777 |
|
|
778 |
|
|
779 |
lemma alts_triangle_inequality:
|
|
780 |
shows "rsize (RALTS (r # rs)) \<le> rsize r + rlist_size rs + 1 "
|
|
781 |
apply(subgoal_tac "rsize (RALTS (r # rs) ) = rsize r + rlist_size rs + 1")
|
|
782 |
apply auto[1]
|
|
783 |
apply(induct rs)
|
|
784 |
apply simp
|
|
785 |
apply auto
|
|
786 |
done
|
|
787 |
|
|
788 |
lemma seq_equal_term_nosimp_entire_bounded:
|
|
789 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
790 |
\<Longrightarrow> \<exists>N3. \<forall>s. rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
791 |
(rdistinct ((rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) ) {}) ) ) \<le> N3"
|
|
792 |
apply(subgoal_tac "\<exists>N3. \<forall>s. rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
793 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) ) \<le>
|
|
794 |
rsize (RSEQ (rders_simp r1 s) r2) +
|
|
795 |
rlist_size (map rsimp (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) + 1")
|
|
796 |
prefer 2
|
|
797 |
using alts_triangle_inequality apply presburger
|
|
798 |
using seq_first_term_bounded
|
|
799 |
using seq_second_term_bounded
|
|
800 |
apply(subgoal_tac "\<exists>N3. \<forall>s. rlist_size (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) < N3")
|
|
801 |
prefer 2
|
|
802 |
apply meson
|
|
803 |
apply(subgoal_tac "\<exists>Nr'. \<forall>s. rsize (RSEQ (rders_simp r1 s) r2) \<le> Nr'")
|
|
804 |
prefer 2
|
|
805 |
apply (meson order_le_less)
|
|
806 |
apply(erule exE)
|
|
807 |
apply(erule exE)
|
|
808 |
sorry
|
|
809 |
|
|
810 |
lemma alts_simp_bounded_by_sloppy1_version:
|
|
811 |
shows "\<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
812 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le>
|
|
813 |
rsize (RALTS (rdistinct ((RSEQ (rders_simp r1 s) r2) #
|
|
814 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
815 |
)
|
|
816 |
{}
|
|
817 |
)
|
|
818 |
) "
|
|
819 |
sorry
|
|
820 |
|
|
821 |
lemma alts_simp_bounded_by_sloppy1:
|
|
822 |
shows "rsize (rsimp (RALTS (rdistinct ((RSEQ (rders_simp r1 s) r2) #
|
|
823 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
824 |
)
|
|
825 |
{}
|
|
826 |
)
|
|
827 |
)) \<le>
|
|
828 |
rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
829 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
830 |
)
|
|
831 |
)"
|
|
832 |
sorry
|
|
833 |
|
|
834 |
lemma hand_made_def_rlist_size:
|
|
835 |
shows "rlist_size rs = sum_list (map rsize rs)"
|
|
836 |
proof (induct rs)
|
|
837 |
case Nil show ?case by simp
|
|
838 |
next
|
|
839 |
case (Cons a rs) thus ?case
|
|
840 |
by simp
|
|
841 |
qed
|
|
842 |
|
|
843 |
(*this section deals with the property of distinctBy: creates a list without duplicates*)
|
|
844 |
lemma distinct_mono:
|
|
845 |
shows "rlist_size (rdistinct (a # s) {}) \<le> rlist_size (a # (rdistinct s {}) )"
|
|
846 |
sorry
|
|
847 |
|
|
848 |
lemma distinct_acc_mono:
|
|
849 |
shows "A \<subseteq> B \<Longrightarrow> rlist_size (rdistinct s A) \<ge> rlist_size (rdistinct s B)"
|
|
850 |
apply(induct s arbitrary: A B)
|
|
851 |
apply simp
|
|
852 |
apply(case_tac "a \<in> A")
|
|
853 |
apply(subgoal_tac "a \<in> B")
|
|
854 |
|
|
855 |
apply simp
|
|
856 |
|
|
857 |
apply blast
|
|
858 |
apply(subgoal_tac "rlist_size (rdistinct (a # s) A) = rlist_size (a # (rdistinct s (A \<union> {a})))")
|
|
859 |
apply(case_tac "a \<in> B")
|
|
860 |
apply(subgoal_tac "rlist_size (rdistinct (a # s) B) = rlist_size ( (rdistinct s B))")
|
|
861 |
apply (metis Un_insert_right dual_order.trans insert_subset le_add_same_cancel2 rlist_size.simps(1) sup_bot_right zero_order(1))
|
|
862 |
apply simp
|
|
863 |
apply auto
|
|
864 |
by (meson insert_mono)
|
|
865 |
|
|
866 |
|
|
867 |
lemma distinct_mono2:
|
|
868 |
shows " rlist_size (rdistinct s {a}) \<le> rlist_size (rdistinct s {})"
|
|
869 |
apply(induct s)
|
|
870 |
apply simp
|
|
871 |
apply simp
|
|
872 |
using distinct_acc_mono by auto
|
|
873 |
|
|
874 |
|
|
875 |
|
|
876 |
lemma distinct_mono_spares_first_elem:
|
|
877 |
shows "rsize (RALTS (rdistinct (a # s) {})) \<le> rsize (RALTS (a # (rdistinct s {})))"
|
|
878 |
apply simp
|
|
879 |
apply (subgoal_tac "rlist_size ( (rdistinct s {a})) \<le> rlist_size ( (rdistinct s {})) ")
|
|
880 |
using hand_made_def_rlist_size apply auto[1]
|
|
881 |
using distinct_mono2 by auto
|
|
882 |
|
|
883 |
lemma sloppy1_bounded_by_sloppiest:
|
|
884 |
shows "rsize (RALTS (rdistinct ((RSEQ (rders_simp r1 s) r2) #
|
|
885 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))
|
|
886 |
)
|
|
887 |
{}
|
|
888 |
)
|
|
889 |
) \<le> rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
890 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {})
|
|
891 |
|
|
892 |
|
|
893 |
)
|
|
894 |
)"
|
|
895 |
|
|
896 |
sorry
|
|
897 |
|
|
898 |
|
|
899 |
lemma alts_simp_bounded_by_sloppiest_version:
|
|
900 |
shows "\<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
901 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le>
|
|
902 |
rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
903 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}) ) ) "
|
|
904 |
by (meson alts_simp_bounded_by_sloppy1_version order_trans sloppy1_bounded_by_sloppiest)
|
|
905 |
|
|
906 |
|
|
907 |
lemma seq_equal_term_entire_bounded:
|
|
908 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
909 |
\<Longrightarrow> \<exists>N3. \<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
910 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le> N3"
|
|
911 |
using seq_equal_term_nosimp_entire_bounded
|
|
912 |
apply(subgoal_tac " \<exists>N3. \<forall>s. rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
913 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}) ) ) \<le> N3")
|
|
914 |
apply(erule exE)
|
|
915 |
prefer 2
|
|
916 |
apply blast
|
|
917 |
apply(subgoal_tac "\<forall>s. rsize (rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
918 |
(rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))) )) \<le>
|
|
919 |
rsize (RALTS ((RSEQ (rders_simp r1 s) r2) #
|
|
920 |
(rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}) ) ) ")
|
|
921 |
prefer 2
|
|
922 |
using alts_simp_bounded_by_sloppiest_version apply blast
|
|
923 |
apply(rule_tac x = "Suc N3 " in exI)
|
|
924 |
apply(rule allI)
|
|
925 |
|
|
926 |
apply(subgoal_tac " rsize
|
|
927 |
(rsimp
|
|
928 |
(RALTS
|
|
929 |
(RSEQ (rders_simp r1 s) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s))))
|
|
930 |
\<le> rsize
|
|
931 |
(RALTS
|
|
932 |
(RSEQ (rders_simp r1 s) r2 #
|
|
933 |
rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {}))")
|
|
934 |
prefer 2
|
|
935 |
apply presburger
|
|
936 |
apply(subgoal_tac " rsize
|
|
937 |
(RALTS
|
|
938 |
(RSEQ (rders_simp r1 s) r2 #
|
|
939 |
rdistinct (rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)) {})) \<le> N3")
|
|
940 |
|
|
941 |
apply linarith
|
|
942 |
apply simp
|
|
943 |
done
|
|
944 |
|
|
945 |
|
|
946 |
|
|
947 |
lemma M1seq:
|
|
948 |
fixes r1 r2
|
|
949 |
shows "(\<forall>s. rsize (rders_simp r1 s) < N1 \<and> rsize (rders_simp r2 s) < N2)
|
|
950 |
\<Longrightarrow> \<exists>N3.\<forall>s.(rsize (rders_simp (RSEQ r1 r2) s)) < N3"
|
|
951 |
apply(frule seq_equal_term_entire_bounded)
|
|
952 |
apply(erule exE)
|
|
953 |
apply(rule_tac x = "max (N3+2) (Suc (Suc (rsize r1) + (rsize r2)))" in exI)
|
|
954 |
apply(rule allI)
|
|
955 |
apply(case_tac "s = []")
|
|
956 |
prefer 2
|
434
|
957 |
apply (metis add_2_eq_Suc' le_imp_less_Suc less_SucI max.strict_coboundedI1 shape_derssimp_seq)
|
|
958 |
by (metis add.assoc less_Suc_eq less_max_iff_disj plus_1_eq_Suc rders_simp.simps(1) rsize.simps(5))
|
|
959 |
|
433
|
960 |
(* apply (simp add: less_SucI shape_derssimp_seq(2))
|
|
961 |
apply (meson less_SucI less_max_iff_disj)
|
|
962 |
apply simp
|
|
963 |
done*)
|
|
964 |
|
|
965 |
(*lemma empty_diff:
|
|
966 |
shows "s = [] \<Longrightarrow>
|
|
967 |
(rsize (rders_simp (RSEQ r1 r2) s)) \<le>
|
|
968 |
(max
|
|
969 |
(rsize (rsimp (RALTS (RSEQ (rders r1 s) r2 # rders_cond_list r2 (nullable_bools r1 (orderedPref s)) (orderedSuf s)))))
|
|
970 |
(Suc (rsize r1 + rsize r2)) ) "
|
|
971 |
apply simp
|
|
972 |
done*)
|
|
973 |
(*For star related bound*)
|
|
974 |
|
|
975 |
lemma star_is_a_singleton_list_derc:
|
434
|
976 |
shows " \<exists>Ss. rders_simp (RSTAR r) [c] = rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))"
|
433
|
977 |
apply simp
|
|
978 |
apply(rule_tac x = "[[c]]" in exI)
|
|
979 |
apply auto
|
434
|
980 |
apply(case_tac "rsimp (rder c r)")
|
|
981 |
apply simp
|
|
982 |
apply auto
|
|
983 |
apply(subgoal_tac "rsimp (RSEQ x41 x42) = RSEQ x41 x42")
|
|
984 |
prefer 2
|
|
985 |
apply (metis rsimp_idem)
|
|
986 |
apply(subgoal_tac "rsimp x41 = x41")
|
|
987 |
prefer 2
|
|
988 |
using rsimp_inner_idem1 apply blast
|
|
989 |
apply(subgoal_tac "rsimp x42 = x42")
|
|
990 |
prefer 2
|
|
991 |
using rsimp_inner_idem1 apply blast
|
|
992 |
apply simp
|
|
993 |
apply(subgoal_tac "map rsimp x5 = x5")
|
|
994 |
prefer 2
|
|
995 |
using rsimp_inner_idem3 apply blast
|
|
996 |
apply simp
|
|
997 |
apply(subgoal_tac "rflts x5 = x5")
|
|
998 |
prefer 2
|
|
999 |
using rsimp_inner_idem4 apply blast
|
|
1000 |
apply simp
|
|
1001 |
using rsimp_inner_idem4 by auto
|
|
1002 |
|
|
1003 |
|
433
|
1004 |
|
|
1005 |
lemma rder_rsimp_ALTs_commute:
|
|
1006 |
shows " (rder x (rsimp_ALTs rs)) = rsimp_ALTs (map (rder x) rs)"
|
|
1007 |
apply(induct rs)
|
|
1008 |
apply simp
|
|
1009 |
apply(case_tac rs)
|
|
1010 |
apply simp
|
|
1011 |
apply auto
|
|
1012 |
done
|
|
1013 |
|
434
|
1014 |
|
433
|
1015 |
|
|
1016 |
fun star_update :: "char \<Rightarrow> rrexp \<Rightarrow> char list list => char list list" where
|
|
1017 |
"star_update c r [] = []"
|
|
1018 |
|"star_update c r (s # Ss) = (if (rnullable (rders_simp r s))
|
|
1019 |
then (s@[c]) # [c] # (star_update c r Ss)
|
|
1020 |
else s # (star_update c r Ss) )"
|
|
1021 |
|
434
|
1022 |
lemma star_update_case1:
|
|
1023 |
shows "rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # [c] # (star_update c r Ss)"
|
|
1024 |
|
|
1025 |
by force
|
|
1026 |
|
|
1027 |
lemma star_update_case2:
|
|
1028 |
shows "\<not>rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = s # (star_update c r Ss)"
|
|
1029 |
by simp
|
|
1030 |
|
|
1031 |
lemma rsimp_alts_idem:
|
|
1032 |
shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs (a # [(rsimp (rsimp_ALTs as))] ))"
|
|
1033 |
sorry
|
|
1034 |
|
|
1035 |
lemma rsimp_alts_idem2:
|
|
1036 |
shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs ((rsimp a) # [(rsimp (rsimp_ALTs as))] ))"
|
|
1037 |
sorry
|
|
1038 |
|
|
1039 |
lemma evolution_step1:
|
|
1040 |
shows "rsimp
|
|
1041 |
(rsimp_ALTs
|
|
1042 |
(rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1043 |
rsimp
|
|
1044 |
(rsimp_ALTs
|
|
1045 |
(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)))])) "
|
|
1046 |
using rsimp_alts_idem by auto
|
|
1047 |
|
|
1048 |
lemma evolution_step2:
|
|
1049 |
assumes " rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1050 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))"
|
|
1051 |
shows "rsimp
|
|
1052 |
(rsimp_ALTs
|
|
1053 |
(rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
|
|
1054 |
rsimp
|
|
1055 |
(rsimp_ALTs
|
|
1056 |
(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)))])) "
|
|
1057 |
by (simp add: assms rsimp_alts_idem)
|
|
1058 |
|
|
1059 |
|
|
1060 |
(*
|
|
1061 |
proof (prove)
|
|
1062 |
goal (1 subgoal):
|
|
1063 |
1. map f (a # s) = f a # map f s
|
|
1064 |
Auto solve_direct: the current goal can be solved directly with
|
|
1065 |
HOL.nitpick_simp(115): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
|
|
1066 |
List.list.map(2): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
|
|
1067 |
List.list.simps(9): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
|
|
1068 |
*)
|
433
|
1069 |
lemma starseq_list_evolution:
|
|
1070 |
fixes r :: rrexp and Ss :: "char list list" and x :: char
|
|
1071 |
shows "rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss) ) =
|
|
1072 |
rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)) )"
|
|
1073 |
apply(induct Ss)
|
434
|
1074 |
apply simp
|
|
1075 |
apply(subst List.list.map(2))
|
|
1076 |
apply(subst evolution_step2)
|
|
1077 |
apply simp
|
|
1078 |
apply(case_tac "rnullable (rders_simp r a)")
|
|
1079 |
apply(subst star_update_case1)
|
|
1080 |
apply simp
|
|
1081 |
apply(subst List.list.map)+
|
|
1082 |
sledgehammer
|
433
|
1083 |
sorry
|
|
1084 |
|
|
1085 |
|
|
1086 |
lemma star_seqs_produce_star_seqs:
|
|
1087 |
shows "rsimp (rsimp_ALTs (map (rder x \<circ> (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss))
|
|
1088 |
= rsimp (rsimp_ALTs (map ( (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss))"
|
|
1089 |
by (meson comp_apply)
|
|
1090 |
|
434
|
1091 |
lemma map_der_lambda_composition:
|
|
1092 |
shows "map (rder x) (map (\<lambda>s. f s) Ss) = map (\<lambda>s. (rder x (f s))) Ss"
|
|
1093 |
by force
|
|
1094 |
|
|
1095 |
lemma ralts_vs_rsimpalts:
|
|
1096 |
shows "rsimp (RALTS rs) = rsimp (rsimp_ALTs rs)"
|
|
1097 |
sorry
|
433
|
1098 |
|
|
1099 |
lemma linearity_of_list_of_star_or_starseqs:
|
|
1100 |
fixes r::rrexp and Ss::"char list list" and x::char
|
|
1101 |
shows "\<exists>Ssa. rsimp (rder x (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))) =
|
434
|
1102 |
rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ssa)))"
|
|
1103 |
apply(subst rder_rsimp_ALTs_commute)
|
|
1104 |
apply(subst map_der_lambda_composition)
|
|
1105 |
using starseq_list_evolution
|
|
1106 |
apply(rule_tac x = "star_update x r Ss" in exI)
|
|
1107 |
apply(subst ralts_vs_rsimpalts)
|
|
1108 |
by simp
|
|
1109 |
|
433
|
1110 |
|
|
1111 |
|
434
|
1112 |
(*certified correctness---does not depend on any previous sorry*)
|
|
1113 |
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));
|
|
1114 |
xs @ [x] \<noteq> []; xs \<noteq> []\<rbrakk> \<Longrightarrow>
|
|
1115 |
\<exists>Ss. rders_simp (RSTAR r ) (xs @ [x]) =
|
|
1116 |
rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) )"
|
|
1117 |
apply(subgoal_tac "\<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))")
|
|
1118 |
prefer 2
|
|
1119 |
apply blast
|
|
1120 |
apply(erule exE)
|
|
1121 |
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))))")
|
|
1122 |
prefer 2
|
|
1123 |
using rders_simp_append
|
|
1124 |
using rders_simp_one_char apply presburger
|
|
1125 |
apply(rule_tac x= "Ss" in exI)
|
|
1126 |
apply(subgoal_tac " rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
|
|
1127 |
rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
|
|
1128 |
prefer 2
|
|
1129 |
using inside_simp_removal rsimp_idem apply presburger
|
|
1130 |
apply(subgoal_tac "rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
|
|
1131 |
rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
|
|
1132 |
prefer 2
|
|
1133 |
using rder.simps(4) apply presburger
|
|
1134 |
apply(subgoal_tac "rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
|
|
1135 |
rsimp (rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss)))")
|
|
1136 |
apply (metis rsimp_idem)
|
|
1137 |
by (metis map_der_lambda_composition)
|
|
1138 |
|
|
1139 |
lemma simp_in_lambdas :
|
|
1140 |
shows "
|
|
1141 |
rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) ) =
|
|
1142 |
rsimp (RALTS (map (\<lambda>s1. (rsimp (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))))) Ss))"
|
|
1143 |
by (metis (no_types, lifting) comp_apply list.map_comp map_eq_conv rsimp.simps(2) rsimp_idem)
|
|
1144 |
|
433
|
1145 |
|
|
1146 |
lemma starder_is_a_list_of_stars_or_starseqs:
|
434
|
1147 |
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
|
1148 |
apply(induct s rule: rev_induct)
|
|
1149 |
apply simp
|
|
1150 |
apply(case_tac "xs = []")
|
|
1151 |
using star_is_a_singleton_list_derc
|
434
|
1152 |
apply(simp)
|
|
1153 |
apply(subgoal_tac "\<exists>Ss. rders_simp (RSTAR r) (xs @ [x]) =
|
|
1154 |
rsimp (RALTS (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss))")
|
|
1155 |
prefer 2
|
|
1156 |
using star_list_push_der apply presburger
|
|
1157 |
|
|
1158 |
|
|
1159 |
sorry
|
433
|
1160 |
|
|
1161 |
|
|
1162 |
lemma finite_star:
|
|
1163 |
shows "(\<forall>s. rsize (rders_simp r0 s) < N0 )
|
|
1164 |
\<Longrightarrow> \<exists>N3. \<forall>s.(rsize (rders_simp (RSTAR r0) s)) < N3"
|
|
1165 |
|
|
1166 |
sorry
|
|
1167 |
|
|
1168 |
|
|
1169 |
lemma rderssimp_zero:
|
|
1170 |
shows"rders_simp RZERO s = RZERO"
|
|
1171 |
apply(induction s)
|
|
1172 |
apply simp
|
|
1173 |
by simp
|
|
1174 |
|
|
1175 |
lemma rderssimp_one:
|
|
1176 |
shows"rders_simp RONE (a # s) = RZERO"
|
|
1177 |
apply(induction s)
|
|
1178 |
apply simp
|
|
1179 |
by simp
|
|
1180 |
|
|
1181 |
lemma rderssimp_char:
|
|
1182 |
shows "rders_simp (RCHAR c) s = RONE \<or> rders_simp (RCHAR c) s = RZERO \<or> rders_simp (RCHAR c) s = (RCHAR c)"
|
|
1183 |
apply auto
|
|
1184 |
by (metis rder.simps(2) rder.simps(3) rders_simp.elims rders_simp.simps(2) rderssimp_one rsimp.simps(4))
|
|
1185 |
|
|
1186 |
lemma finite_size_ders:
|
|
1187 |
fixes r
|
|
1188 |
shows " \<exists>Nr. \<forall>s. rsize (rders_simp r s) < Nr"
|
|
1189 |
apply(induct r rule: rrexp.induct)
|
|
1190 |
apply auto
|
|
1191 |
apply(rule_tac x = "2" in exI)
|
|
1192 |
using rderssimp_zero rsize.simps(1) apply presburger
|
|
1193 |
apply(rule_tac x = "2" in exI)
|
|
1194 |
apply (metis Suc_1 lessI rders_simp.elims rderssimp_one rsize.simps(1) rsize.simps(2))
|
|
1195 |
apply(rule_tac x = "2" in meta_spec)
|
|
1196 |
apply (metis lessI rderssimp_char rsize.simps(1) rsize.simps(2) rsize.simps(3))
|
|
1197 |
|
|
1198 |
using M1seq apply blast
|
|
1199 |
prefer 2
|
|
1200 |
|
|
1201 |
apply (simp add: finite_star)
|
|
1202 |
sorry
|
|
1203 |
|
434
|
1204 |
lemma finite_list_of_ders:
|
|
1205 |
fixes r
|
|
1206 |
shows"\<exists>dersset. ( (finite dersset) \<and> (\<forall>s. (rders_simp r s) \<in> dersset) )"
|
|
1207 |
sorry
|
|
1208 |
|
|
1209 |
|
433
|
1210 |
|
|
1211 |
unused_thms
|
|
1212 |
lemma seq_ders_shape:
|
|
1213 |
shows "E"
|
|
1214 |
|
|
1215 |
oops
|
|
1216 |
|
|
1217 |
(*rsimp (rders (RSEQ r1 r2) s) =
|
|
1218 |
rsimp RALT [RSEQ (rders r1 s) r2, rders r2 si, ...]
|
|
1219 |
where si is the i-th shortest suffix of s such that si \<in> L r2"
|
|
1220 |
*)
|
|
1221 |
|
|
1222 |
|
|
1223 |
end
|