author | Christian Urban <christian.urban@kcl.ac.uk> |
Sun, 08 May 2022 09:58:50 +0100 | |
changeset 504 | 79fdaad6f36b |
child 509 | a42524ca6fc4 |
permissions | -rw-r--r-- |
504
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
theory Blexer2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
imports "Lexer" "PDerivs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
begin |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
section \<open>Bit-Encodings\<close> |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
datatype bit = Z | S |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
fun code :: "val \<Rightarrow> bit list" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
"code Void = []" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
| "code (Char c) = []" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
| "code (Left v) = Z # (code v)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
| "code (Right v) = S # (code v)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
| "code (Seq v1 v2) = (code v1) @ (code v2)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
| "code (Stars []) = [S]" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
| "code (Stars (v # vs)) = (Z # code v) @ code (Stars vs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
fun |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
Stars_add :: "val \<Rightarrow> val \<Rightarrow> val" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
"Stars_add v (Stars vs) = Stars (v # vs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
function |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
"decode' bs ZERO = (undefined, bs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
| "decode' bs ONE = (Void, bs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
| "decode' bs (CH d) = (Char d, bs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
| "decode' [] (ALT r1 r2) = (Void, [])" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
| "decode' (Z # bs) (ALT r1 r2) = (let (v, bs') = decode' bs r1 in (Left v, bs'))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
| "decode' (S # bs) (ALT r1 r2) = (let (v, bs') = decode' bs r2 in (Right v, bs'))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
| "decode' bs (SEQ r1 r2) = (let (v1, bs') = decode' bs r1 in |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
let (v2, bs'') = decode' bs' r2 in (Seq v1 v2, bs''))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
| "decode' [] (STAR r) = (Void, [])" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
38 |
| "decode' (S # bs) (STAR r) = (Stars [], bs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
| "decode' (Z # bs) (STAR r) = (let (v, bs') = decode' bs r in |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |
let (vs, bs'') = decode' bs' (STAR r) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
41 |
in (Stars_add v vs, bs''))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
by pat_completeness auto |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
43 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
44 |
lemma decode'_smaller: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
assumes "decode'_dom (bs, r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
shows "length (snd (decode' bs r)) \<le> length bs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
apply(induct bs r) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
apply(auto simp add: decode'.psimps split: prod.split) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
50 |
using dual_order.trans apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
51 |
by (meson dual_order.trans le_SucI) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
52 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
53 |
termination "decode'" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
54 |
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
55 |
apply(auto dest!: decode'_smaller) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
56 |
by (metis less_Suc_eq_le snd_conv) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
57 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
58 |
definition |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
59 |
decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
60 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
61 |
"decode ds r \<equiv> (let (v, ds') = decode' ds r |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
62 |
in (if ds' = [] then Some v else None))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
63 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
64 |
lemma decode'_code_Stars: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
65 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
66 |
shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
67 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
68 |
apply(induct vs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
69 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
70 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
71 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
72 |
lemma decode'_code: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
73 |
assumes "\<Turnstile> v : r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
74 |
shows "decode' ((code v) @ ds) r = (v, ds)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
75 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
76 |
apply(induct v r arbitrary: ds) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
77 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
78 |
using decode'_code_Stars by blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
79 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
80 |
lemma decode_code: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
81 |
assumes "\<Turnstile> v : r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
82 |
shows "decode (code v) r = Some v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
83 |
using assms unfolding decode_def |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
84 |
by (smt append_Nil2 decode'_code old.prod.case) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
85 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
86 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
87 |
section {* Annotated Regular Expressions *} |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
88 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
89 |
datatype arexp = |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
90 |
AZERO |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
91 |
| AONE "bit list" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
92 |
| ACHAR "bit list" char |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
93 |
| ASEQs "bit list" "arexp list" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
94 |
| AALTs "bit list" "arexp list" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
95 |
| ASTAR "bit list" arexp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
96 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
97 |
abbreviation |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
98 |
"AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
99 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
100 |
abbreviation |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
101 |
"ASEQ bs r1 r2 \<equiv> ASEQs bs [r1, r2]" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
102 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
103 |
fun asize :: "arexp \<Rightarrow> nat" where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
104 |
"asize AZERO = 1" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
105 |
| "asize (AONE cs) = 1" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
106 |
| "asize (ACHAR cs c) = 1" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
107 |
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
108 |
| "asize (ASEQs cs rs) = Suc (sum_list (map asize rs))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
109 |
| "asize (ASTAR cs r) = Suc (asize r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
110 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
111 |
fun |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
112 |
erase :: "arexp \<Rightarrow> rexp" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
113 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
114 |
"erase AZERO = ZERO" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
115 |
| "erase (AONE _) = ONE" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
116 |
| "erase (ACHAR _ c) = CH c" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
117 |
| "erase (AALTs _ []) = ZERO" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
118 |
| "erase (AALTs _ [r]) = (erase r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
119 |
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
120 |
| "erase (ASEQs _ []) = ONE" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
121 |
| "erase (ASEQs _ [r]) = (erase r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
122 |
| "erase (ASEQs bs (r#rs)) = SEQ (erase r) (erase (ASEQs bs rs))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
123 |
| "erase (ASTAR _ r) = STAR (erase r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
124 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
125 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
126 |
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
127 |
"fuse bs AZERO = AZERO" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
128 |
| "fuse bs (AONE cs) = AONE (bs @ cs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
129 |
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
130 |
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
131 |
| "fuse bs (ASEQs cs rs) = ASEQs (bs @ cs) rs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
132 |
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
133 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
134 |
lemma fuse_append: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
135 |
shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
136 |
apply(induct r) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
137 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
138 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
139 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
140 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
141 |
fun intern :: "rexp \<Rightarrow> arexp" where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
142 |
"intern ZERO = AZERO" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
143 |
| "intern ONE = AONE []" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
144 |
| "intern (CH c) = ACHAR [] c" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
145 |
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1)) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
146 |
(fuse [S] (intern r2))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
147 |
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
148 |
| "intern (STAR r) = ASTAR [] (intern r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
149 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
150 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
151 |
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bit list" where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
152 |
"retrieve (AONE bs) Void = bs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
153 |
| "retrieve (ACHAR bs c) (Char d) = bs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
154 |
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
155 |
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
156 |
| "retrieve (AALTs bs (r#rs)) (Right v) = bs @ retrieve (AALTs [] rs) v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
157 |
| "retrieve (ASEQs bs []) v = bs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
158 |
| "retrieve (ASEQs bs [r]) v = bs @ retrieve r v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
159 |
| "retrieve (ASEQs bs (r#rs)) (Seq v1 v2) = bs @ retrieve r v1 @ retrieve (ASEQs [] rs) v2" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
160 |
| "retrieve (ASTAR bs r) (Stars []) = bs @ [S]" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
161 |
| "retrieve (ASTAR bs r) (Stars (v#vs)) = |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
162 |
bs @ [Z] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
163 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
164 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
165 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
166 |
fun |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
167 |
bnullable :: "arexp \<Rightarrow> bool" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
168 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
169 |
"bnullable (AZERO) = False" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
170 |
| "bnullable (AONE bs) = True" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
171 |
| "bnullable (ACHAR bs c) = False" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
172 |
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
173 |
| "bnullable (ASEQs bs rs) = (\<forall>r \<in> set rs. bnullable r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
174 |
| "bnullable (ASTAR bs r) = True" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
175 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
176 |
abbreviation |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
177 |
bnullables :: "arexp list \<Rightarrow> bool" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
178 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
179 |
"bnullables rs \<equiv> (\<exists>r \<in> set rs. bnullable r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
180 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
181 |
fun |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
182 |
bmkeps :: "arexp \<Rightarrow> bit list" and |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
183 |
bmkepss :: "arexp list \<Rightarrow> bit list" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
184 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
185 |
"bmkeps(AONE bs) = bs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
186 |
| "bmkeps(ASEQs bs rs) = bs @ concat (map bmkeps rs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
187 |
| "bmkeps(AALTs bs rs) = bs @ (bmkepss rs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
188 |
| "bmkeps(ASTAR bs r) = bs @ [S]" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
189 |
| "bmkepss (r # rs) = (if bnullable(r) then (bmkeps r) else (bmkepss rs))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
190 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
191 |
lemma bmkepss1: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
192 |
assumes "\<not> bnullables rs1" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
193 |
shows "bmkepss (rs1 @ rs2) = bmkepss rs2" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
194 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
195 |
by (induct rs1) (auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
196 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
197 |
lemma bmkepss2: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
198 |
assumes "bnullables rs1" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
199 |
shows "bmkepss (rs1 @ rs2) = bmkepss rs1" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
200 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
201 |
by (induct rs1) (auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
202 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
203 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
204 |
fun |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
205 |
bder :: "char \<Rightarrow> arexp \<Rightarrow> arexp" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
206 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
207 |
"bder c (AZERO) = AZERO" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
208 |
| "bder c (AONE bs) = AZERO" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
209 |
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
210 |
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
211 |
| "bder c (ASEQs bs []) = AZERO" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
212 |
| "bder c (ASEQs bs [r1]) = fuse bs (bder c r1)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
213 |
| "bder c (ASEQs bs (r1#rs)) = |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
214 |
(if bnullable r1 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
215 |
then AALT bs (ASEQs [] ((bder c r1) # rs)) (fuse (bmkeps r1) (bder c (ASEQs [] rs))) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
216 |
else ASEQs bs ((bder c r1) # rs))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
217 |
| "bder c (ASTAR bs r) = ASEQ (bs @ [Z]) (bder c r) (ASTAR [] r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
218 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
219 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
220 |
fun |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
221 |
bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
222 |
where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
223 |
"bders r [] = r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
224 |
| "bders r (c#s) = bders (bder c r) s" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
225 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
226 |
lemma bders_append: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
227 |
"bders c (s1 @ s2) = bders (bders c s1) s2" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
228 |
apply(induct s1 arbitrary: c s2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
229 |
apply(simp_all) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
230 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
231 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
232 |
lemma bnullable_correctness: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
233 |
shows "nullable (erase r) = bnullable r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
234 |
apply(induct r rule: erase.induct) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
235 |
apply(simp_all) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
236 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
237 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
238 |
lemma erase_fuse: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
239 |
shows "erase (fuse bs r) = erase r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
240 |
apply(induct r rule: erase.induct) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
241 |
apply(simp_all) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
242 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
243 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
244 |
lemma erase_intern [simp]: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
245 |
shows "erase (intern r) = r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
246 |
apply(induct r) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
247 |
apply(simp_all add: erase_fuse) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
248 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
249 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
250 |
lemma erase_ASEQs: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
251 |
shows "erase (ASEQs [] rs) = erase (ASEQs bs rs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
252 |
apply(induct rs arbitrary: bs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
253 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
254 |
apply(case_tac rs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
255 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
256 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
257 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
258 |
lemma erase_bder [simp]: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
259 |
shows "erase (bder a r) = der a (erase r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
260 |
apply(induct r rule: erase.induct) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
261 |
apply(simp_all add: erase_fuse bnullable_correctness) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
262 |
apply(case_tac va) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
263 |
apply(simp_all add: erase_fuse bnullable_correctness) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
264 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
265 |
apply(simp_all add: erase_fuse bnullable_correctness erase_ASEQs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
266 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
267 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
268 |
lemma erase_bders [simp]: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
269 |
shows "erase (bders r s) = ders s (erase r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
270 |
apply(induct s arbitrary: r ) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
271 |
apply(simp_all) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
272 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
273 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
274 |
lemma bnullable_fuse: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
275 |
shows "bnullable (fuse bs r) = bnullable r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
276 |
apply(induct r arbitrary: bs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
277 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
278 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
279 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
280 |
lemma retrieve_encode_STARS: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
281 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
282 |
shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
283 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
284 |
apply(induct vs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
285 |
apply(simp_all) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
286 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
287 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
288 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
289 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
290 |
lemma retrieve_fuse2: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
291 |
assumes "\<Turnstile> v : (erase r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
292 |
shows "retrieve (fuse bs r) v = bs @ retrieve r v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
293 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
294 |
apply(induct r arbitrary: v bs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
295 |
apply(auto elim: Prf_elims)[4] |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
296 |
defer |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
297 |
apply(case_tac x2a) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
298 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
299 |
using Prf_elims(1) apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
300 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
301 |
apply(case_tac list) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
302 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
303 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
304 |
apply (smt (verit, best) Prf_elims(3) append_assoc retrieve.simps(4) retrieve.simps(5)) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
305 |
using retrieve_encode_STARS |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
306 |
apply(auto elim!: Prf_elims)[1] |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
307 |
apply(case_tac vs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
308 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
309 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
310 |
apply(case_tac x2a) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
311 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
312 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
313 |
apply(case_tac list) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
314 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
315 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
316 |
by (smt (verit, best) Prf_elims(2) append_assoc retrieve.simps(8)) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
317 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
318 |
lemma retrieve_fuse: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
319 |
assumes "\<Turnstile> v : r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
320 |
shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
321 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
322 |
by (simp_all add: retrieve_fuse2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
323 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
324 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
325 |
lemma retrieve_code: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
326 |
assumes "\<Turnstile> v : r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
327 |
shows "code v = retrieve (intern r) v" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
328 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
329 |
apply(induct v r ) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
330 |
apply(simp_all add: retrieve_fuse retrieve_encode_STARS) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
331 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
332 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
333 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
334 |
lemma retrieve_AALTs_bnullable1: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
335 |
assumes "bnullable r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
336 |
shows "retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs)))) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
337 |
= bs @ retrieve r (mkeps (erase r))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
338 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
339 |
apply(case_tac rs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
340 |
apply(auto simp add: bnullable_correctness) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
341 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
342 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
343 |
lemma retrieve_AALTs_bnullable2: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
344 |
assumes "\<not>bnullable r" "bnullables rs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
345 |
shows "retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs)))) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
346 |
= retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
347 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
348 |
apply(induct rs arbitrary: r bs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
349 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
350 |
using bnullable_correctness apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
351 |
apply(case_tac rs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
352 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
353 |
using bnullable_correctness apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
354 |
apply(case_tac rs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
355 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
356 |
done |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
357 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
358 |
lemma bmkeps_retrieve_AALTs: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
359 |
assumes "\<forall>r \<in> set rs. bnullable r \<longrightarrow> bmkeps r = retrieve r (mkeps (erase r))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
360 |
"bnullables rs" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
361 |
shows "bs @ bmkepss rs = retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
362 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
363 |
apply(induct rs arbitrary: bs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
364 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
365 |
using retrieve_AALTs_bnullable1 apply presburger |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
366 |
apply (metis retrieve_AALTs_bnullable2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
367 |
apply (simp add: retrieve_AALTs_bnullable1) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
368 |
by (metis retrieve_AALTs_bnullable2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
369 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
370 |
lemma bmkeps_retrieve_ASEQs: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
371 |
assumes "\<forall>r \<in> set rs. bmkeps r = retrieve r (mkeps (erase r))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
372 |
"\<forall>r \<in> set rs. bnullable r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
373 |
shows "x1 @ concat (map bmkeps rs) = retrieve (ASEQs x1 rs) (mkeps (erase (ASEQs x1 rs)))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
374 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
375 |
apply(induct rs arbitrary: x1) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
376 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
377 |
apply(case_tac rs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
378 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
379 |
by (metis erase_ASEQs self_append_conv2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
380 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
381 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
382 |
lemma bmkeps_retrieve: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
383 |
assumes "bnullable r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
384 |
shows "bmkeps r = retrieve r (mkeps (erase r))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
385 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
386 |
apply(induct r) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
387 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
388 |
defer |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
389 |
using bmkeps_retrieve_AALTs apply auto |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
390 |
by (simp add: bmkeps_retrieve_ASEQs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
391 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
392 |
lemma bder_retrieve: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
393 |
assumes "\<Turnstile> v : der c (erase r)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
394 |
shows "retrieve (bder c r) v = retrieve r (injval (erase r) c v)" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
395 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
396 |
apply(induct r arbitrary: v rule: erase.induct) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
397 |
using Prf_elims(1) apply auto[1] |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
398 |
using Prf_elims(1) apply auto[1] |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
399 |
apply(auto)[1] |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
400 |
apply (metis Prf_elims(4) injval.simps(1) retrieve.simps(1) retrieve.simps(2)) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
401 |
using Prf_elims(1) apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
402 |
(* AALTs case *) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
403 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
404 |
apply(erule Prf_elims) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
405 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
406 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
407 |
apply(rename_tac "r\<^sub>1" "r\<^sub>2" rs v) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
408 |
apply(erule Prf_elims) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
409 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
410 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
411 |
apply(case_tac rs) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
412 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
413 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
414 |
using Prf_elims(3) apply fastforce |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
415 |
(* ASTAR case *) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
416 |
prefer 4 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
417 |
apply(rename_tac bs r v) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
418 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
419 |
apply(erule Prf_elims) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
420 |
apply(clarify) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
421 |
apply(erule Prf_elims) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
422 |
apply(clarify) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
423 |
apply (simp add: retrieve_fuse2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
424 |
(* ASEQ case *) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
425 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
426 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
427 |
apply (simp add: erase_fuse retrieve_fuse2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
428 |
apply(auto)[1] |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
429 |
using Prf_elims(1) apply auto[1] |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
430 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
431 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
432 |
apply(subgoal_tac "nullable (erase r)") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
433 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
434 |
using bnullable_correctness apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
435 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
436 |
apply(erule Prf_elims) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
437 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
438 |
using Prf_elims(2) apply force |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
439 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
440 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
441 |
apply(subgoal_tac "\<not>nullable (erase r)") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
442 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
443 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
444 |
using bnullable_correctness apply presburger |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
445 |
using Prf_elims(2) apply force |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
446 |
apply (simp add: bmkeps_retrieve erase_fuse retrieve_fuse2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
447 |
apply(case_tac va) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
448 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
449 |
apply (simp add: erase_fuse retrieve_fuse2) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
450 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
451 |
apply(auto) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
452 |
apply(subgoal_tac "nullable (erase v)") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
453 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
454 |
using bnullable_correctness apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
455 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
456 |
apply(erule Prf_elims) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
457 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
458 |
apply(erule Prf_elims) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
459 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
460 |
apply(case_tac list) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
461 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
462 |
apply(rotate_tac 1) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
463 |
apply(drule_tac x="Left v1" in meta_spec) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
464 |
apply(drule meta_mp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
465 |
apply(rule Prf.intros) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
466 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
467 |
apply(rule Prf.intros) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
468 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
469 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
470 |
apply simp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
471 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
472 |
apply(case_tac "bnullable a") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
473 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
474 |
apply(subgoal_tac "nullable (erase a)") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
475 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
476 |
using bnullable_correctness apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
477 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
478 |
apply(rotate_tac 1) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
479 |
apply(drule_tac x="Left v1" in meta_spec) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
480 |
apply(drule meta_mp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
481 |
apply(rule Prf.intros) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
482 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
483 |
apply(rule Prf.intros) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
484 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
485 |
apply force |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
486 |
apply simp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
487 |
apply(subgoal_tac "\<not>nullable (erase a)") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
488 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
489 |
using bnullable_correctness apply presburger |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
490 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
491 |
apply(rotate_tac 1) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
492 |
apply(drule_tac x="Left v1" in meta_spec) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
493 |
apply(drule meta_mp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
494 |
apply(rule Prf.intros) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
495 |
using Prf.intros(1) apply blast |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
496 |
apply simp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
497 |
using Prf.intros(3) apply fastforce |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
498 |
apply(subgoal_tac "\<not>nullable (erase v)") |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
499 |
prefer 2 |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
500 |
using bnullable_correctness apply presburger |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
501 |
apply(simp) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
502 |
using Prf_elims(2) by force |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
503 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
504 |
lemma MAIN_decode: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
505 |
assumes "\<Turnstile> v : ders s r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
506 |
shows "Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
507 |
using assms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
508 |
proof (induct s arbitrary: v rule: rev_induct) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
509 |
case Nil |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
510 |
have "\<Turnstile> v : ders [] r" by fact |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
511 |
then have "\<Turnstile> v : r" by simp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
512 |
then have "Some v = decode (retrieve (intern r) v) r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
513 |
using decode_code retrieve_code by auto |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
514 |
then show "Some (flex r id [] v) = decode (retrieve (bders (intern r) []) v) r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
515 |
by simp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
516 |
next |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
517 |
case (snoc c s v) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
518 |
have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
519 |
Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" by fact |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
520 |
have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
521 |
then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
522 |
by (simp add: Prf_injval ders_append) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
523 |
have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
524 |
by (simp add: flex_append) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
525 |
also have "... = decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
526 |
using asm2 IH by simp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
527 |
also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
528 |
using asm by (simp_all add: bder_retrieve ders_append) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
529 |
finally show "Some (flex r id (s @ [c]) v) = |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
530 |
decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
531 |
qed |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
532 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
533 |
definition blexer where |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
534 |
"blexer r s \<equiv> if bnullable (bders (intern r) s) then |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
535 |
decode (bmkeps (bders (intern r) s)) r else None" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
536 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
537 |
lemma blexer_correctness: |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
538 |
shows "blexer r s = lexer r s" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
539 |
proof - |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
540 |
{ define bds where "bds \<equiv> bders (intern r) s" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
541 |
define ds where "ds \<equiv> ders s r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
542 |
assume asm: "nullable ds" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
543 |
have era: "erase bds = ds" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
544 |
unfolding ds_def bds_def by simp |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
545 |
have mke: "\<Turnstile> mkeps ds : ds" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
546 |
using asm by (simp add: mkeps_nullable) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
547 |
have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
548 |
using bmkeps_retrieve |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
549 |
using asm era |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
550 |
using bnullable_correctness by force |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
551 |
also have "... = Some (flex r id s (mkeps ds))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
552 |
using mke by (simp_all add: MAIN_decode ds_def bds_def) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
553 |
finally have "decode (bmkeps bds) r = Some (flex r id s (mkeps ds))" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
554 |
unfolding bds_def ds_def . |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
555 |
} |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
556 |
then show "blexer r s = lexer r s" |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
557 |
unfolding blexer_def lexer_flex |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
558 |
by (auto simp add: bnullable_correctness[symmetric]) |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
559 |
qed |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
560 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
561 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
562 |
unused_thms |
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
563 |
|
79fdaad6f36b
added ASEQs version of Blexer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
564 |
end |