|
1 |
|
2 theory Re |
|
3 imports "Main" |
|
4 begin |
|
5 |
|
6 |
|
7 section {* Sequential Composition of Sets *} |
|
8 |
|
9 definition |
|
10 Sequ :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100) |
|
11 where |
|
12 "A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}" |
|
13 |
|
14 text {* Two Simple Properties about Sequential Composition *} |
|
15 |
|
16 lemma seq_empty [simp]: |
|
17 shows "A ;; {[]} = A" |
|
18 and "{[]} ;; A = A" |
|
19 by (simp_all add: Sequ_def) |
|
20 |
|
21 lemma seq_null [simp]: |
|
22 shows "A ;; {} = {}" |
|
23 and "{} ;; A = {}" |
|
24 by (simp_all add: Sequ_def) |
|
25 |
|
26 section {* Regular Expressions *} |
|
27 |
|
28 datatype rexp = |
|
29 NULL |
|
30 | EMPTY |
|
31 | CHAR char |
|
32 | SEQ rexp rexp |
|
33 | ALT rexp rexp |
|
34 |
|
35 section {* Semantics of Regular Expressions *} |
|
36 |
|
37 fun |
|
38 L :: "rexp \<Rightarrow> string set" |
|
39 where |
|
40 "L (NULL) = {}" |
|
41 | "L (EMPTY) = {[]}" |
|
42 | "L (CHAR c) = {[c]}" |
|
43 | "L (SEQ r1 r2) = (L r1) ;; (L r2)" |
|
44 | "L (ALT r1 r2) = (L r1) \<union> (L r2)" |
|
45 |
|
46 fun |
|
47 nullable :: "rexp \<Rightarrow> bool" |
|
48 where |
|
49 "nullable (NULL) = False" |
|
50 | "nullable (EMPTY) = True" |
|
51 | "nullable (CHAR c) = False" |
|
52 | "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)" |
|
53 | "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)" |
|
54 |
|
55 lemma nullable_correctness: |
|
56 shows "nullable r \<longleftrightarrow> [] \<in> (L r)" |
|
57 apply (induct r) |
|
58 apply(auto simp add: Sequ_def) |
|
59 done |
|
60 |
|
61 section {* Values *} |
|
62 |
|
63 datatype val = |
|
64 Void |
|
65 | Char char |
|
66 | Seq val val |
|
67 | Right val |
|
68 | Left val |
|
69 |
|
70 section {* The string behind a value *} |
|
71 |
|
72 fun |
|
73 flat :: "val \<Rightarrow> string" |
|
74 where |
|
75 "flat(Void) = []" |
|
76 | "flat(Char c) = [c]" |
|
77 | "flat(Left v) = flat(v)" |
|
78 | "flat(Right v) = flat(v)" |
|
79 | "flat(Seq v1 v2) = flat(v1) @ flat(v2)" |
|
80 |
|
81 section {* Relation between values and regular expressions *} |
|
82 |
|
83 inductive |
|
84 Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<turnstile> _ : _" [100, 100] 100) |
|
85 where |
|
86 "\<lbrakk>\<turnstile> v1 : r1; \<turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<turnstile> Seq v1 v2 : SEQ r1 r2" |
|
87 | "\<turnstile> v1 : r1 \<Longrightarrow> \<turnstile> Left v1 : ALT r1 r2" |
|
88 | "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2" |
|
89 | "\<turnstile> Void : EMPTY" |
|
90 | "\<turnstile> Char c : CHAR c" |
|
91 |
|
92 lemma not_nullable_flat: |
|
93 assumes "\<turnstile> v : r" "\<not>nullable r" |
|
94 shows "flat v \<noteq> []" |
|
95 using assms |
|
96 apply(induct) |
|
97 apply(auto) |
|
98 done |
|
99 |
|
100 lemma Prf_flat_L: |
|
101 assumes "\<turnstile> v : r" shows "flat v \<in> L r" |
|
102 using assms |
|
103 apply(induct v r rule: Prf.induct) |
|
104 apply(auto simp add: Sequ_def) |
|
105 done |
|
106 |
|
107 lemma L_flat_Prf: |
|
108 "L(r) = {flat v | v. \<turnstile> v : r}" |
|
109 apply(induct r) |
|
110 apply(auto dest: Prf_flat_L simp add: Sequ_def) |
|
111 apply (metis Prf.intros(4) flat.simps(1)) |
|
112 apply (metis Prf.intros(5) flat.simps(2)) |
|
113 apply (metis Prf.intros(1) flat.simps(5)) |
|
114 apply (metis Prf.intros(2) flat.simps(3)) |
|
115 apply (metis Prf.intros(3) flat.simps(4)) |
|
116 apply(erule Prf.cases) |
|
117 apply(auto) |
|
118 done |
|
119 |
|
120 section {* Greedy Ordering according to Frisch/Cardelli *} |
|
121 |
|
122 inductive |
|
123 GrOrd :: "val \<Rightarrow> val \<Rightarrow> bool" ("_ gr\<succ> _") |
|
124 where |
|
125 "v1 gr\<succ> v1' \<Longrightarrow> (Seq v1 v2) gr\<succ> (Seq v1' v2')" |
|
126 | "v2 gr\<succ> v2' \<Longrightarrow> (Seq v1 v2) gr\<succ> (Seq v1 v2')" |
|
127 | "v1 gr\<succ> v2 \<Longrightarrow> (Left v1) gr\<succ> (Left v2)" |
|
128 | "v1 gr\<succ> v2 \<Longrightarrow> (Right v1) gr\<succ> (Right v2)" |
|
129 | "(Left v2) gr\<succ>(Right v1)" |
|
130 | "(Char c) gr\<succ> (Char c)" |
|
131 | "(Void) gr\<succ> (Void)" |
|
132 |
|
133 lemma Gr_refl: |
|
134 assumes "\<turnstile> v : r" |
|
135 shows "v gr\<succ> v" |
|
136 using assms |
|
137 apply(induct) |
|
138 apply(auto intro: GrOrd.intros) |
|
139 done |
|
140 |
|
141 lemma Gr_total: |
|
142 assumes "\<turnstile> v1 : r" "\<turnstile> v2 : r" |
|
143 shows "v1 gr\<succ> v2 \<or> v2 gr\<succ> v1" |
|
144 using assms |
|
145 apply(induct v1 r arbitrary: v2 rule: Prf.induct) |
|
146 apply(rotate_tac 4) |
|
147 apply(erule Prf.cases) |
|
148 apply(simp_all)[5] |
|
149 apply(clarify) |
|
150 apply (metis GrOrd.intros(1) GrOrd.intros(2)) |
|
151 apply(rotate_tac 2) |
|
152 apply(erule Prf.cases) |
|
153 apply(simp_all) |
|
154 apply(clarify) |
|
155 apply (metis GrOrd.intros(3)) |
|
156 apply(clarify) |
|
157 apply (metis GrOrd.intros(5)) |
|
158 apply(rotate_tac 2) |
|
159 apply(erule Prf.cases) |
|
160 apply(simp_all) |
|
161 apply(clarify) |
|
162 apply (metis GrOrd.intros(5)) |
|
163 apply(clarify) |
|
164 apply (metis GrOrd.intros(4)) |
|
165 apply(erule Prf.cases) |
|
166 apply(simp_all) |
|
167 apply (metis GrOrd.intros(7)) |
|
168 apply(erule Prf.cases) |
|
169 apply(simp_all) |
|
170 apply (metis GrOrd.intros(6)) |
|
171 done |
|
172 |
|
173 lemma Gr_trans: |
|
174 assumes "v1 gr\<succ> v2" "v2 gr\<succ> v3" |
|
175 and "\<turnstile> v1 : r" "\<turnstile> v2 : r" "\<turnstile> v3 : r" |
|
176 shows "v1 gr\<succ> v3" |
|
177 using assms |
|
178 apply(induct r arbitrary: v1 v2 v3) |
|
179 apply(erule Prf.cases) |
|
180 apply(simp_all)[5] |
|
181 apply(erule Prf.cases) |
|
182 apply(simp_all)[5] |
|
183 apply(erule Prf.cases) |
|
184 apply(simp_all)[5] |
|
185 apply(erule Prf.cases) |
|
186 apply(simp_all)[5] |
|
187 apply(erule Prf.cases) |
|
188 apply(simp_all)[5] |
|
189 defer |
|
190 (* ALT case *) |
|
191 apply(erule Prf.cases) |
|
192 apply(simp_all (no_asm_use))[5] |
|
193 apply(erule Prf.cases) |
|
194 apply(simp_all (no_asm_use))[5] |
|
195 apply(erule Prf.cases) |
|
196 apply(simp_all (no_asm_use))[5] |
|
197 apply(clarify) |
|
198 apply(erule GrOrd.cases) |
|
199 apply(simp_all (no_asm_use))[7] |
|
200 apply(erule GrOrd.cases) |
|
201 apply(simp_all (no_asm_use))[7] |
|
202 apply (metis GrOrd.intros(3)) |
|
203 apply(clarify) |
|
204 apply(erule GrOrd.cases) |
|
205 apply(simp_all (no_asm_use))[7] |
|
206 apply(erule GrOrd.cases) |
|
207 apply(simp_all (no_asm_use))[7] |
|
208 apply (metis GrOrd.intros(5)) |
|
209 apply(erule Prf.cases) |
|
210 apply(simp_all (no_asm_use))[5] |
|
211 apply(clarify) |
|
212 apply(erule GrOrd.cases) |
|
213 apply(simp_all (no_asm_use))[7] |
|
214 apply(erule GrOrd.cases) |
|
215 apply(simp_all (no_asm_use))[7] |
|
216 apply (metis GrOrd.intros(5)) |
|
217 apply(erule Prf.cases) |
|
218 apply(simp_all (no_asm_use))[5] |
|
219 apply(erule Prf.cases) |
|
220 apply(simp_all (no_asm_use))[5] |
|
221 apply(clarify) |
|
222 apply(erule GrOrd.cases) |
|
223 apply(simp_all (no_asm_use))[7] |
|
224 apply(clarify) |
|
225 apply(erule GrOrd.cases) |
|
226 apply(simp_all (no_asm_use))[7] |
|
227 apply(erule Prf.cases) |
|
228 apply(simp_all (no_asm_use))[5] |
|
229 apply(clarify) |
|
230 apply(erule GrOrd.cases) |
|
231 apply(simp_all (no_asm_use))[7] |
|
232 apply(erule GrOrd.cases) |
|
233 apply(simp_all (no_asm_use))[7] |
|
234 apply(clarify) |
|
235 apply(erule GrOrd.cases) |
|
236 apply(simp_all (no_asm_use))[7] |
|
237 apply(erule GrOrd.cases) |
|
238 apply(simp_all (no_asm_use))[7] |
|
239 apply (metis GrOrd.intros(4)) |
|
240 (* SEQ case *) |
|
241 apply(erule Prf.cases) |
|
242 apply(simp_all (no_asm_use))[5] |
|
243 apply(erule Prf.cases) |
|
244 apply(simp_all (no_asm_use))[5] |
|
245 apply(erule Prf.cases) |
|
246 apply(simp_all (no_asm_use))[5] |
|
247 apply(clarify) |
|
248 apply(erule GrOrd.cases) |
|
249 apply(simp_all (no_asm_use))[7] |
|
250 apply(erule GrOrd.cases) |
|
251 apply(simp_all (no_asm_use))[7] |
|
252 apply(clarify) |
|
253 apply (metis GrOrd.intros(1)) |
|
254 apply (metis GrOrd.intros(1)) |
|
255 apply(erule GrOrd.cases) |
|
256 apply(simp_all (no_asm_use))[7] |
|
257 apply (metis GrOrd.intros(1)) |
|
258 by (metis GrOrd.intros(1) Gr_refl) |
|
259 |
|
260 |
|
261 section {* Values Sets *} |
|
262 |
|
263 definition prefix :: "string \<Rightarrow> string \<Rightarrow> bool" ("_ \<sqsubseteq> _" [100, 100] 100) |
|
264 where |
|
265 "s1 \<sqsubseteq> s2 \<equiv> \<exists>s3. s1 @ s3 = s2" |
|
266 |
|
267 definition sprefix :: "string \<Rightarrow> string \<Rightarrow> bool" ("_ \<sqsubset> _" [100, 100] 100) |
|
268 where |
|
269 "s1 \<sqsubset> s2 \<equiv> (s1 \<sqsubseteq> s2 \<and> s1 \<noteq> s2)" |
|
270 |
|
271 lemma length_sprefix: |
|
272 "s1 \<sqsubset> s2 \<Longrightarrow> length s1 < length s2" |
|
273 unfolding sprefix_def prefix_def |
|
274 by (auto) |
|
275 |
|
276 definition Prefixes :: "string \<Rightarrow> string set" where |
|
277 "Prefixes s \<equiv> {sp. sp \<sqsubseteq> s}" |
|
278 |
|
279 definition Suffixes :: "string \<Rightarrow> string set" where |
|
280 "Suffixes s \<equiv> rev ` (Prefixes (rev s))" |
|
281 |
|
282 lemma Suffixes_in: |
|
283 "\<exists>s1. s1 @ s2 = s3 \<Longrightarrow> s2 \<in> Suffixes s3" |
|
284 unfolding Suffixes_def Prefixes_def prefix_def image_def |
|
285 apply(auto) |
|
286 by (metis rev_rev_ident) |
|
287 |
|
288 lemma Prefixes_Cons: |
|
289 "Prefixes (c # s) = {[]} \<union> {c # sp | sp. sp \<in> Prefixes s}" |
|
290 unfolding Prefixes_def prefix_def |
|
291 apply(auto simp add: append_eq_Cons_conv) |
|
292 done |
|
293 |
|
294 lemma finite_Prefixes: |
|
295 "finite (Prefixes s)" |
|
296 apply(induct s) |
|
297 apply(auto simp add: Prefixes_def prefix_def)[1] |
|
298 apply(simp add: Prefixes_Cons) |
|
299 done |
|
300 |
|
301 lemma finite_Suffixes: |
|
302 "finite (Suffixes s)" |
|
303 unfolding Suffixes_def |
|
304 apply(rule finite_imageI) |
|
305 apply(rule finite_Prefixes) |
|
306 done |
|
307 |
|
308 lemma prefix_Cons: |
|
309 "((c # s1) \<sqsubseteq> (c # s2)) = (s1 \<sqsubseteq> s2)" |
|
310 apply(auto simp add: prefix_def) |
|
311 done |
|
312 |
|
313 lemma prefix_append: |
|
314 "((s @ s1) \<sqsubseteq> (s @ s2)) = (s1 \<sqsubseteq> s2)" |
|
315 apply(induct s) |
|
316 apply(simp) |
|
317 apply(simp add: prefix_Cons) |
|
318 done |
|
319 |
|
320 |
|
321 definition Values :: "rexp \<Rightarrow> string \<Rightarrow> val set" where |
|
322 "Values r s \<equiv> {v. \<turnstile> v : r \<and> flat v \<sqsubseteq> s}" |
|
323 |
|
324 definition rest :: "val \<Rightarrow> string \<Rightarrow> string" where |
|
325 "rest v s \<equiv> drop (length (flat v)) s" |
|
326 |
|
327 lemma rest_flat: |
|
328 assumes "flat v1 \<sqsubseteq> s" |
|
329 shows "flat v1 @ rest v1 s = s" |
|
330 using assms |
|
331 apply(auto simp add: rest_def prefix_def) |
|
332 done |
|
333 |
|
334 |
|
335 lemma rest_Suffixes: |
|
336 "rest v s \<in> Suffixes s" |
|
337 unfolding rest_def |
|
338 by (metis Suffixes_in append_take_drop_id) |
|
339 |
|
340 |
|
341 lemma Values_recs: |
|
342 "Values (NULL) s = {}" |
|
343 "Values (EMPTY) s = {Void}" |
|
344 "Values (CHAR c) s = (if [c] \<sqsubseteq> s then {Char c} else {})" |
|
345 "Values (ALT r1 r2) s = {Left v | v. v \<in> Values r1 s} \<union> {Right v | v. v \<in> Values r2 s}" |
|
346 "Values (SEQ r1 r2) s = {Seq v1 v2 | v1 v2. v1 \<in> Values r1 s \<and> v2 \<in> Values r2 (rest v1 s)}" |
|
347 unfolding Values_def |
|
348 apply(auto) |
|
349 (*NULL*) |
|
350 apply(erule Prf.cases) |
|
351 apply(simp_all)[5] |
|
352 (*EMPTY*) |
|
353 apply(erule Prf.cases) |
|
354 apply(simp_all)[5] |
|
355 apply(rule Prf.intros) |
|
356 apply (metis append_Nil prefix_def) |
|
357 (*CHAR*) |
|
358 apply(erule Prf.cases) |
|
359 apply(simp_all)[5] |
|
360 apply(rule Prf.intros) |
|
361 apply(erule Prf.cases) |
|
362 apply(simp_all)[5] |
|
363 (*ALT*) |
|
364 apply(erule Prf.cases) |
|
365 apply(simp_all)[5] |
|
366 apply (metis Prf.intros(2)) |
|
367 apply (metis Prf.intros(3)) |
|
368 (*SEQ*) |
|
369 apply(erule Prf.cases) |
|
370 apply(simp_all)[5] |
|
371 apply (simp add: append_eq_conv_conj prefix_def rest_def) |
|
372 apply (metis Prf.intros(1)) |
|
373 apply (simp add: append_eq_conv_conj prefix_def rest_def) |
|
374 done |
|
375 |
|
376 lemma Values_finite: |
|
377 "finite (Values r s)" |
|
378 apply(induct r arbitrary: s) |
|
379 apply(simp_all add: Values_recs) |
|
380 thm finite_surj |
|
381 apply(rule_tac f="\<lambda>(x, y). Seq x y" and |
|
382 A="{(v1, v2) | v1 v2. v1 \<in> Values r1 s \<and> v2 \<in> Values r2 (rest v1 s)}" in finite_surj) |
|
383 prefer 2 |
|
384 apply(auto)[1] |
|
385 apply(rule_tac B="\<Union>sp \<in> Suffixes s. {(v1, v2). v1 \<in> Values r1 s \<and> v2 \<in> Values r2 sp}" in finite_subset) |
|
386 apply(auto)[1] |
|
387 apply (metis rest_Suffixes) |
|
388 apply(rule finite_UN_I) |
|
389 apply(rule finite_Suffixes) |
|
390 apply(simp) |
|
391 done |
|
392 |
|
393 section {* Sulzmann functions *} |
|
394 |
|
395 fun |
|
396 mkeps :: "rexp \<Rightarrow> val" |
|
397 where |
|
398 "mkeps(EMPTY) = Void" |
|
399 | "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)" |
|
400 | "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))" |
|
401 |
|
402 section {* Derivatives *} |
|
403 |
|
404 fun |
|
405 der :: "char \<Rightarrow> rexp \<Rightarrow> rexp" |
|
406 where |
|
407 "der c (NULL) = NULL" |
|
408 | "der c (EMPTY) = NULL" |
|
409 | "der c (CHAR c') = (if c = c' then EMPTY else NULL)" |
|
410 | "der c (ALT r1 r2) = ALT (der c r1) (der c r2)" |
|
411 | "der c (SEQ r1 r2) = |
|
412 (if nullable r1 |
|
413 then ALT (SEQ (der c r1) r2) (der c r2) |
|
414 else SEQ (der c r1) r2)" |
|
415 |
|
416 fun |
|
417 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp" |
|
418 where |
|
419 "ders [] r = r" |
|
420 | "ders (c # s) r = ders s (der c r)" |
|
421 |
|
422 |
|
423 section {* Injection function *} |
|
424 |
|
425 fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val" |
|
426 where |
|
427 "injval (EMPTY) c Void = Char c" |
|
428 | "injval (CHAR d) c Void = Char d" |
|
429 | "injval (CHAR d) c (Char c') = Seq (Char d) (Char c')" |
|
430 | "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)" |
|
431 | "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)" |
|
432 | "injval (SEQ r1 r2) c (Char c') = Seq (Char c) (Char c')" |
|
433 | "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2" |
|
434 | "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2" |
|
435 | "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)" |
|
436 |
|
437 fun |
|
438 lex :: "rexp \<Rightarrow> string \<Rightarrow> val option" |
|
439 where |
|
440 "lex r [] = (if nullable r then Some(mkeps r) else None)" |
|
441 | "lex r (c#s) = (case (lex (der c r) s) of |
|
442 None \<Rightarrow> None |
|
443 | Some(v) \<Rightarrow> Some(injval r c v))" |
|
444 |
|
445 fun |
|
446 lex2 :: "rexp \<Rightarrow> string \<Rightarrow> val" |
|
447 where |
|
448 "lex2 r [] = mkeps r" |
|
449 | "lex2 r (c#s) = injval r c (lex2 (der c r) s)" |
|
450 |
|
451 |
|
452 section {* Projection function *} |
|
453 |
|
454 fun projval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val" |
|
455 where |
|
456 "projval (CHAR d) c _ = Void" |
|
457 | "projval (ALT r1 r2) c (Left v1) = Left (projval r1 c v1)" |
|
458 | "projval (ALT r1 r2) c (Right v2) = Right (projval r2 c v2)" |
|
459 | "projval (SEQ r1 r2) c (Seq v1 v2) = |
|
460 (if flat v1 = [] then Right(projval r2 c v2) |
|
461 else if nullable r1 then Left (Seq (projval r1 c v1) v2) |
|
462 else Seq (projval r1 c v1) v2)" |
|
463 |
|
464 |
|
465 |
|
466 lemma mkeps_nullable: |
|
467 assumes "nullable(r)" |
|
468 shows "\<turnstile> mkeps r : r" |
|
469 using assms |
|
470 apply(induct rule: nullable.induct) |
|
471 apply(auto intro: Prf.intros) |
|
472 done |
|
473 |
|
474 lemma mkeps_flat: |
|
475 assumes "nullable(r)" |
|
476 shows "flat (mkeps r) = []" |
|
477 using assms |
|
478 apply(induct rule: nullable.induct) |
|
479 apply(auto) |
|
480 done |
|
481 |
|
482 lemma v3: |
|
483 assumes "\<turnstile> v : der c r" |
|
484 shows "\<turnstile> (injval r c v) : r" |
|
485 using assms |
|
486 apply(induct arbitrary: v rule: der.induct) |
|
487 apply(simp) |
|
488 apply(erule Prf.cases) |
|
489 apply(simp_all)[5] |
|
490 apply(simp) |
|
491 apply(erule Prf.cases) |
|
492 apply(simp_all)[5] |
|
493 apply(case_tac "c = c'") |
|
494 apply(simp) |
|
495 apply(erule Prf.cases) |
|
496 apply(simp_all)[5] |
|
497 apply (metis Prf.intros(5)) |
|
498 apply(simp) |
|
499 apply(erule Prf.cases) |
|
500 apply(simp_all)[5] |
|
501 apply(simp) |
|
502 apply(erule Prf.cases) |
|
503 apply(simp_all)[5] |
|
504 apply (metis Prf.intros(2)) |
|
505 apply (metis Prf.intros(3)) |
|
506 apply(simp) |
|
507 apply(case_tac "nullable r1") |
|
508 apply(simp) |
|
509 apply(erule Prf.cases) |
|
510 apply(simp_all)[5] |
|
511 apply(auto)[1] |
|
512 apply(erule Prf.cases) |
|
513 apply(simp_all)[5] |
|
514 apply(auto)[1] |
|
515 apply (metis Prf.intros(1)) |
|
516 apply(auto)[1] |
|
517 apply (metis Prf.intros(1) mkeps_nullable) |
|
518 apply(simp) |
|
519 apply(erule Prf.cases) |
|
520 apply(simp_all)[5] |
|
521 apply(auto)[1] |
|
522 apply(rule Prf.intros) |
|
523 apply(auto)[2] |
|
524 done |
|
525 |
|
526 lemma v3_proj: |
|
527 assumes "\<turnstile> v : r" and "\<exists>s. (flat v) = c # s" |
|
528 shows "\<turnstile> (projval r c v) : der c r" |
|
529 using assms |
|
530 apply(induct rule: Prf.induct) |
|
531 prefer 4 |
|
532 apply(simp) |
|
533 prefer 4 |
|
534 apply(simp) |
|
535 apply (metis Prf.intros(4)) |
|
536 prefer 2 |
|
537 apply(simp) |
|
538 apply (metis Prf.intros(2)) |
|
539 prefer 2 |
|
540 apply(simp) |
|
541 apply (metis Prf.intros(3)) |
|
542 apply(auto) |
|
543 apply(rule Prf.intros) |
|
544 apply(simp) |
|
545 apply (metis Prf_flat_L nullable_correctness) |
|
546 apply(rule Prf.intros) |
|
547 apply(rule Prf.intros) |
|
548 apply (metis Cons_eq_append_conv) |
|
549 apply(simp) |
|
550 apply(rule Prf.intros) |
|
551 apply (metis Cons_eq_append_conv) |
|
552 apply(simp) |
|
553 done |
|
554 |
|
555 lemma v4: |
|
556 assumes "\<turnstile> v : der c r" |
|
557 shows "flat (injval r c v) = c # (flat v)" |
|
558 using assms |
|
559 apply(induct arbitrary: v rule: der.induct) |
|
560 apply(simp) |
|
561 apply(erule Prf.cases) |
|
562 apply(simp_all)[5] |
|
563 apply(simp) |
|
564 apply(erule Prf.cases) |
|
565 apply(simp_all)[5] |
|
566 apply(simp) |
|
567 apply(case_tac "c = c'") |
|
568 apply(simp) |
|
569 apply(auto)[1] |
|
570 apply(erule Prf.cases) |
|
571 apply(simp_all)[5] |
|
572 apply(simp) |
|
573 apply(erule Prf.cases) |
|
574 apply(simp_all)[5] |
|
575 apply(simp) |
|
576 apply(erule Prf.cases) |
|
577 apply(simp_all)[5] |
|
578 apply(simp) |
|
579 apply(case_tac "nullable r1") |
|
580 apply(simp) |
|
581 apply(erule Prf.cases) |
|
582 apply(simp_all (no_asm_use))[5] |
|
583 apply(auto)[1] |
|
584 apply(erule Prf.cases) |
|
585 apply(simp_all)[5] |
|
586 apply(clarify) |
|
587 apply(simp only: injval.simps flat.simps) |
|
588 apply(auto)[1] |
|
589 apply (metis mkeps_flat) |
|
590 apply(simp) |
|
591 apply(erule Prf.cases) |
|
592 apply(simp_all)[5] |
|
593 done |
|
594 |
|
595 lemma v4_proj: |
|
596 assumes "\<turnstile> v : r" and "\<exists>s. (flat v) = c # s" |
|
597 shows "c # flat (projval r c v) = flat v" |
|
598 using assms |
|
599 apply(induct rule: Prf.induct) |
|
600 prefer 4 |
|
601 apply(simp) |
|
602 prefer 4 |
|
603 apply(simp) |
|
604 prefer 2 |
|
605 apply(simp) |
|
606 prefer 2 |
|
607 apply(simp) |
|
608 apply(auto) |
|
609 by (metis Cons_eq_append_conv) |
|
610 |
|
611 lemma v4_proj2: |
|
612 assumes "\<turnstile> v : r" and "(flat v) = c # s" |
|
613 shows "flat (projval r c v) = s" |
|
614 using assms |
|
615 by (metis list.inject v4_proj) |
|
616 |
|
617 |
|
618 section {* Alternative Posix definition *} |
|
619 |
|
620 inductive |
|
621 PMatch :: "string \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<in> _ \<rightarrow> _" [100, 100, 100] 100) |
|
622 where |
|
623 "[] \<in> EMPTY \<rightarrow> Void" |
|
624 | "[c] \<in> (CHAR c) \<rightarrow> (Char c)" |
|
625 | "s \<in> r1 \<rightarrow> v \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Left v)" |
|
626 | "\<lbrakk>s \<in> r2 \<rightarrow> v; s \<notin> L(r1)\<rbrakk> \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Right v)" |
|
627 | "\<lbrakk>s1 \<in> r1 \<rightarrow> v1; s2 \<in> r2 \<rightarrow> v2; |
|
628 \<not>(\<exists>s3 s4. s3 \<noteq> [] \<and> s3 @ s4 = s2 \<and> (s1 @ s3) \<in> L r1 \<and> s4 \<in> L r2)\<rbrakk> \<Longrightarrow> |
|
629 (s1 @ s2) \<in> (SEQ r1 r2) \<rightarrow> (Seq v1 v2)" |
|
630 |
|
631 |
|
632 lemma PMatch_mkeps: |
|
633 assumes "nullable r" |
|
634 shows "[] \<in> r \<rightarrow> mkeps r" |
|
635 using assms |
|
636 apply(induct r) |
|
637 apply(auto) |
|
638 apply (metis PMatch.intros(1)) |
|
639 apply(subst append.simps(1)[symmetric]) |
|
640 apply (rule PMatch.intros) |
|
641 apply(simp) |
|
642 apply(simp) |
|
643 apply(auto)[1] |
|
644 apply (rule PMatch.intros) |
|
645 apply(simp) |
|
646 apply (rule PMatch.intros) |
|
647 apply(simp) |
|
648 apply (rule PMatch.intros) |
|
649 apply(simp) |
|
650 by (metis nullable_correctness) |
|
651 |
|
652 |
|
653 lemma PMatch1: |
|
654 assumes "s \<in> r \<rightarrow> v" |
|
655 shows "\<turnstile> v : r" "flat v = s" |
|
656 using assms |
|
657 apply(induct s r v rule: PMatch.induct) |
|
658 apply(auto) |
|
659 apply (metis Prf.intros(4)) |
|
660 apply (metis Prf.intros(5)) |
|
661 apply (metis Prf.intros(2)) |
|
662 apply (metis Prf.intros(3)) |
|
663 apply (metis Prf.intros(1)) |
|
664 done |
|
665 |
|
666 lemma PMatch_Values: |
|
667 assumes "s \<in> r \<rightarrow> v" |
|
668 shows "v \<in> Values r s" |
|
669 using assms |
|
670 apply(simp add: Values_def PMatch1) |
|
671 by (metis append_Nil2 prefix_def) |
|
672 |
|
673 lemma PMatch2: |
|
674 assumes "s \<in> (der c r) \<rightarrow> v" |
|
675 shows "(c#s) \<in> r \<rightarrow> (injval r c v)" |
|
676 using assms |
|
677 apply(induct c r arbitrary: s v rule: der.induct) |
|
678 apply(auto) |
|
679 apply(erule PMatch.cases) |
|
680 apply(simp_all)[5] |
|
681 apply(erule PMatch.cases) |
|
682 apply(simp_all)[5] |
|
683 apply(case_tac "c = c'") |
|
684 apply(simp) |
|
685 apply(erule PMatch.cases) |
|
686 apply(simp_all)[5] |
|
687 apply (metis PMatch.intros(2)) |
|
688 apply(simp) |
|
689 apply(erule PMatch.cases) |
|
690 apply(simp_all)[5] |
|
691 apply(erule PMatch.cases) |
|
692 apply(simp_all)[5] |
|
693 apply (metis PMatch.intros(3)) |
|
694 apply(clarify) |
|
695 apply(rule PMatch.intros) |
|
696 apply metis |
|
697 apply(simp add: L_flat_Prf) |
|
698 apply(auto)[1] |
|
699 thm v3_proj |
|
700 apply(frule_tac c="c" in v3_proj) |
|
701 apply metis |
|
702 apply(drule_tac x="projval r1 c v" in spec) |
|
703 apply(drule mp) |
|
704 apply (metis v4_proj2) |
|
705 apply(simp) |
|
706 apply(case_tac "nullable r1") |
|
707 apply(simp) |
|
708 defer |
|
709 apply(simp) |
|
710 apply(erule PMatch.cases) |
|
711 apply(simp_all)[5] |
|
712 apply(clarify) |
|
713 apply(subst append.simps(2)[symmetric]) |
|
714 apply(rule PMatch.intros) |
|
715 apply metis |
|
716 apply metis |
|
717 apply(auto)[1] |
|
718 apply(simp add: L_flat_Prf) |
|
719 apply(auto)[1] |
|
720 apply(frule_tac c="c" in v3_proj) |
|
721 apply metis |
|
722 apply(drule_tac x="s3" in spec) |
|
723 apply(drule mp) |
|
724 apply(rule_tac x="projval r1 c v" in exI) |
|
725 apply(rule conjI) |
|
726 apply (metis v4_proj2) |
|
727 apply(simp) |
|
728 apply metis |
|
729 (* nullable case *) |
|
730 apply(erule PMatch.cases) |
|
731 apply(simp_all)[5] |
|
732 apply(clarify) |
|
733 apply(erule PMatch.cases) |
|
734 apply(simp_all)[5] |
|
735 apply(clarify) |
|
736 apply(subst append.simps(2)[symmetric]) |
|
737 apply(rule PMatch.intros) |
|
738 apply metis |
|
739 apply metis |
|
740 apply(auto)[1] |
|
741 apply(simp add: L_flat_Prf) |
|
742 apply(auto)[1] |
|
743 apply(frule_tac c="c" in v3_proj) |
|
744 apply metis |
|
745 apply(drule_tac x="s3" in spec) |
|
746 apply(drule mp) |
|
747 apply (metis v4_proj2) |
|
748 apply(simp) |
|
749 (* interesting case *) |
|
750 apply(clarify) |
|
751 apply(simp) |
|
752 thm L.simps |
|
753 apply(subst (asm) L.simps(4)[symmetric]) |
|
754 apply(simp only: L_flat_Prf) |
|
755 apply(simp) |
|
756 apply(subst append.simps(1)[symmetric]) |
|
757 apply(rule PMatch.intros) |
|
758 apply (metis PMatch_mkeps) |
|
759 apply metis |
|
760 apply(auto) |
|
761 apply(simp only: L_flat_Prf) |
|
762 apply(simp) |
|
763 apply(auto) |
|
764 apply(drule_tac x="Seq (projval r1 c v) vb" in spec) |
|
765 apply(drule mp) |
|
766 apply(simp) |
|
767 apply (metis append_Cons butlast_snoc last_snoc neq_Nil_conv rotate1.simps(2) v4_proj2) |
|
768 apply(subgoal_tac "\<turnstile> projval r1 c v : der c r1") |
|
769 apply (metis Prf.intros(1)) |
|
770 apply(rule v3_proj) |
|
771 apply(simp) |
|
772 by (metis Cons_eq_append_conv) |
|
773 |
|
774 lemma lex_correct1: |
|
775 assumes "s \<notin> L r" |
|
776 shows "lex r s = None" |
|
777 using assms |
|
778 apply(induct s arbitrary: r) |
|
779 apply(simp) |
|
780 apply (metis nullable_correctness) |
|
781 apply(auto) |
|
782 apply(drule_tac x="der a r" in meta_spec) |
|
783 apply(drule meta_mp) |
|
784 apply(auto) |
|
785 apply(simp add: L_flat_Prf) |
|
786 by (metis v3 v4) |
|
787 |
|
788 |
|
789 lemma lex_correct2: |
|
790 assumes "s \<in> L r" |
|
791 shows "\<exists>v. lex r s = Some(v) \<and> \<turnstile> v : r \<and> flat v = s" |
|
792 using assms |
|
793 apply(induct s arbitrary: r) |
|
794 apply(simp) |
|
795 apply (metis mkeps_flat mkeps_nullable nullable_correctness) |
|
796 apply(drule_tac x="der a r" in meta_spec) |
|
797 apply(drule meta_mp) |
|
798 apply(simp add: L_flat_Prf) |
|
799 apply(auto) |
|
800 apply (metis v3_proj v4_proj2) |
|
801 apply (metis v3) |
|
802 apply(rule v4) |
|
803 by metis |
|
804 |
|
805 lemma lex_correct3: |
|
806 assumes "s \<in> L r" |
|
807 shows "\<exists>v. lex r s = Some(v) \<and> s \<in> r \<rightarrow> v" |
|
808 using assms |
|
809 apply(induct s arbitrary: r) |
|
810 apply(simp) |
|
811 apply (metis PMatch_mkeps nullable_correctness) |
|
812 apply(drule_tac x="der a r" in meta_spec) |
|
813 apply(drule meta_mp) |
|
814 apply(simp add: L_flat_Prf) |
|
815 apply(auto) |
|
816 apply (metis v3_proj v4_proj2) |
|
817 apply(rule PMatch2) |
|
818 apply(simp) |
|
819 done |
|
820 |
|
821 lemma lex_correct4: |
|
822 assumes "s \<in> L r" |
|
823 shows "s \<in> r \<rightarrow> (lex2 r s)" |
|
824 using assms |
|
825 apply(induct s arbitrary: r) |
|
826 apply(simp) |
|
827 apply (metis PMatch_mkeps nullable_correctness) |
|
828 apply(simp) |
|
829 apply(rule PMatch2) |
|
830 apply(drule_tac x="der a r" in meta_spec) |
|
831 apply(drule meta_mp) |
|
832 apply(simp add: L_flat_Prf) |
|
833 apply(auto) |
|
834 apply (metis v3_proj v4_proj2) |
|
835 done |
|
836 |
|
837 lemma |
|
838 "lex2 (ALT (CHAR a) (ALT (CHAR b) (SEQ (CHAR a) (CHAR b)))) [a,b] = Right (Right (Seq (Char a) (Char b)))" |
|
839 apply(simp) |
|
840 done |
|
841 |
|
842 |
|
843 section {* Sulzmann's Ordering of values *} |
|
844 |
|
845 |
|
846 inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<succ>_ _" [100, 100, 100] 100) |
|
847 where |
|
848 "v2 \<succ>r2 v2' \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1 v2')" |
|
849 | "\<lbrakk>v1 \<succ>r1 v1'; v1 \<noteq> v1'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" |
|
850 | "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Right v2)" |
|
851 | "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Left v1)" |
|
852 | "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')" |
|
853 | "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')" |
|
854 | "Void \<succ>EMPTY Void" |
|
855 | "(Char c) \<succ>(CHAR c) (Char c)" |
|
856 |
|
857 inductive ValOrd2 :: "val \<Rightarrow> val \<Rightarrow> bool" ("_ 2\<succ> _" [100, 100] 100) |
|
858 where |
|
859 "v2 2\<succ> v2' \<Longrightarrow> (Seq v1 v2) 2\<succ> (Seq v1 v2')" |
|
860 | "\<lbrakk>v1 2\<succ> v1'; v1 \<noteq> v1'\<rbrakk> \<Longrightarrow> (Seq v1 v2) 2\<succ> (Seq v1' v2')" |
|
861 | "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) 2\<succ> (Right v2)" |
|
862 | "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) 2\<succ> (Left v1)" |
|
863 | "v2 2\<succ> v2' \<Longrightarrow> (Right v2) 2\<succ> (Right v2')" |
|
864 | "v1 2\<succ> v1' \<Longrightarrow> (Left v1) 2\<succ> (Left v1')" |
|
865 | "Void 2\<succ> Void" |
|
866 | "(Char c) 2\<succ> (Char c)" |
|
867 |
|
868 lemma Ord1: |
|
869 "v1 \<succ>r v2 \<Longrightarrow> v1 2\<succ> v2" |
|
870 apply(induct rule: ValOrd.induct) |
|
871 apply(auto intro: ValOrd2.intros) |
|
872 done |
|
873 |
|
874 lemma Ord2: |
|
875 "v1 2\<succ> v2 \<Longrightarrow> \<exists>r. v1 \<succ>r v2" |
|
876 apply(induct v1 v2 rule: ValOrd2.induct) |
|
877 apply(auto intro: ValOrd.intros) |
|
878 done |
|
879 |
|
880 lemma Ord3: |
|
881 "\<lbrakk>v1 2\<succ> v2; \<turnstile> v1 : r\<rbrakk> \<Longrightarrow> v1 \<succ>r v2" |
|
882 apply(induct v1 v2 arbitrary: r rule: ValOrd2.induct) |
|
883 apply(auto intro: ValOrd.intros elim: Prf.cases) |
|
884 done |
|
885 |
|
886 section {* Posix definition *} |
|
887 |
|
888 definition POSIX :: "val \<Rightarrow> rexp \<Rightarrow> bool" |
|
889 where |
|
890 "POSIX v r \<equiv> (\<turnstile> v : r \<and> (\<forall>v'. (\<turnstile> v' : r \<and> flat v' \<sqsubseteq> flat v) \<longrightarrow> v \<succ>r v'))" |
|
891 |
|
892 lemma ValOrd_refl: |
|
893 assumes "\<turnstile> v : r" |
|
894 shows "v \<succ>r v" |
|
895 using assms |
|
896 apply(induct) |
|
897 apply(auto intro: ValOrd.intros) |
|
898 done |
|
899 |
|
900 lemma ValOrd_total: |
|
901 shows "\<lbrakk>\<turnstile> v1 : r; \<turnstile> v2 : r\<rbrakk> \<Longrightarrow> v1 \<succ>r v2 \<or> v2 \<succ>r v1" |
|
902 apply(induct r arbitrary: v1 v2) |
|
903 apply(auto) |
|
904 apply(erule Prf.cases) |
|
905 apply(simp_all)[5] |
|
906 apply(erule Prf.cases) |
|
907 apply(simp_all)[5] |
|
908 apply(erule Prf.cases) |
|
909 apply(simp_all)[5] |
|
910 apply (metis ValOrd.intros(7)) |
|
911 apply(erule Prf.cases) |
|
912 apply(simp_all)[5] |
|
913 apply(erule Prf.cases) |
|
914 apply(simp_all)[5] |
|
915 apply (metis ValOrd.intros(8)) |
|
916 apply(erule Prf.cases) |
|
917 apply(simp_all)[5] |
|
918 apply(erule Prf.cases) |
|
919 apply(simp_all)[5] |
|
920 apply(clarify) |
|
921 apply(case_tac "v1a = v1b") |
|
922 apply(simp) |
|
923 apply(rule ValOrd.intros(1)) |
|
924 apply (metis ValOrd.intros(1)) |
|
925 apply(rule ValOrd.intros(2)) |
|
926 apply(auto)[2] |
|
927 apply(erule contrapos_np) |
|
928 apply(rule ValOrd.intros(2)) |
|
929 apply(auto) |
|
930 apply(erule Prf.cases) |
|
931 apply(simp_all)[5] |
|
932 apply(erule Prf.cases) |
|
933 apply(simp_all)[5] |
|
934 apply (metis Ord1 Ord3 Prf.intros(2) ValOrd2.intros(6)) |
|
935 apply(rule ValOrd.intros) |
|
936 apply(erule contrapos_np) |
|
937 apply(rule ValOrd.intros) |
|
938 apply (metis le_eq_less_or_eq neq_iff) |
|
939 apply(erule Prf.cases) |
|
940 apply(simp_all)[5] |
|
941 apply(rule ValOrd.intros) |
|
942 apply(erule contrapos_np) |
|
943 apply(rule ValOrd.intros) |
|
944 apply (metis le_eq_less_or_eq neq_iff) |
|
945 apply(rule ValOrd.intros) |
|
946 apply(erule contrapos_np) |
|
947 apply(rule ValOrd.intros) |
|
948 by metis |
|
949 |
|
950 lemma ValOrd_anti: |
|
951 shows "\<lbrakk>\<turnstile> v1 : r; \<turnstile> v2 : r; v1 \<succ>r v2; v2 \<succ>r v1\<rbrakk> \<Longrightarrow> v1 = v2" |
|
952 apply(induct r arbitrary: v1 v2) |
|
953 apply(erule Prf.cases) |
|
954 apply(simp_all)[5] |
|
955 apply(erule Prf.cases) |
|
956 apply(simp_all)[5] |
|
957 apply(erule Prf.cases) |
|
958 apply(simp_all)[5] |
|
959 apply(erule Prf.cases) |
|
960 apply(simp_all)[5] |
|
961 apply(erule Prf.cases) |
|
962 apply(simp_all)[5] |
|
963 apply(erule Prf.cases) |
|
964 apply(simp_all)[5] |
|
965 apply(erule Prf.cases) |
|
966 apply(simp_all)[5] |
|
967 apply(erule ValOrd.cases) |
|
968 apply(simp_all)[8] |
|
969 apply(erule ValOrd.cases) |
|
970 apply(simp_all)[8] |
|
971 apply(erule ValOrd.cases) |
|
972 apply(simp_all)[8] |
|
973 apply(erule Prf.cases) |
|
974 apply(simp_all)[5] |
|
975 apply(erule Prf.cases) |
|
976 apply(simp_all)[5] |
|
977 apply(erule ValOrd.cases) |
|
978 apply(simp_all)[8] |
|
979 apply(erule ValOrd.cases) |
|
980 apply(simp_all)[8] |
|
981 apply(erule ValOrd.cases) |
|
982 apply(simp_all)[8] |
|
983 apply(erule ValOrd.cases) |
|
984 apply(simp_all)[8] |
|
985 apply(erule Prf.cases) |
|
986 apply(simp_all)[5] |
|
987 apply(erule ValOrd.cases) |
|
988 apply(simp_all)[8] |
|
989 apply(erule ValOrd.cases) |
|
990 apply(simp_all)[8] |
|
991 apply(erule ValOrd.cases) |
|
992 apply(simp_all)[8] |
|
993 apply(erule ValOrd.cases) |
|
994 apply(simp_all)[8] |
|
995 done |
|
996 |
|
997 lemma POSIX_ALT_I1: |
|
998 assumes "POSIX v1 r1" |
|
999 shows "POSIX (Left v1) (ALT r1 r2)" |
|
1000 using assms |
|
1001 unfolding POSIX_def |
|
1002 apply(auto) |
|
1003 apply (metis Prf.intros(2)) |
|
1004 apply(rotate_tac 2) |
|
1005 apply(erule Prf.cases) |
|
1006 apply(simp_all)[5] |
|
1007 apply(auto) |
|
1008 apply(rule ValOrd.intros) |
|
1009 apply(auto) |
|
1010 apply(rule ValOrd.intros) |
|
1011 by (metis le_eq_less_or_eq length_sprefix sprefix_def) |
|
1012 |
|
1013 lemma POSIX_ALT_I2: |
|
1014 assumes "POSIX v2 r2" "\<forall>v'. \<turnstile> v' : r1 \<longrightarrow> length (flat v2) > length (flat v')" |
|
1015 shows "POSIX (Right v2) (ALT r1 r2)" |
|
1016 using assms |
|
1017 unfolding POSIX_def |
|
1018 apply(auto) |
|
1019 apply (metis Prf.intros) |
|
1020 apply(rotate_tac 3) |
|
1021 apply(erule Prf.cases) |
|
1022 apply(simp_all)[5] |
|
1023 apply(auto) |
|
1024 apply(rule ValOrd.intros) |
|
1025 apply metis |
|
1026 apply(rule ValOrd.intros) |
|
1027 apply metis |
|
1028 done |
|
1029 |
|
1030 section {* tryout with all-mkeps *} |
|
1031 |
|
1032 fun |
|
1033 alleps :: "rexp \<Rightarrow> val set" |
|
1034 where |
|
1035 "alleps(NULL) = {}" |
|
1036 | "alleps(EMPTY) = {Void}" |
|
1037 | "alleps(CHAR c) = {}" |
|
1038 | "alleps(SEQ r1 r2) = {Seq v1 v2 | v1 v2. v1 \<in> alleps r1 \<and> v2 \<in> alleps r2}" |
|
1039 | "alleps(ALT r1 r2) = {Left v1 | v1. v1 \<in> alleps r1} \<union> {Right v2 | v2. v2 \<in> alleps r2}" |
|
1040 |
|
1041 fun injall :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val set" |
|
1042 where |
|
1043 "injall (EMPTY) c Void = {}" |
|
1044 | "injall (CHAR d) c Void = (if c = d then {Char d} else {})" |
|
1045 | "injall (ALT r1 r2) c (Left v1) = {Left v | v. v \<in> injall r1 c v1}" |
|
1046 | "injall (ALT r1 r2) c (Right v2) = {Right v | v. v \<in> injall r2 c v2}" |
|
1047 | "injall (SEQ r1 r2) c (Seq v1 v2) = {Seq v v2 | v. v \<in> injall r1 c v1}" |
|
1048 | "injall (SEQ r1 r2) c (Left (Seq v1 v2)) = {Seq v v2 | v. v \<in> injall r1 c v1}" |
|
1049 | "injall (SEQ r1 r2) c (Right v2) = {Seq v v' | v v'. v \<in> alleps r1 \<and> v' \<in> injall r2 c v2}" |
|
1050 |
|
1051 fun |
|
1052 allvals :: "rexp \<Rightarrow> string \<Rightarrow> val set" |
|
1053 where |
|
1054 "allvals r [] = alleps r" |
|
1055 | "allvals r (c#s) = {v | v v'. v \<in> injall r c v' \<and> v' \<in> allvals (der c r) s}" |
|
1056 |
|
1057 lemma q1: |
|
1058 assumes "v \<in> alleps r" |
|
1059 shows "\<turnstile> v : r \<and> flat v = []" |
|
1060 using assms |
|
1061 apply(induct r arbitrary: v) |
|
1062 apply(auto intro: Prf.intros) |
|
1063 done |
|
1064 |
|
1065 |
|
1066 lemma allvals_NULL: |
|
1067 shows "allvals (NULL) s = {}" |
|
1068 apply(induct_tac s) |
|
1069 apply(simp) |
|
1070 apply(simp) |
|
1071 done |
|
1072 |
|
1073 lemma allvals_EMPTY: |
|
1074 shows "allvals (EMPTY) [] = {Void}" |
|
1075 and "s \<noteq> [] \<Longrightarrow> allvals (EMPTY) s = {}" |
|
1076 apply(simp) |
|
1077 apply(case_tac s) |
|
1078 apply(simp) |
|
1079 apply(simp add: allvals_NULL) |
|
1080 done |
|
1081 |
|
1082 lemma allvals_CHAR: |
|
1083 shows "allvals (CHAR c) [c] = {Char c}" |
|
1084 and "s \<noteq> [c] \<Longrightarrow> allvals (CHAR c) s = {}" |
|
1085 apply(simp) |
|
1086 apply(case_tac s) |
|
1087 apply(simp) |
|
1088 apply(case_tac "c = a") |
|
1089 apply(simp add: allvals_EMPTY) |
|
1090 apply(simp add: allvals_NULL) |
|
1091 done |
|
1092 |
|
1093 lemma allvals_ALT: |
|
1094 shows "allvals (ALT r1 r2) s = {Left v1 | v1. v1 \<in> allvals r1 s} \<union> |
|
1095 {Right v2 | v2. v2 \<in> allvals r2 s}" |
|
1096 apply(induct s arbitrary: r1 r2) |
|
1097 apply(simp) |
|
1098 apply(simp) |
|
1099 apply(auto) |
|
1100 apply blast |
|
1101 apply(rule_tac x="Left v'" in exI) |
|
1102 apply(simp) |
|
1103 apply(rule_tac x="Right v'" in exI) |
|
1104 apply(simp) |
|
1105 done |
|
1106 |
|
1107 lemma allvals_SEQ_Nil: |
|
1108 "allvals (SEQ r1 r2) [] = {Seq v1 v2 | v1 v2. v1 \<in> allvals r1 [] \<and> v2 \<in> allvals r2 []}" |
|
1109 by simp |
|
1110 |
|
1111 lemma allvals_SEQ: |
|
1112 shows "allvals (SEQ r1 r2) s = {Seq v1 v2 | v1 v2 s1 s2. |
|
1113 s = s1 @ s2 \<and> v1 \<in> allvals r1 s1 \<and> v2 \<in> allvals r2 s2}" |
|
1114 using assms |
|
1115 apply(induct s arbitrary: r1 r2) |
|
1116 apply(simp) |
|
1117 apply(simp) |
|
1118 apply(auto) |
|
1119 apply(simp_all add: allvals_ALT) |
|
1120 apply(auto) |
|
1121 apply (metis (mono_tags, lifting) allvals.simps(2) append_Cons mem_Collect_eq) |
|
1122 apply fastforce |
|
1123 prefer 2 |
|
1124 apply(rule_tac x="a#s1" in exI) |
|
1125 apply(rule_tac x="s2" in exI) |
|
1126 apply(simp) |
|
1127 apply(fastforce) |
|
1128 prefer 2 |
|
1129 apply(subst (asm) Cons_eq_append_conv) |
|
1130 apply(auto)[1] |
|
1131 using Prf_flat_L nullable_correctness q1 apply fastforce |
|
1132 apply(rule_tac x="Seq v' v2" in exI) |
|
1133 apply(simp) |
|
1134 apply(rule_tac x="ys'" in exI) |
|
1135 apply(rule_tac x="s2" in exI) |
|
1136 apply(simp) |
|
1137 apply(subst (asm) Cons_eq_append_conv) |
|
1138 apply(auto)[1] |
|
1139 apply(rule_tac x="Right v'" in exI) |
|
1140 apply(simp) |
|
1141 apply(rule_tac x="Left (Seq v' v2)" in exI) |
|
1142 apply(simp) |
|
1143 apply(auto)[1] |
|
1144 done |
|
1145 |
|
1146 lemma q11: |
|
1147 assumes "nullable r" "\<turnstile> v : r" "flat v = []" |
|
1148 shows "v \<in> alleps r" |
|
1149 using assms |
|
1150 apply(induct r arbitrary: v) |
|
1151 apply(auto) |
|
1152 apply(erule Prf.cases) |
|
1153 apply(simp_all) |
|
1154 apply(erule Prf.cases) |
|
1155 apply(simp_all) |
|
1156 apply(erule Prf.cases) |
|
1157 apply(simp_all) |
|
1158 apply(auto) |
|
1159 apply(subgoal_tac "nullable r2a") |
|
1160 apply(auto) |
|
1161 using not_nullable_flat apply auto[1] |
|
1162 apply(erule Prf.cases) |
|
1163 apply(simp_all) |
|
1164 apply(auto) |
|
1165 apply(subgoal_tac "nullable r1a") |
|
1166 apply(auto) |
|
1167 using not_nullable_flat apply auto[1] |
|
1168 done |
|
1169 |
|
1170 lemma q33: |
|
1171 assumes "nullable r" |
|
1172 shows "alleps r = {v. \<turnstile> v : r \<and> flat v = []}" |
|
1173 using assms |
|
1174 apply(auto) |
|
1175 apply (simp_all add: q1) |
|
1176 by (simp add: q11) |
|
1177 |
|
1178 |
|
1179 lemma k0: |
|
1180 assumes "\<turnstile> v : der a r" "v' \<in> injall r a v" |
|
1181 shows "flat v' = a # flat v" |
|
1182 using assms |
|
1183 apply(induct a r arbitrary: v v' rule: der.induct) |
|
1184 apply(simp_all) |
|
1185 apply(erule Prf.cases) |
|
1186 apply(simp_all) |
|
1187 apply(erule Prf.cases) |
|
1188 apply(simp_all) |
|
1189 apply(case_tac "c = c'") |
|
1190 apply(erule Prf.cases) |
|
1191 apply(simp_all) |
|
1192 apply(erule Prf.cases) |
|
1193 apply(simp_all) |
|
1194 apply(erule Prf.cases) |
|
1195 apply(simp_all) |
|
1196 apply(auto)[1] |
|
1197 apply(auto)[1] |
|
1198 apply(case_tac "nullable r1") |
|
1199 apply(auto) |
|
1200 apply(erule Prf.cases) |
|
1201 apply(simp_all) |
|
1202 apply(auto) |
|
1203 apply(erule Prf.cases) |
|
1204 apply(simp_all) |
|
1205 apply(auto) |
|
1206 using q1 apply blast |
|
1207 apply(erule Prf.cases) |
|
1208 apply(simp_all) |
|
1209 apply(auto) |
|
1210 done |
|
1211 |
|
1212 lemma k: |
|
1213 assumes "\<turnstile> v' : der a r" "v \<in> injall r a v'" |
|
1214 shows "\<turnstile> v : r" |
|
1215 using assms |
|
1216 apply(induct a r arbitrary: v v' rule: der.induct) |
|
1217 apply(simp_all) |
|
1218 apply(erule Prf.cases) |
|
1219 apply(simp_all) |
|
1220 apply(erule Prf.cases) |
|
1221 apply(simp_all) |
|
1222 apply(case_tac "c = c'") |
|
1223 apply(erule Prf.cases) |
|
1224 apply(simp_all) |
|
1225 apply(rule Prf.intros) |
|
1226 apply(erule Prf.cases) |
|
1227 apply(simp_all) |
|
1228 apply(erule Prf.cases) |
|
1229 apply(simp_all) |
|
1230 apply(auto intro: Prf.intros)[1] |
|
1231 apply(auto intro: Prf.intros)[1] |
|
1232 apply(case_tac "nullable r1") |
|
1233 apply(auto) |
|
1234 apply(erule Prf.cases) |
|
1235 apply(simp_all) |
|
1236 apply(auto) |
|
1237 apply(erule Prf.cases) |
|
1238 apply(simp_all) |
|
1239 apply(auto) |
|
1240 apply(auto intro: Prf.intros)[1] |
|
1241 using Prf.intros(1) q1 apply blast |
|
1242 apply(erule Prf.cases) |
|
1243 apply(simp_all) |
|
1244 apply(auto) |
|
1245 using Prf.intros(1) by auto |
|
1246 |
|
1247 |
|
1248 |
|
1249 lemma q22: |
|
1250 assumes "v \<in> allvals r s" |
|
1251 shows "\<turnstile> v : r \<and> s \<in> L (r) \<and> flat v = s" |
|
1252 using assms |
|
1253 apply(induct s arbitrary: v r) |
|
1254 apply(auto) |
|
1255 apply(simp_all add: q1) |
|
1256 using Prf_flat_L q1 apply fastforce |
|
1257 apply(drule_tac x="v'" in meta_spec) |
|
1258 apply(drule_tac x="der a r" in meta_spec) |
|
1259 apply(simp) |
|
1260 apply(clarify) |
|
1261 apply(rule k) |
|
1262 apply(assumption) |
|
1263 apply(assumption) |
|
1264 apply(drule_tac x="v'" in meta_spec) |
|
1265 apply(drule_tac x="der a r" in meta_spec) |
|
1266 apply(simp) |
|
1267 apply(clarify) |
|
1268 using Prf_flat_L v3 v4 apply fastforce |
|
1269 apply(drule_tac x="v'" in meta_spec) |
|
1270 apply(drule_tac x="der a r" in meta_spec) |
|
1271 apply(simp) |
|
1272 apply(clarify) |
|
1273 using k0 by blast |
|
1274 |
|
1275 lemma ra: |
|
1276 assumes "v \<in> allvals r1 s" |
|
1277 shows "Left v \<in> allvals (ALT r1 r2) s" |
|
1278 using assms |
|
1279 apply(induct s arbitrary: r1 r2 v) |
|
1280 apply(simp) |
|
1281 apply(auto) |
|
1282 apply(rule_tac x="Left v'" in exI) |
|
1283 apply(simp) |
|
1284 done |
|
1285 |
|
1286 lemma rb: |
|
1287 assumes "v \<in> allvals r2 s" |
|
1288 shows "Right v \<in> allvals (ALT r1 r2) s" |
|
1289 using assms |
|
1290 apply(induct s arbitrary: r1 r2 v) |
|
1291 apply(simp) |
|
1292 apply(auto) |
|
1293 apply(rule_tac x="Right v'" in exI) |
|
1294 apply(simp) |
|
1295 done |
|
1296 |
|
1297 lemma r1: |
|
1298 assumes "v1 \<in> alleps r1" "v2 \<in> allvals r2 s2" |
|
1299 shows "Seq v1 v2 \<in> allvals (SEQ r1 r2) s2" |
|
1300 using assms |
|
1301 apply(induct s2 arbitrary: r1 r2 v1 v2) |
|
1302 apply(simp) |
|
1303 apply(simp) |
|
1304 apply(auto) |
|
1305 apply(rule_tac x="Right v'" in exI) |
|
1306 apply(simp) |
|
1307 apply(rule rb) |
|
1308 apply(simp) |
|
1309 using not_nullable_flat q1 by blast |
|
1310 |
|
1311 lemma r2: |
|
1312 assumes "v1 \<in> allvals r1 s1" "v2 \<in> allvals r2 s2" |
|
1313 shows "Seq v1 v2 \<in> allvals (SEQ r1 r2) (s1 @ s2)" |
|
1314 using assms |
|
1315 apply(induct s1 arbitrary: r1 r2 v1 v2 s2) |
|
1316 apply(simp) |
|
1317 apply(rule r1) |
|
1318 apply(simp) |
|
1319 apply(simp) |
|
1320 apply(simp) |
|
1321 apply(auto) |
|
1322 apply(drule_tac x="der a r1" in meta_spec) |
|
1323 apply(drule_tac x="r2" in meta_spec) |
|
1324 apply(drule_tac x="v'" in meta_spec) |
|
1325 apply(drule_tac x="v2" in meta_spec) |
|
1326 apply(drule_tac x="s2" in meta_spec) |
|
1327 apply(simp) |
|
1328 apply(rule_tac x="Left (Seq v' v2)" in exI) |
|
1329 apply(simp) |
|
1330 apply(rule ra) |
|
1331 apply(simp) |
|
1332 apply(drule_tac x="der a r1" in meta_spec) |
|
1333 apply(drule_tac x="r2" in meta_spec) |
|
1334 apply(drule_tac x="v'" in meta_spec) |
|
1335 apply(drule_tac x="v2" in meta_spec) |
|
1336 apply(drule_tac x="s2" in meta_spec) |
|
1337 apply(simp) |
|
1338 apply(rule_tac x="Seq v' v2" in exI) |
|
1339 apply(simp) |
|
1340 done |
|
1341 |
|
1342 lemma q22a: |
|
1343 assumes " s \<in> L (r)" |
|
1344 shows "\<exists>v. v \<in> allvals r s \<and> flat v = s" |
|
1345 using assms |
|
1346 apply(induct r arbitrary: s) |
|
1347 apply(auto) |
|
1348 apply(simp add: Sequ_def) |
|
1349 apply(auto) |
|
1350 apply(drule_tac x="s1" in meta_spec) |
|
1351 apply(drule_tac x="s2" in meta_spec) |
|
1352 apply(auto) |
|
1353 apply(rule_tac x="Seq v va" in exI) |
|
1354 apply(simp) |
|
1355 apply(rule r2) |
|
1356 apply(simp) |
|
1357 apply(simp) |
|
1358 apply(drule_tac x="s" in meta_spec) |
|
1359 apply(simp) |
|
1360 apply(auto) |
|
1361 apply(rule_tac x="Left v" in exI) |
|
1362 apply(simp) |
|
1363 apply(rule ra) |
|
1364 apply(simp) |
|
1365 apply(drule_tac x="s" in meta_spec) |
|
1366 apply(drule_tac x="s" in meta_spec) |
|
1367 apply(simp) |
|
1368 apply(auto) |
|
1369 apply(rule_tac x="Right v" in exI) |
|
1370 apply(simp) |
|
1371 apply(rule rb) |
|
1372 apply(simp) |
|
1373 done |
|
1374 |
|
1375 lemma q22b: |
|
1376 assumes " s \<in> L (r)" "\<turnstile> v : r" "flat v = s" |
|
1377 shows "v \<in> allvals r s" |
|
1378 using assms |
|
1379 apply(induct r arbitrary: s v) |
|
1380 apply(auto) |
|
1381 apply(erule Prf.cases) |
|
1382 apply(simp_all) |
|
1383 apply(erule Prf.cases) |
|
1384 apply(simp_all) |
|
1385 apply(simp add: Sequ_def) |
|
1386 apply(auto) |
|
1387 apply(erule Prf.cases) |
|
1388 apply(simp_all) |
|
1389 apply(simp add: append_eq_append_conv2) |
|
1390 apply(auto) |
|
1391 apply (metis Prf_flat_L append_assoc r2) |
|
1392 apply (metis Prf_flat_L r2) |
|
1393 apply(erule Prf.cases) |
|
1394 apply(simp_all) |
|
1395 apply(auto intro: ra rb)[2] |
|
1396 apply(rule rb) |
|
1397 apply (simp add: Prf_flat_L) |
|
1398 apply(erule Prf.cases) |
|
1399 apply(simp_all) |
|
1400 apply(auto intro: ra rb)[2] |
|
1401 apply(rule ra) |
|
1402 by (simp add: Prf_flat_L) |
|
1403 |
|
1404 |
|
1405 lemma q2: |
|
1406 assumes "s \<in> L(r)" |
|
1407 shows "allvals r s = {v. \<turnstile> v : r \<and> s \<in> L (r) \<and> flat v = s}" |
|
1408 using assms |
|
1409 apply(auto) |
|
1410 apply (simp add: q22) |
|
1411 apply (simp add: q22) |
|
1412 by (simp add: q22b) |
|
1413 |
|
1414 lemma r3a: |
|
1415 assumes "v' \<in> allvals (SEQ r1 r2) (s1 @ s2)" |
|
1416 "(s1 @ s2) \<in> L (SEQ r1 r2)" |
|
1417 shows "\<exists>v1 v2. v' = Seq v1 v2 \<and> v1 \<in> allvals r1 s1 \<and> v2 \<in> allvals r2 s2" |
|
1418 using assms |
|
1419 apply(subst (asm) q2) |
|
1420 apply(auto) |
|
1421 apply(erule_tac Prf.cases) |
|
1422 apply(simp_all) |
|
1423 apply(rule conjI) |
|
1424 apply(simp add: append_eq_append_conv2) |
|
1425 apply(auto) |
|
1426 apply(subst q2) |
|
1427 oops |
|
1428 |
|
1429 lemma r3: |
|
1430 assumes "Seq v1 v2 \<in> allvals (SEQ r1 r2) (s1 @ s2)" |
|
1431 "flat v1 = s1" "flat v2 = s2" |
|
1432 "(s1 @ s2) \<in> L (SEQ r1 r2)" |
|
1433 shows "v1 \<in> allvals r1 s1" "v2 \<in> allvals r2 s2" |
|
1434 using assms |
|
1435 apply(subst (asm) q2) |
|
1436 apply(auto) |
|
1437 apply(erule_tac Prf.cases) |
|
1438 apply(simp_all) |
|
1439 apply(subst q2) |
|
1440 apply(auto) |
|
1441 using Prf_flat_L apply blast |
|
1442 using Prf_flat_L apply blast |
|
1443 using assms |
|
1444 apply(subst (asm) q2) |
|
1445 apply(auto) |
|
1446 apply(erule_tac Prf.cases) |
|
1447 apply(simp_all) |
|
1448 apply(subst q2) |
|
1449 apply(auto) |
|
1450 using Prf_flat_L apply blast |
|
1451 using Prf_flat_L apply blast |
|
1452 done |
|
1453 |
|
1454 |
|
1455 definition POSIX2 :: "val \<Rightarrow> rexp \<Rightarrow> string \<Rightarrow> bool" |
|
1456 where |
|
1457 "POSIX2 v r s \<equiv> (\<turnstile> v : r \<and> flat v = s \<and> (\<forall>v'\<in>allvals r s. v \<succ>r v'))" |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 lemma k1: |
|
1463 assumes "nullable r" |
|
1464 shows "POSIX2 v r [] \<Longrightarrow> \<forall>v' \<in> alleps r. v \<succ>r v'" |
|
1465 using assms |
|
1466 apply(induct r arbitrary: v) |
|
1467 apply(simp_all) |
|
1468 apply(simp add: POSIX2_def) |
|
1469 apply(auto) |
|
1470 apply(simp add: POSIX2_def) |
|
1471 apply(simp add: POSIX2_def) |
|
1472 apply(simp add: POSIX2_def) |
|
1473 apply(simp add: POSIX2_def) |
|
1474 apply(simp add: POSIX2_def) |
|
1475 done |
|
1476 |
|
1477 lemma k2: |
|
1478 assumes "s \<in> L r" |
|
1479 shows "POSIX2 v r s \<Longrightarrow> \<forall>v' \<in> allvals r s. v \<succ>r v'" |
|
1480 using assms |
|
1481 apply(induct s arbitrary: r v) |
|
1482 apply(simp) |
|
1483 apply(rule k1) |
|
1484 apply (simp add: nullable_correctness) |
|
1485 apply(simp) |
|
1486 apply(simp) |
|
1487 apply(auto) |
|
1488 apply(simp only: POSIX2_def) |
|
1489 apply(simp) |
|
1490 apply(clarify) |
|
1491 apply(drule_tac x="x" in spec) |
|
1492 apply(drule mp) |
|
1493 apply(auto) |
|
1494 done |
|
1495 |
|
1496 lemma pos: |
|
1497 assumes "s \<in> r \<rightarrow> v" |
|
1498 shows "v \<in> allvals r s" |
|
1499 using assms |
|
1500 apply(subst q2) |
|
1501 using PMatch1(1) PMatch1(2) Prf_flat_L apply blast |
|
1502 apply(simp) |
|
1503 using PMatch1(1) PMatch1(2) Prf_flat_L by blast |
|
1504 |
|
1505 lemma mkeps_val: |
|
1506 assumes "nullable r" |
|
1507 shows "mkeps r \<in> alleps r" |
|
1508 using assms |
|
1509 apply(induct r) |
|
1510 apply(auto) |
|
1511 done |
|
1512 |
|
1513 lemma injval_injall: |
|
1514 assumes "\<turnstile> v : der a r" |
|
1515 shows "injval r a v \<in> injall r a v" |
|
1516 using assms |
|
1517 apply(induct a r arbitrary: v rule: der.induct) |
|
1518 apply(simp) |
|
1519 apply(erule Prf.cases) |
|
1520 apply(simp_all) |
|
1521 apply(erule Prf.cases) |
|
1522 apply(simp_all) |
|
1523 apply(case_tac "c = c'") |
|
1524 apply(simp) |
|
1525 apply(erule Prf.cases) |
|
1526 apply(simp_all) |
|
1527 apply(erule Prf.cases) |
|
1528 apply(simp_all) |
|
1529 apply(erule Prf.cases) |
|
1530 apply(simp_all) |
|
1531 apply(case_tac "nullable r1") |
|
1532 apply(simp) |
|
1533 apply(erule Prf.cases) |
|
1534 apply(simp_all) |
|
1535 apply(auto) |
|
1536 apply(erule Prf.cases) |
|
1537 apply(simp_all) |
|
1538 using mkeps_val apply blast |
|
1539 apply(erule Prf.cases) |
|
1540 apply(simp_all) |
|
1541 done |
|
1542 |
|
1543 |
|
1544 lemma mkeps_val1: |
|
1545 assumes "nullable r" "v \<succ>r mkeps r" "flat v = []" "\<turnstile> v : r" |
|
1546 shows "v = mkeps r" |
|
1547 using assms |
|
1548 apply(induct r arbitrary: v) |
|
1549 apply(auto) |
|
1550 apply(erule ValOrd.cases) |
|
1551 apply(auto) |
|
1552 apply(erule ValOrd.cases) |
|
1553 apply(auto) |
|
1554 apply(erule Prf.cases) |
|
1555 apply(auto) |
|
1556 apply(erule Prf.cases) |
|
1557 apply(auto) |
|
1558 apply(erule Prf.cases) |
|
1559 apply(auto) |
|
1560 apply(erule ValOrd.cases) |
|
1561 apply(auto) |
|
1562 apply(erule ValOrd.cases) |
|
1563 apply(auto) |
|
1564 apply(erule Prf.cases) |
|
1565 apply(auto) |
|
1566 apply(erule ValOrd.cases) |
|
1567 apply(auto) |
|
1568 apply(erule ValOrd.cases) |
|
1569 apply(auto) |
|
1570 apply(erule Prf.cases) |
|
1571 apply(auto) |
|
1572 apply(erule ValOrd.cases) |
|
1573 apply(auto) |
|
1574 apply (simp add: not_nullable_flat) |
|
1575 apply(erule ValOrd.cases) |
|
1576 apply(auto) |
|
1577 done |
|
1578 |
|
1579 lemma sulzmann_our: |
|
1580 assumes "v \<in> alleps r" "nullable r" |
|
1581 shows "mkeps r \<succ>r v" |
|
1582 using assms |
|
1583 apply(induct r arbitrary: v) |
|
1584 apply(simp_all) |
|
1585 apply(rule ValOrd.intros) |
|
1586 apply(auto)[1] |
|
1587 apply(case_tac "mkeps r1 = v1") |
|
1588 apply(simp) |
|
1589 apply(rule ValOrd.intros) |
|
1590 apply(blast) |
|
1591 apply(rule ValOrd.intros) |
|
1592 apply(blast) |
|
1593 apply(simp) |
|
1594 apply(auto) |
|
1595 apply(rule ValOrd.intros) |
|
1596 apply(blast) |
|
1597 apply(rule ValOrd.intros) |
|
1598 apply(blast) |
|
1599 apply(rule ValOrd.intros) |
|
1600 using not_nullable_flat q1 apply blast |
|
1601 apply(rule ValOrd.intros) |
|
1602 using q1 apply auto[1] |
|
1603 apply(rule ValOrd.intros) |
|
1604 apply (simp add: q1) |
|
1605 apply(rule ValOrd.intros) |
|
1606 apply(blast) |
|
1607 done |
|
1608 |
|
1609 lemma destruct: |
|
1610 assumes "\<forall>s3. s1 @ s3 \<in> L r1 \<longrightarrow> s3 = [] \<or> (\<forall>s4. s3 @ s4 = s2 \<longrightarrow> s4 \<notin> L r2)" |
|
1611 and "s1 \<in> L r1" "s2 \<in> L r2" "(s1' @ s2') \<sqsubseteq> (s1 @ s2)" |
|
1612 and "s1'@ s2' \<in> L (SEQ r1 r2)" "s1' \<in> L r1" |
|
1613 shows "s1' \<sqsubseteq> s1" |
|
1614 using assms |
|
1615 apply(simp add: prefix_def) |
|
1616 apply(auto) |
|
1617 apply(simp add: append_eq_append_conv2) |
|
1618 apply(auto) |
|
1619 apply(simp add: Sequ_def) |
|
1620 apply(auto) |
|
1621 apply(drule_tac x="us" in spec) |
|
1622 apply(simp) |
|
1623 apply(auto) |
|
1624 apply(simp add: append_eq_append_conv2) |
|
1625 apply(auto) |
|
1626 oops |
|
1627 |
|
1628 lemma inj_ord: |
|
1629 assumes "v1 \<succ>(der a r) v2" "s \<in> (der a r) \<rightarrow> v1" "s' \<in> L (der a r)" |
|
1630 "v1 \<in> allvals (der a r) s" "v2 \<in> allvals (der a r) s'" "s' \<sqsubseteq> s" |
|
1631 shows "injval r a v1 \<succ>r injval r a v2" |
|
1632 using assms |
|
1633 apply(induct a r arbitrary: s s' v1 v2 rule: der.induct) |
|
1634 apply(simp_all) |
|
1635 (*apply(simp add: allvals_NULL) |
|
1636 apply(simp add: allvals_NULL)*) |
|
1637 apply(case_tac "c = c'") |
|
1638 apply(simp) |
|
1639 apply(case_tac "s = []") |
|
1640 apply(subgoal_tac "s' = []") |
|
1641 prefer 2 |
|
1642 using allvals_EMPTY(2) apply blast |
|
1643 apply(simp add: allvals_EMPTY) |
|
1644 apply(rule ValOrd.intros) |
|
1645 apply(simp add: allvals_EMPTY) |
|
1646 apply(simp) |
|
1647 (*apply(simp add: allvals_NULL)*) |
|
1648 (* ALT case *) |
|
1649 apply(simp add: allvals_ALT) |
|
1650 apply(auto)[1] |
|
1651 apply(erule ValOrd.cases) |
|
1652 apply(simp_all) |
|
1653 apply(rule ValOrd.intros) |
|
1654 apply(erule PMatch.cases) |
|
1655 apply(simp_all) |
|
1656 apply(erule ValOrd.cases) |
|
1657 apply(simp_all) |
|
1658 apply(rule ValOrd.intros) |
|
1659 apply(subst v4) |
|
1660 apply(simp) |
|
1661 apply (simp add: q22) |
|
1662 apply(subst v4) |
|
1663 apply(simp) |
|
1664 apply (simp add: q22) |
|
1665 apply(simp) |
|
1666 apply(erule ValOrd.cases) |
|
1667 apply(simp_all) |
|
1668 apply(rule ValOrd.intros) |
|
1669 apply(subst v4) |
|
1670 apply (simp add: q22) |
|
1671 apply(subst v4) |
|
1672 apply (simp add: q22) |
|
1673 apply(simp) |
|
1674 apply(erule ValOrd.cases) |
|
1675 apply(simp_all) |
|
1676 apply(rule ValOrd.intros) |
|
1677 apply(erule PMatch.cases) |
|
1678 apply(simp_all) |
|
1679 using q22 apply auto[1] |
|
1680 apply(erule PMatch.cases) |
|
1681 apply(simp_all) |
|
1682 apply(erule ValOrd.cases) |
|
1683 apply(simp_all) |
|
1684 apply(rule ValOrd.intros) |
|
1685 using q22 apply auto[1] |
|
1686 apply(erule PMatch.cases) |
|
1687 apply(simp_all) |
|
1688 apply(erule ValOrd.cases) |
|
1689 apply(simp_all) |
|
1690 apply(rule ValOrd.intros) |
|
1691 apply(subst v4) |
|
1692 apply (simp add: q22) |
|
1693 apply(subst v4) |
|
1694 apply (simp add: q22) |
|
1695 apply(simp) |
|
1696 apply(erule PMatch.cases) |
|
1697 apply(simp_all) |
|
1698 apply(erule ValOrd.cases) |
|
1699 apply(simp_all) |
|
1700 apply(rule ValOrd.intros) |
|
1701 apply(subst v4) |
|
1702 apply (simp add: q22) |
|
1703 apply(subst v4) |
|
1704 apply (simp add: q22) |
|
1705 apply(simp) |
|
1706 using q22 apply auto[1] |
|
1707 apply(erule PMatch.cases) |
|
1708 apply(simp_all) |
|
1709 apply(erule ValOrd.cases) |
|
1710 apply(simp_all) |
|
1711 apply(rule ValOrd.intros) |
|
1712 using q22 apply auto[1] |
|
1713 (* seq case *) |
|
1714 apply(case_tac "nullable r1") |
|
1715 apply(simp) |
|
1716 prefer 2 |
|
1717 apply(simp) |
|
1718 apply(simp add: allvals_SEQ) |
|
1719 apply(auto)[1] |
|
1720 apply(erule ValOrd.cases) |
|
1721 apply(simp_all) |
|
1722 apply(clarify) |
|
1723 apply(rule ValOrd.intros) |
|
1724 apply(simp) |
|
1725 apply(rule ValOrd.intros) |
|
1726 apply(erule PMatch.cases) |
|
1727 apply(simp_all) |
|
1728 apply(clarify) |
|
1729 apply(rotate_tac 1) |
|
1730 apply(drule_tac x="s1b" in meta_spec) |
|
1731 apply(rotate_tac 13) |
|
1732 apply(drule_tac x="s1a" in meta_spec) |
|
1733 apply(drule_tac x="v1c" in meta_spec) |
|
1734 apply(drule_tac x="v1'" in meta_spec) |
|
1735 apply(simp) |
|
1736 apply(subgoal_tac "s1 = s1b") |
|
1737 prefer 2 |
|
1738 apply (metis PMatch1(2) q22) |
|
1739 apply(simp) |
|
1740 apply(clarify) |
|
1741 apply(drule destruct) |
|
1742 apply (metis PMatch1(2) q22) |
|
1743 apply (metis PMatch1(2) q22) |
|
1744 apply(assumption) |
|
1745 apply (metis PMatch1(2) q22) |
|
1746 apply (metis PMatch1(2) q22) |
|
1747 apply(subgoal_tac "s2a = s2b") |
|
1748 prefer 2 |
|
1749 apply (metis PMatch1(2) q22) |
|
1750 apply(drule destruct) |
|
1751 apply (metis PMatch1(2) q22) |
|
1752 apply (metis PMatch1(2) q22) |
|
1753 apply(assumption) |
|
1754 back |
|
1755 apply (metis PMatch1(2) q22) |
|
1756 apply (metis PMatch1(2) q22) |
|
1757 |
|
1758 |
|
1759 |
|
1760 apply(simp add: allvals_ALT) |
|
1761 apply(auto) |
|
1762 apply(erule ValOrd.cases) |
|
1763 apply(simp_all) |
|
1764 apply(clarify) |
|
1765 apply(erule ValOrd.cases) |
|
1766 apply(simp_all) |
|
1767 apply(clarify) |
|
1768 apply(rule ValOrd.intros) |
|
1769 apply(blast) |
|
1770 apply(rule ValOrd.intros) |
|
1771 apply(clarify) |
|
1772 apply(simp add: allvals_SEQ) |
|
1773 apply(auto)[1] |
|
1774 apply(erule PMatch.cases) |
|
1775 apply(simp_all) |
|
1776 apply(clarify) |
|
1777 apply(erule PMatch.cases) |
|
1778 apply(simp_all) |
|
1779 apply(auto) |
|
1780 apply(drule_tac x="s1b" in meta_spec) |
|
1781 apply(drule_tac x="v1" in meta_spec) |
|
1782 apply(drule_tac x="v1'a" in meta_spec) |
|
1783 apply(simp) |
|
1784 apply(drule_tac meta_mp) |
|
1785 apply(subgoal_tac "s1 = s1b") |
|
1786 apply(simp) |
|
1787 apply (metis PMatch1(2) q22) |
|
1788 apply(drule_tac meta_mp) |
|
1789 apply(subgoal_tac "s1a = s1b") |
|
1790 apply(simp) |
|
1791 apply(simp add: append_eq_append_conv2) |
|
1792 apply(auto)[1] |
|
1793 apply(subgoal_tac "s2 = s2a") |
|
1794 apply(simp) |
|
1795 apply(clarify) |
|
1796 prefer 2 |
|
1797 using q22 apply blast |
|
1798 using q22 apply blast |
|
1799 using q22 apply blast |
|
1800 apply(subgoal_tac "usa = []") |
|
1801 apply(simp) |
|
1802 prefer 2 |
|
1803 using q22 apply blast |
|
1804 prefer 3 |
|
1805 apply(simp) |
|
1806 prefer 4 |
|
1807 apply(erule PMatch.cases) |
|
1808 apply(simp_all) |
|
1809 apply(clarify) |
|
1810 apply(erule PMatch.cases) |
|
1811 apply(simp_all) |
|
1812 apply(auto) |
|
1813 apply(erule ValOrd.cases) |
|
1814 apply(simp_all) |
|
1815 apply(clarify) |
|
1816 apply(simp) |
|
1817 prefer 5 |
|
1818 apply(erule PMatch.cases) |
|
1819 apply(simp_all) |
|
1820 apply(clarify) |
|
1821 apply(erule ValOrd.cases) |
|
1822 apply(simp_all) |
|
1823 apply(clarify) |
|
1824 apply(simp add: allvals_SEQ) |
|
1825 apply(auto)[1] |
|
1826 apply (simp add: q22) |
|
1827 apply(simp add: allvals_SEQ) |
|
1828 apply(auto)[1] |
|
1829 apply(simp add: append_eq_append_conv2) |
|
1830 apply(auto)[1] |
|
1831 apply (simp add: q22) |
|
1832 thm PMatch2 |
|
1833 apply(drule PMatch2) |
|
1834 |
|
1835 |
|
1836 lemma sulzmann_our: |
|
1837 assumes "\<forall>v' \<in> allvals r s. v \<succ>r v'" "s \<in> L r" "\<turnstile> v : r" "flat v = s" |
|
1838 shows "s \<in> r \<rightarrow> v" |
|
1839 using assms |
|
1840 apply(induct s arbitrary: r v) |
|
1841 apply(simp_all) |
|
1842 apply(subst (asm) q33) |
|
1843 apply (simp add: nullable_correctness) |
|
1844 apply(simp) |
|
1845 apply(drule_tac x="mkeps r" in spec) |
|
1846 apply(drule mp) |
|
1847 apply(rule conjI) |
|
1848 using mkeps_val not_nullable_flat q1 apply blast |
|
1849 using mkeps_flat not_nullable_flat apply blast |
|
1850 apply(subgoal_tac "nullable r") |
|
1851 apply(drule mkeps_val1) |
|
1852 apply(assumption) |
|
1853 apply(simp) |
|
1854 apply(simp) |
|
1855 apply(simp) |
|
1856 using PMatch_mkeps not_nullable_flat apply blast |
|
1857 using not_nullable_flat apply blast |
|
1858 apply(drule_tac x="der a r" in meta_spec) |
|
1859 apply(drule_tac x="projval r a v" in meta_spec) |
|
1860 apply(drule meta_mp) |
|
1861 defer |
|
1862 apply(drule meta_mp) |
|
1863 using Prf_flat_L v3_proj v4_proj2 apply blast |
|
1864 apply(drule meta_mp) |
|
1865 using v3_proj apply blast |
|
1866 apply(drule meta_mp) |
|
1867 apply (simp add: v4_proj2) |
|
1868 defer |
|
1869 apply(rule ballI) |
|
1870 apply(drule_tac x="injval r a x" in spec) |
|
1871 apply(auto) |
|
1872 apply(drule_tac x="x" in spec) |
|
1873 apply(drule mp) |
|
1874 apply(rule injval_injall) |
|
1875 using q22 apply blast |
|
1876 apply(simp) |
|
1877 (* HERE *) |
|
1878 |
|
1879 |
|
1880 lemma our_sulzmann: |
|
1881 assumes "s \<in> r \<rightarrow> v" "v' \<in> allvals r s" |
|
1882 shows "v \<succ>r v'" |
|
1883 using assms |
|
1884 apply(induct r arbitrary: s v v') |
|
1885 apply(erule PMatch.cases) |
|
1886 apply(simp_all)[5] |
|
1887 apply(erule PMatch.cases) |
|
1888 apply(simp_all)[5] |
|
1889 apply(rule ValOrd.intros) |
|
1890 apply(erule PMatch.cases) |
|
1891 apply(simp_all)[5] |
|
1892 apply(rule ValOrd.intros) |
|
1893 (* SEQ - case *) |
|
1894 apply(erule PMatch.cases) |
|
1895 apply(simp_all)[5] |
|
1896 apply(clarify) |
|
1897 apply(subst (asm) (3) q2) |
|
1898 apply(simp add: Sequ_def) |
|
1899 apply(rule_tac x="s1" in exI) |
|
1900 apply(rule_tac x="s2" in exI) |
|
1901 apply(simp) |
|
1902 apply(rule conjI) |
|
1903 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
1904 apply (metis PMatch1(1) PMatch1(2) Prf_flat_L) |
|
1905 apply(simp) |
|
1906 apply(clarify) |
|
1907 apply(erule Prf.cases) |
|
1908 apply(simp_all)[5] |
|
1909 apply(case_tac "v1 = v1a") |
|
1910 apply(simp) |
|
1911 apply(rule ValOrd.intros) |
|
1912 apply(rotate_tac 1) |
|
1913 apply(drule_tac x="s2" in meta_spec) |
|
1914 apply(drule_tac x="v2" in meta_spec) |
|
1915 apply(drule_tac x="v2a" in meta_spec) |
|
1916 apply(simp) |
|
1917 apply(drule_tac meta_mp) |
|
1918 apply(subst q2) |
|
1919 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
1920 apply(simp) |
|
1921 apply(rule conjI) |
|
1922 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
1923 apply (simp add: PMatch1(2)) |
|
1924 apply(simp) |
|
1925 apply(rule ValOrd.intros) |
|
1926 prefer 2 |
|
1927 apply(simp) |
|
1928 apply(drule_tac x="s1" in meta_spec) |
|
1929 apply(drule_tac x="v1" in meta_spec) |
|
1930 apply(drule_tac x="v1a" in meta_spec) |
|
1931 apply(simp) |
|
1932 apply(drule_tac meta_mp) |
|
1933 apply(subst q2) |
|
1934 apply (metis PMatch1(1) PMatch1(2) Prf_flat_L) |
|
1935 apply(simp) |
|
1936 apply(rule conjI) |
|
1937 apply (metis PMatch1(1) PMatch1(2) Prf_flat_L) |
|
1938 apply(subst (asm) append_eq_append_conv2) |
|
1939 apply(auto)[1] |
|
1940 using Prf_flat_L apply fastforce |
|
1941 |
|
1942 apply(drule_tac x="us" in spec) |
|
1943 apply(auto)[1] |
|
1944 |
|
1945 using Prf_flat_L apply fastforce |
|
1946 using Prf_flat_L apply blast |
|
1947 apply(drule_tac meta_mp) |
|
1948 apply(subst q2) |
|
1949 using Prf_flat_L apply fastforce |
|
1950 apply(simp) |
|
1951 using Prf_flat_L apply fastforce |
|
1952 apply(simp) |
|
1953 apply(drule_tac x="flat v1a" in meta_spec) |
|
1954 apply(drule_tac x="v1" in meta_spec) |
|
1955 apply(drule_tac x="v1a" in meta_spec) |
|
1956 apply(drule_tac meta_mp) |
|
1957 apply(simp) |
|
1958 apply(drule meta_mp) |
|
1959 apply(subst q2) |
|
1960 apply (metis PMatch1(1) PMatch1(2) Prf_flat_L) |
|
1961 apply(simp) |
|
1962 apply(rule conjI) |
|
1963 apply (metis PMatch1(1) PMatch1(2) Prf_flat_L) |
|
1964 apply(drule_tac x="[]" in spec) |
|
1965 apply(auto)[1] |
|
1966 |
|
1967 using Prf_flat_L apply fast |
|
1968 apply(drule_tac x="us" in spec) |
|
1969 apply(simp) |
|
1970 |
|
1971 apply (simp add: Prf_flat_L) |
|
1972 apply(simp) |
|
1973 thm PMatch1 |
|
1974 qed |
|
1975 done |
|
1976 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
1977 apply(simp) |
|
1978 apply(clarify) |
|
1979 apply(erule Prf.cases) |
|
1980 apply(simp_all) |
|
1981 apply(rule ValOrd.intros) |
|
1982 apply(drule_tac x="v1" in meta_spec) |
|
1983 apply(drule meta_mp) |
|
1984 apply(subst q2) |
|
1985 apply (simp add: Prf_flat_L) |
|
1986 apply(simp) |
|
1987 apply (simp add: Prf_flat_L) |
|
1988 apply(simp) |
|
1989 apply(rule ValOrd.intros) |
|
1990 apply(auto)[1] |
|
1991 apply (simp add: PMatch1(2)) |
|
1992 apply (simp add: PMatch1(2)) |
|
1993 apply(subst (asm) (2) q2) |
|
1994 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
1995 apply(simp) |
|
1996 apply(clarify) |
|
1997 apply(erule Prf.cases) |
|
1998 apply(simp_all) |
|
1999 prefer 2 |
|
2000 apply(rule ValOrd.intros) |
|
2001 using q22b apply blast |
|
2002 apply(rule ValOrd.intros) |
|
2003 apply(auto) |
|
2004 using Prf_flat_L apply blast |
|
2005 apply(subst (asm) (3) q2) |
|
2006 apply(simp add: Sequ_def) |
|
2007 apply(rule_tac x="s1" in exI) |
|
2008 apply(rule_tac x="s2" in exI) |
|
2009 apply(simp) |
|
2010 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
2011 apply(simp) |
|
2012 apply(clarify) |
|
2013 apply(erule Prf.cases) |
|
2014 apply(simp_all) |
|
2015 apply(auto simp add: Sequ_def)[1] |
|
2016 apply(case_tac "v1 = v1a") |
|
2017 apply(simp) |
|
2018 apply(rule ValOrd.intros) |
|
2019 apply(rotate_tac 3) |
|
2020 apply(drule_tac x="v2a" in meta_spec) |
|
2021 apply(drule_tac meta_mp) |
|
2022 apply(subst q2) |
|
2023 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
2024 apply(simp) |
|
2025 apply(rule conjI) |
|
2026 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
2027 apply (metis PMatch1(2) same_append_eq) |
|
2028 apply(simp) |
|
2029 apply(rule ValOrd.intros) |
|
2030 apply(drule_tac x="v1a" in meta_spec) |
|
2031 apply(drule_tac meta_mp) |
|
2032 apply(subst q2) |
|
2033 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
2034 apply(simp) |
|
2035 apply(rule conjI) |
|
2036 using PMatch1(1) PMatch1(2) Prf_flat_L apply fastforce |
|
2037 prefer 2 |
|
2038 apply(simp) |
|
2039 prefer 2 |
|
2040 apply(simp) |
|
2041 apply(rotate_tac 7) |
|
2042 apply(drule sym) |
|
2043 apply(simp) |
|
2044 apply(subst (asm) (2) append_eq_append_conv2) |
|
2045 apply(auto)[1] |
|
2046 apply(frule_tac x="us" in spec) |
|
2047 apply(auto)[1] |
|
2048 prefer 2 |
|
2049 apply(drule_tac x="flat v2a" in spec) |
|
2050 apply(auto)[1] |
|
2051 |
|
2052 apply(subgoal_tac "flat v2a = s2") |
|
2053 apply(simp) |
|
2054 |
|
2055 apply(simp add: append_eq_append_conv2) |
|
2056 apply(auto) |
|
2057 prefer 2 |
|
2058 apply blast |
|
2059 prefer 2 |
|
2060 apply (metis Prf_flat_L append_self_conv2) |
|
2061 prefer 4 |
|
2062 |
|
2063 |
|
2064 |
|
2065 lemma our_sulzmann: |
|
2066 assumes "s \<in> r \<rightarrow> v" |
|
2067 shows "POSIX2 v r s" |
|
2068 using assms |
|
2069 apply(induct s r v) |
|
2070 apply(auto) |
|
2071 apply(simp add: POSIX2_def) |
|
2072 using Prf.intros(4) ValOrd.intros(7) apply blast |
|
2073 apply(simp add: POSIX2_def) |
|
2074 apply (simp add: Prf.intros(5) ValOrd.intros(8)) |
|
2075 apply(simp add: POSIX2_def) |
|
2076 apply(auto) |
|
2077 apply(rule Prf.intros) |
|
2078 apply(simp) |
|
2079 apply(subgoal_tac "(\<exists>x1. x = Left x1) \<or> (\<exists>x1. x = Right x1)") |
|
2080 apply(auto)[1] |
|
2081 apply(rule ValOrd.intros) |
|
2082 apply(drule_tac x="x1" in bspec) |
|
2083 apply(subst (asm) q2) |
|
2084 apply (simp add: Prf_flat_L) |
|
2085 apply(simp) |
|
2086 apply(subst q2) |
|
2087 apply (simp add: Prf_flat_L) |
|
2088 apply(auto)[1] |
|
2089 apply(rotate_tac 2) |
|
2090 apply(erule Prf.cases) |
|
2091 apply(simp_all) |
|
2092 apply(rotate_tac 2) |
|
2093 apply(erule Prf.cases) |
|
2094 apply(simp_all) |
|
2095 apply (simp add: Prf_flat_L) |
|
2096 apply(rule ValOrd.intros) |
|
2097 apply(subst (asm) (2) q2) |
|
2098 apply (simp add: Prf_flat_L) |
|
2099 apply(auto)[1] |
|
2100 defer |
|
2101 apply(simp add: POSIX2_def) |
|
2102 apply(auto)[1] |
|
2103 apply(rule Prf.intros) |
|
2104 apply (simp add: Prf_flat_L) |
|
2105 apply(subgoal_tac "(\<exists>x1. x = Left x1) \<or> (\<exists>x1. x = Right x1)") |
|
2106 apply(auto)[1] |
|
2107 apply(rule ValOrd.intros) |
|
2108 apply(subst (asm) (2) q2) |
|
2109 apply (simp add: Prf_flat_L) |
|
2110 apply(auto)[1] |
|
2111 apply(rotate_tac 4) |
|
2112 apply(erule Prf.cases) |
|
2113 apply(simp_all) |
|
2114 apply(auto)[1] |
|
2115 using Prf_flat_L apply force |
|
2116 apply(rule ValOrd.intros) |
|
2117 apply(drule_tac x="x1" in bspec) |
|
2118 apply(subst (asm) q2) |
|
2119 apply (simp add: Prf_flat_L) |
|
2120 apply(auto)[1] |
|
2121 apply(subst q2) |
|
2122 apply(rotate_tac 3) |
|
2123 apply(erule Prf.cases) |
|
2124 apply(simp_all) |
|
2125 apply(rotate_tac 3) |
|
2126 apply(erule Prf.cases) |
|
2127 apply(simp_all) |
|
2128 defer |
|
2129 apply(auto)[1] |
|
2130 apply(simp add: POSIX2_def) |
|
2131 apply(auto intro: Prf.intros)[1] |
|
2132 apply(subgoal_tac "(\<exists>x1 x2. x = Seq x1 x2 \<and> flat v1 @ flat v2 = flat x1 @ flat x2)") |
|
2133 apply(auto)[1] |
|
2134 apply(case_tac "v1 = x1") |
|
2135 apply(simp) |
|
2136 apply(rule ValOrd.intros) |
|
2137 apply(rotate_tac 6) |
|
2138 apply(drule_tac x="x2" in bspec) |
|
2139 apply(subst (asm) q2) |
|
2140 apply (simp add: Sequ_def Prf_flat_L) |
|
2141 |
|
2142 using Prf_flat_L apply blast |
|
2143 apply(auto)[1] |
|
2144 apply(rotate_tac 6) |
|
2145 apply(erule Prf.cases) |
|
2146 apply(simp_all) |
|
2147 apply(subst q2) |
|
2148 apply (simp add: Prf_flat_L) |
|
2149 apply(auto)[1] |
|
2150 apply(auto simp add: Sequ_def) |
|
2151 using Prf_flat_L apply blast |
|
2152 apply(rule ValOrd.intros) |
|
2153 apply(rotate_tac 5) |
|
2154 apply(drule_tac x="x1" in bspec) |
|
2155 apply(rotate_tac 1) |
|
2156 apply(subst (asm) q2) |
|
2157 apply (simp add: Sequ_def Prf_flat_L) |
|
2158 using Prf_flat_L apply blast |
|
2159 apply(auto)[1] |
|
2160 apply(subst q2) |
|
2161 apply (simp add: Sequ_def Prf_flat_L) |
|
2162 apply(auto)[1] |
|
2163 apply(rotate_tac 7) |
|
2164 apply(erule Prf.cases) |
|
2165 apply(simp_all) |
|
2166 apply (simp add: Sequ_def Prf_flat_L) |
|
2167 apply(rotate_tac 7) |
|
2168 apply(erule Prf.cases) |
|
2169 apply(simp_all) |
|
2170 apply(auto)[1] |
|
2171 apply(simp add: append_eq_append_conv2) |
|
2172 apply(auto simp add: Sequ_def)[1] |
|
2173 using Prf_flat_L apply fastforce |
|
2174 apply(simp add: append_eq_append_conv2) |
|
2175 apply(auto simp add: Sequ_def)[1] |
|
2176 |
|
2177 apply(auto)[1] |
|
2178 |
|
2179 apply(simp add: POSIX2_def) |
|
2180 apply(simp add: POSIX2_def) |
|
2181 apply(simp add: POSIX2_def) |
|
2182 apply(simp add: POSIX2_def) |
|
2183 apply(simp add: POSIX2_def) |
|
2184 |
|
2185 lemma "s \<in> L(r) \<Longrightarrow> \<exists>v. POSIX2 v r s" |
|
2186 apply(induct r arbitrary: s) |
|
2187 apply(auto) |
|
2188 apply(rule_tac x="Void" in exI) |
|
2189 apply(simp add: POSIX2_def) |
|
2190 apply (simp add: Prf.intros(4) ValOrd.intros(7)) |
|
2191 apply(rule_tac x="Char x" in exI) |
|
2192 apply(simp add: POSIX2_def) |
|
2193 apply (simp add: Prf.intros(5) ValOrd.intros(8)) |
|
2194 defer |
|
2195 apply(drule_tac x="s" in meta_spec) |
|
2196 apply(auto)[1] |
|
2197 apply(rule_tac x="Left v" in exI) |
|
2198 apply(simp add: POSIX2_def) |
|
2199 apply(auto)[1] |
|
2200 using Prf.intros(2) apply blast |
|
2201 |
|
2202 apply(case_tac s) |
|
2203 apply(simp) |
|
2204 apply(auto)[1] |
|
2205 apply (simp add: ValOrd.intros(6)) |
|
2206 apply(rule ValOrd.intros) |
|
2207 |
|
2208 thm PMatch.intros[no_vars] |
|
2209 |
|
2210 lemma POSIX_PMatch: |
|
2211 assumes "s \<in> r \<rightarrow> v" "v' \<in> Values r s" |
|
2212 shows "v \<succ>r v' \<or> length (flat v') < length (flat v)" |
|
2213 using assms |
|
2214 apply(induct r arbitrary: s v v' rule: rexp.induct) |
|
2215 apply(simp_all add: Values_recs) |
|
2216 apply(erule PMatch.cases) |
|
2217 apply(simp_all)[5] |
|
2218 apply (metis ValOrd.intros(7)) |
|
2219 apply(erule PMatch.cases) |
|
2220 apply(simp_all)[5] |
|
2221 apply(simp add: prefix_def) |
|
2222 apply (metis ValOrd.intros(8)) |
|
2223 apply(auto)[1] |
|
2224 defer |
|
2225 apply(auto)[1] |
|
2226 apply(erule PMatch.cases) |
|
2227 apply(simp_all)[5] |
|
2228 apply (metis ValOrd.intros(6)) |
|
2229 apply (metis (no_types, lifting) PMatch1(2) Prf_flat_L Values_def length_sprefix mem_Collect_eq sprefix_def) |
|
2230 apply(erule PMatch.cases) |
|
2231 apply(simp_all)[5] |
|
2232 apply (metis (no_types, lifting) PMatch1(2) ValOrd.intros(3) Values_def length_sprefix mem_Collect_eq order_refl sprefix_def) |
|
2233 apply (metis ValOrd.intros(5)) |
|
2234 apply(erule PMatch.cases) |
|
2235 apply(simp_all)[5] |
|
2236 apply(auto) |
|
2237 apply(case_tac "v1a = v1") |
|
2238 apply(simp) |
|
2239 apply(rule ValOrd.intros(1)) |
|
2240 apply (metis PMatch1(2) append_Nil comm_monoid_diff_class.diff_cancel drop_0 drop_all drop_append order_refl rest_def) |
|
2241 apply(rule ValOrd.intros(2)) |
|
2242 apply(auto) |
|
2243 apply(drule_tac x="s1" in meta_spec) |
|
2244 apply(drule_tac x="v1a" in meta_spec) |
|
2245 apply(drule_tac x="v1" in meta_spec) |
|
2246 apply(auto) |
|
2247 apply(drule meta_mp) |
|
2248 defer |
|
2249 apply(auto)[1] |
|
2250 apply(frule PMatch1) |
|
2251 apply(drule PMatch1(2)) |
|
2252 apply(frule PMatch1) |
|
2253 apply(drule PMatch1(2)) |
|
2254 apply(auto)[1] |
|
2255 apply(simp add: Values_def) |
|
2256 apply(simp add: prefix_def) |
|
2257 apply(auto)[1] |
|
2258 apply(simp add: append_eq_append_conv2) |
|
2259 apply(auto)[1] |
|
2260 apply(rotate_tac 10) |
|
2261 apply(drule sym) |
|
2262 apply(simp) |
|
2263 apply(simp add: rest_def) |
|
2264 apply(case_tac "s3a = []") |
|
2265 apply(auto)[1] |
|
2266 |
|
2267 |
|
2268 apply (metis ValOrd.intros(6)) |
|
2269 apply (metis (no_types, lifting) PMatch1(2) ValOrd.intros(3) Values_def length_sprefix mem_Collect_eq order_refl sprefix_def) |
|
2270 apply(auto)[1] |
|
2271 apply (metis (no_types, lifting) PMatch1(2) Prf_flat_L Values_def length_sprefix mem_Collect_eq sprefix_def) |
|
2272 apply (metis ValOrd.intros(5)) |
|
2273 apply(auto)[1] |
|
2274 apply(erule Prf.cases) |
|
2275 apply(simp_all)[5] |
|
2276 apply(erule Prf.cases) |
|
2277 apply(simp_all)[5] |
|
2278 apply(erule Prf.cases) |
|
2279 apply(simp_all)[5] |
|
2280 apply(erule PMatch.cases) |
|
2281 apply(simp_all)[5] |
|
2282 defer |
|
2283 apply(erule Prf.cases) |
|
2284 apply(simp_all)[5] |
|
2285 apply(erule PMatch.cases) |
|
2286 apply(simp_all)[5] |
|
2287 apply(clarify) |
|
2288 apply(simp add: L_flat_Prf) |
|
2289 |
|
2290 apply(clarify) |
|
2291 apply (metis ValOrd.intros(8)) |
|
2292 apply (metis POSIX_ALT_I1) |
|
2293 apply(rule POSIX_ALT_I2) |
|
2294 apply(simp) |
|
2295 apply(auto)[1] |
|
2296 apply(simp add: POSIX_def) |
|
2297 apply(frule PMatch1(1)) |
|
2298 apply(frule PMatch1(2)) |
|
2299 apply(simp) |
|
2300 |
|
2301 |
|
2302 lemma POSIX_PMatch: |
|
2303 assumes "s \<in> r \<rightarrow> v" |
|
2304 shows "POSIX v r" |
|
2305 using assms |
|
2306 apply(induct arbitrary: rule: PMatch.induct) |
|
2307 apply(auto) |
|
2308 apply(simp add: POSIX_def) |
|
2309 apply(auto)[1] |
|
2310 apply (metis Prf.intros(4)) |
|
2311 apply(erule Prf.cases) |
|
2312 apply(simp_all)[5] |
|
2313 apply (metis ValOrd.intros(7)) |
|
2314 apply(simp add: POSIX_def) |
|
2315 apply(auto)[1] |
|
2316 apply (metis Prf.intros(5)) |
|
2317 apply(erule Prf.cases) |
|
2318 apply(simp_all)[5] |
|
2319 apply (metis ValOrd.intros(8)) |
|
2320 apply (metis POSIX_ALT_I1) |
|
2321 apply(rule POSIX_ALT_I2) |
|
2322 apply(simp) |
|
2323 apply(auto)[1] |
|
2324 apply(simp add: POSIX_def) |
|
2325 apply(frule PMatch1(1)) |
|
2326 apply(frule PMatch1(2)) |
|
2327 apply(simp) |
|
2328 |
|
2329 |
|
2330 |
|
2331 lemma ValOrd_PMatch: |
|
2332 assumes "s \<in> r \<rightarrow> v1" "\<turnstile> v2 : r" "flat v2 = s" |
|
2333 shows "v1 \<succ>r v2" |
|
2334 using assms |
|
2335 apply(induct arbitrary: v2 rule: PMatch.induct) |
|
2336 apply(erule Prf.cases) |
|
2337 apply(simp_all)[5] |
|
2338 apply (metis ValOrd.intros(7)) |
|
2339 apply(erule Prf.cases) |
|
2340 apply(simp_all)[5] |
|
2341 apply (metis ValOrd.intros(8)) |
|
2342 apply(erule Prf.cases) |
|
2343 apply(simp_all)[5] |
|
2344 apply(clarify) |
|
2345 apply (metis ValOrd.intros(6)) |
|
2346 apply(clarify) |
|
2347 apply (metis PMatch1(2) ValOrd.intros(3) order_refl) |
|
2348 apply(erule Prf.cases) |
|
2349 apply(simp_all)[5] |
|
2350 apply(clarify) |
|
2351 apply (metis Prf_flat_L) |
|
2352 apply (metis ValOrd.intros(5)) |
|
2353 (* Seq case *) |
|
2354 apply(erule Prf.cases) |
|
2355 apply(simp_all)[5] |
|
2356 apply(auto) |
|
2357 apply(case_tac "v1 = v1a") |
|
2358 apply(auto) |
|
2359 apply (metis PMatch1(2) ValOrd.intros(1) same_append_eq) |
|
2360 apply(rule ValOrd.intros(2)) |
|
2361 apply(auto) |
|
2362 apply(drule_tac x="v1a" in meta_spec) |
|
2363 apply(drule_tac meta_mp) |
|
2364 apply(simp) |
|
2365 apply(drule_tac meta_mp) |
|
2366 prefer 2 |
|
2367 apply(simp) |
|
2368 apply(simp add: append_eq_append_conv2) |
|
2369 apply(auto) |
|
2370 apply (metis Prf_flat_L) |
|
2371 apply(case_tac "us = []") |
|
2372 apply(simp) |
|
2373 apply(drule_tac x="us" in spec) |
|
2374 apply(drule mp) |
|
2375 |
|
2376 thm L_flat_Prf |
|
2377 apply(simp add: L_flat_Prf) |
|
2378 thm append_eq_append_conv2 |
|
2379 apply(simp add: append_eq_append_conv2) |
|
2380 apply(auto) |
|
2381 apply(drule_tac x="us" in spec) |
|
2382 apply(drule mp) |
|
2383 apply metis |
|
2384 apply (metis append_Nil2) |
|
2385 apply(case_tac "us = []") |
|
2386 apply(auto) |
|
2387 apply(drule_tac x="s2" in spec) |
|
2388 apply(drule mp) |
|
2389 |
|
2390 apply(auto)[1] |
|
2391 apply(drule_tac x="v1a" in meta_spec) |
|
2392 apply(simp) |
|
2393 |
|
2394 lemma refl_on_ValOrd: |
|
2395 "refl_on (Values r s) {(v1, v2). v1 \<succ>r v2 \<and> v1 \<in> Values r s \<and> v2 \<in> Values r s}" |
|
2396 unfolding refl_on_def |
|
2397 apply(auto) |
|
2398 apply(rule ValOrd_refl) |
|
2399 apply(simp add: Values_def) |
|
2400 done |
|
2401 |
|
2402 |
|
2403 section {* Posix definition *} |
|
2404 |
|
2405 definition POSIX :: "val \<Rightarrow> rexp \<Rightarrow> bool" |
|
2406 where |
|
2407 "POSIX v r \<equiv> (\<turnstile> v : r \<and> (\<forall>v'. (\<turnstile> v' : r \<and> flat v = flat v') \<longrightarrow> v \<succ>r v'))" |
|
2408 |
|
2409 definition POSIX2 :: "val \<Rightarrow> rexp \<Rightarrow> bool" |
|
2410 where |
|
2411 "POSIX2 v r \<equiv> (\<turnstile> v : r \<and> (\<forall>v'. (\<turnstile> v' : r \<and> flat v = flat v') \<longrightarrow> v 2\<succ> v'))" |
|
2412 |
|
2413 lemma "POSIX v r = POSIX2 v r" |
|
2414 unfolding POSIX_def POSIX2_def |
|
2415 apply(auto) |
|
2416 apply(rule Ord1) |
|
2417 apply(auto) |
|
2418 apply(rule Ord3) |
|
2419 apply(auto) |
|
2420 done |
|
2421 |
|
2422 section {* POSIX for some constructors *} |
|
2423 |
|
2424 lemma POSIX_SEQ1: |
|
2425 assumes "POSIX (Seq v1 v2) (SEQ r1 r2)" "\<turnstile> v1 : r1" "\<turnstile> v2 : r2" |
|
2426 shows "POSIX v1 r1" |
|
2427 using assms |
|
2428 unfolding POSIX_def |
|
2429 apply(auto) |
|
2430 apply(drule_tac x="Seq v' v2" in spec) |
|
2431 apply(simp) |
|
2432 apply(erule impE) |
|
2433 apply(rule Prf.intros) |
|
2434 apply(simp) |
|
2435 apply(simp) |
|
2436 apply(erule ValOrd.cases) |
|
2437 apply(simp_all) |
|
2438 apply(clarify) |
|
2439 by (metis ValOrd_refl) |
|
2440 |
|
2441 lemma POSIX_SEQ2: |
|
2442 assumes "POSIX (Seq v1 v2) (SEQ r1 r2)" "\<turnstile> v1 : r1" "\<turnstile> v2 : r2" |
|
2443 shows "POSIX v2 r2" |
|
2444 using assms |
|
2445 unfolding POSIX_def |
|
2446 apply(auto) |
|
2447 apply(drule_tac x="Seq v1 v'" in spec) |
|
2448 apply(simp) |
|
2449 apply(erule impE) |
|
2450 apply(rule Prf.intros) |
|
2451 apply(simp) |
|
2452 apply(simp) |
|
2453 apply(erule ValOrd.cases) |
|
2454 apply(simp_all) |
|
2455 done |
|
2456 |
|
2457 lemma POSIX_ALT2: |
|
2458 assumes "POSIX (Left v1) (ALT r1 r2)" |
|
2459 shows "POSIX v1 r1" |
|
2460 using assms |
|
2461 unfolding POSIX_def |
|
2462 apply(auto) |
|
2463 apply(erule Prf.cases) |
|
2464 apply(simp_all)[5] |
|
2465 apply(drule_tac x="Left v'" in spec) |
|
2466 apply(simp) |
|
2467 apply(drule mp) |
|
2468 apply(rule Prf.intros) |
|
2469 apply(auto) |
|
2470 apply(erule ValOrd.cases) |
|
2471 apply(simp_all) |
|
2472 done |
|
2473 |
|
2474 lemma POSIX_ALT1a: |
|
2475 assumes "POSIX (Right v2) (ALT r1 r2)" |
|
2476 shows "POSIX v2 r2" |
|
2477 using assms |
|
2478 unfolding POSIX_def |
|
2479 apply(auto) |
|
2480 apply(erule Prf.cases) |
|
2481 apply(simp_all)[5] |
|
2482 apply(drule_tac x="Right v'" in spec) |
|
2483 apply(simp) |
|
2484 apply(drule mp) |
|
2485 apply(rule Prf.intros) |
|
2486 apply(auto) |
|
2487 apply(erule ValOrd.cases) |
|
2488 apply(simp_all) |
|
2489 done |
|
2490 |
|
2491 lemma POSIX_ALT1b: |
|
2492 assumes "POSIX (Right v2) (ALT r1 r2)" |
|
2493 shows "(\<forall>v'. (\<turnstile> v' : r2 \<and> flat v' = flat v2) \<longrightarrow> v2 \<succ>r2 v')" |
|
2494 using assms |
|
2495 apply(drule_tac POSIX_ALT1a) |
|
2496 unfolding POSIX_def |
|
2497 apply(auto) |
|
2498 done |
|
2499 |
|
2500 lemma POSIX_ALT_I1: |
|
2501 assumes "POSIX v1 r1" |
|
2502 shows "POSIX (Left v1) (ALT r1 r2)" |
|
2503 using assms |
|
2504 unfolding POSIX_def |
|
2505 apply(auto) |
|
2506 apply (metis Prf.intros(2)) |
|
2507 apply(rotate_tac 2) |
|
2508 apply(erule Prf.cases) |
|
2509 apply(simp_all)[5] |
|
2510 apply(auto) |
|
2511 apply(rule ValOrd.intros) |
|
2512 apply(auto) |
|
2513 apply(rule ValOrd.intros) |
|
2514 by simp |
|
2515 |
|
2516 lemma POSIX_ALT_I2: |
|
2517 assumes "POSIX v2 r2" "\<forall>v'. \<turnstile> v' : r1 \<longrightarrow> length (flat v2) > length (flat v')" |
|
2518 shows "POSIX (Right v2) (ALT r1 r2)" |
|
2519 using assms |
|
2520 unfolding POSIX_def |
|
2521 apply(auto) |
|
2522 apply (metis Prf.intros) |
|
2523 apply(rotate_tac 3) |
|
2524 apply(erule Prf.cases) |
|
2525 apply(simp_all)[5] |
|
2526 apply(auto) |
|
2527 apply(rule ValOrd.intros) |
|
2528 apply metis |
|
2529 done |
|
2530 |
|
2531 lemma mkeps_POSIX: |
|
2532 assumes "nullable r" |
|
2533 shows "POSIX (mkeps r) r" |
|
2534 using assms |
|
2535 apply(induct r) |
|
2536 apply(auto)[1] |
|
2537 apply(simp add: POSIX_def) |
|
2538 apply(auto)[1] |
|
2539 apply (metis Prf.intros(4)) |
|
2540 apply(erule Prf.cases) |
|
2541 apply(simp_all)[5] |
|
2542 apply (metis ValOrd.intros) |
|
2543 apply(simp) |
|
2544 apply(auto)[1] |
|
2545 apply(simp add: POSIX_def) |
|
2546 apply(auto)[1] |
|
2547 apply (metis mkeps.simps(2) mkeps_nullable nullable.simps(5)) |
|
2548 apply(rotate_tac 6) |
|
2549 apply(erule Prf.cases) |
|
2550 apply(simp_all)[5] |
|
2551 apply (simp add: mkeps_flat) |
|
2552 apply(case_tac "mkeps r1a = v1") |
|
2553 apply(simp) |
|
2554 apply (metis ValOrd.intros(1)) |
|
2555 apply (rule ValOrd.intros(2)) |
|
2556 apply metis |
|
2557 apply(simp) |
|
2558 (* ALT case *) |
|
2559 thm mkeps.simps |
|
2560 apply(simp) |
|
2561 apply(erule disjE) |
|
2562 apply(simp) |
|
2563 apply (metis POSIX_ALT_I1) |
|
2564 (* *) |
|
2565 apply(auto)[1] |
|
2566 thm POSIX_ALT_I1 |
|
2567 apply (metis POSIX_ALT_I1) |
|
2568 apply(simp (no_asm) add: POSIX_def) |
|
2569 apply(auto)[1] |
|
2570 apply(rule Prf.intros(3)) |
|
2571 apply(simp only: POSIX_def) |
|
2572 apply(rotate_tac 4) |
|
2573 apply(erule Prf.cases) |
|
2574 apply(simp_all)[5] |
|
2575 thm mkeps_flat |
|
2576 apply(simp add: mkeps_flat) |
|
2577 apply(auto)[1] |
|
2578 thm Prf_flat_L nullable_correctness |
|
2579 apply (metis Prf_flat_L nullable_correctness) |
|
2580 apply(rule ValOrd.intros) |
|
2581 apply(subst (asm) POSIX_def) |
|
2582 apply(clarify) |
|
2583 apply(drule_tac x="v2" in spec) |
|
2584 by simp |
|
2585 |
|
2586 |
|
2587 |
|
2588 text {* |
|
2589 Injection value is related to r |
|
2590 *} |
|
2591 |
|
2592 |
|
2593 |
|
2594 text {* |
|
2595 The string behind the injection value is an added c |
|
2596 *} |
|
2597 |
|
2598 |
|
2599 lemma injval_inj: "inj_on (injval r c) {v. \<turnstile> v : der c r}" |
|
2600 apply(induct c r rule: der.induct) |
|
2601 unfolding inj_on_def |
|
2602 apply(auto)[1] |
|
2603 apply(erule Prf.cases) |
|
2604 apply(simp_all)[5] |
|
2605 apply(auto)[1] |
|
2606 apply(erule Prf.cases) |
|
2607 apply(simp_all)[5] |
|
2608 apply(auto)[1] |
|
2609 apply(erule Prf.cases) |
|
2610 apply(simp_all)[5] |
|
2611 apply(erule Prf.cases) |
|
2612 apply(simp_all)[5] |
|
2613 apply(erule Prf.cases) |
|
2614 apply(simp_all)[5] |
|
2615 apply(auto)[1] |
|
2616 apply(erule Prf.cases) |
|
2617 apply(simp_all)[5] |
|
2618 apply(erule Prf.cases) |
|
2619 apply(simp_all)[5] |
|
2620 apply(erule Prf.cases) |
|
2621 apply(simp_all)[5] |
|
2622 apply(auto)[1] |
|
2623 apply(erule Prf.cases) |
|
2624 apply(simp_all)[5] |
|
2625 apply(erule Prf.cases) |
|
2626 apply(simp_all)[5] |
|
2627 apply(clarify) |
|
2628 apply(erule Prf.cases) |
|
2629 apply(simp_all)[5] |
|
2630 apply(erule Prf.cases) |
|
2631 apply(simp_all)[5] |
|
2632 apply(clarify) |
|
2633 apply(erule Prf.cases) |
|
2634 apply(simp_all)[5] |
|
2635 apply(clarify) |
|
2636 apply (metis list.distinct(1) mkeps_flat v4) |
|
2637 apply(erule Prf.cases) |
|
2638 apply(simp_all)[5] |
|
2639 apply(clarify) |
|
2640 apply(rotate_tac 6) |
|
2641 apply(erule Prf.cases) |
|
2642 apply(simp_all)[5] |
|
2643 apply (metis list.distinct(1) mkeps_flat v4) |
|
2644 apply(erule Prf.cases) |
|
2645 apply(simp_all)[5] |
|
2646 apply(erule Prf.cases) |
|
2647 apply(simp_all)[5] |
|
2648 done |
|
2649 |
|
2650 lemma Values_nullable: |
|
2651 assumes "nullable r1" |
|
2652 shows "mkeps r1 \<in> Values r1 s" |
|
2653 using assms |
|
2654 apply(induct r1 arbitrary: s) |
|
2655 apply(simp_all) |
|
2656 apply(simp add: Values_recs) |
|
2657 apply(simp add: Values_recs) |
|
2658 apply(simp add: Values_recs) |
|
2659 apply(auto)[1] |
|
2660 done |
|
2661 |
|
2662 lemma Values_injval: |
|
2663 assumes "v \<in> Values (der c r) s" |
|
2664 shows "injval r c v \<in> Values r (c#s)" |
|
2665 using assms |
|
2666 apply(induct c r arbitrary: v s rule: der.induct) |
|
2667 apply(simp add: Values_recs) |
|
2668 apply(simp add: Values_recs) |
|
2669 apply(case_tac "c = c'") |
|
2670 apply(simp) |
|
2671 apply(simp add: Values_recs) |
|
2672 apply(simp add: prefix_def) |
|
2673 apply(simp) |
|
2674 apply(simp add: Values_recs) |
|
2675 apply(simp) |
|
2676 apply(simp add: Values_recs) |
|
2677 apply(auto)[1] |
|
2678 apply(case_tac "nullable r1") |
|
2679 apply(simp) |
|
2680 apply(simp add: Values_recs) |
|
2681 apply(auto)[1] |
|
2682 apply(simp add: rest_def) |
|
2683 apply(subst v4) |
|
2684 apply(simp add: Values_def) |
|
2685 apply(simp add: Values_def) |
|
2686 apply(rule Values_nullable) |
|
2687 apply(assumption) |
|
2688 apply(simp add: rest_def) |
|
2689 apply(subst mkeps_flat) |
|
2690 apply(assumption) |
|
2691 apply(simp) |
|
2692 apply(simp) |
|
2693 apply(simp add: Values_recs) |
|
2694 apply(auto)[1] |
|
2695 apply(simp add: rest_def) |
|
2696 apply(subst v4) |
|
2697 apply(simp add: Values_def) |
|
2698 apply(simp add: Values_def) |
|
2699 done |
|
2700 |
|
2701 lemma Values_projval: |
|
2702 assumes "v \<in> Values r (c#s)" "\<exists>s. flat v = c # s" |
|
2703 shows "projval r c v \<in> Values (der c r) s" |
|
2704 using assms |
|
2705 apply(induct r arbitrary: v s c rule: rexp.induct) |
|
2706 apply(simp add: Values_recs) |
|
2707 apply(simp add: Values_recs) |
|
2708 apply(case_tac "c = char") |
|
2709 apply(simp) |
|
2710 apply(simp add: Values_recs) |
|
2711 apply(simp) |
|
2712 apply(simp add: Values_recs) |
|
2713 apply(simp add: prefix_def) |
|
2714 apply(case_tac "nullable rexp1") |
|
2715 apply(simp) |
|
2716 apply(simp add: Values_recs) |
|
2717 apply(auto)[1] |
|
2718 apply(simp add: rest_def) |
|
2719 apply (metis hd_Cons_tl hd_append2 list.sel(1)) |
|
2720 apply(simp add: rest_def) |
|
2721 apply(simp add: append_eq_Cons_conv) |
|
2722 apply(auto)[1] |
|
2723 apply(subst v4_proj2) |
|
2724 apply(simp add: Values_def) |
|
2725 apply(assumption) |
|
2726 apply(simp) |
|
2727 apply(simp) |
|
2728 apply(simp add: Values_recs) |
|
2729 apply(auto)[1] |
|
2730 apply(auto simp add: Values_def not_nullable_flat)[1] |
|
2731 apply(simp add: append_eq_Cons_conv) |
|
2732 apply(auto)[1] |
|
2733 apply(simp add: append_eq_Cons_conv) |
|
2734 apply(auto)[1] |
|
2735 apply(simp add: rest_def) |
|
2736 apply(subst v4_proj2) |
|
2737 apply(simp add: Values_def) |
|
2738 apply(assumption) |
|
2739 apply(simp) |
|
2740 apply(simp add: Values_recs) |
|
2741 apply(auto)[1] |
|
2742 done |
|
2743 |
|
2744 |
|
2745 definition "MValue v r s \<equiv> (v \<in> Values r s \<and> (\<forall>v' \<in> Values r s. v 2\<succ> v'))" |
|
2746 |
|
2747 lemma MValue_ALTE: |
|
2748 assumes "MValue v (ALT r1 r2) s" |
|
2749 shows "(\<exists>vl. v = Left vl \<and> MValue vl r1 s \<and> (\<forall>vr \<in> Values r2 s. length (flat vr) \<le> length (flat vl))) \<or> |
|
2750 (\<exists>vr. v = Right vr \<and> MValue vr r2 s \<and> (\<forall>vl \<in> Values r1 s. length (flat vl) < length (flat vr)))" |
|
2751 using assms |
|
2752 apply(simp add: MValue_def) |
|
2753 apply(simp add: Values_recs) |
|
2754 apply(auto) |
|
2755 apply(drule_tac x="Left x" in bspec) |
|
2756 apply(simp) |
|
2757 apply(erule ValOrd2.cases) |
|
2758 apply(simp_all) |
|
2759 apply(drule_tac x="Right vr" in bspec) |
|
2760 apply(simp) |
|
2761 apply(erule ValOrd2.cases) |
|
2762 apply(simp_all) |
|
2763 apply(drule_tac x="Right x" in bspec) |
|
2764 apply(simp) |
|
2765 apply(erule ValOrd2.cases) |
|
2766 apply(simp_all) |
|
2767 apply(drule_tac x="Left vl" in bspec) |
|
2768 apply(simp) |
|
2769 apply(erule ValOrd2.cases) |
|
2770 apply(simp_all) |
|
2771 done |
|
2772 |
|
2773 lemma MValue_ALTI1: |
|
2774 assumes "MValue vl r1 s" "\<forall>vr \<in> Values r2 s. length (flat vr) \<le> length (flat vl)" |
|
2775 shows "MValue (Left vl) (ALT r1 r2) s" |
|
2776 using assms |
|
2777 apply(simp add: MValue_def) |
|
2778 apply(simp add: Values_recs) |
|
2779 apply(auto) |
|
2780 apply(rule ValOrd2.intros) |
|
2781 apply metis |
|
2782 apply(rule ValOrd2.intros) |
|
2783 apply metis |
|
2784 done |
|
2785 |
|
2786 lemma MValue_ALTI2: |
|
2787 assumes "MValue vr r2 s" "\<forall>vl \<in> Values r1 s. length (flat vl) < length (flat vr)" |
|
2788 shows "MValue (Right vr) (ALT r1 r2) s" |
|
2789 using assms |
|
2790 apply(simp add: MValue_def) |
|
2791 apply(simp add: Values_recs) |
|
2792 apply(auto) |
|
2793 apply(rule ValOrd2.intros) |
|
2794 apply metis |
|
2795 apply(rule ValOrd2.intros) |
|
2796 apply metis |
|
2797 done |
|
2798 |
|
2799 lemma t: "(c#xs = c#ys) \<Longrightarrow> xs = ys" |
|
2800 by (metis list.sel(3)) |
|
2801 |
|
2802 lemma t2: "(xs = ys) \<Longrightarrow> (c#xs) = (c#ys)" |
|
2803 by (metis) |
|
2804 |
|
2805 lemma "\<not>(nullable r) \<Longrightarrow> \<not>(\<exists>v. \<turnstile> v : r \<and> flat v = [])" |
|
2806 by (metis Prf_flat_L nullable_correctness) |
|
2807 |
|
2808 |
|
2809 lemma LeftRight: |
|
2810 assumes "(Left v1) \<succ>(der c (ALT r1 r2)) (Right v2)" |
|
2811 and "\<turnstile> v1 : der c r1" "\<turnstile> v2 : der c r2" |
|
2812 shows "(injval (ALT r1 r2) c (Left v1)) \<succ>(ALT r1 r2) (injval (ALT r1 r2) c (Right v2))" |
|
2813 using assms |
|
2814 apply(simp) |
|
2815 apply(erule ValOrd.cases) |
|
2816 apply(simp_all)[8] |
|
2817 apply(rule ValOrd.intros) |
|
2818 apply(clarify) |
|
2819 apply(subst v4) |
|
2820 apply(simp) |
|
2821 apply(subst v4) |
|
2822 apply(simp) |
|
2823 apply(simp) |
|
2824 done |
|
2825 |
|
2826 lemma RightLeft: |
|
2827 assumes "(Right v1) \<succ>(der c (ALT r1 r2)) (Left v2)" |
|
2828 and "\<turnstile> v1 : der c r2" "\<turnstile> v2 : der c r1" |
|
2829 shows "(injval (ALT r1 r2) c (Right v1)) \<succ>(ALT r1 r2) (injval (ALT r1 r2) c (Left v2))" |
|
2830 using assms |
|
2831 apply(simp) |
|
2832 apply(erule ValOrd.cases) |
|
2833 apply(simp_all)[8] |
|
2834 apply(rule ValOrd.intros) |
|
2835 apply(clarify) |
|
2836 apply(subst v4) |
|
2837 apply(simp) |
|
2838 apply(subst v4) |
|
2839 apply(simp) |
|
2840 apply(simp) |
|
2841 done |
|
2842 |
|
2843 lemma h: |
|
2844 assumes "nullable r1" "\<turnstile> v1 : der c r1" |
|
2845 shows "injval r1 c v1 \<succ>r1 mkeps r1" |
|
2846 using assms |
|
2847 apply(induct r1 arbitrary: v1 rule: der.induct) |
|
2848 apply(simp) |
|
2849 apply(simp) |
|
2850 apply(erule Prf.cases) |
|
2851 apply(simp_all)[5] |
|
2852 apply(simp) |
|
2853 apply(simp) |
|
2854 apply(erule Prf.cases) |
|
2855 apply(simp_all)[5] |
|
2856 apply(clarify) |
|
2857 apply(auto)[1] |
|
2858 apply (metis ValOrd.intros(6)) |
|
2859 apply (metis ValOrd.intros(6)) |
|
2860 apply (metis ValOrd.intros(3) le_add2 list.size(3) mkeps_flat monoid_add_class.add.right_neutral) |
|
2861 apply(auto)[1] |
|
2862 apply (metis ValOrd.intros(4) length_greater_0_conv list.distinct(1) list.size(3) mkeps_flat v4) |
|
2863 apply (metis ValOrd.intros(4) length_greater_0_conv list.distinct(1) list.size(3) mkeps_flat v4) |
|
2864 apply (metis ValOrd.intros(5)) |
|
2865 apply(simp) |
|
2866 apply(erule Prf.cases) |
|
2867 apply(simp_all)[5] |
|
2868 apply(clarify) |
|
2869 apply(erule Prf.cases) |
|
2870 apply(simp_all)[5] |
|
2871 apply(clarify) |
|
2872 apply (metis ValOrd.intros(2) list.distinct(1) mkeps_flat v4) |
|
2873 apply(clarify) |
|
2874 by (metis ValOrd.intros(1)) |
|
2875 |
|
2876 lemma LeftRightSeq: |
|
2877 assumes "(Left (Seq v1 v2)) \<succ>(der c (SEQ r1 r2)) (Right v3)" |
|
2878 and "nullable r1" "\<turnstile> v1 : der c r1" |
|
2879 shows "(injval (SEQ r1 r2) c (Seq v1 v2)) \<succ>(SEQ r1 r2) (injval (SEQ r1 r2) c (Right v2))" |
|
2880 using assms |
|
2881 apply(simp) |
|
2882 apply(erule ValOrd.cases) |
|
2883 apply(simp_all)[8] |
|
2884 apply(clarify) |
|
2885 apply(simp) |
|
2886 apply(rule ValOrd.intros(2)) |
|
2887 prefer 2 |
|
2888 apply (metis list.distinct(1) mkeps_flat v4) |
|
2889 by (metis h) |
|
2890 |
|
2891 lemma rr1: |
|
2892 assumes "\<turnstile> v : r" "\<not>nullable r" |
|
2893 shows "flat v \<noteq> []" |
|
2894 using assms |
|
2895 by (metis Prf_flat_L nullable_correctness) |
|
2896 |
|
2897 (* HERE *) |
|
2898 |
|
2899 lemma Prf_inj_test: |
|
2900 assumes "v1 \<succ>(der c r) v2" |
|
2901 "v1 \<in> Values (der c r) s" |
|
2902 "v2 \<in> Values (der c r) s" |
|
2903 "injval r c v1 \<in> Values r (c#s)" |
|
2904 "injval r c v2 \<in> Values r (c#s)" |
|
2905 shows "(injval r c v1) 2\<succ> (injval r c v2)" |
|
2906 using assms |
|
2907 apply(induct c r arbitrary: v1 v2 s rule: der.induct) |
|
2908 (* NULL case *) |
|
2909 apply(simp add: Values_recs) |
|
2910 (* EMPTY case *) |
|
2911 apply(simp add: Values_recs) |
|
2912 (* CHAR case *) |
|
2913 apply(case_tac "c = c'") |
|
2914 apply(simp) |
|
2915 apply(simp add: Values_recs) |
|
2916 apply (metis ValOrd2.intros(8)) |
|
2917 apply(simp add: Values_recs) |
|
2918 (* ALT case *) |
|
2919 apply(simp) |
|
2920 apply(simp add: Values_recs) |
|
2921 apply(auto)[1] |
|
2922 apply(erule ValOrd.cases) |
|
2923 apply(simp_all)[8] |
|
2924 apply (metis ValOrd2.intros(6)) |
|
2925 apply(erule ValOrd.cases) |
|
2926 apply(simp_all)[8] |
|
2927 apply(rule ValOrd2.intros) |
|
2928 apply(subst v4) |
|
2929 apply(simp add: Values_def) |
|
2930 apply(subst v4) |
|
2931 apply(simp add: Values_def) |
|
2932 apply(simp) |
|
2933 apply(erule ValOrd.cases) |
|
2934 apply(simp_all)[8] |
|
2935 apply(rule ValOrd2.intros) |
|
2936 apply(subst v4) |
|
2937 apply(simp add: Values_def) |
|
2938 apply(subst v4) |
|
2939 apply(simp add: Values_def) |
|
2940 apply(simp) |
|
2941 apply(erule ValOrd.cases) |
|
2942 apply(simp_all)[8] |
|
2943 apply (metis ValOrd2.intros(5)) |
|
2944 (* SEQ case*) |
|
2945 apply(simp) |
|
2946 apply(case_tac "nullable r1") |
|
2947 apply(simp) |
|
2948 defer |
|
2949 apply(simp) |
|
2950 apply(simp add: Values_recs) |
|
2951 apply(auto)[1] |
|
2952 apply(erule ValOrd.cases) |
|
2953 apply(simp_all)[8] |
|
2954 apply(clarify) |
|
2955 apply(rule ValOrd2.intros) |
|
2956 apply(simp) |
|
2957 apply (metis Ord1) |
|
2958 apply(clarify) |
|
2959 apply(rule ValOrd2.intros) |
|
2960 apply(subgoal_tac "rest v1 (flat v1 @ flat v2) = flat v2") |
|
2961 apply(simp) |
|
2962 apply(subgoal_tac "rest (injval r1 c v1) (c # flat v1 @ flat v2) = flat v2") |
|
2963 apply(simp) |
|
2964 oops |
|
2965 |
|
2966 lemma Prf_inj_test: |
|
2967 assumes "v1 \<succ>(der c r) v2" |
|
2968 "v1 \<in> Values (der c r) s" |
|
2969 "v2 \<in> Values (der c r) s" |
|
2970 "injval r c v1 \<in> Values r (c#s)" |
|
2971 "injval r c v2 \<in> Values r (c#s)" |
|
2972 shows "(injval r c v1) 2\<succ> (injval r c v2)" |
|
2973 using assms |
|
2974 apply(induct c r arbitrary: v1 v2 s rule: der.induct) |
|
2975 (* NULL case *) |
|
2976 apply(simp add: Values_recs) |
|
2977 (* EMPTY case *) |
|
2978 apply(simp add: Values_recs) |
|
2979 (* CHAR case *) |
|
2980 apply(case_tac "c = c'") |
|
2981 apply(simp) |
|
2982 apply(simp add: Values_recs) |
|
2983 apply (metis ValOrd2.intros(8)) |
|
2984 apply(simp add: Values_recs) |
|
2985 (* ALT case *) |
|
2986 apply(simp) |
|
2987 apply(simp add: Values_recs) |
|
2988 apply(auto)[1] |
|
2989 apply(erule ValOrd.cases) |
|
2990 apply(simp_all)[8] |
|
2991 apply (metis ValOrd2.intros(6)) |
|
2992 apply(erule ValOrd.cases) |
|
2993 apply(simp_all)[8] |
|
2994 apply(rule ValOrd2.intros) |
|
2995 apply(subst v4) |
|
2996 apply(simp add: Values_def) |
|
2997 apply(subst v4) |
|
2998 apply(simp add: Values_def) |
|
2999 apply(simp) |
|
3000 apply(erule ValOrd.cases) |
|
3001 apply(simp_all)[8] |
|
3002 apply(rule ValOrd2.intros) |
|
3003 apply(subst v4) |
|
3004 apply(simp add: Values_def) |
|
3005 apply(subst v4) |
|
3006 apply(simp add: Values_def) |
|
3007 apply(simp) |
|
3008 apply(erule ValOrd.cases) |
|
3009 apply(simp_all)[8] |
|
3010 apply (metis ValOrd2.intros(5)) |
|
3011 (* SEQ case*) |
|
3012 apply(simp) |
|
3013 apply(case_tac "nullable r1") |
|
3014 apply(simp) |
|
3015 defer |
|
3016 apply(simp) |
|
3017 apply(simp add: Values_recs) |
|
3018 apply(auto)[1] |
|
3019 apply(erule ValOrd.cases) |
|
3020 apply(simp_all)[8] |
|
3021 apply(clarify) |
|
3022 apply(rule ValOrd2.intros) |
|
3023 apply(simp) |
|
3024 apply (metis Ord1) |
|
3025 apply(clarify) |
|
3026 apply(rule ValOrd2.intros) |
|
3027 apply metis |
|
3028 using injval_inj |
|
3029 apply(simp add: Values_def inj_on_def) |
|
3030 apply metis |
|
3031 apply(simp add: Values_recs) |
|
3032 apply(auto)[1] |
|
3033 apply(erule ValOrd.cases) |
|
3034 apply(simp_all)[8] |
|
3035 apply(clarify) |
|
3036 apply(erule ValOrd.cases) |
|
3037 apply(simp_all)[8] |
|
3038 apply(clarify) |
|
3039 apply (metis Ord1 ValOrd2.intros(1)) |
|
3040 apply(clarify) |
|
3041 apply(rule ValOrd2.intros(2)) |
|
3042 apply metis |
|
3043 using injval_inj |
|
3044 apply(simp add: Values_def inj_on_def) |
|
3045 apply metis |
|
3046 apply(erule ValOrd.cases) |
|
3047 apply(simp_all)[8] |
|
3048 apply(rule ValOrd2.intros(2)) |
|
3049 thm h |
|
3050 apply(rule Ord1) |
|
3051 apply(rule h) |
|
3052 apply(simp) |
|
3053 apply(simp add: Values_def) |
|
3054 apply(simp add: Values_def) |
|
3055 apply (metis list.distinct(1) mkeps_flat v4) |
|
3056 apply(erule ValOrd.cases) |
|
3057 apply(simp_all)[8] |
|
3058 apply(clarify) |
|
3059 apply(simp add: Values_def) |
|
3060 defer |
|
3061 apply(erule ValOrd.cases) |
|
3062 apply(simp_all)[8] |
|
3063 apply(clarify) |
|
3064 apply(rule ValOrd2.intros(1)) |
|
3065 apply(rotate_tac 1) |
|
3066 apply(drule_tac x="v2" in meta_spec) |
|
3067 apply(rotate_tac 8) |
|
3068 apply(drule_tac x="v2'" in meta_spec) |
|
3069 apply(rotate_tac 8) |
|
3070 oops |
|
3071 |
|
3072 lemma POSIX_der: |
|
3073 assumes "POSIX v (der c r)" "\<turnstile> v : der c r" |
|
3074 shows "POSIX (injval r c v) r" |
|
3075 using assms |
|
3076 unfolding POSIX_def |
|
3077 apply(auto) |
|
3078 thm v3 |
|
3079 apply (erule v3) |
|
3080 thm v4 |
|
3081 apply(subst (asm) v4) |
|
3082 apply(assumption) |
|
3083 apply(drule_tac x="projval r c v'" in spec) |
|
3084 apply(drule mp) |
|
3085 apply(rule conjI) |
|
3086 thm v3_proj |
|
3087 apply(rule v3_proj) |
|
3088 apply(simp) |
|
3089 apply(rule_tac x="flat v" in exI) |
|
3090 apply(simp) |
|
3091 thm t |
|
3092 apply(rule_tac c="c" in t) |
|
3093 apply(simp) |
|
3094 thm v4_proj |
|
3095 apply(subst v4_proj) |
|
3096 apply(simp) |
|
3097 apply(rule_tac x="flat v" in exI) |
|
3098 apply(simp) |
|
3099 apply(simp) |
|
3100 oops |
|
3101 |
|
3102 lemma POSIX_der: |
|
3103 assumes "POSIX v (der c r)" "\<turnstile> v : der c r" |
|
3104 shows "POSIX (injval r c v) r" |
|
3105 using assms |
|
3106 apply(induct c r arbitrary: v rule: der.induct) |
|
3107 (* null case*) |
|
3108 apply(simp add: POSIX_def) |
|
3109 apply(auto)[1] |
|
3110 apply(erule Prf.cases) |
|
3111 apply(simp_all)[5] |
|
3112 apply(erule Prf.cases) |
|
3113 apply(simp_all)[5] |
|
3114 (* empty case *) |
|
3115 apply(simp add: POSIX_def) |
|
3116 apply(auto)[1] |
|
3117 apply(erule Prf.cases) |
|
3118 apply(simp_all)[5] |
|
3119 apply(erule Prf.cases) |
|
3120 apply(simp_all)[5] |
|
3121 (* char case *) |
|
3122 apply(simp add: POSIX_def) |
|
3123 apply(case_tac "c = c'") |
|
3124 apply(auto)[1] |
|
3125 apply(erule Prf.cases) |
|
3126 apply(simp_all)[5] |
|
3127 apply (metis Prf.intros(5)) |
|
3128 apply(erule Prf.cases) |
|
3129 apply(simp_all)[5] |
|
3130 apply(erule Prf.cases) |
|
3131 apply(simp_all)[5] |
|
3132 apply (metis ValOrd.intros(8)) |
|
3133 apply(auto)[1] |
|
3134 apply(erule Prf.cases) |
|
3135 apply(simp_all)[5] |
|
3136 apply(erule Prf.cases) |
|
3137 apply(simp_all)[5] |
|
3138 (* alt case *) |
|
3139 apply(erule Prf.cases) |
|
3140 apply(simp_all)[5] |
|
3141 apply(clarify) |
|
3142 apply(simp (no_asm) add: POSIX_def) |
|
3143 apply(auto)[1] |
|
3144 apply (metis Prf.intros(2) v3) |
|
3145 apply(rotate_tac 4) |
|
3146 apply(erule Prf.cases) |
|
3147 apply(simp_all)[5] |
|
3148 apply (metis POSIX_ALT2 POSIX_def ValOrd.intros(6)) |
|
3149 apply (metis ValOrd.intros(3) order_refl) |
|
3150 apply(simp (no_asm) add: POSIX_def) |
|
3151 apply(auto)[1] |
|
3152 apply (metis Prf.intros(3) v3) |
|
3153 apply(rotate_tac 4) |
|
3154 apply(erule Prf.cases) |
|
3155 apply(simp_all)[5] |
|
3156 defer |
|
3157 apply (metis POSIX_ALT1a POSIX_def ValOrd.intros(5)) |
|
3158 prefer 2 |
|
3159 apply(subst (asm) (5) POSIX_def) |
|
3160 apply(auto)[1] |
|
3161 apply(rotate_tac 5) |
|
3162 apply(erule Prf.cases) |
|
3163 apply(simp_all)[5] |
|
3164 apply(rule ValOrd.intros) |
|
3165 apply(subst (asm) v4) |
|
3166 apply(simp) |
|
3167 apply(drule_tac x="Left (projval r1a c v1)" in spec) |
|
3168 apply(clarify) |
|
3169 apply(drule mp) |
|
3170 apply(rule conjI) |
|
3171 apply (metis Prf.intros(2) v3_proj) |
|
3172 apply(simp) |
|
3173 apply (metis v4_proj2) |
|
3174 apply(erule ValOrd.cases) |
|
3175 apply(simp_all)[8] |
|
3176 apply (metis less_not_refl v4_proj2) |
|
3177 (* seq case *) |
|
3178 apply(case_tac "nullable r1") |
|
3179 defer |
|
3180 apply(simp add: POSIX_def) |
|
3181 apply(auto)[1] |
|
3182 apply(erule Prf.cases) |
|
3183 apply(simp_all)[5] |
|
3184 apply (metis Prf.intros(1) v3) |
|
3185 apply(erule Prf.cases) |
|
3186 apply(simp_all)[5] |
|
3187 apply(erule Prf.cases) |
|
3188 apply(simp_all)[5] |
|
3189 apply(clarify) |
|
3190 apply(subst (asm) (3) v4) |
|
3191 apply(simp) |
|
3192 apply(simp) |
|
3193 apply(subgoal_tac "flat v1a \<noteq> []") |
|
3194 prefer 2 |
|
3195 apply (metis Prf_flat_L nullable_correctness) |
|
3196 apply(subgoal_tac "\<exists>s. flat v1a = c # s") |
|
3197 prefer 2 |
|
3198 apply (metis append_eq_Cons_conv) |
|
3199 apply(auto)[1] |
|
3200 oops |
|
3201 |
|
3202 |
|
3203 lemma POSIX_ex: "\<turnstile> v : r \<Longrightarrow> \<exists>v. POSIX v r" |
|
3204 apply(induct r arbitrary: v) |
|
3205 apply(erule Prf.cases) |
|
3206 apply(simp_all)[5] |
|
3207 apply(erule Prf.cases) |
|
3208 apply(simp_all)[5] |
|
3209 apply(rule_tac x="Void" in exI) |
|
3210 apply(simp add: POSIX_def) |
|
3211 apply(auto)[1] |
|
3212 apply (metis Prf.intros(4)) |
|
3213 apply(erule Prf.cases) |
|
3214 apply(simp_all)[5] |
|
3215 apply (metis ValOrd.intros(7)) |
|
3216 apply(erule Prf.cases) |
|
3217 apply(simp_all)[5] |
|
3218 apply(rule_tac x="Char c" in exI) |
|
3219 apply(simp add: POSIX_def) |
|
3220 apply(auto)[1] |
|
3221 apply (metis Prf.intros(5)) |
|
3222 apply(erule Prf.cases) |
|
3223 apply(simp_all)[5] |
|
3224 apply (metis ValOrd.intros(8)) |
|
3225 apply(erule Prf.cases) |
|
3226 apply(simp_all)[5] |
|
3227 apply(auto)[1] |
|
3228 apply(drule_tac x="v1" in meta_spec) |
|
3229 apply(drule_tac x="v2" in meta_spec) |
|
3230 apply(auto)[1] |
|
3231 defer |
|
3232 apply(erule Prf.cases) |
|
3233 apply(simp_all)[5] |
|
3234 apply(auto)[1] |
|
3235 apply (metis POSIX_ALT_I1) |
|
3236 apply (metis POSIX_ALT_I1 POSIX_ALT_I2) |
|
3237 apply(case_tac "nullable r1a") |
|
3238 apply(rule_tac x="Seq (mkeps r1a) va" in exI) |
|
3239 apply(auto simp add: POSIX_def)[1] |
|
3240 apply (metis Prf.intros(1) mkeps_nullable) |
|
3241 apply(simp add: mkeps_flat) |
|
3242 apply(rotate_tac 7) |
|
3243 apply(erule Prf.cases) |
|
3244 apply(simp_all)[5] |
|
3245 apply(case_tac "mkeps r1 = v1a") |
|
3246 apply(simp) |
|
3247 apply (rule ValOrd.intros(1)) |
|
3248 apply (metis append_Nil mkeps_flat) |
|
3249 apply (rule ValOrd.intros(2)) |
|
3250 apply(drule mkeps_POSIX) |
|
3251 apply(simp add: POSIX_def) |
|
3252 oops |
|
3253 |
|
3254 lemma POSIX_ex2: "\<turnstile> v : r \<Longrightarrow> \<exists>v. POSIX v r \<and> \<turnstile> v : r" |
|
3255 apply(induct r arbitrary: v) |
|
3256 apply(erule Prf.cases) |
|
3257 apply(simp_all)[5] |
|
3258 apply(erule Prf.cases) |
|
3259 apply(simp_all)[5] |
|
3260 apply(rule_tac x="Void" in exI) |
|
3261 apply(simp add: POSIX_def) |
|
3262 apply(auto)[1] |
|
3263 oops |
|
3264 |
|
3265 lemma POSIX_ALT_cases: |
|
3266 assumes "\<turnstile> v : (ALT r1 r2)" "POSIX v (ALT r1 r2)" |
|
3267 shows "(\<exists>v1. v = Left v1 \<and> POSIX v1 r1) \<or> (\<exists>v2. v = Right v2 \<and> POSIX v2 r2)" |
|
3268 using assms |
|
3269 apply(erule_tac Prf.cases) |
|
3270 apply(simp_all) |
|
3271 unfolding POSIX_def |
|
3272 apply(auto) |
|
3273 apply (metis POSIX_ALT2 POSIX_def assms(2)) |
|
3274 by (metis POSIX_ALT1b assms(2)) |
|
3275 |
|
3276 lemma POSIX_ALT_cases2: |
|
3277 assumes "POSIX v (ALT r1 r2)" "\<turnstile> v : (ALT r1 r2)" |
|
3278 shows "(\<exists>v1. v = Left v1 \<and> POSIX v1 r1) \<or> (\<exists>v2. v = Right v2 \<and> POSIX v2 r2)" |
|
3279 using assms POSIX_ALT_cases by auto |
|
3280 |
|
3281 lemma Prf_flat_empty: |
|
3282 assumes "\<turnstile> v : r" "flat v = []" |
|
3283 shows "nullable r" |
|
3284 using assms |
|
3285 apply(induct) |
|
3286 apply(auto) |
|
3287 done |
|
3288 |
|
3289 lemma POSIX_proj: |
|
3290 assumes "POSIX v r" "\<turnstile> v : r" "\<exists>s. flat v = c#s" |
|
3291 shows "POSIX (projval r c v) (der c r)" |
|
3292 using assms |
|
3293 apply(induct r c v arbitrary: rule: projval.induct) |
|
3294 defer |
|
3295 defer |
|
3296 defer |
|
3297 defer |
|
3298 apply(erule Prf.cases) |
|
3299 apply(simp_all)[5] |
|
3300 apply(erule Prf.cases) |
|
3301 apply(simp_all)[5] |
|
3302 apply(erule Prf.cases) |
|
3303 apply(simp_all)[5] |
|
3304 apply(erule Prf.cases) |
|
3305 apply(simp_all)[5] |
|
3306 apply(erule Prf.cases) |
|
3307 apply(simp_all)[5] |
|
3308 apply(erule Prf.cases) |
|
3309 apply(simp_all)[5] |
|
3310 apply(erule Prf.cases) |
|
3311 apply(simp_all)[5] |
|
3312 apply(erule Prf.cases) |
|
3313 apply(simp_all)[5] |
|
3314 apply(erule Prf.cases) |
|
3315 apply(simp_all)[5] |
|
3316 apply(erule Prf.cases) |
|
3317 apply(simp_all)[5] |
|
3318 apply(simp add: POSIX_def) |
|
3319 apply(auto)[1] |
|
3320 apply(erule Prf.cases) |
|
3321 apply(simp_all)[5] |
|
3322 oops |
|
3323 |
|
3324 lemma POSIX_proj: |
|
3325 assumes "POSIX v r" "\<turnstile> v : r" "\<exists>s. flat v = c#s" |
|
3326 shows "POSIX (projval r c v) (der c r)" |
|
3327 using assms |
|
3328 apply(induct r arbitrary: c v rule: rexp.induct) |
|
3329 apply(erule Prf.cases) |
|
3330 apply(simp_all)[5] |
|
3331 apply(erule Prf.cases) |
|
3332 apply(simp_all)[5] |
|
3333 apply(erule Prf.cases) |
|
3334 apply(simp_all)[5] |
|
3335 apply(simp add: POSIX_def) |
|
3336 apply(auto)[1] |
|
3337 apply(erule Prf.cases) |
|
3338 apply(simp_all)[5] |
|
3339 oops |
|
3340 |
|
3341 lemma POSIX_proj: |
|
3342 assumes "POSIX v r" "\<turnstile> v : r" "\<exists>s. flat v = c#s" |
|
3343 shows "POSIX (projval r c v) (der c r)" |
|
3344 using assms |
|
3345 apply(induct r c v arbitrary: rule: projval.induct) |
|
3346 defer |
|
3347 defer |
|
3348 defer |
|
3349 defer |
|
3350 apply(erule Prf.cases) |
|
3351 apply(simp_all)[5] |
|
3352 apply(erule Prf.cases) |
|
3353 apply(simp_all)[5] |
|
3354 apply(erule Prf.cases) |
|
3355 apply(simp_all)[5] |
|
3356 apply(erule Prf.cases) |
|
3357 apply(simp_all)[5] |
|
3358 apply(erule Prf.cases) |
|
3359 apply(simp_all)[5] |
|
3360 apply(erule Prf.cases) |
|
3361 apply(simp_all)[5] |
|
3362 apply(erule Prf.cases) |
|
3363 apply(simp_all)[5] |
|
3364 apply(erule Prf.cases) |
|
3365 apply(simp_all)[5] |
|
3366 apply(erule Prf.cases) |
|
3367 apply(simp_all)[5] |
|
3368 apply(erule Prf.cases) |
|
3369 apply(simp_all)[5] |
|
3370 apply(simp add: POSIX_def) |
|
3371 apply(auto)[1] |
|
3372 apply(erule Prf.cases) |
|
3373 apply(simp_all)[5] |
|
3374 oops |
|
3375 |
|
3376 lemma Prf_inj: |
|
3377 assumes "v1 \<succ>(der c r) v2" "\<turnstile> v1 : der c r" "\<turnstile> v2 : der c r" "flat v1 = flat v2" |
|
3378 shows "(injval r c v1) \<succ>r (injval r c v2)" |
|
3379 using assms |
|
3380 apply(induct arbitrary: v1 v2 rule: der.induct) |
|
3381 (* NULL case *) |
|
3382 apply(simp) |
|
3383 apply(erule ValOrd.cases) |
|
3384 apply(simp_all)[8] |
|
3385 (* EMPTY case *) |
|
3386 apply(erule ValOrd.cases) |
|
3387 apply(simp_all)[8] |
|
3388 (* CHAR case *) |
|
3389 apply(case_tac "c = c'") |
|
3390 apply(simp) |
|
3391 apply(erule ValOrd.cases) |
|
3392 apply(simp_all)[8] |
|
3393 apply(rule ValOrd.intros) |
|
3394 apply(simp) |
|
3395 apply(erule ValOrd.cases) |
|
3396 apply(simp_all)[8] |
|
3397 (* ALT case *) |
|
3398 apply(simp) |
|
3399 apply(erule ValOrd.cases) |
|
3400 apply(simp_all)[8] |
|
3401 apply(rule ValOrd.intros) |
|
3402 apply(subst v4) |
|
3403 apply(clarify) |
|
3404 apply(rotate_tac 3) |
|
3405 apply(erule Prf.cases) |
|
3406 apply(simp_all)[5] |
|
3407 apply(subst v4) |
|
3408 apply(clarify) |
|
3409 apply(rotate_tac 2) |
|
3410 apply(erule Prf.cases) |
|
3411 apply(simp_all)[5] |
|
3412 apply(simp) |
|
3413 apply(rule ValOrd.intros) |
|
3414 apply(clarify) |
|
3415 apply(rotate_tac 3) |
|
3416 apply(erule Prf.cases) |
|
3417 apply(simp_all)[5] |
|
3418 apply(clarify) |
|
3419 apply(erule Prf.cases) |
|
3420 apply(simp_all)[5] |
|
3421 apply(rule ValOrd.intros) |
|
3422 apply(clarify) |
|
3423 apply(erule Prf.cases) |
|
3424 apply(simp_all)[5] |
|
3425 apply(erule Prf.cases) |
|
3426 apply(simp_all)[5] |
|
3427 (* SEQ case*) |
|
3428 apply(simp) |
|
3429 apply(case_tac "nullable r1") |
|
3430 defer |
|
3431 apply(simp) |
|
3432 apply(erule ValOrd.cases) |
|
3433 apply(simp_all)[8] |
|
3434 apply(clarify) |
|
3435 apply(erule Prf.cases) |
|
3436 apply(simp_all)[5] |
|
3437 apply(erule Prf.cases) |
|
3438 apply(simp_all)[5] |
|
3439 apply(clarify) |
|
3440 apply(rule ValOrd.intros) |
|
3441 apply(simp) |
|
3442 oops |
|
3443 |
|
3444 |
|
3445 text {* |
|
3446 Injection followed by projection is the identity. |
|
3447 *} |
|
3448 |
|
3449 lemma proj_inj_id: |
|
3450 assumes "\<turnstile> v : der c r" |
|
3451 shows "projval r c (injval r c v) = v" |
|
3452 using assms |
|
3453 apply(induct r arbitrary: c v rule: rexp.induct) |
|
3454 apply(simp) |
|
3455 apply(erule Prf.cases) |
|
3456 apply(simp_all)[5] |
|
3457 apply(simp) |
|
3458 apply(erule Prf.cases) |
|
3459 apply(simp_all)[5] |
|
3460 apply(simp) |
|
3461 apply(case_tac "c = char") |
|
3462 apply(simp) |
|
3463 apply(erule Prf.cases) |
|
3464 apply(simp_all)[5] |
|
3465 apply(simp) |
|
3466 apply(erule Prf.cases) |
|
3467 apply(simp_all)[5] |
|
3468 defer |
|
3469 apply(simp) |
|
3470 apply(erule Prf.cases) |
|
3471 apply(simp_all)[5] |
|
3472 apply(simp) |
|
3473 apply(case_tac "nullable rexp1") |
|
3474 apply(simp) |
|
3475 apply(erule Prf.cases) |
|
3476 apply(simp_all)[5] |
|
3477 apply(auto)[1] |
|
3478 apply(erule Prf.cases) |
|
3479 apply(simp_all)[5] |
|
3480 apply(auto)[1] |
|
3481 apply (metis list.distinct(1) v4) |
|
3482 apply(auto)[1] |
|
3483 apply (metis mkeps_flat) |
|
3484 apply(auto) |
|
3485 apply(erule Prf.cases) |
|
3486 apply(simp_all)[5] |
|
3487 apply(auto)[1] |
|
3488 apply(simp add: v4) |
|
3489 done |
|
3490 |
|
3491 text {* |
|
3492 |
|
3493 HERE: Crucial lemma that does not go through in the sequence case. |
|
3494 |
|
3495 *} |
|
3496 lemma v5: |
|
3497 assumes "\<turnstile> v : der c r" "POSIX v (der c r)" |
|
3498 shows "POSIX (injval r c v) r" |
|
3499 using assms |
|
3500 apply(induct arbitrary: v rule: der.induct) |
|
3501 (* NULL case *) |
|
3502 apply(simp) |
|
3503 apply(erule Prf.cases) |
|
3504 apply(simp_all)[5] |
|
3505 (* EMPTY case *) |
|
3506 apply(simp) |
|
3507 apply(erule Prf.cases) |
|
3508 apply(simp_all)[5] |
|
3509 (* CHAR case *) |
|
3510 apply(simp) |
|
3511 apply(case_tac "c = c'") |
|
3512 apply(auto simp add: POSIX_def)[1] |
|
3513 apply(erule Prf.cases) |
|
3514 apply(simp_all)[5] |
|
3515 oops |