444
|
1 |
theory BasicIdentities imports
|
|
2 |
"Lexer" "PDerivs"
|
|
3 |
begin
|
|
4 |
|
|
5 |
datatype rrexp =
|
|
6 |
RZERO
|
|
7 |
| RONE
|
|
8 |
| RCHAR char
|
|
9 |
| RSEQ rrexp rrexp
|
|
10 |
| RALTS "rrexp list"
|
|
11 |
| RSTAR rrexp
|
|
12 |
|
|
13 |
abbreviation
|
|
14 |
"RALT r1 r2 \<equiv> RALTS [r1, r2]"
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
fun
|
|
19 |
rnullable :: "rrexp \<Rightarrow> bool"
|
|
20 |
where
|
|
21 |
"rnullable (RZERO) = False"
|
|
22 |
| "rnullable (RONE ) = True"
|
|
23 |
| "rnullable (RCHAR c) = False"
|
|
24 |
| "rnullable (RALTS rs) = (\<exists>r \<in> set rs. rnullable r)"
|
|
25 |
| "rnullable (RSEQ r1 r2) = (rnullable r1 \<and> rnullable r2)"
|
|
26 |
| "rnullable (RSTAR r) = True"
|
|
27 |
|
|
28 |
|
|
29 |
fun
|
|
30 |
rder :: "char \<Rightarrow> rrexp \<Rightarrow> rrexp"
|
|
31 |
where
|
|
32 |
"rder c (RZERO) = RZERO"
|
|
33 |
| "rder c (RONE) = RZERO"
|
|
34 |
| "rder c (RCHAR d) = (if c = d then RONE else RZERO)"
|
|
35 |
| "rder c (RALTS rs) = RALTS (map (rder c) rs)"
|
|
36 |
| "rder c (RSEQ r1 r2) =
|
|
37 |
(if rnullable r1
|
|
38 |
then RALT (RSEQ (rder c r1) r2) (rder c r2)
|
|
39 |
else RSEQ (rder c r1) r2)"
|
|
40 |
| "rder c (RSTAR r) = RSEQ (rder c r) (RSTAR r)"
|
|
41 |
|
|
42 |
|
|
43 |
fun
|
|
44 |
rders :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
|
|
45 |
where
|
|
46 |
"rders r [] = r"
|
|
47 |
| "rders r (c#s) = rders (rder c r) s"
|
|
48 |
|
|
49 |
fun rdistinct :: "'a list \<Rightarrow>'a set \<Rightarrow> 'a list"
|
|
50 |
where
|
|
51 |
"rdistinct [] acc = []"
|
|
52 |
| "rdistinct (x#xs) acc =
|
|
53 |
(if x \<in> acc then rdistinct xs acc
|
|
54 |
else x # (rdistinct xs ({x} \<union> acc)))"
|
|
55 |
|
488
|
56 |
lemma rdistinct1:
|
|
57 |
assumes "a \<in> acc"
|
|
58 |
shows "a \<notin> set (rdistinct rs acc)"
|
|
59 |
using assms
|
|
60 |
apply(induct rs arbitrary: acc a)
|
|
61 |
apply(auto)
|
|
62 |
done
|
|
63 |
|
|
64 |
|
478
|
65 |
lemma rdistinct_does_the_job:
|
|
66 |
shows "distinct (rdistinct rs s)"
|
|
67 |
apply(induct rs arbitrary: s)
|
488
|
68 |
apply simp
|
478
|
69 |
apply simp
|
488
|
70 |
apply(auto)
|
|
71 |
by (simp add: rdistinct1)
|
|
72 |
|
|
73 |
|
478
|
74 |
|
|
75 |
|
475
|
76 |
lemma rdistinct_concat:
|
|
77 |
shows "set rs \<subseteq> rset \<Longrightarrow> rdistinct (rs @ rsa) rset = rdistinct rsa rset"
|
|
78 |
apply(induct rs)
|
|
79 |
apply simp+
|
|
80 |
done
|
|
81 |
|
|
82 |
lemma rdistinct_concat2:
|
|
83 |
shows "\<forall>r \<in> set rs. r \<in> rset \<Longrightarrow> rdistinct (rs @ rsa) rset = rdistinct rsa rset"
|
|
84 |
by (simp add: rdistinct_concat subsetI)
|
|
85 |
|
444
|
86 |
|
467
|
87 |
lemma distinct_not_exist:
|
|
88 |
shows "a \<notin> set rs \<Longrightarrow> rdistinct rs rset = rdistinct rs (insert a rset)"
|
|
89 |
apply(induct rs arbitrary: rset)
|
|
90 |
apply simp
|
|
91 |
apply(case_tac "aa \<in> rset")
|
|
92 |
apply simp
|
|
93 |
apply(subgoal_tac "a \<noteq> aa")
|
|
94 |
prefer 2
|
|
95 |
apply simp
|
|
96 |
apply simp
|
|
97 |
done
|
444
|
98 |
|
478
|
99 |
lemma rdistinct_on_distinct:
|
|
100 |
shows "distinct rs \<Longrightarrow> rdistinct rs {} = rs"
|
|
101 |
apply(induct rs)
|
|
102 |
apply simp
|
|
103 |
apply(subgoal_tac "rdistinct rs {} = rs")
|
|
104 |
prefer 2
|
|
105 |
apply simp
|
|
106 |
using distinct_not_exist by fastforce
|
|
107 |
|
481
|
108 |
|
478
|
109 |
lemma distinct_rdistinct_append:
|
481
|
110 |
assumes "distinct rs1" "\<forall>r \<in> set rs1. r \<notin> acc"
|
|
111 |
shows "rdistinct (rs1 @ rsa) acc = rs1 @ (rdistinct rsa (acc \<union> set rs1))"
|
|
112 |
using assms
|
|
113 |
apply(induct rs1 arbitrary: rsa acc)
|
|
114 |
apply(auto)[1]
|
|
115 |
apply(auto)[1]
|
|
116 |
apply(drule_tac x="rsa" in meta_spec)
|
|
117 |
apply(drule_tac x="{a} \<union> acc" in meta_spec)
|
|
118 |
apply(simp)
|
|
119 |
apply(drule meta_mp)
|
|
120 |
apply(auto)[1]
|
|
121 |
apply(simp)
|
|
122 |
done
|
|
123 |
|
478
|
124 |
|
488
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
lemma rdistinct_set_equality1:
|
|
129 |
shows "set (rdistinct rs acc) = set rs - acc"
|
|
130 |
apply(induct rs acc rule: rdistinct.induct)
|
|
131 |
apply(auto)
|
|
132 |
done
|
478
|
133 |
|
|
134 |
lemma rdistinct_set_equality:
|
|
135 |
shows "set (rdistinct rs {}) = set rs"
|
488
|
136 |
by (simp add: rdistinct_set_equality1)
|
478
|
137 |
|
444
|
138 |
|
|
139 |
fun rflts :: "rrexp list \<Rightarrow> rrexp list"
|
|
140 |
where
|
|
141 |
"rflts [] = []"
|
|
142 |
| "rflts (RZERO # rs) = rflts rs"
|
|
143 |
| "rflts ((RALTS rs1) # rs) = rs1 @ rflts rs"
|
|
144 |
| "rflts (r1 # rs) = r1 # rflts rs"
|
|
145 |
|
478
|
146 |
lemma rflts_def_idiot:
|
|
147 |
shows "\<lbrakk> a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1\<rbrakk>
|
|
148 |
\<Longrightarrow> rflts (a # rs) = a # rflts rs"
|
|
149 |
apply(case_tac a)
|
|
150 |
apply simp_all
|
|
151 |
done
|
|
152 |
|
|
153 |
lemma rflts_def_idiot2:
|
|
154 |
shows "\<lbrakk>a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1; a \<in> set rs\<rbrakk> \<Longrightarrow> a \<in> set (rflts rs)"
|
|
155 |
apply(induct rs)
|
|
156 |
apply simp
|
|
157 |
by (metis append.assoc in_set_conv_decomp insert_iff list.simps(15) rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
lemma flts_append:
|
|
162 |
shows "rflts (rs1 @ rs2) = rflts rs1 @ rflts rs2"
|
|
163 |
apply(induct rs1)
|
|
164 |
apply simp
|
|
165 |
apply(case_tac a)
|
|
166 |
apply simp+
|
|
167 |
done
|
|
168 |
|
444
|
169 |
|
|
170 |
fun rsimp_ALTs :: " rrexp list \<Rightarrow> rrexp"
|
|
171 |
where
|
|
172 |
"rsimp_ALTs [] = RZERO"
|
|
173 |
| "rsimp_ALTs [r] = r"
|
|
174 |
| "rsimp_ALTs rs = RALTS rs"
|
|
175 |
|
465
|
176 |
lemma rsimpalts_gte2elems:
|
|
177 |
shows "size rlist \<ge> 2 \<Longrightarrow> rsimp_ALTs rlist = RALTS rlist"
|
|
178 |
apply(induct rlist)
|
|
179 |
apply simp
|
|
180 |
apply(induct rlist)
|
|
181 |
apply simp
|
|
182 |
apply (metis Suc_le_length_iff rsimp_ALTs.simps(3))
|
|
183 |
by blast
|
|
184 |
|
|
185 |
lemma rsimpalts_conscons:
|
|
186 |
shows "rsimp_ALTs (r1 # rsa @ r2 # rsb) = RALTS (r1 # rsa @ r2 # rsb)"
|
|
187 |
by (metis Nil_is_append_conv list.exhaust rsimp_ALTs.simps(3))
|
|
188 |
|
476
|
189 |
lemma rsimp_alts_equal:
|
|
190 |
shows "rsimp_ALTs (rsa @ a # rsb @ a # rsc) = RALTS (rsa @ a # rsb @ a # rsc) "
|
|
191 |
by (metis append_Cons append_Nil neq_Nil_conv rsimpalts_conscons)
|
|
192 |
|
465
|
193 |
|
444
|
194 |
fun rsimp_SEQ :: " rrexp \<Rightarrow> rrexp \<Rightarrow> rrexp"
|
|
195 |
where
|
|
196 |
"rsimp_SEQ RZERO _ = RZERO"
|
|
197 |
| "rsimp_SEQ _ RZERO = RZERO"
|
|
198 |
| "rsimp_SEQ RONE r2 = r2"
|
|
199 |
| "rsimp_SEQ r1 r2 = RSEQ r1 r2"
|
|
200 |
|
|
201 |
|
|
202 |
fun rsimp :: "rrexp \<Rightarrow> rrexp"
|
|
203 |
where
|
|
204 |
"rsimp (RSEQ r1 r2) = rsimp_SEQ (rsimp r1) (rsimp r2)"
|
|
205 |
| "rsimp (RALTS rs) = rsimp_ALTs (rdistinct (rflts (map rsimp rs)) {}) "
|
|
206 |
| "rsimp r = r"
|
|
207 |
|
|
208 |
|
|
209 |
fun
|
|
210 |
rders_simp :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
|
|
211 |
where
|
|
212 |
"rders_simp r [] = r"
|
|
213 |
| "rders_simp r (c#s) = rders_simp (rsimp (rder c r)) s"
|
|
214 |
|
|
215 |
fun rsize :: "rrexp \<Rightarrow> nat" where
|
|
216 |
"rsize RZERO = 1"
|
|
217 |
| "rsize (RONE) = 1"
|
|
218 |
| "rsize (RCHAR c) = 1"
|
|
219 |
| "rsize (RALTS rs) = Suc (sum_list (map rsize rs))"
|
|
220 |
| "rsize (RSEQ r1 r2) = Suc (rsize r1 + rsize r2)"
|
|
221 |
| "rsize (RSTAR r) = Suc (rsize r)"
|
|
222 |
|
|
223 |
|
|
224 |
lemma rder_rsimp_ALTs_commute:
|
|
225 |
shows " (rder x (rsimp_ALTs rs)) = rsimp_ALTs (map (rder x) rs)"
|
|
226 |
apply(induct rs)
|
|
227 |
apply simp
|
|
228 |
apply(case_tac rs)
|
|
229 |
apply simp
|
|
230 |
apply auto
|
|
231 |
done
|
|
232 |
|
|
233 |
|
|
234 |
lemma rsimp_aalts_smaller:
|
|
235 |
shows "rsize (rsimp_ALTs rs) \<le> rsize (RALTS rs)"
|
|
236 |
apply(induct rs)
|
|
237 |
apply simp
|
|
238 |
apply simp
|
|
239 |
apply(case_tac "rs = []")
|
|
240 |
apply simp
|
|
241 |
apply(subgoal_tac "\<exists>rsp ap. rs = ap # rsp")
|
|
242 |
apply(erule exE)+
|
|
243 |
apply simp
|
|
244 |
apply simp
|
|
245 |
by(meson neq_Nil_conv)
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
lemma rSEQ_mono:
|
|
252 |
shows "rsize (rsimp_SEQ r1 r2) \<le>rsize ( RSEQ r1 r2)"
|
|
253 |
apply auto
|
|
254 |
apply(induct r1)
|
|
255 |
apply auto
|
|
256 |
apply(case_tac "r2")
|
|
257 |
apply simp_all
|
|
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 |
done
|
|
267 |
|
|
268 |
lemma ralts_cap_mono:
|
|
269 |
shows "rsize (RALTS rs) \<le> Suc ( sum_list (map rsize rs)) "
|
|
270 |
by simp
|
|
271 |
|
478
|
272 |
|
444
|
273 |
|
|
274 |
|
|
275 |
lemma rflts_mono:
|
|
276 |
shows "sum_list (map rsize (rflts rs))\<le> sum_list (map rsize rs)"
|
|
277 |
apply(induct rs)
|
|
278 |
apply simp
|
|
279 |
apply(case_tac "a = RZERO")
|
|
280 |
apply simp
|
|
281 |
apply(case_tac "\<exists>rs1. a = RALTS rs1")
|
|
282 |
apply(erule exE)
|
|
283 |
apply simp
|
|
284 |
apply(subgoal_tac "rflts (a # rs) = a # (rflts rs)")
|
|
285 |
prefer 2
|
|
286 |
using rflts_def_idiot apply blast
|
|
287 |
apply simp
|
|
288 |
done
|
|
289 |
|
|
290 |
lemma rdistinct_smaller: shows "sum_list (map rsize (rdistinct rs ss)) \<le>
|
|
291 |
sum_list (map rsize rs )"
|
|
292 |
apply (induct rs arbitrary: ss)
|
|
293 |
apply simp
|
|
294 |
by (simp add: trans_le_add2)
|
|
295 |
|
|
296 |
lemma rdistinct_phi_smaller: "sum_list (map rsize (rdistinct rs {})) \<le> sum_list (map rsize rs)"
|
|
297 |
by (simp add: rdistinct_smaller)
|
|
298 |
|
|
299 |
|
|
300 |
lemma rsimp_alts_mono :
|
|
301 |
shows "\<And>x. (\<And>xa. xa \<in> set x \<Longrightarrow> rsize (rsimp xa) \<le> rsize xa) \<Longrightarrow>
|
|
302 |
rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {})) \<le> Suc (sum_list (map rsize x))"
|
|
303 |
apply(subgoal_tac "rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {} ))
|
|
304 |
\<le> rsize (RALTS (rdistinct (rflts (map rsimp x)) {} ))")
|
|
305 |
prefer 2
|
|
306 |
using rsimp_aalts_smaller apply auto[1]
|
|
307 |
apply(subgoal_tac "rsize (RALTS (rdistinct (rflts (map rsimp x)) {})) \<le>Suc( sum_list (map rsize (rdistinct (rflts (map rsimp x)) {})))")
|
|
308 |
prefer 2
|
|
309 |
using ralts_cap_mono apply blast
|
|
310 |
apply(subgoal_tac "sum_list (map rsize (rdistinct (rflts (map rsimp x)) {})) \<le>
|
|
311 |
sum_list (map rsize ( (rflts (map rsimp x))))")
|
|
312 |
prefer 2
|
|
313 |
using rdistinct_smaller apply presburger
|
|
314 |
apply(subgoal_tac "sum_list (map rsize (rflts (map rsimp x))) \<le>
|
|
315 |
sum_list (map rsize (map rsimp x))")
|
|
316 |
prefer 2
|
|
317 |
using rflts_mono apply blast
|
|
318 |
apply(subgoal_tac "sum_list (map rsize (map rsimp x)) \<le> sum_list (map rsize x)")
|
|
319 |
prefer 2
|
|
320 |
|
|
321 |
apply (simp add: sum_list_mono)
|
|
322 |
by linarith
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
|
328 |
lemma rsimp_mono:
|
|
329 |
shows "rsize (rsimp r) \<le> rsize r"
|
|
330 |
apply(induct r)
|
|
331 |
apply simp_all
|
|
332 |
apply(subgoal_tac "rsize (rsimp_SEQ (rsimp r1) (rsimp r2)) \<le> rsize (RSEQ (rsimp r1) (rsimp r2))")
|
|
333 |
apply force
|
|
334 |
using rSEQ_mono
|
|
335 |
apply presburger
|
|
336 |
using rsimp_alts_mono by auto
|
|
337 |
|
|
338 |
lemma idiot:
|
|
339 |
shows "rsimp_SEQ RONE r = r"
|
|
340 |
apply(case_tac r)
|
|
341 |
apply simp_all
|
|
342 |
done
|
|
343 |
|
|
344 |
lemma no_alt_short_list_after_simp:
|
|
345 |
shows "RALTS rs = rsimp r \<Longrightarrow> rsimp_ALTs rs = RALTS rs"
|
|
346 |
sorry
|
|
347 |
|
|
348 |
lemma no_further_dB_after_simp:
|
|
349 |
shows "RALTS rs = rsimp r \<Longrightarrow> rdistinct rs {} = rs"
|
|
350 |
sorry
|
|
351 |
|
|
352 |
|
|
353 |
lemma idiot2:
|
|
354 |
shows " \<lbrakk>r1 \<noteq> RZERO; r1 \<noteq> RONE;r2 \<noteq> RZERO\<rbrakk>
|
|
355 |
\<Longrightarrow> rsimp_SEQ r1 r2 = RSEQ r1 r2"
|
|
356 |
apply(case_tac r1)
|
|
357 |
apply(case_tac r2)
|
|
358 |
apply simp_all
|
|
359 |
apply(case_tac r2)
|
|
360 |
apply simp_all
|
|
361 |
apply(case_tac r2)
|
|
362 |
apply simp_all
|
|
363 |
apply(case_tac r2)
|
|
364 |
apply simp_all
|
|
365 |
apply(case_tac r2)
|
|
366 |
apply simp_all
|
|
367 |
done
|
|
368 |
|
|
369 |
lemma rders__onechar:
|
|
370 |
shows " (rders_simp r [c]) = (rsimp (rders r [c]))"
|
|
371 |
by simp
|
|
372 |
|
|
373 |
lemma rders_append:
|
|
374 |
"rders c (s1 @ s2) = rders (rders c s1) s2"
|
|
375 |
apply(induct s1 arbitrary: c s2)
|
|
376 |
apply(simp_all)
|
|
377 |
done
|
|
378 |
|
|
379 |
lemma rders_simp_append:
|
|
380 |
"rders_simp c (s1 @ s2) = rders_simp (rders_simp c s1) s2"
|
|
381 |
apply(induct s1 arbitrary: c s2)
|
465
|
382 |
apply(simp_all)
|
444
|
383 |
done
|
|
384 |
|
480
|
385 |
|
444
|
386 |
|
|
387 |
lemma set_related_list:
|
|
388 |
shows "distinct rs \<Longrightarrow> length rs = card (set rs)"
|
|
389 |
by (simp add: distinct_card)
|
|
390 |
(*this section deals with the property of distinctBy: creates a list without duplicates*)
|
|
391 |
lemma rdistinct_never_added_twice:
|
|
392 |
shows "rdistinct (a # rs) {a} = rdistinct rs {a}"
|
|
393 |
by force
|
|
394 |
|
|
395 |
|
478
|
396 |
|
444
|
397 |
|
476
|
398 |
|
444
|
399 |
|
|
400 |
|
|
401 |
lemma rders_simp_one_char:
|
|
402 |
shows "rders_simp r [c] = rsimp (rder c r)"
|
|
403 |
apply auto
|
|
404 |
done
|
|
405 |
|
|
406 |
lemma rsimp_idem:
|
|
407 |
shows "rsimp (rsimp r) = rsimp r"
|
|
408 |
sorry
|
|
409 |
|
|
410 |
corollary rsimp_inner_idem1:
|
|
411 |
shows "rsimp r = RSEQ r1 r2 \<Longrightarrow> rsimp r1 = r1 \<and> rsimp r2 = r2"
|
|
412 |
|
|
413 |
sorry
|
|
414 |
|
|
415 |
corollary rsimp_inner_idem2:
|
|
416 |
shows "rsimp r = RALTS rs \<Longrightarrow> \<forall>r' \<in> (set rs). rsimp r' = r'"
|
|
417 |
sorry
|
|
418 |
|
|
419 |
corollary rsimp_inner_idem3:
|
|
420 |
shows "rsimp r = RALTS rs \<Longrightarrow> map rsimp rs = rs"
|
|
421 |
by (meson map_idI rsimp_inner_idem2)
|
|
422 |
|
|
423 |
corollary rsimp_inner_idem4:
|
465
|
424 |
shows "rsimp r = RALTS rs \<Longrightarrow> rflts rs = rs"
|
444
|
425 |
sorry
|
|
426 |
|
|
427 |
|
|
428 |
lemma head_one_more_simp:
|
|
429 |
shows "map rsimp (r # rs) = map rsimp (( rsimp r) # rs)"
|
|
430 |
by (simp add: rsimp_idem)
|
|
431 |
|
|
432 |
lemma head_one_more_dersimp:
|
|
433 |
shows "map rsimp ((rder x (rders_simp r s) # rs)) = map rsimp ((rders_simp r (s@[x]) ) # rs)"
|
|
434 |
using head_one_more_simp rders_simp_append rders_simp_one_char by presburger
|
|
435 |
|
|
436 |
|
|
437 |
|
488
|
438 |
fun
|
|
439 |
RL :: "rrexp \<Rightarrow> string set"
|
|
440 |
where
|
|
441 |
"RL (RZERO) = {}"
|
|
442 |
| "RL (RONE) = {[]}"
|
|
443 |
| "RL (RCHAR c) = {[c]}"
|
|
444 |
| "RL (RSEQ r1 r2) = (RL r1) ;; (RL r2)"
|
|
445 |
| "RL (RALTS rs) = (\<Union> (set (map RL rs)))"
|
|
446 |
| "RL (RSTAR r) = (RL r)\<star>"
|
|
447 |
|
|
448 |
|
|
449 |
lemma RL_rnullable:
|
|
450 |
shows "rnullable r = ([] \<in> RL r)"
|
|
451 |
apply(induct r)
|
|
452 |
apply(auto simp add: Sequ_def)
|
|
453 |
done
|
|
454 |
|
|
455 |
lemma RL_rder:
|
|
456 |
shows "RL (rder c r) = Der c (RL r)"
|
|
457 |
apply(induct r)
|
|
458 |
apply(auto simp add: Sequ_def Der_def)
|
|
459 |
apply (metis append_Cons)
|
|
460 |
using RL_rnullable apply blast
|
|
461 |
apply (metis append_eq_Cons_conv)
|
|
462 |
apply (metis append_Cons)
|
|
463 |
apply (metis RL_rnullable append_eq_Cons_conv)
|
|
464 |
apply (metis Star.step append_Cons)
|
|
465 |
using Star_decomp by auto
|
|
466 |
|
|
467 |
|
|
468 |
|
|
469 |
|
|
470 |
lemma RL_rsimp_RSEQ:
|
|
471 |
shows "RL (rsimp_SEQ r1 r2) = (RL r1 ;; RL r2)"
|
|
472 |
apply(induct r1 r2 rule: rsimp_SEQ.induct)
|
|
473 |
apply(simp_all)
|
|
474 |
done
|
|
475 |
|
|
476 |
lemma RL_rsimp_RALTS:
|
|
477 |
shows "RL (rsimp_ALTs rs) = (\<Union> (set (map RL rs)))"
|
|
478 |
apply(induct rs rule: rsimp_ALTs.induct)
|
|
479 |
apply(simp_all)
|
|
480 |
done
|
|
481 |
|
|
482 |
lemma RL_rsimp_rdistinct:
|
|
483 |
shows "(\<Union> (set (map RL (rdistinct rs {})))) = (\<Union> (set (map RL rs)))"
|
|
484 |
apply(auto)
|
|
485 |
apply (metis rdistinct_set_equality)
|
|
486 |
by (metis rdistinct_set_equality)
|
|
487 |
|
|
488 |
lemma RL_rsimp_rflts:
|
|
489 |
shows "(\<Union> (set (map RL (rflts rs)))) = (\<Union> (set (map RL rs)))"
|
|
490 |
apply(induct rs rule: rflts.induct)
|
|
491 |
apply(simp_all)
|
|
492 |
done
|
|
493 |
|
|
494 |
lemma RL_rsimp:
|
|
495 |
shows "RL r = RL (rsimp r)"
|
|
496 |
apply(induct r rule: rsimp.induct)
|
|
497 |
apply(auto simp add: Sequ_def RL_rsimp_RSEQ)
|
|
498 |
using RL_rsimp_RALTS RL_rsimp_rdistinct RL_rsimp_rflts apply auto[1]
|
|
499 |
by (smt (verit, del_insts) RL_rsimp_RALTS RL_rsimp_rdistinct RL_rsimp_rflts UN_E image_iff list.set_map)
|
|
500 |
|
|
501 |
lemma RL_rders:
|
|
502 |
shows "RL (rders_simp r s) = RL (rders r s)"
|
|
503 |
apply(induct s arbitrary: r rule: rev_induct)
|
|
504 |
apply(simp)
|
|
505 |
apply(simp add: rders_append rders_simp_append)
|
|
506 |
apply(subst RL_rsimp[symmetric])
|
|
507 |
using RL_rder by force
|
|
508 |
|
|
509 |
|
|
510 |
lemma der_simp_nullability:
|
|
511 |
shows "rnullable r = rnullable (rsimp r)"
|
|
512 |
using RL_rnullable RL_rsimp by auto
|
|
513 |
|
444
|
514 |
|
|
515 |
lemma ders_simp_nullability:
|
|
516 |
shows "rnullable (rders r s) = rnullable (rders_simp r s)"
|
488
|
517 |
apply(induct s arbitrary: r rule: rev_induct)
|
|
518 |
apply(simp)
|
|
519 |
apply(simp add: rders_append rders_simp_append)
|
|
520 |
apply(simp only: RL_rnullable)
|
|
521 |
apply(simp only: RL_rder)
|
|
522 |
apply(subst RL_rsimp[symmetric])
|
|
523 |
apply(simp only: RL_rder)
|
|
524 |
by (simp add: RL_rders)
|
444
|
525 |
|
488
|
526 |
|
|
527 |
|
|
528 |
|
480
|
529 |
|
|
530 |
|
444
|
531 |
lemma first_elem_seqder:
|
|
532 |
shows "\<not>rnullable r1p \<Longrightarrow> map rsimp (rder x (RSEQ r1p r2)
|
|
533 |
# rs) = map rsimp ((RSEQ (rder x r1p) r2) # rs) "
|
|
534 |
by auto
|
|
535 |
|
|
536 |
lemma first_elem_seqder1:
|
|
537 |
shows "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) =
|
|
538 |
map rsimp ( (RSEQ (rsimp (rder x (rders_simp r xs))) r2) # rs)"
|
|
539 |
by (simp add: rsimp_idem)
|
|
540 |
|
|
541 |
lemma first_elem_seqdersimps:
|
|
542 |
shows "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) =
|
|
543 |
map rsimp ( (RSEQ (rders_simp r (xs @ [x])) r2) # rs)"
|
|
544 |
using first_elem_seqder1 rders_simp_append by auto
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
478
|
554 |
lemma idem_after_simp1:
|
|
555 |
shows "rsimp_ALTs (rdistinct (rflts [rsimp aa]) {}) = rsimp aa"
|
|
556 |
apply(case_tac "rsimp aa")
|
|
557 |
apply simp+
|
|
558 |
apply (metis no_alt_short_list_after_simp no_further_dB_after_simp)
|
|
559 |
by simp
|
|
560 |
|
|
561 |
lemma identity_wwo0:
|
|
562 |
shows "rsimp (rsimp_ALTs (RZERO # rs)) = rsimp (rsimp_ALTs rs)"
|
|
563 |
by (metis idem_after_simp1 list.exhaust list.simps(8) list.simps(9) rflts.simps(2) rsimp.simps(2) rsimp.simps(3) rsimp_ALTs.simps(1) rsimp_ALTs.simps(2) rsimp_ALTs.simps(3))
|
|
564 |
|
|
565 |
|
|
566 |
lemma distinct_removes_last:
|
|
567 |
shows "\<lbrakk>a \<in> set as\<rbrakk>
|
|
568 |
\<Longrightarrow> rdistinct as rset = rdistinct (as @ [a]) rset"
|
|
569 |
and "rdistinct (ab # as @ [ab]) rset1 = rdistinct (ab # as) rset1"
|
|
570 |
apply(induct as arbitrary: rset ab rset1 a)
|
|
571 |
apply simp
|
|
572 |
apply simp
|
|
573 |
apply(case_tac "aa \<in> rset")
|
|
574 |
apply(case_tac "a = aa")
|
|
575 |
apply (metis append_Cons)
|
|
576 |
apply simp
|
|
577 |
apply(case_tac "a \<in> set as")
|
|
578 |
apply (metis append_Cons rdistinct.simps(2) set_ConsD)
|
|
579 |
apply(case_tac "a = aa")
|
|
580 |
prefer 2
|
|
581 |
apply simp
|
|
582 |
apply (metis append_Cons)
|
|
583 |
apply(case_tac "ab \<in> rset1")
|
|
584 |
prefer 2
|
|
585 |
apply(subgoal_tac "rdistinct (ab # (a # as) @ [ab]) rset1 =
|
|
586 |
ab # (rdistinct ((a # as) @ [ab]) (insert ab rset1))")
|
|
587 |
prefer 2
|
|
588 |
apply force
|
|
589 |
apply(simp only:)
|
|
590 |
apply(subgoal_tac "rdistinct (ab # a # as) rset1 = ab # (rdistinct (a # as) (insert ab rset1))")
|
|
591 |
apply(simp only:)
|
|
592 |
apply(subgoal_tac "rdistinct ((a # as) @ [ab]) (insert ab rset1) = rdistinct (a # as) (insert ab rset1)")
|
|
593 |
apply blast
|
|
594 |
apply(case_tac "a \<in> insert ab rset1")
|
|
595 |
apply simp
|
|
596 |
apply (metis insertI1)
|
|
597 |
apply simp
|
|
598 |
apply (meson insertI1)
|
|
599 |
apply simp
|
|
600 |
apply(subgoal_tac "rdistinct ((a # as) @ [ab]) rset1 = rdistinct (a # as) rset1")
|
|
601 |
apply simp
|
|
602 |
by (metis append_Cons insert_iff insert_is_Un rdistinct.simps(2))
|
|
603 |
|
|
604 |
|
|
605 |
lemma distinct_removes_middle:
|
|
606 |
shows "\<lbrakk>a \<in> set as\<rbrakk>
|
|
607 |
\<Longrightarrow> rdistinct (as @ as2) rset = rdistinct (as @ [a] @ as2) rset"
|
|
608 |
and "rdistinct (ab # as @ [ab] @ as3) rset1 = rdistinct (ab # as @ as3) rset1"
|
|
609 |
apply(induct as arbitrary: rset rset1 ab as2 as3 a)
|
|
610 |
apply simp
|
|
611 |
apply simp
|
|
612 |
apply(case_tac "a \<in> rset")
|
|
613 |
apply simp
|
|
614 |
apply metis
|
|
615 |
apply simp
|
|
616 |
apply (metis insertI1)
|
|
617 |
apply(case_tac "a = ab")
|
|
618 |
apply simp
|
|
619 |
apply(case_tac "ab \<in> rset")
|
|
620 |
apply simp
|
|
621 |
apply presburger
|
|
622 |
apply (meson insertI1)
|
|
623 |
apply(case_tac "a \<in> rset")
|
|
624 |
apply (metis (no_types, opaque_lifting) Un_insert_left append_Cons insert_iff rdistinct.simps(2) sup_bot_left)
|
|
625 |
apply(case_tac "ab \<in> rset")
|
|
626 |
apply simp
|
|
627 |
apply (meson insert_iff)
|
|
628 |
apply simp
|
|
629 |
by (metis insertI1)
|
|
630 |
|
|
631 |
|
|
632 |
lemma distinct_removes_middle3:
|
|
633 |
shows "\<lbrakk>a \<in> set as\<rbrakk>
|
|
634 |
\<Longrightarrow> rdistinct (as @ a #as2) rset = rdistinct (as @ as2) rset"
|
|
635 |
using distinct_removes_middle(1) by fastforce
|
|
636 |
|
|
637 |
lemma distinct_removes_last2:
|
|
638 |
shows "\<lbrakk>a \<in> set as\<rbrakk>
|
|
639 |
\<Longrightarrow> rdistinct as rset = rdistinct (as @ [a]) rset"
|
|
640 |
by (simp add: distinct_removes_last(1))
|
|
641 |
|
|
642 |
lemma distinct_removes_middle2:
|
|
643 |
shows "a \<in> set as \<Longrightarrow> rdistinct (as @ [a] @ rs) {} = rdistinct (as @ rs) {}"
|
|
644 |
by (metis distinct_removes_middle(1))
|
|
645 |
|
|
646 |
lemma distinct_removes_list:
|
|
647 |
shows "\<lbrakk> \<forall>r \<in> set rs. r \<in> set as\<rbrakk> \<Longrightarrow> rdistinct (as @ rs) {} = rdistinct as {}"
|
|
648 |
apply(induct rs)
|
|
649 |
apply simp+
|
|
650 |
apply(subgoal_tac "rdistinct (as @ a # rs) {} = rdistinct (as @ rs) {}")
|
|
651 |
prefer 2
|
|
652 |
apply (metis append_Cons append_Nil distinct_removes_middle(1))
|
|
653 |
by presburger
|
|
654 |
|
|
655 |
|
|
656 |
lemma spawn_simp_rsimpalts:
|
|
657 |
shows "rsimp (rsimp_ALTs rs) = rsimp (rsimp_ALTs (map rsimp rs))"
|
|
658 |
apply(cases rs)
|
|
659 |
apply simp
|
|
660 |
apply(case_tac list)
|
|
661 |
apply simp
|
|
662 |
apply(subst rsimp_idem[symmetric])
|
|
663 |
apply simp
|
|
664 |
apply(subgoal_tac "rsimp_ALTs rs = RALTS rs")
|
|
665 |
apply(simp only:)
|
|
666 |
apply(subgoal_tac "rsimp_ALTs (map rsimp rs) = RALTS (map rsimp rs)")
|
|
667 |
apply(simp only:)
|
|
668 |
prefer 2
|
|
669 |
apply simp
|
|
670 |
prefer 2
|
|
671 |
using rsimp_ALTs.simps(3) apply presburger
|
|
672 |
apply auto
|
|
673 |
apply(subst rsimp_idem)+
|
|
674 |
by (metis comp_apply rsimp_idem)
|
444
|
675 |
|
|
676 |
|
|
677 |
|
|
678 |
|
478
|
679 |
inductive good1 :: "rrexp \<Rightarrow> bool"
|
|
680 |
where
|
|
681 |
"\<lbrakk>RZERO \<notin> set rs; \<nexists>rs1. RALTS rs1 \<in> set rs\<rbrakk> \<Longrightarrow> good1 (RALTS rs)"
|
|
682 |
|"good1 RZERO"
|
|
683 |
|"good1 RONE"
|
|
684 |
|"good1 (RCHAR c)"
|
|
685 |
|"good1 (RSEQ r1 r2)"
|
|
686 |
|"good1 (RSTAR r0)"
|
444
|
687 |
|
478
|
688 |
inductive goods :: "rrexp list \<Rightarrow> bool"
|
|
689 |
where
|
|
690 |
"goods []"
|
|
691 |
|"\<lbrakk>goods rs; r \<noteq> RZERO; \<nexists>rs1. RALTS rs1 = r\<rbrakk> \<Longrightarrow> goods (r # rs)"
|
|
692 |
|
|
693 |
lemma goods_good1:
|
|
694 |
shows "goods rs = good1 (RALTS rs)"
|
|
695 |
apply(induct rs)
|
|
696 |
apply (simp add: good1.intros(1) goods.intros(1))
|
|
697 |
apply(case_tac "goods rs")
|
|
698 |
apply(case_tac a)
|
|
699 |
apply simp
|
|
700 |
using good1.simps goods.cases apply auto[1]
|
|
701 |
apply (simp add: good1.simps goods.intros(2))
|
|
702 |
apply (simp add: good1.simps goods.intros(2))
|
|
703 |
apply (simp add: good1.simps goods.intros(2))
|
|
704 |
using good1.simps goods.cases apply auto[1]
|
|
705 |
apply (metis good1.cases good1.intros(1) goods.intros(2) rrexp.distinct(15) rrexp.distinct(21) rrexp.distinct(25) rrexp.distinct(29) rrexp.distinct(7) rrexp.distinct(9) rrexp.inject(3) set_ConsD)
|
|
706 |
apply simp
|
|
707 |
by (metis good1.cases good1.intros(1) goods.cases list.distinct(1) list.inject list.set_intros(2) rrexp.distinct(15) rrexp.distinct(29) rrexp.distinct(7) rrexp.inject(3) rrexp.simps(26) rrexp.simps(30))
|
|
708 |
|
488
|
709 |
lemma rsimp_good10:
|
|
710 |
shows "good1 (rsimp r)"
|
|
711 |
apply(induct r)
|
|
712 |
apply simp
|
|
713 |
|
|
714 |
apply (simp add: good1.intros(2))
|
|
715 |
apply simp
|
|
716 |
|
|
717 |
apply (simp add: good1.intros(3))
|
|
718 |
|
|
719 |
apply (simp add: good1.intros(4))
|
|
720 |
sledgehammer
|
|
721 |
|
|
722 |
sorry
|
|
723 |
|
478
|
724 |
lemma rsimp_good1:
|
|
725 |
shows "rsimp r = r1 \<Longrightarrow> good1 r1"
|
488
|
726 |
using rsimp_good10 by blast
|
478
|
727 |
|
488
|
728 |
|
478
|
729 |
|
|
730 |
lemma rsimp_no_dup:
|
|
731 |
shows "rsimp r = RALTS rs \<Longrightarrow> distinct rs"
|
|
732 |
sorry
|
|
733 |
|
|
734 |
|
|
735 |
lemma rsimp_good1_2:
|
|
736 |
shows "map rsimp rsa = [RALTS rs] \<Longrightarrow> good1 (RALTS rs)"
|
|
737 |
by (metis Cons_eq_map_D rsimp_good1)
|
|
738 |
|
|
739 |
|
|
740 |
|
|
741 |
lemma simp_singlealt_flatten:
|
|
742 |
shows "rsimp (RALTS [RALTS rsa]) = rsimp (RALTS (rsa @ []))"
|
|
743 |
apply(induct rsa)
|
|
744 |
apply simp
|
|
745 |
apply simp
|
|
746 |
by (metis idem_after_simp1 list.simps(9) rsimp.simps(2))
|
|
747 |
|
|
748 |
|
|
749 |
lemma good1_rsimpalts:
|
|
750 |
shows "rsimp r = RALTS rs \<Longrightarrow> rsimp_ALTs rs = RALTS rs"
|
|
751 |
by (metis no_alt_short_list_after_simp)
|
|
752 |
|
|
753 |
|
|
754 |
lemma good1_flts:
|
|
755 |
shows "good1 (RALTS rs1) \<Longrightarrow> rflts rs1 = rs1"
|
|
756 |
apply(induct rs1)
|
|
757 |
apply simp
|
|
758 |
by (metis good1.cases good1.intros(1) list.set_intros(1) rflts_def_idiot rrexp.distinct(21) rrexp.distinct(25) rrexp.distinct(29) rrexp.inject(3) rsimp.simps(3) rsimp.simps(4) rsimp_inner_idem4 set_subset_Cons subsetD)
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
lemma good1_flatten:
|
|
763 |
shows "\<lbrakk> rsimp r = (RALTS rs1)\<rbrakk>
|
|
764 |
\<Longrightarrow> rflts (rsimp_ALTs rs1 # map rsimp rsb) = rflts (rs1 @ map rsimp rsb)"
|
|
765 |
apply(subst good1_rsimpalts)
|
|
766 |
apply simp+
|
|
767 |
apply(subgoal_tac "rflts (rs1 @ map rsimp rsb) = rs1 @ rflts (map rsimp rsb)")
|
|
768 |
apply simp
|
|
769 |
apply(subgoal_tac "good1 (RALTS rs1)")
|
|
770 |
prefer 2
|
|
771 |
using rsimp_good1 apply blast
|
|
772 |
using flts_append good1_flts by presburger
|
|
773 |
|
|
774 |
lemma flatten_rsimpalts:
|
|
775 |
shows "rflts (rsimp_ALTs (rdistinct (rflts (map rsimp rsa)) {}) # map rsimp rsb) =
|
|
776 |
rflts ( (rdistinct (rflts (map rsimp rsa)) {}) @ map rsimp rsb)"
|
|
777 |
apply(case_tac "map rsimp rsa")
|
|
778 |
apply simp
|
|
779 |
apply(case_tac "list")
|
|
780 |
apply simp
|
|
781 |
apply(case_tac a)
|
|
782 |
apply simp+
|
|
783 |
apply(rename_tac rs1)
|
|
784 |
apply(subgoal_tac "good1 (RALTS rs1)")
|
|
785 |
apply(subgoal_tac "distinct rs1")
|
|
786 |
apply(subst rdistinct_on_distinct)
|
|
787 |
apply blast
|
|
788 |
apply(subst rdistinct_on_distinct)
|
|
789 |
apply blast
|
|
790 |
using good1_flatten apply blast
|
|
791 |
|
|
792 |
using rsimp_no_dup apply force
|
|
793 |
|
|
794 |
using rsimp_good1_2 apply presburger
|
|
795 |
|
|
796 |
apply simp+
|
|
797 |
apply(case_tac "rflts (a # aa # lista)")
|
|
798 |
apply simp
|
|
799 |
by (smt (verit) append_Cons append_Nil empty_iff good1_flatten list.distinct(1) rdistinct.simps(2) rsimp.simps(2) rsimp_ALTs.elims rsimp_good1)
|
|
800 |
|
|
801 |
|
|
802 |
lemma flts_good_good:
|
|
803 |
shows "\<forall>r \<in> set rs. good1 r \<Longrightarrow> good1 (RALTS (rflts rs ))"
|
|
804 |
apply(induct rs)
|
|
805 |
apply simp
|
|
806 |
using goods.intros(1) goods_good1 apply auto[1]
|
|
807 |
apply(case_tac "a")
|
|
808 |
apply simp
|
|
809 |
apply (metis goods.intros(2) goods_good1 list.set_intros(2) rflts.simps(4) rrexp.distinct(1) rrexp.distinct(15))
|
|
810 |
apply simp
|
|
811 |
using goods.intros(2) goods_good1 apply blast
|
|
812 |
using goods.intros(2) goods_good1 apply auto[1]
|
|
813 |
apply(subgoal_tac "good1 a")
|
|
814 |
apply (metis Un_iff good1.cases good1.intros(1) list.set_intros(2) rflts.simps(3) rrexp.distinct(15) rrexp.distinct(21) rrexp.distinct(25) rrexp.distinct(29) rrexp.distinct(7) rrexp.inject(3) set_append)
|
|
815 |
apply simp
|
|
816 |
by (metis goods.intros(2) goods_good1 list.set_intros(2) rflts.simps(7) rrexp.distinct(29) rrexp.distinct(9))
|
|
817 |
|
|
818 |
|
|
819 |
lemma simp_flatten_aux1:
|
|
820 |
shows "\<forall>r \<in> set (map rsimp rsa). good1 r"
|
|
821 |
apply(induct rsa)
|
|
822 |
apply(simp add: goods.intros)
|
|
823 |
using rsimp_good1 by auto
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
lemma simp_flatten_aux:
|
|
828 |
shows "\<forall>r \<in> set rs. good1 r \<Longrightarrow> rflts (rdistinct (rflts rs) {}) = (rdistinct (rflts rs) {})"
|
|
829 |
sorry
|
476
|
830 |
|
444
|
831 |
|
|
832 |
|
488
|
833 |
lemma rdistinct_concat_general:
|
|
834 |
shows "rdistinct (rs1 @ rs2) {} = (rdistinct rs1 {}) @ (rdistinct rs2 (set rs1))"
|
|
835 |
|
|
836 |
sorry
|
|
837 |
|
|
838 |
lemma distinct_once_enough:
|
|
839 |
shows "rdistinct (rs @ rsa) {} = rdistinct (rdistinct rs {} @ rsa) {}"
|
|
840 |
apply(subgoal_tac "distinct (rdistinct rs {})")
|
|
841 |
apply(subgoal_tac
|
|
842 |
" rdistinct (rdistinct rs {} @ rsa) {} = rdistinct rs {} @ (rdistinct rsa (set rs))")
|
|
843 |
apply(simp only:)
|
|
844 |
using rdistinct_concat_general apply blast
|
|
845 |
apply (simp add: distinct_rdistinct_append rdistinct_set_equality)
|
|
846 |
by (simp add: rdistinct_does_the_job)
|
|
847 |
|
|
848 |
|
444
|
849 |
lemma simp_flatten:
|
|
850 |
shows "rsimp (RALTS ((RALTS rsa) # rsb)) = rsimp (RALTS (rsa @ rsb))"
|
478
|
851 |
apply simp
|
|
852 |
apply(subst flatten_rsimpalts)
|
|
853 |
apply(simp add: flts_append)
|
|
854 |
apply(subgoal_tac "\<forall>r \<in> set (map rsimp rsa). good1 r")
|
|
855 |
apply (metis distinct_once_enough simp_flatten_aux)
|
|
856 |
using simp_flatten_aux1 by blast
|
444
|
857 |
|
478
|
858 |
lemma simp_flatten3:
|
|
859 |
shows "rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) = rsimp (RALTS (rsa @ rs @ rsb))"
|
444
|
860 |
sorry
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
fun vsuf :: "char list \<Rightarrow> rrexp \<Rightarrow> char list list" where
|
|
865 |
"vsuf [] _ = []"
|
|
866 |
|"vsuf (c#cs) r1 = (if (rnullable r1) then (vsuf cs (rder c r1)) @ [c # cs]
|
|
867 |
else (vsuf cs (rder c r1))
|
|
868 |
) "
|
|
869 |
|
|
870 |
|
|
871 |
|
|
872 |
|
|
873 |
|
|
874 |
|
|
875 |
fun star_update :: "char \<Rightarrow> rrexp \<Rightarrow> char list list \<Rightarrow> char list list" where
|
|
876 |
"star_update c r [] = []"
|
486
|
877 |
|"star_update c r (s # Ss) = (if (rnullable (rders r s))
|
444
|
878 |
then (s@[c]) # [c] # (star_update c r Ss)
|
|
879 |
else (s@[c]) # (star_update c r Ss) )"
|
|
880 |
|
486
|
881 |
|
444
|
882 |
fun star_updates :: "char list \<Rightarrow> rrexp \<Rightarrow> char list list \<Rightarrow> char list list"
|
|
883 |
where
|
|
884 |
"star_updates [] r Ss = Ss"
|
|
885 |
| "star_updates (c # cs) r Ss = star_updates cs r (star_update c r Ss)"
|
|
886 |
|
486
|
887 |
lemma stupdates_append: shows
|
|
888 |
"star_updates (s @ [c]) r Ss = star_update c r (star_updates s r Ss)"
|
|
889 |
apply(induct s arbitrary: Ss)
|
|
890 |
apply simp
|
|
891 |
apply simp
|
|
892 |
done
|
|
893 |
|
444
|
894 |
|
478
|
895 |
lemma distinct_flts_no0:
|
|
896 |
shows " rflts (map rsimp (rdistinct rs (insert RZERO rset))) =
|
|
897 |
rflts (map rsimp (rdistinct rs rset)) "
|
|
898 |
|
|
899 |
apply(induct rs arbitrary: rset)
|
|
900 |
apply simp
|
|
901 |
apply(case_tac a)
|
|
902 |
apply simp+
|
|
903 |
apply (smt (verit, ccfv_SIG) rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
904 |
prefer 2
|
|
905 |
apply simp
|
|
906 |
by (smt (verit, ccfv_threshold) Un_insert_right insert_iff list.simps(9) rdistinct.simps(2) rflts.simps(2) rflts.simps(3) rflts_def_idiot rrexp.distinct(7))
|
444
|
907 |
|
478
|
908 |
lemma flts_removes0:
|
|
909 |
shows " rflts (rs @ [RZERO]) =
|
|
910 |
rflts rs"
|
|
911 |
apply(induct rs)
|
|
912 |
apply simp
|
|
913 |
by (metis append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
914 |
|
|
915 |
|
|
916 |
lemma rflts_spills_last:
|
|
917 |
shows "a = RALTS rs \<Longrightarrow> rflts (rs1 @ [a]) = rflts rs1 @ rs"
|
|
918 |
apply (induct rs1)
|
|
919 |
apply simp
|
|
920 |
by (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
921 |
|
|
922 |
lemma flts_keeps1:
|
|
923 |
shows " rflts (rs @ [RONE]) =
|
|
924 |
rflts rs @ [RONE] "
|
|
925 |
apply (induct rs)
|
|
926 |
apply simp
|
|
927 |
by (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
928 |
|
|
929 |
lemma flts_keeps_others:
|
|
930 |
shows "\<lbrakk>a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1\<rbrakk> \<Longrightarrow>rflts (rs @ [a]) = rflts rs @ [a]"
|
|
931 |
apply(induct rs)
|
|
932 |
apply simp
|
|
933 |
apply (simp add: rflts_def_idiot)
|
|
934 |
apply(case_tac a)
|
|
935 |
apply simp
|
|
936 |
using flts_keeps1 apply blast
|
|
937 |
apply (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
938 |
apply (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
939 |
apply blast
|
|
940 |
by (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
|
|
941 |
|
|
942 |
lemma spilled_alts_contained:
|
|
943 |
shows "\<lbrakk>a = RALTS rs ; a \<in> set rs1\<rbrakk> \<Longrightarrow> \<forall>r \<in> set rs. r \<in> set (rflts rs1)"
|
|
944 |
apply(induct rs1)
|
|
945 |
apply simp
|
|
946 |
apply(case_tac "a = aa")
|
|
947 |
apply simp
|
|
948 |
apply(subgoal_tac " a \<in> set rs1")
|
|
949 |
prefer 2
|
|
950 |
apply (meson set_ConsD)
|
|
951 |
apply(case_tac aa)
|
|
952 |
using rflts.simps(2) apply presburger
|
|
953 |
apply fastforce
|
|
954 |
apply fastforce
|
|
955 |
apply fastforce
|
|
956 |
apply fastforce
|
|
957 |
by fastforce
|
|
958 |
|
|
959 |
|
|
960 |
lemma distinct_removes_duplicate_flts:
|
|
961 |
shows " a \<in> set rsa
|
|
962 |
\<Longrightarrow> rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} =
|
|
963 |
rdistinct (rflts (map rsimp rsa)) {}"
|
|
964 |
apply(subgoal_tac "rsimp a \<in> set (map rsimp rsa)")
|
|
965 |
prefer 2
|
|
966 |
apply simp
|
|
967 |
apply(induct "rsimp a")
|
|
968 |
apply simp
|
|
969 |
using flts_removes0 apply presburger
|
|
970 |
apply(subgoal_tac " rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} =
|
|
971 |
rdistinct (rflts (map rsimp rsa @ [RONE])) {}")
|
|
972 |
apply (simp only:)
|
|
973 |
apply(subst flts_keeps1)
|
|
974 |
apply (metis distinct_removes_last2 rflts_def_idiot2 rrexp.simps(20) rrexp.simps(6))
|
|
975 |
apply presburger
|
|
976 |
apply(subgoal_tac " rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} =
|
|
977 |
rdistinct ((rflts (map rsimp rsa)) @ [RCHAR x]) {}")
|
|
978 |
apply (simp only:)
|
|
979 |
prefer 2
|
|
980 |
apply (metis flts_keeps_others rrexp.distinct(21) rrexp.distinct(3))
|
|
981 |
apply (metis distinct_removes_last2 rflts_def_idiot2 rrexp.distinct(21) rrexp.distinct(3))
|
|
982 |
|
|
983 |
apply (metis distinct_removes_last2 flts_keeps_others rflts_def_idiot2 rrexp.distinct(25) rrexp.distinct(5))
|
|
984 |
prefer 2
|
|
985 |
apply (metis distinct_removes_last2 flts_keeps_others flts_removes0 rflts_def_idiot2 rrexp.distinct(29))
|
|
986 |
apply(subgoal_tac "rflts (map rsimp rsa @ [rsimp a]) = rflts (map rsimp rsa) @ x")
|
|
987 |
prefer 2
|
|
988 |
apply (simp add: rflts_spills_last)
|
|
989 |
apply(simp only:)
|
|
990 |
apply(subgoal_tac "\<forall> r \<in> set x. r \<in> set (rflts (map rsimp rsa))")
|
|
991 |
prefer 2
|
|
992 |
using spilled_alts_contained apply presburger
|
|
993 |
using distinct_removes_list by blast
|
444
|
994 |
|
|
995 |
|
|
996 |
|
|
997 |
(*some basic facts about rsimp*)
|
|
998 |
|
|
999 |
|
|
1000 |
|
|
1001 |
|
|
1002 |
end |