author | Christian Urban <urbanc@in.tum.de> |
Tue, 14 May 2019 21:43:11 +0100 | |
changeset 322 | 22e34f93cd5d |
parent 318 | 43e070803c1c |
child 323 | 09ce1cdb70ab |
permissions | -rw-r--r-- |
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
|
311 | 2 |
theory BitCoded |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
3 |
imports "Lexer" |
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
begin |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
6 |
section {* Bit-Encodings *} |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
7 |
|
289 | 8 |
datatype bit = Z | S |
9 |
||
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
10 |
fun |
289 | 11 |
code :: "val \<Rightarrow> bit list" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
12 |
where |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
13 |
"code Void = []" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
14 |
| "code (Char c) = []" |
289 | 15 |
| "code (Left v) = Z # (code v)" |
16 |
| "code (Right v) = S # (code v)" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
17 |
| "code (Seq v1 v2) = (code v1) @ (code v2)" |
289 | 18 |
| "code (Stars []) = [S]" |
19 |
| "code (Stars (v # vs)) = (Z # code v) @ code (Stars vs)" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
20 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
21 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
22 |
fun |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
23 |
Stars_add :: "val \<Rightarrow> val \<Rightarrow> val" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
24 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
25 |
"Stars_add v (Stars vs) = Stars (v # vs)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
26 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
27 |
function |
289 | 28 |
decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
29 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
30 |
"decode' ds ZERO = (Void, [])" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
31 |
| "decode' ds ONE = (Void, ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
32 |
| "decode' ds (CHAR d) = (Char d, ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
33 |
| "decode' [] (ALT r1 r2) = (Void, [])" |
289 | 34 |
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))" |
35 |
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))" |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
36 |
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
37 |
let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
38 |
| "decode' [] (STAR r) = (Void, [])" |
289 | 39 |
| "decode' (S # ds) (STAR r) = (Stars [], ds)" |
40 |
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
41 |
let (vs, ds'') = decode' ds' (STAR r) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
42 |
in (Stars_add v vs, ds''))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
43 |
by pat_completeness auto |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
44 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
45 |
lemma decode'_smaller: |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
46 |
assumes "decode'_dom (ds, r)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
47 |
shows "length (snd (decode' ds r)) \<le> length ds" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
48 |
using assms |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
49 |
apply(induct ds r) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
50 |
apply(auto simp add: decode'.psimps split: prod.split) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
51 |
using dual_order.trans apply blast |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
52 |
by (meson dual_order.trans le_SucI) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
53 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
54 |
termination "decode'" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
55 |
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
56 |
apply(auto dest!: decode'_smaller) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
57 |
by (metis less_Suc_eq_le snd_conv) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
58 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
59 |
definition |
289 | 60 |
decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
61 |
where |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
62 |
"decode ds r \<equiv> (let (v, ds') = decode' ds r |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
63 |
in (if ds' = [] then Some v else None))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
64 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
65 |
lemma decode'_code_Stars: |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
66 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
67 |
shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
68 |
using assms |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
69 |
apply(induct vs) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
70 |
apply(auto) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
71 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
72 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
73 |
lemma decode'_code: |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
74 |
assumes "\<Turnstile> v : r" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
75 |
shows "decode' ((code v) @ ds) r = (v, ds)" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
76 |
using assms |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
77 |
apply(induct v r arbitrary: ds) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
78 |
apply(auto) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
79 |
using decode'_code_Stars by blast |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
80 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
81 |
lemma decode_code: |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
82 |
assumes "\<Turnstile> v : r" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
83 |
shows "decode (code v) r = Some v" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
84 |
using assms unfolding decode_def |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
85 |
by (smt append_Nil2 decode'_code old.prod.case) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
86 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
87 |
|
311 | 88 |
section {* Annotated Regular Expressions *} |
89 |
||
314 | 90 |
datatype arexp = |
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
91 |
AZERO |
289 | 92 |
| AONE "bit list" |
93 |
| ACHAR "bit list" char |
|
94 |
| ASEQ "bit list" arexp arexp |
|
311 | 95 |
| AALTs "bit list" "arexp list" |
289 | 96 |
| ASTAR "bit list" arexp |
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
97 |
|
311 | 98 |
abbreviation |
99 |
"AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]" |
|
100 |
||
317 | 101 |
fun asize :: "arexp \<Rightarrow> nat" where |
102 |
"asize AZERO = 1" |
|
103 |
| "asize (AONE cs) = 1" |
|
104 |
| "asize (ACHAR cs c) = 1" |
|
105 |
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))" |
|
106 |
| "asize (ASEQ cs r1 r2) = Suc (asize r1 + asize r2)" |
|
107 |
| "asize (ASTAR cs r) = Suc (asize r)" |
|
108 |
||
322 | 109 |
fun |
110 |
erase :: "arexp \<Rightarrow> rexp" |
|
111 |
where |
|
112 |
"erase AZERO = ZERO" |
|
113 |
| "erase (AONE _) = ONE" |
|
114 |
| "erase (ACHAR _ c) = CHAR c" |
|
115 |
| "erase (AALTs _ []) = ZERO" |
|
116 |
| "erase (AALTs _ [r]) = (erase r)" |
|
117 |
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))" |
|
118 |
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)" |
|
119 |
| "erase (ASTAR _ r) = STAR (erase r)" |
|
120 |
||
121 |
fun nonalt :: "arexp \<Rightarrow> bool" |
|
122 |
where |
|
123 |
"nonalt (AALTs bs2 rs) = False" |
|
124 |
| "nonalt r = True" |
|
125 |
||
126 |
||
127 |
fun good :: "arexp \<Rightarrow> bool" where |
|
128 |
"good AZERO = False" |
|
129 |
| "good (AONE cs) = True" |
|
130 |
| "good (ACHAR cs c) = True" |
|
131 |
| "good (AALTs cs []) = False" |
|
132 |
| "good (AALTs cs (r#rs)) = (\<forall>r' \<in> set (r#rs). good r')" |
|
133 |
| "good (ASEQ cs r1 r2) = (good r1 \<and> good r2)" |
|
134 |
| "good (ASTAR cs r) = True" |
|
135 |
||
136 |
||
317 | 137 |
|
311 | 138 |
|
289 | 139 |
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where |
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
140 |
"fuse bs AZERO = AZERO" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
141 |
| "fuse bs (AONE cs) = AONE (bs @ cs)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
142 |
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c" |
311 | 143 |
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs" |
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
144 |
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
145 |
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
146 |
|
314 | 147 |
lemma fuse_append: |
148 |
shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)" |
|
149 |
apply(induct r) |
|
150 |
apply(auto) |
|
151 |
done |
|
152 |
||
153 |
||
289 | 154 |
fun intern :: "rexp \<Rightarrow> arexp" where |
155 |
"intern ZERO = AZERO" |
|
156 |
| "intern ONE = AONE []" |
|
157 |
| "intern (CHAR c) = ACHAR [] c" |
|
158 |
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1)) |
|
295 | 159 |
(fuse [S] (intern r2))" |
289 | 160 |
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)" |
161 |
| "intern (STAR r) = ASTAR [] (intern r)" |
|
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
162 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
163 |
|
289 | 164 |
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bit list" where |
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
165 |
"retrieve (AONE bs) Void = bs" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
166 |
| "retrieve (ACHAR bs c) (Char d) = bs" |
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
167 |
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v" |
311 | 168 |
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v" |
169 |
| "retrieve (AALTs bs (r#rs)) (Right v) = bs @ retrieve (AALTs [] rs) v" |
|
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
170 |
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2" |
289 | 171 |
| "retrieve (ASTAR bs r) (Stars []) = bs @ [S]" |
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
172 |
| "retrieve (ASTAR bs r) (Stars (v#vs)) = |
289 | 173 |
bs @ [Z] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)" |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
174 |
|
322 | 175 |
|
289 | 176 |
|
177 |
fun |
|
178 |
bnullable :: "arexp \<Rightarrow> bool" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
179 |
where |
289 | 180 |
"bnullable (AZERO) = False" |
181 |
| "bnullable (AONE bs) = True" |
|
182 |
| "bnullable (ACHAR bs c) = False" |
|
311 | 183 |
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)" |
289 | 184 |
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)" |
185 |
| "bnullable (ASTAR bs r) = True" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
186 |
|
289 | 187 |
fun |
188 |
bmkeps :: "arexp \<Rightarrow> bit list" |
|
189 |
where |
|
190 |
"bmkeps(AONE bs) = bs" |
|
191 |
| "bmkeps(ASEQ bs r1 r2) = bs @ (bmkeps r1) @ (bmkeps r2)" |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
192 |
| "bmkeps(AALTs bs [r]) = bs @ (bmkeps r)" |
311 | 193 |
| "bmkeps(AALTs bs (r#rs)) = (if bnullable(r) then bs @ (bmkeps r) else (bmkeps (AALTs bs rs)))" |
289 | 194 |
| "bmkeps(ASTAR bs r) = bs @ [S]" |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
195 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
196 |
|
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
197 |
fun |
289 | 198 |
bder :: "char \<Rightarrow> arexp \<Rightarrow> arexp" |
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
199 |
where |
289 | 200 |
"bder c (AZERO) = AZERO" |
201 |
| "bder c (AONE bs) = AZERO" |
|
202 |
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)" |
|
311 | 203 |
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)" |
289 | 204 |
| "bder c (ASEQ bs r1 r2) = |
205 |
(if bnullable r1 |
|
206 |
then AALT bs (ASEQ [] (bder c r1) r2) (fuse (bmkeps r1) (bder c r2)) |
|
207 |
else ASEQ bs (bder c r1) r2)" |
|
208 |
| "bder c (ASTAR bs r) = ASEQ bs (fuse [Z] (bder c r)) (ASTAR [] r)" |
|
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
209 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
210 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
211 |
fun |
289 | 212 |
bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp" |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
213 |
where |
289 | 214 |
"bders r [] = r" |
215 |
| "bders r (c#s) = bders (bder c r) s" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
216 |
|
289 | 217 |
lemma bders_append: |
218 |
"bders r (s1 @ s2) = bders (bders r s1) s2" |
|
287 | 219 |
apply(induct s1 arbitrary: r s2) |
220 |
apply(simp_all) |
|
221 |
done |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
222 |
|
289 | 223 |
lemma bnullable_correctness: |
224 |
shows "nullable (erase r) = bnullable r" |
|
311 | 225 |
apply(induct r rule: erase.induct) |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
226 |
apply(simp_all) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
227 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
228 |
|
289 | 229 |
lemma erase_fuse: |
230 |
shows "erase (fuse bs r) = erase r" |
|
311 | 231 |
apply(induct r rule: erase.induct) |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
232 |
apply(simp_all) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
233 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
234 |
|
311 | 235 |
lemma erase_intern [simp]: |
289 | 236 |
shows "erase (intern r) = r" |
287 | 237 |
apply(induct r) |
289 | 238 |
apply(simp_all add: erase_fuse) |
287 | 239 |
done |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
240 |
|
311 | 241 |
lemma erase_bder [simp]: |
289 | 242 |
shows "erase (bder a r) = der a (erase r)" |
311 | 243 |
apply(induct r rule: erase.induct) |
289 | 244 |
apply(simp_all add: erase_fuse bnullable_correctness) |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
245 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
246 |
|
311 | 247 |
lemma erase_bders [simp]: |
289 | 248 |
shows "erase (bders r s) = ders s (erase r)" |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
249 |
apply(induct s arbitrary: r ) |
289 | 250 |
apply(simp_all) |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
251 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
252 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
253 |
lemma retrieve_encode_STARS: |
289 | 254 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v" |
255 |
shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
256 |
using assms |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
257 |
apply(induct vs) |
289 | 258 |
apply(simp_all) |
259 |
done |
|
260 |
||
261 |
lemma retrieve_fuse2: |
|
262 |
assumes "\<Turnstile> v : (erase r)" |
|
263 |
shows "retrieve (fuse bs r) v = bs @ retrieve r v" |
|
264 |
using assms |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
265 |
apply(induct r arbitrary: v bs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
266 |
apply(auto elim: Prf_elims)[4] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
267 |
defer |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
268 |
using retrieve_encode_STARS |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
269 |
apply(auto elim!: Prf_elims)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
270 |
apply(case_tac vs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
271 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
272 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
273 |
(* AALTs case *) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
274 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
275 |
apply(case_tac x2a) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
276 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
277 |
apply(auto elim!: Prf_elims)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
278 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
279 |
apply(case_tac list) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
280 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
281 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
282 |
apply(auto elim!: Prf_elims)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
283 |
done |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
284 |
|
289 | 285 |
lemma retrieve_fuse: |
286 |
assumes "\<Turnstile> v : r" |
|
287 |
shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v" |
|
288 |
using assms |
|
289 |
by (simp_all add: retrieve_fuse2) |
|
290 |
||
291 |
||
292 |
lemma retrieve_code: |
|
293 |
assumes "\<Turnstile> v : r" |
|
294 |
shows "code v = retrieve (intern r) v" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
295 |
using assms |
311 | 296 |
apply(induct v r ) |
289 | 297 |
apply(simp_all add: retrieve_fuse retrieve_encode_STARS) |
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
298 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
299 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
300 |
lemma r: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
301 |
assumes "bnullable (AALTs bs (a # rs))" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
302 |
shows "bnullable a \<or> (\<not> bnullable a \<and> bnullable (AALTs bs rs))" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
303 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
304 |
apply(induct rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
305 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
306 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
307 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
308 |
lemma r0: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
309 |
assumes "bnullable a" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
310 |
shows "bmkeps (AALTs bs (a # rs)) = bs @ (bmkeps a)" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
311 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
312 |
by (metis bmkeps.simps(3) bmkeps.simps(4) list.exhaust) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
313 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
314 |
lemma r1: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
315 |
assumes "\<not> bnullable a" "bnullable (AALTs bs rs)" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
316 |
shows "bmkeps (AALTs bs (a # rs)) = bmkeps (AALTs bs rs)" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
317 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
318 |
apply(induct rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
319 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
320 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
321 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
322 |
lemma r2: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
323 |
assumes "x \<in> set rs" "bnullable x" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
324 |
shows "bnullable (AALTs bs rs)" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
325 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
326 |
apply(induct rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
327 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
328 |
done |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
329 |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
330 |
lemma r3: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
331 |
assumes "\<not> bnullable r" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
332 |
" \<exists> x \<in> set rs. bnullable x" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
333 |
shows "retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs))) = |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
334 |
retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs))))" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
335 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
336 |
apply(induct rs arbitrary: r bs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
337 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
338 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
339 |
using bnullable_correctness apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
340 |
apply(auto simp add: bnullable_correctness mkeps_nullable retrieve_fuse2) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
341 |
apply(subst retrieve_fuse2[symmetric]) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
342 |
apply (smt bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
343 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
344 |
apply(case_tac "bnullable a") |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
345 |
apply (smt append_Nil2 bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) fuse.simps(4) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable retrieve_fuse2) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
346 |
apply(drule_tac x="a" in meta_spec) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
347 |
apply(drule_tac x="bs" in meta_spec) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
348 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
349 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
350 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
351 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
352 |
apply(subst retrieve_fuse2[symmetric]) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
353 |
apply(case_tac rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
354 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
355 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
356 |
apply (simp add: bnullable_correctness) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
357 |
apply (metis append_Nil2 bnullable_correctness erase_fuse fuse.simps(4) list.set_intros(1) mkeps.simps(3) mkeps_nullable nullable.simps(4) r2) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
358 |
apply (simp add: bnullable_correctness) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
359 |
apply (metis append_Nil2 bnullable_correctness erase.simps(6) erase_fuse fuse.simps(4) list.set_intros(2) mkeps.simps(3) mkeps_nullable r2) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
360 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
361 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
362 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
363 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
364 |
lemma t: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
365 |
assumes "\<forall>r \<in> set rs. nullable (erase r) \<longrightarrow> bmkeps r = retrieve r (mkeps (erase r))" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
366 |
"nullable (erase (AALTs bs rs))" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
367 |
shows " bmkeps (AALTs bs rs) = retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
368 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
369 |
apply(induct rs arbitrary: bs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
370 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
371 |
apply(auto simp add: bnullable_correctness) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
372 |
apply(case_tac rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
373 |
apply(auto simp add: bnullable_correctness)[2] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
374 |
apply(subst r1) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
375 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
376 |
apply(rule r2) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
377 |
apply(assumption) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
378 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
379 |
apply(drule_tac x="bs" in meta_spec) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
380 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
381 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
382 |
prefer 2 |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
383 |
apply(case_tac "bnullable a") |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
384 |
apply(subst r0) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
385 |
apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
386 |
apply(subgoal_tac "nullable (erase a)") |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
387 |
prefer 2 |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
388 |
using bnullable_correctness apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
389 |
apply (metis (no_types, lifting) erase.simps(5) erase.simps(6) list.exhaust mkeps.simps(3) retrieve.simps(3) retrieve.simps(4)) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
390 |
apply(subst r1) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
391 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
392 |
using r2 apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
393 |
apply(drule_tac x="bs" in meta_spec) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
394 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
395 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
396 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
397 |
using r3 apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
398 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
399 |
using r3 by blast |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
400 |
|
289 | 401 |
lemma bmkeps_retrieve: |
402 |
assumes "nullable (erase r)" |
|
403 |
shows "bmkeps r = retrieve r (mkeps (erase r))" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
404 |
using assms |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
405 |
apply(induct r) |
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
406 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
407 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
408 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
409 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
410 |
defer |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
411 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
412 |
apply(rule t) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
413 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
414 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
415 |
|
289 | 416 |
lemma bder_retrieve: |
417 |
assumes "\<Turnstile> v : der c (erase r)" |
|
418 |
shows "retrieve (bder c r) v = retrieve r (injval (erase r) c v)" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
419 |
using assms |
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
420 |
apply(induct r arbitrary: v rule: erase.induct) |
318 | 421 |
apply(simp) |
422 |
apply(erule Prf_elims) |
|
423 |
apply(simp) |
|
424 |
apply(erule Prf_elims) |
|
425 |
apply(simp) |
|
426 |
apply(case_tac "c = ca") |
|
427 |
apply(simp) |
|
428 |
apply(erule Prf_elims) |
|
429 |
apply(simp) |
|
430 |
apply(simp) |
|
431 |
apply(erule Prf_elims) |
|
432 |
apply(simp) |
|
433 |
apply(erule Prf_elims) |
|
434 |
apply(simp) |
|
435 |
apply(simp) |
|
436 |
apply(rename_tac "r\<^sub>1" "r\<^sub>2" rs v) |
|
437 |
apply(erule Prf_elims) |
|
438 |
apply(simp) |
|
439 |
apply(simp) |
|
440 |
apply(case_tac rs) |
|
441 |
apply(simp) |
|
442 |
apply(simp) |
|
443 |
apply (smt Prf_elims(3) injval.simps(2) injval.simps(3) retrieve.simps(4) retrieve.simps(5) same_append_eq) |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
444 |
apply(simp) |
318 | 445 |
apply(case_tac "nullable (erase r1)") |
446 |
apply(simp) |
|
447 |
apply(erule Prf_elims) |
|
448 |
apply(subgoal_tac "bnullable r1") |
|
449 |
prefer 2 |
|
450 |
using bnullable_correctness apply blast |
|
451 |
apply(simp) |
|
452 |
apply(erule Prf_elims) |
|
453 |
apply(simp) |
|
454 |
apply(subgoal_tac "bnullable r1") |
|
455 |
prefer 2 |
|
456 |
using bnullable_correctness apply blast |
|
457 |
apply(simp) |
|
458 |
apply(simp add: retrieve_fuse2) |
|
459 |
apply(simp add: bmkeps_retrieve) |
|
460 |
apply(simp) |
|
461 |
apply(erule Prf_elims) |
|
462 |
apply(simp) |
|
463 |
using bnullable_correctness apply blast |
|
464 |
apply(rename_tac bs r v) |
|
465 |
apply(simp) |
|
466 |
apply(erule Prf_elims) |
|
467 |
apply(clarify) |
|
468 |
apply(erule Prf_elims) |
|
469 |
apply(clarify) |
|
470 |
apply(subst injval.simps) |
|
471 |
apply(simp del: retrieve.simps) |
|
472 |
apply(subst retrieve.simps) |
|
473 |
apply(subst retrieve.simps) |
|
474 |
apply(simp) |
|
475 |
apply(simp add: retrieve_fuse2) |
|
476 |
done |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
477 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
478 |
|
318 | 479 |
|
289 | 480 |
lemma MAIN_decode: |
481 |
assumes "\<Turnstile> v : ders s r" |
|
482 |
shows "Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" |
|
483 |
using assms |
|
484 |
proof (induct s arbitrary: v rule: rev_induct) |
|
485 |
case Nil |
|
486 |
have "\<Turnstile> v : ders [] r" by fact |
|
487 |
then have "\<Turnstile> v : r" by simp |
|
488 |
then have "Some v = decode (retrieve (intern r) v) r" |
|
489 |
using decode_code retrieve_code by auto |
|
490 |
then show "Some (flex r id [] v) = decode (retrieve (bders (intern r) []) v) r" |
|
491 |
by simp |
|
492 |
next |
|
493 |
case (snoc c s v) |
|
494 |
have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> |
|
495 |
Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" by fact |
|
496 |
have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact |
|
497 |
then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" |
|
318 | 498 |
by (simp add: Prf_injval ders_append) |
289 | 499 |
have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))" |
500 |
by (simp add: flex_append) |
|
501 |
also have "... = decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r" |
|
502 |
using asm2 IH by simp |
|
503 |
also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r" |
|
318 | 504 |
using asm by (simp_all add: bder_retrieve ders_append) |
289 | 505 |
finally show "Some (flex r id (s @ [c]) v) = |
506 |
decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append) |
|
507 |
qed |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
508 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
509 |
|
318 | 510 |
definition blex where |
511 |
"blex a s \<equiv> if bnullable (bders a s) then Some (bmkeps (bders a s)) else None" |
|
512 |
||
513 |
||
514 |
||
289 | 515 |
definition blexer where |
516 |
"blexer r s \<equiv> if bnullable (bders (intern r) s) then |
|
517 |
decode (bmkeps (bders (intern r) s)) r else None" |
|
518 |
||
519 |
lemma blexer_correctness: |
|
520 |
shows "blexer r s = lexer r s" |
|
521 |
proof - |
|
522 |
{ define bds where "bds \<equiv> bders (intern r) s" |
|
523 |
define ds where "ds \<equiv> ders s r" |
|
524 |
assume asm: "nullable ds" |
|
525 |
have era: "erase bds = ds" |
|
526 |
unfolding ds_def bds_def by simp |
|
527 |
have mke: "\<Turnstile> mkeps ds : ds" |
|
528 |
using asm by (simp add: mkeps_nullable) |
|
529 |
have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r" |
|
530 |
using bmkeps_retrieve |
|
531 |
using asm era by (simp add: bmkeps_retrieve) |
|
532 |
also have "... = Some (flex r id s (mkeps ds))" |
|
533 |
using mke by (simp_all add: MAIN_decode ds_def bds_def) |
|
534 |
finally have "decode (bmkeps bds) r = Some (flex r id s (mkeps ds))" |
|
535 |
unfolding bds_def ds_def . |
|
536 |
} |
|
537 |
then show "blexer r s = lexer r s" |
|
538 |
unfolding blexer_def lexer_flex |
|
293 | 539 |
apply(subst bnullable_correctness[symmetric]) |
540 |
apply(simp) |
|
541 |
done |
|
289 | 542 |
qed |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
543 |
|
295 | 544 |
|
314 | 545 |
fun distinctBy :: "'a list \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b set \<Rightarrow> 'a list" |
546 |
where |
|
547 |
"distinctBy [] f acc = []" |
|
548 |
| "distinctBy (x#xs) f acc = |
|
549 |
(if (f x) \<in> acc then distinctBy xs f acc |
|
550 |
else x # (distinctBy xs f ({f x} \<union> acc)))" |
|
551 |
||
552 |
fun flts :: "arexp list \<Rightarrow> arexp list" |
|
553 |
where |
|
554 |
"flts [] = []" |
|
555 |
| "flts (AZERO # rs) = flts rs" |
|
556 |
| "flts ((AALTs bs rs1) # rs) = (map (fuse bs) rs1) @ flts rs" |
|
557 |
| "flts (r1 # rs) = r1 # flts rs" |
|
558 |
||
559 |
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp" |
|
560 |
where |
|
561 |
"bsimp_ASEQ _ AZERO _ = AZERO" |
|
562 |
| "bsimp_ASEQ _ _ AZERO = AZERO" |
|
563 |
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2" |
|
564 |
| "bsimp_ASEQ bs1 r1 r2 = ASEQ bs1 r1 r2" |
|
565 |
||
566 |
||
567 |
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp" |
|
568 |
where |
|
569 |
"bsimp_AALTs _ [] = AZERO" |
|
570 |
| "bsimp_AALTs bs1 [r] = fuse bs1 r" |
|
571 |
| "bsimp_AALTs bs1 rs = AALTs bs1 rs" |
|
572 |
||
573 |
||
574 |
fun bsimp :: "arexp \<Rightarrow> arexp" |
|
575 |
where |
|
576 |
"bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)" |
|
577 |
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (flts (map bsimp rs))" |
|
578 |
| "bsimp r = r" |
|
579 |
||
322 | 580 |
value "good (AALTs [] [AALTs [] [AONE []]])" |
581 |
value "bsimp (AALTs [] [AONE [], AALTs [] [AONE []]])" |
|
582 |
||
583 |
||
314 | 584 |
fun |
585 |
bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp" |
|
586 |
where |
|
587 |
"bders_simp r [] = r" |
|
588 |
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s" |
|
589 |
||
590 |
definition blexer_simp where |
|
591 |
"blexer_simp r s \<equiv> if bnullable (bders_simp (intern r) s) then |
|
592 |
decode (bmkeps (bders_simp (intern r) s)) r else None" |
|
593 |
||
594 |
||
317 | 595 |
lemma asize0: |
596 |
shows "0 < asize r" |
|
597 |
apply(induct r) |
|
598 |
apply(auto) |
|
599 |
done |
|
600 |
||
601 |
||
314 | 602 |
lemma bders_simp_append: |
603 |
shows "bders_simp r (s1 @ s2) = bders_simp (bders_simp r s1) s2" |
|
604 |
apply(induct s1 arbitrary: r s2) |
|
605 |
apply(simp) |
|
606 |
apply(simp) |
|
607 |
done |
|
608 |
||
317 | 609 |
lemma bsimp_ASEQ_size: |
610 |
shows "asize (bsimp_ASEQ bs r1 r2) \<le> Suc (asize r1 + asize r2)" |
|
611 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct) |
|
612 |
apply(auto) |
|
613 |
done |
|
314 | 614 |
|
317 | 615 |
lemma fuse_size: |
616 |
shows "asize (fuse bs r) = asize r" |
|
617 |
apply(induct r) |
|
618 |
apply(auto) |
|
619 |
done |
|
620 |
||
621 |
lemma flts_size: |
|
622 |
shows "sum_list (map asize (flts rs)) \<le> sum_list (map asize rs)" |
|
623 |
apply(induct rs rule: flts.induct) |
|
624 |
apply(simp_all) |
|
625 |
by (metis (mono_tags, lifting) add_mono_thms_linordered_semiring(1) comp_apply fuse_size le_SucI order_refl sum_list_cong) |
|
626 |
||
627 |
||
628 |
lemma bsimp_AALTs_size: |
|
629 |
shows "asize (bsimp_AALTs bs rs) \<le> Suc (sum_list (map asize rs))" |
|
630 |
apply(induct rs rule: bsimp_AALTs.induct) |
|
631 |
apply(auto simp add: fuse_size) |
|
632 |
done |
|
322 | 633 |
|
634 |
||
317 | 635 |
lemma bsimp_size: |
636 |
shows "asize (bsimp r) \<le> asize r" |
|
637 |
apply(induct r) |
|
638 |
apply(simp_all) |
|
639 |
apply (meson Suc_le_mono add_mono_thms_linordered_semiring(1) bsimp_ASEQ_size le_trans) |
|
640 |
apply(rule le_trans) |
|
641 |
apply(rule bsimp_AALTs_size) |
|
642 |
apply(simp) |
|
643 |
apply(rule le_trans) |
|
644 |
apply(rule flts_size) |
|
645 |
by (simp add: sum_list_mono) |
|
646 |
||
322 | 647 |
lemma bsimp_asize0: |
648 |
shows "(\<Sum>x\<leftarrow>rs. asize (bsimp x)) \<le> sum_list (map asize rs)" |
|
649 |
apply(induct rs) |
|
650 |
apply(auto) |
|
651 |
by (simp add: add_mono bsimp_size) |
|
652 |
||
653 |
||
317 | 654 |
|
655 |
||
656 |
||
657 |
||
658 |
lemma bsimp_AALTs_size2: |
|
659 |
assumes "\<forall>r \<in> set rs. nonalt r" |
|
660 |
shows "asize (bsimp_AALTs bs rs) \<ge> sum_list (map asize rs)" |
|
661 |
using assms |
|
662 |
apply(induct rs rule: bsimp_AALTs.induct) |
|
663 |
apply(simp_all add: fuse_size) |
|
664 |
done |
|
665 |
||
666 |
lemma qq: |
|
667 |
shows "map (asize \<circ> fuse bs) rs = map asize rs" |
|
668 |
apply(induct rs) |
|
669 |
apply(auto simp add: fuse_size) |
|
670 |
done |
|
671 |
||
672 |
lemma flts_size2: |
|
673 |
assumes "\<exists>bs rs'. AALTs bs rs' \<in> set rs" |
|
674 |
shows "sum_list (map asize (flts rs)) < sum_list (map asize rs)" |
|
675 |
using assms |
|
676 |
apply(induct rs) |
|
677 |
apply(auto simp add: qq) |
|
678 |
apply (simp add: flts_size less_Suc_eq_le) |
|
679 |
apply(case_tac a) |
|
680 |
apply(auto simp add: qq) |
|
681 |
prefer 2 |
|
682 |
apply (simp add: flts_size le_imp_less_Suc) |
|
683 |
using less_Suc_eq by auto |
|
684 |
||
314 | 685 |
lemma L_bsimp_ASEQ: |
686 |
"L (SEQ (erase r1) (erase r2)) = L (erase (bsimp_ASEQ bs r1 r2))" |
|
687 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct) |
|
688 |
apply(simp_all) |
|
689 |
by (metis erase_fuse fuse.simps(4)) |
|
690 |
||
691 |
lemma L_bsimp_AALTs: |
|
692 |
"L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))" |
|
693 |
apply(induct bs rs rule: bsimp_AALTs.induct) |
|
694 |
apply(simp_all add: erase_fuse) |
|
695 |
done |
|
696 |
||
697 |
lemma L_erase_AALTs: |
|
698 |
shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))" |
|
699 |
apply(induct rs) |
|
700 |
apply(simp) |
|
701 |
apply(simp) |
|
702 |
apply(case_tac rs) |
|
703 |
apply(simp) |
|
704 |
apply(simp) |
|
705 |
done |
|
706 |
||
707 |
lemma L_erase_flts: |
|
708 |
shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))" |
|
709 |
apply(induct rs rule: flts.induct) |
|
710 |
apply(simp_all) |
|
711 |
apply(auto) |
|
712 |
using L_erase_AALTs erase_fuse apply auto[1] |
|
713 |
by (simp add: L_erase_AALTs erase_fuse) |
|
714 |
||
715 |
||
716 |
lemma L_bsimp_erase: |
|
717 |
shows "L (erase r) = L (erase (bsimp r))" |
|
718 |
apply(induct r) |
|
719 |
apply(simp) |
|
720 |
apply(simp) |
|
721 |
apply(simp) |
|
722 |
apply(auto simp add: Sequ_def)[1] |
|
723 |
apply(subst L_bsimp_ASEQ[symmetric]) |
|
724 |
apply(auto simp add: Sequ_def)[1] |
|
725 |
apply(subst (asm) L_bsimp_ASEQ[symmetric]) |
|
726 |
apply(auto simp add: Sequ_def)[1] |
|
727 |
apply(simp) |
|
728 |
apply(subst L_bsimp_AALTs[symmetric]) |
|
729 |
defer |
|
730 |
apply(simp) |
|
731 |
apply(subst (2)L_erase_AALTs) |
|
732 |
apply(subst L_erase_flts) |
|
733 |
apply(auto) |
|
734 |
apply (simp add: L_erase_AALTs) |
|
735 |
using L_erase_AALTs by blast |
|
736 |
||
317 | 737 |
lemma bsimp_ASEQ0: |
738 |
shows "bsimp_ASEQ bs r1 AZERO = AZERO" |
|
739 |
apply(induct r1) |
|
740 |
apply(auto) |
|
741 |
done |
|
742 |
||
743 |
||
314 | 744 |
|
745 |
lemma bsimp_ASEQ1: |
|
746 |
assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs" |
|
747 |
shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2" |
|
748 |
using assms |
|
749 |
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct) |
|
750 |
apply(auto) |
|
751 |
done |
|
752 |
||
753 |
lemma bsimp_ASEQ2: |
|
754 |
shows "bsimp_ASEQ bs (AONE bs1) r2 = fuse (bs @ bs1) r2" |
|
755 |
apply(induct r2) |
|
756 |
apply(auto) |
|
757 |
done |
|
758 |
||
759 |
||
760 |
lemma L_bders_simp: |
|
761 |
shows "L (erase (bders_simp r s)) = L (erase (bders r s))" |
|
762 |
apply(induct s arbitrary: r rule: rev_induct) |
|
763 |
apply(simp) |
|
764 |
apply(simp) |
|
765 |
apply(simp add: ders_append) |
|
766 |
apply(simp add: bders_simp_append) |
|
767 |
apply(simp add: L_bsimp_erase[symmetric]) |
|
768 |
by (simp add: der_correctness) |
|
769 |
||
770 |
lemma b1: |
|
771 |
"bsimp_ASEQ bs1 (AONE bs) r = fuse (bs1 @ bs) r" |
|
772 |
apply(induct r) |
|
773 |
apply(auto) |
|
774 |
done |
|
775 |
||
776 |
lemma b2: |
|
777 |
assumes "bnullable r" |
|
778 |
shows "bmkeps (fuse bs r) = bs @ bmkeps r" |
|
779 |
by (simp add: assms bmkeps_retrieve bnullable_correctness erase_fuse mkeps_nullable retrieve_fuse2) |
|
780 |
||
781 |
lemma b3: |
|
782 |
shows "bnullable r = bnullable (bsimp r)" |
|
783 |
using L_bsimp_erase bnullable_correctness nullable_correctness by auto |
|
784 |
||
785 |
||
786 |
lemma b4: |
|
787 |
shows "bnullable (bders_simp r s) = bnullable (bders r s)" |
|
788 |
by (metis L_bders_simp bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1)) |
|
789 |
||
790 |
lemma q1: |
|
791 |
assumes "\<forall>r \<in> set rs. bmkeps(bsimp r) = bmkeps r" |
|
792 |
shows "map (\<lambda>r. bmkeps(bsimp r)) rs = map bmkeps rs" |
|
793 |
using assms |
|
794 |
apply(induct rs) |
|
795 |
apply(simp) |
|
796 |
apply(simp) |
|
797 |
done |
|
798 |
||
799 |
lemma q3: |
|
800 |
assumes "\<exists>r \<in> set rs. bnullable r" |
|
801 |
shows "bmkeps (AALTs bs rs) = bmkeps (bsimp_AALTs bs rs)" |
|
802 |
using assms |
|
803 |
apply(induct bs rs rule: bsimp_AALTs.induct) |
|
804 |
apply(simp) |
|
805 |
apply(simp) |
|
806 |
apply (simp add: b2) |
|
807 |
apply(simp) |
|
808 |
done |
|
809 |
||
810 |
lemma qq1: |
|
811 |
assumes "\<exists>r \<in> set rs. bnullable r" |
|
812 |
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs)" |
|
813 |
using assms |
|
814 |
apply(induct rs arbitrary: rs1 bs) |
|
815 |
apply(simp) |
|
816 |
apply(simp) |
|
817 |
by (metis Nil_is_append_conv bmkeps.simps(4) neq_Nil_conv r0 split_list_last) |
|
818 |
||
819 |
lemma qq2: |
|
820 |
assumes "\<forall>r \<in> set rs. \<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r" |
|
821 |
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs1)" |
|
822 |
using assms |
|
823 |
apply(induct rs arbitrary: rs1 bs) |
|
824 |
apply(simp) |
|
825 |
apply(simp) |
|
826 |
by (metis append_assoc in_set_conv_decomp r1 r2) |
|
827 |
||
828 |
lemma qq3: |
|
829 |
shows "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)" |
|
830 |
apply(induct rs arbitrary: bs) |
|
831 |
apply(simp) |
|
832 |
apply(simp) |
|
833 |
done |
|
834 |
||
317 | 835 |
lemma fuse_empty: |
836 |
shows "fuse [] r = r" |
|
837 |
apply(induct r) |
|
838 |
apply(auto) |
|
839 |
done |
|
840 |
||
841 |
lemma flts_fuse: |
|
842 |
shows "map (fuse bs) (flts rs) = flts (map (fuse bs) rs)" |
|
843 |
apply(induct rs arbitrary: bs rule: flts.induct) |
|
844 |
apply(auto simp add: fuse_append) |
|
845 |
done |
|
846 |
||
847 |
lemma bsimp_ASEQ_fuse: |
|
848 |
shows "fuse bs1 (bsimp_ASEQ bs2 r1 r2) = bsimp_ASEQ (bs1 @ bs2) r1 r2" |
|
849 |
apply(induct r1 r2 arbitrary: bs1 bs2 rule: bsimp_ASEQ.induct) |
|
850 |
apply(auto) |
|
851 |
done |
|
852 |
||
853 |
lemma bsimp_AALTs_fuse: |
|
854 |
assumes "\<forall>r \<in> set rs. fuse bs1 (fuse bs2 r) = fuse (bs1 @ bs2) r" |
|
855 |
shows "fuse bs1 (bsimp_AALTs bs2 rs) = bsimp_AALTs (bs1 @ bs2) rs" |
|
856 |
using assms |
|
857 |
apply(induct bs2 rs arbitrary: bs1 rule: bsimp_AALTs.induct) |
|
858 |
apply(auto) |
|
859 |
done |
|
860 |
||
861 |
||
862 |
||
863 |
lemma bsimp_fuse: |
|
864 |
shows "fuse bs (bsimp r) = bsimp (fuse bs r)" |
|
865 |
apply(induct r arbitrary: bs) |
|
866 |
apply(simp) |
|
867 |
apply(simp) |
|
868 |
apply(simp) |
|
869 |
prefer 3 |
|
870 |
apply(simp) |
|
871 |
apply(simp) |
|
872 |
apply (simp add: bsimp_ASEQ_fuse) |
|
873 |
apply(simp) |
|
874 |
by (simp add: bsimp_AALTs_fuse fuse_append) |
|
875 |
||
876 |
lemma bsimp_fuse_AALTs: |
|
877 |
shows "fuse bs (bsimp (AALTs [] rs)) = bsimp (AALTs bs rs)" |
|
878 |
apply(subst bsimp_fuse) |
|
879 |
apply(simp) |
|
880 |
done |
|
881 |
||
882 |
lemma bsimp_fuse_AALTs2: |
|
883 |
shows "fuse bs (bsimp_AALTs [] rs) = bsimp_AALTs bs rs" |
|
884 |
using bsimp_AALTs_fuse fuse_append by auto |
|
885 |
||
886 |
||
887 |
lemma bsimp_ASEQ_idem: |
|
888 |
assumes "bsimp (bsimp r1) = bsimp r1" "bsimp (bsimp r2) = bsimp r2" |
|
889 |
shows "bsimp (bsimp_ASEQ x1 (bsimp r1) (bsimp r2)) = bsimp_ASEQ x1 (bsimp r1) (bsimp r2)" |
|
890 |
using assms |
|
891 |
apply(case_tac "bsimp r1 = AZERO") |
|
892 |
apply(simp) |
|
893 |
apply(case_tac "bsimp r2 = AZERO") |
|
894 |
apply(simp) |
|
895 |
apply (metis bnullable.elims(2) bnullable.elims(3) bsimp.simps(3) bsimp_ASEQ.simps(2) bsimp_ASEQ.simps(3) bsimp_ASEQ.simps(4) bsimp_ASEQ.simps(5) bsimp_ASEQ.simps(6)) |
|
896 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs") |
|
897 |
apply(auto)[1] |
|
898 |
apply(subst bsimp_ASEQ2) |
|
899 |
apply(subst bsimp_ASEQ2) |
|
900 |
apply (metis assms(2) bsimp_fuse) |
|
901 |
apply(subst bsimp_ASEQ1) |
|
902 |
apply(auto) |
|
903 |
done |
|
904 |
||
905 |
||
906 |
fun nonnested :: "arexp \<Rightarrow> bool" |
|
907 |
where |
|
908 |
"nonnested (AALTs bs2 []) = True" |
|
909 |
| "nonnested (AALTs bs2 ((AALTs bs1 rs1) # rs2)) = False" |
|
910 |
| "nonnested (AALTs bs2 (r # rs2)) = nonnested (AALTs bs2 rs2)" |
|
911 |
| "nonnested r = True" |
|
912 |
||
913 |
||
914 |
lemma k0: |
|
915 |
shows "flts (r # rs1) = flts [r] @ flts rs1" |
|
916 |
apply(induct r arbitrary: rs1) |
|
917 |
apply(auto) |
|
918 |
done |
|
919 |
||
920 |
lemma k00: |
|
921 |
shows "flts (rs1 @ rs2) = flts rs1 @ flts rs2" |
|
922 |
apply(induct rs1 arbitrary: rs2) |
|
923 |
apply(auto) |
|
924 |
by (metis append.assoc k0) |
|
925 |
||
926 |
lemma k0a: |
|
927 |
shows "flts [AALTs bs rs] = map (fuse bs) rs" |
|
928 |
apply(simp) |
|
929 |
done |
|
930 |
||
931 |
fun spill where |
|
932 |
"spill (AALTs bs rs) = map (fuse bs) rs" |
|
933 |
||
934 |
lemma k0a2: |
|
935 |
assumes "\<not> nonalt r" |
|
936 |
shows "flts [r] = spill r" |
|
937 |
using assms |
|
938 |
apply(case_tac r) |
|
939 |
apply(simp_all) |
|
940 |
done |
|
941 |
||
942 |
lemma k0b: |
|
943 |
assumes "nonalt r" "r \<noteq> AZERO" |
|
944 |
shows "flts [r] = [r]" |
|
945 |
using assms |
|
946 |
apply(case_tac r) |
|
947 |
apply(simp_all) |
|
948 |
done |
|
949 |
||
950 |
lemma nn1: |
|
951 |
assumes "nonnested (AALTs bs rs)" |
|
952 |
shows "\<nexists>bs1 rs1. flts rs = [AALTs bs1 rs1]" |
|
953 |
using assms |
|
954 |
apply(induct rs rule: flts.induct) |
|
955 |
apply(auto) |
|
956 |
done |
|
957 |
||
958 |
lemma nn1q: |
|
959 |
assumes "nonnested (AALTs bs rs)" |
|
960 |
shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set (flts rs)" |
|
961 |
using assms |
|
962 |
apply(induct rs rule: flts.induct) |
|
963 |
apply(auto) |
|
964 |
done |
|
965 |
||
966 |
lemma nn1qq: |
|
967 |
assumes "nonnested (AALTs bs rs)" |
|
968 |
shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set rs" |
|
969 |
using assms |
|
970 |
apply(induct rs rule: flts.induct) |
|
971 |
apply(auto) |
|
972 |
done |
|
973 |
||
974 |
lemma nn10: |
|
975 |
assumes "nonnested (AALTs cs rs)" |
|
976 |
shows "nonnested (AALTs (bs @ cs) rs)" |
|
977 |
using assms |
|
978 |
apply(induct rs arbitrary: cs bs) |
|
979 |
apply(simp_all) |
|
980 |
apply(case_tac a) |
|
981 |
apply(simp_all) |
|
982 |
done |
|
983 |
||
984 |
lemma nn11a: |
|
985 |
assumes "nonalt r" |
|
986 |
shows "nonalt (fuse bs r)" |
|
987 |
using assms |
|
988 |
apply(induct r) |
|
989 |
apply(auto) |
|
990 |
done |
|
991 |
||
992 |
||
993 |
lemma nn1a: |
|
994 |
assumes "nonnested r" |
|
995 |
shows "nonnested (fuse bs r)" |
|
996 |
using assms |
|
997 |
apply(induct bs r arbitrary: rule: fuse.induct) |
|
998 |
apply(simp_all add: nn10) |
|
999 |
done |
|
1000 |
||
1001 |
lemma n0: |
|
1002 |
shows "nonnested (AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. nonalt r)" |
|
1003 |
apply(induct rs arbitrary: bs) |
|
1004 |
apply(auto) |
|
1005 |
apply (metis list.set_intros(1) nn1qq nonalt.elims(3)) |
|
1006 |
apply (metis list.set_intros(2) nn1qq nonalt.elims(3)) |
|
1007 |
by (metis nonalt.elims(2) nonnested.simps(3) nonnested.simps(4) nonnested.simps(5) nonnested.simps(6) nonnested.simps(7)) |
|
1008 |
||
1009 |
||
1010 |
||
1011 |
||
1012 |
lemma nn1c: |
|
1013 |
assumes "\<forall>r \<in> set rs. nonnested r" |
|
1014 |
shows "\<forall>r \<in> set (flts rs). nonalt r" |
|
1015 |
using assms |
|
1016 |
apply(induct rs rule: flts.induct) |
|
1017 |
apply(auto) |
|
1018 |
apply(rule nn11a) |
|
1019 |
by (metis nn1qq nonalt.elims(3)) |
|
1020 |
||
1021 |
lemma nn1bb: |
|
1022 |
assumes "\<forall>r \<in> set rs. nonalt r" |
|
1023 |
shows "nonnested (bsimp_AALTs bs rs)" |
|
1024 |
using assms |
|
1025 |
apply(induct bs rs rule: bsimp_AALTs.induct) |
|
1026 |
apply(auto) |
|
1027 |
apply (metis nn11a nonalt.simps(1) nonnested.elims(3)) |
|
1028 |
using n0 by auto |
|
1029 |
||
1030 |
lemma nn1b: |
|
1031 |
shows "nonnested (bsimp r)" |
|
1032 |
apply(induct r) |
|
1033 |
apply(simp_all) |
|
1034 |
apply(case_tac "bsimp r1 = AZERO") |
|
1035 |
apply(simp) |
|
1036 |
apply(case_tac "bsimp r2 = AZERO") |
|
1037 |
apply(simp) |
|
1038 |
apply(subst bsimp_ASEQ0) |
|
1039 |
apply(simp) |
|
1040 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs") |
|
1041 |
apply(auto)[1] |
|
1042 |
apply(subst bsimp_ASEQ2) |
|
1043 |
apply (simp add: nn1a) |
|
1044 |
apply(subst bsimp_ASEQ1) |
|
1045 |
apply(auto) |
|
1046 |
apply(rule nn1bb) |
|
1047 |
apply(auto) |
|
1048 |
by (metis (mono_tags, hide_lams) imageE nn1c set_map) |
|
1049 |
||
318 | 1050 |
lemma nn1d: |
1051 |
assumes "bsimp r = AALTs bs rs" |
|
1052 |
shows "\<forall>r1 \<in> set rs. \<forall> bs. r1 \<noteq> AALTs bs rs2" |
|
1053 |
using nn1b assms |
|
1054 |
by (metis nn1qq) |
|
1055 |
||
1056 |
lemma nn_flts: |
|
1057 |
assumes "nonnested (AALTs bs rs)" |
|
1058 |
shows "\<forall>r \<in> set (flts rs). nonalt r" |
|
1059 |
using assms |
|
1060 |
apply(induct rs arbitrary: bs rule: flts.induct) |
|
1061 |
apply(auto) |
|
1062 |
done |
|
1063 |
||
317 | 1064 |
lemma rt: |
1065 |
shows "sum_list (map asize (flts (map bsimp rs))) \<le> sum_list (map asize rs)" |
|
1066 |
apply(induct rs) |
|
1067 |
apply(simp) |
|
1068 |
apply(simp) |
|
1069 |
apply(subst k0) |
|
1070 |
apply(simp) |
|
1071 |
by (smt add_le_cancel_right add_mono bsimp_size flts.simps(1) flts_size k0 le_iff_add list.simps(9) map_append sum_list.Cons sum_list.append trans_le_add1) |
|
1072 |
||
318 | 1073 |
lemma bsimp_AALTs_qq: |
1074 |
assumes "1 < length rs" |
|
1075 |
shows "bsimp_AALTs bs rs = AALTs bs rs" |
|
1076 |
using assms |
|
1077 |
apply(case_tac rs) |
|
1078 |
apply(simp) |
|
1079 |
apply(case_tac list) |
|
1080 |
apply(simp_all) |
|
1081 |
done |
|
1082 |
||
322 | 1083 |
lemma good_fuse: |
1084 |
shows "good (fuse bs r) = good r" |
|
1085 |
apply(induct r) |
|
1086 |
apply(auto) |
|
1087 |
apply (metis arexp.distinct(25) arexp.distinct(7) arexp.inject(4) good.elims(3) good.simps(4) good.simps(5)) |
|
1088 |
by (metis good.simps(4) good.simps(5) neq_Nil_conv) |
|
1089 |
||
1090 |
lemma good0: |
|
1091 |
assumes "rs \<noteq> Nil" |
|
1092 |
shows "good (bsimp_AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. good r)" |
|
1093 |
using assms |
|
1094 |
apply(induct bs rs rule: bsimp_AALTs.induct) |
|
1095 |
apply(auto simp add: good_fuse) |
|
1096 |
done |
|
1097 |
||
1098 |
lemma good0a: |
|
1099 |
assumes "flts (map bsimp rs) \<noteq> Nil" |
|
1100 |
shows "good (bsimp (AALTs bs rs)) \<longleftrightarrow> (\<forall>r \<in> set (flts (map bsimp rs)). good r)" |
|
1101 |
using assms |
|
1102 |
apply(simp) |
|
1103 |
apply(rule good0) |
|
1104 |
apply(simp) |
|
1105 |
done |
|
1106 |
||
1107 |
lemma flts0: |
|
1108 |
assumes "r \<noteq> AZERO" "nonalt r" |
|
1109 |
shows "flts [r] \<noteq> []" |
|
1110 |
using assms |
|
1111 |
apply(induct r) |
|
1112 |
apply(simp_all) |
|
1113 |
done |
|
1114 |
||
1115 |
lemma flts1: |
|
1116 |
assumes "good r" |
|
1117 |
shows "flts [r] \<noteq> []" |
|
1118 |
using assms |
|
1119 |
apply(induct r) |
|
1120 |
apply(simp_all) |
|
1121 |
apply(case_tac x2a) |
|
1122 |
apply(simp) |
|
1123 |
apply(simp) |
|
1124 |
done |
|
1125 |
||
1126 |
lemma flts2: |
|
1127 |
assumes "good r" |
|
1128 |
shows "\<forall>r' \<in> set (flts [r]). good r'" |
|
1129 |
using assms |
|
1130 |
apply(induct r) |
|
1131 |
apply(simp) |
|
1132 |
apply(simp) |
|
1133 |
apply(simp) |
|
1134 |
prefer 2 |
|
1135 |
apply(simp) |
|
1136 |
apply(auto)[1] |
|
1137 |
apply (metis good.simps(5) good_fuse in_set_insert insert_Nil list.exhaust) |
|
1138 |
prefer 2 |
|
1139 |
apply(simp) |
|
1140 |
by fastforce |
|
1141 |
||
1142 |
lemma flts3a: |
|
1143 |
assumes "good r" |
|
1144 |
shows "good (AALTs bs (flts [r]))" |
|
1145 |
using assms |
|
1146 |
by (metis flts1 flts2 good.simps(5) neq_Nil_conv) |
|
1147 |
||
1148 |
||
1149 |
lemma flts3: |
|
1150 |
assumes "\<forall>r \<in> set rs. good r \<or> r = AZERO" |
|
1151 |
shows "\<forall>r \<in> set (flts rs). good r" |
|
1152 |
using assms |
|
1153 |
apply(induct rs arbitrary: rule: flts.induct) |
|
1154 |
apply(simp_all) |
|
1155 |
by (metis UnE flts2 k0a set_map) |
|
1156 |
||
1157 |
lemma flts3b: |
|
1158 |
assumes "\<exists>r\<in>set rs. good r" |
|
1159 |
shows "flts rs \<noteq> []" |
|
1160 |
using assms |
|
1161 |
apply(induct rs arbitrary: rule: flts.induct) |
|
1162 |
apply(simp) |
|
1163 |
apply(simp) |
|
1164 |
apply(simp) |
|
1165 |
apply(auto) |
|
1166 |
done |
|
1167 |
||
1168 |
lemma flts4: |
|
1169 |
assumes "bsimp_AALTs bs (flts rs) = AZERO" |
|
1170 |
shows "\<forall>r \<in> set rs. \<not> good r" |
|
1171 |
using assms |
|
1172 |
apply(induct rs arbitrary: bs rule: flts.induct) |
|
1173 |
apply(auto) |
|
1174 |
defer |
|
1175 |
apply (metis (no_types, lifting) Nil_is_append_conv append_self_conv2 bsimp_AALTs.elims butlast.simps(2) butlast_append flts3b nonalt.simps(1) nonalt.simps(2)) |
|
1176 |
apply (metis arexp.distinct(7) bsimp_AALTs.elims flts2 good.simps(1) good.simps(2) good0 k0b list.distinct(1) list.inject nonalt.simps(3)) |
|
1177 |
apply (metis arexp.distinct(3) arexp.distinct(7) bsimp_AALTs.elims fuse.simps(3) list.distinct(1) list.inject) |
|
1178 |
apply (metis arexp.distinct(7) bsimp_AALTs.elims good.simps(1) good.simps(6) good_fuse list.distinct(1) list.inject) |
|
1179 |
apply (metis arexp.distinct(7) bsimp_AALTs.elims list.distinct(1) list.inject) |
|
1180 |
apply (metis arexp.distinct(7) bsimp_AALTs.simps(2) bsimp_AALTs.simps(3) flts.simps(1) flts.simps(2) flts1 good.simps(7) good_fuse neq_Nil_conv) |
|
1181 |
by (metis (no_types, lifting) Nil_is_append_conv append_Nil2 arexp.distinct(7) bsimp_AALTs.elims butlast.simps(2) butlast_append flts1 flts2 good.simps(1) good0 k0a) |
|
1182 |
||
1183 |
lemma flts_nil: |
|
1184 |
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> |
|
1185 |
good (bsimp y) \<or> bsimp y = AZERO" |
|
1186 |
and "\<forall>r\<in>set rs. \<not> good (bsimp r)" |
|
1187 |
shows "flts (map bsimp rs) = []" |
|
1188 |
using assms |
|
1189 |
apply(induct rs) |
|
1190 |
apply(simp) |
|
1191 |
apply(simp) |
|
1192 |
apply(subst k0) |
|
1193 |
apply(simp) |
|
1194 |
by force |
|
1195 |
||
1196 |
||
1197 |
lemma good1: |
|
1198 |
shows "good (bsimp a) \<or> bsimp a = AZERO" |
|
1199 |
apply(induct a taking: asize rule: measure_induct) |
|
1200 |
apply(case_tac x) |
|
1201 |
apply(simp) |
|
1202 |
apply(simp) |
|
1203 |
apply(simp) |
|
1204 |
prefer 3 |
|
1205 |
apply(simp) |
|
1206 |
prefer 2 |
|
1207 |
apply(simp only:) |
|
1208 |
apply(case_tac "x52") |
|
1209 |
apply(simp) |
|
1210 |
apply(simp only: good0a) |
|
1211 |
apply(frule_tac x="a" in spec) |
|
1212 |
apply(drule mp) |
|
1213 |
apply(simp) |
|
1214 |
apply(erule disjE) |
|
1215 |
prefer 2 |
|
1216 |
apply(simp) |
|
1217 |
apply(frule_tac x="AALTs x51 list" in spec) |
|
1218 |
apply(drule mp) |
|
1219 |
apply(simp add: asize0) |
|
1220 |
apply(auto)[1] |
|
1221 |
apply(frule_tac x="AALTs x51 list" in spec) |
|
1222 |
apply(drule mp) |
|
1223 |
apply(simp add: asize0) |
|
1224 |
apply(erule disjE) |
|
1225 |
apply(rule disjI1) |
|
1226 |
apply(simp add: good0) |
|
1227 |
apply(subst good0) |
|
1228 |
apply (metis Nil_is_append_conv flts1 k0) |
|
1229 |
apply(simp) |
|
1230 |
apply(subst k0) |
|
1231 |
apply(simp) |
|
1232 |
apply(auto)[1] |
|
1233 |
using flts2 apply blast |
|
1234 |
apply (metis good0 in_set_member member_rec(2)) |
|
1235 |
apply(simp) |
|
1236 |
apply(rule disjI1) |
|
1237 |
apply(drule flts4) |
|
1238 |
apply(subst k0) |
|
1239 |
apply(subst good0) |
|
1240 |
apply (metis append_is_Nil_conv flts1 k0) |
|
1241 |
apply(auto)[1] |
|
1242 |
using flts2 apply blast |
|
1243 |
apply (metis add.commute add_lessD1 flts_nil list.distinct(1) list.set_cases not_less_eq) |
|
1244 |
(* SEQ case *) |
|
1245 |
apply(simp) |
|
1246 |
apply(case_tac "bsimp x42 = AZERO") |
|
1247 |
apply(simp) |
|
1248 |
apply(case_tac "bsimp x43 = AZERO") |
|
1249 |
apply(simp) |
|
1250 |
apply(subst (2) bsimp_ASEQ0) |
|
1251 |
apply(simp) |
|
1252 |
apply(case_tac "\<exists>bs. bsimp x42 = AONE bs") |
|
1253 |
apply(auto)[1] |
|
1254 |
apply(subst bsimp_ASEQ2) |
|
1255 |
using good_fuse apply force |
|
1256 |
apply(subst bsimp_ASEQ1) |
|
1257 |
apply(auto) |
|
1258 |
using less_add_Suc1 apply blast |
|
1259 |
using less_add_Suc2 by blast |
|
1260 |
||
1261 |
lemma flts_append: |
|
1262 |
"flts (xs1 @ xs2) = flts xs1 @ flts xs2" |
|
1263 |
apply(induct xs1 arbitrary: xs2 rule: rev_induct) |
|
1264 |
apply(auto) |
|
1265 |
apply(case_tac xs) |
|
1266 |
apply(auto) |
|
1267 |
apply(case_tac x) |
|
1268 |
apply(auto) |
|
1269 |
apply(case_tac x) |
|
1270 |
apply(auto) |
|
1271 |
done |
|
1272 |
||
1273 |
lemma g1: |
|
1274 |
assumes "good (bsimp_AALTs bs rs)" |
|
1275 |
shows "bsimp_AALTs bs rs = AALTs bs rs \<or> (\<exists>r. rs = [r] \<and> bsimp_AALTs bs [r] = fuse bs r)" |
|
1276 |
using assms |
|
1277 |
apply(induct rs arbitrary: bs) |
|
1278 |
apply(simp) |
|
1279 |
apply(case_tac rs) |
|
1280 |
apply(simp only:) |
|
1281 |
apply(simp) |
|
1282 |
apply(case_tac list) |
|
1283 |
apply(simp) |
|
1284 |
by simp |
|
1285 |
||
317 | 1286 |
lemma flts_idem: |
322 | 1287 |
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> |
1288 |
bsimp (bsimp y) = bsimp y" |
|
1289 |
shows "map bsimp (flts (map bsimp rs)) = flts (map bsimp rs)" |
|
1290 |
using assms |
|
1291 |
apply(induct rs) |
|
1292 |
apply(simp) |
|
1293 |
apply(simp) |
|
1294 |
apply(subst k0) |
|
1295 |
apply(subst (2) k0) |
|
1296 |
apply(simp add: flts_append) |
|
1297 |
using good1 |
|
1298 |
apply - |
|
1299 |
apply(drule_tac x="a" in meta_spec) |
|
1300 |
apply(erule disjE) |
|
1301 |
prefer 2 |
|
1302 |
apply(simp) |
|
1303 |
using flts.simps |
|
1304 |
apply(case_tac a) |
|
1305 |
apply(simp_all) |
|
1306 |
defer |
|
1307 |
apply(drule g1) |
|
1308 |
apply(erule disjE) |
|
1309 |
apply(simp) |
|
1310 |
defer |
|
1311 |
apply(auto)[1] |
|
1312 |
||
1313 |
||
1314 |
||
1315 |
lemma flts_idem: |
|
1316 |
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> |
|
1317 |
bsimp (bsimp y) = bsimp y" |
|
317 | 1318 |
shows "flts (map bsimp (flts (map bsimp rs))) = flts (map bsimp rs)" |
1319 |
using assms |
|
1320 |
apply(induct rs) |
|
1321 |
apply(simp) |
|
1322 |
apply(simp) |
|
1323 |
apply(subst k0) |
|
1324 |
apply(subst (2) k0) |
|
322 | 1325 |
apply(simp add: flts_append) |
1326 |
using good1 |
|
1327 |
apply - |
|
1328 |
apply(drule_tac x="a" in meta_spec) |
|
1329 |
apply(erule disjE) |
|
1330 |
prefer 2 |
|
1331 |
apply(simp) |
|
1332 |
using flts.simps |
|
1333 |
apply(case_tac a) |
|
1334 |
apply(simp_all) |
|
1335 |
defer |
|
1336 |
apply(drule g1) |
|
1337 |
apply(erule disjE) |
|
1338 |
apply(simp) |
|
1339 |
defer |
|
1340 |
apply(auto)[1] |
|
1341 |
||
1342 |
apply(subst g1) |
|
1343 |
apply(simp) |
|
1344 |
apply(simp) |
|
1345 |
apply (me tis (full_types) arexp.inject(4) bsimp_AALTs.simps(2) flts3a fuse_empty g1 list.distinct(1)) |
|
1346 |
||
1347 |
||
1348 |
||
1349 |
||
317 | 1350 |
apply(case_tac "bsimp a = AZERO") |
1351 |
apply(simp) |
|
1352 |
apply(case_tac "nonalt (bsimp a)") |
|
1353 |
thm k0 k0a k0b |
|
1354 |
apply(subst k0b) |
|
1355 |
apply(simp) |
|
1356 |
apply(simp) |
|
1357 |
apply(simp) |
|
1358 |
apply(subst k0b) |
|
1359 |
apply(simp) |
|
1360 |
apply(simp) |
|
1361 |
apply(simp) |
|
1362 |
apply(subst k0) |
|
1363 |
apply(subst k0b) |
|
1364 |
apply(simp) |
|
1365 |
apply(simp) |
|
1366 |
apply(simp) |
|
1367 |
apply(simp) |
|
1368 |
apply(simp add: k00) |
|
1369 |
apply(subst k0a2) |
|
1370 |
apply(simp) |
|
1371 |
apply(subst k0a2) |
|
1372 |
apply(simp) |
|
1373 |
apply(case_tac a) |
|
1374 |
apply(simp_all) |
|
318 | 1375 |
oops |
317 | 1376 |
|
318 | 1377 |
|
1378 |
lemma flts_0: |
|
1379 |
assumes "nonnested (AALTs bs rs)" |
|
1380 |
shows "\<forall>r \<in> set (flts rs). r \<noteq> AZERO" |
|
1381 |
using assms |
|
1382 |
apply(induct rs arbitrary: bs rule: flts.induct) |
|
1383 |
apply(simp) |
|
1384 |
apply(simp) |
|
1385 |
defer |
|
1386 |
apply(simp) |
|
1387 |
apply(simp) |
|
1388 |
apply(simp) |
|
1389 |
apply(simp) |
|
1390 |
apply(rule ballI) |
|
1391 |
apply(simp) |
|
1392 |
done |
|
322 | 1393 |
|
1394 |
lemma flts_0a: |
|
1395 |
assumes "nonnested (AALTs bs rs)" |
|
1396 |
shows "AZERO \<notin> set (flts rs)" |
|
1397 |
using assms |
|
1398 |
using flts_0 by blast |
|
318 | 1399 |
|
322 | 1400 |
lemma qqq1: |
318 | 1401 |
shows "AZERO \<notin> set (flts (map bsimp rs))" |
322 | 1402 |
by (metis ex_map_conv flts3 good.simps(1) good1) |
1403 |
||
318 | 1404 |
lemma cc: |
1405 |
assumes "bsimp (fuse bs' r) = (AALTs bs rs)" |
|
1406 |
shows "\<forall>r \<in> set rs. r \<noteq> AZERO" |
|
1407 |
using assms |
|
1408 |
apply(induct r arbitrary: rs bs bs' rule: bsimp.induct) |
|
1409 |
apply(simp) |
|
1410 |
apply(case_tac "bsimp r1 = AZERO") |
|
1411 |
apply simp |
|
1412 |
apply(case_tac "bsimp r2 = AZERO") |
|
1413 |
apply(simp) |
|
1414 |
apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'") |
|
1415 |
apply(auto)[1] |
|
1416 |
apply (simp add: bsimp_ASEQ0) |
|
1417 |
apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'") |
|
1418 |
apply(auto)[2] |
|
1419 |
apply (simp add: bsimp_ASEQ2) |
|
1420 |
using bsimp_fuse apply fastforce |
|
1421 |
apply (simp add: bsimp_ASEQ1) |
|
1422 |
prefer 2 |
|
1423 |
apply(simp) |
|
1424 |
defer |
|
1425 |
apply(simp) |
|
1426 |
apply(simp) |
|
1427 |
apply(simp) |
|
1428 |
(* AALT case *) |
|
1429 |
apply(simp only: fuse.simps) |
|
1430 |
apply(simp) |
|
1431 |
apply(case_tac "flts (map bsimp rs)") |
|
1432 |
apply(simp) |
|
1433 |
apply(simp) |
|
1434 |
apply(case_tac list) |
|
1435 |
apply(simp) |
|
1436 |
apply(case_tac a) |
|
1437 |
apply(simp_all) |
|
1438 |
apply(auto) |
|
1439 |
apply (metis ex_map_conv list.set_intros(1) nn1b nn1c nonalt.simps(1)) |
|
1440 |
apply(case_tac rs) |
|
1441 |
apply(simp) |
|
1442 |
apply(simp) |
|
1443 |
apply(case_tac list) |
|
1444 |
apply(simp) |
|
1445 |
||
1446 |
||
1447 |
apply(subgoal_tac "\<forall>r \<in> set (flts (map bsimp rs)). r \<noteq> AZERO") |
|
1448 |
prefer 2 |
|
1449 |
apply(rule_tac bs="bs' @ bs1" in flts_0) |
|
1450 |
||
1451 |
||
1452 |
thm bsimp_AALTs_qq |
|
1453 |
apply(case_tac "1 < length rs") |
|
1454 |
apply(drule_tac bsimp_AALTs_qq) |
|
1455 |
apply(subgoal_tac "nonnested (AALTs bs rsa)") |
|
1456 |
prefer 2 |
|
1457 |
apply (metis nn1b) |
|
1458 |
apply(rule ballI) |
|
1459 |
apply(simp) |
|
1460 |
apply(drule_tac x="r" in meta_spec) |
|
1461 |
apply(simp) |
|
1462 |
(* HERE *) |
|
1463 |
apply(drule flts_0) |
|
1464 |
||
1465 |
||
1466 |
||
1467 |
apply(simp) |
|
1468 |
||
1469 |
||
1470 |
||
1471 |
||
1472 |
apply(subst |
|
1473 |
||
1474 |
apply (sm t arexp.distinct(15) arexp.distinct(21) arexp.distinct(25) arexp.distinct(29) arexp.inject(4) b1 fuse.elims) |
|
1475 |
||
1476 |
prefer 2 |
|
1477 |
||
1478 |
||
1479 |
apply(induct r arbitrary: rs bs bs' rule: bsimp.induct) |
|
1480 |
apply(auto) |
|
1481 |
apply(case_tac "bsimp r1 = AZERO") |
|
1482 |
apply simp |
|
1483 |
apply(case_tac "bsimp r2 = AZERO") |
|
1484 |
apply(simp) |
|
1485 |
apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'") |
|
1486 |
apply(auto) |
|
1487 |
apply (simp add: bsimp_ASEQ0) |
|
1488 |
apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'") |
|
1489 |
apply(auto) |
|
1490 |
apply (simp add: bsimp_ASEQ2) |
|
322 | 1491 |
using bsimp_fuse apply fast force |
318 | 1492 |
apply (simp add: bsimp_ASEQ1) |
1493 |
||
1494 |
||
1495 |
||
1496 |
apply(subst |
|
1497 |
||
1498 |
apply (sm t arexp.distinct(15) arexp.distinct(21) arexp.distinct(25) arexp.distinct(29) arexp.inject(4) b1 fuse.elims) |
|
1499 |
||
1500 |
prefer 2 |
|
1501 |
||
1502 |
||
1503 |
||
1504 |
lemma ww1: |
|
1505 |
assumes "flts [r1] = [r2]" "r1 \<noteq> AZERO" |
|
1506 |
shows "r1 = r2" |
|
1507 |
using assms |
|
1508 |
apply(case_tac r1) |
|
1509 |
apply(simp) |
|
1510 |
apply(simp) |
|
1511 |
apply(simp) |
|
1512 |
apply(simp) |
|
1513 |
prefer 2 |
|
1514 |
apply(simp) |
|
1515 |
apply(simp) |
|
1516 |
apply(auto) |
|
1517 |
oops |
|
1518 |
||
317 | 1519 |
lemma bsimp_idem: |
1520 |
shows "bsimp (bsimp r) = bsimp r" |
|
1521 |
apply(induct r taking: "asize" rule: measure_induct) |
|
1522 |
apply(case_tac x) |
|
1523 |
apply(simp) |
|
1524 |
apply(simp) |
|
1525 |
apply(simp) |
|
1526 |
prefer 3 |
|
1527 |
apply(simp) |
|
1528 |
apply(simp) |
|
1529 |
apply (simp add: bsimp_ASEQ_idem) |
|
1530 |
apply(clarify) |
|
1531 |
apply(case_tac x52) |
|
318 | 1532 |
apply(simp) |
1533 |
(* AALT case where rs is of the form _ # _ *) |
|
1534 |
apply(clarify) |
|
317 | 1535 |
apply(simp) |
318 | 1536 |
apply(case_tac "length (flts (bsimp a # map bsimp list)) \<le> 1") |
1537 |
prefer 2 |
|
1538 |
apply(subst bsimp_AALTs_qq) |
|
1539 |
apply(auto)[1] |
|
1540 |
apply(simp) |
|
322 | 1541 |
apply(subst k0) |
1542 |
apply(simp) |
|
1543 |
apply(simp add: flts_append) |
|
1544 |
apply(subst (2) k0) |
|
1545 |
||
1546 |
apply(simp add: flts_append) |
|
1547 |
||
318 | 1548 |
prefer 2 |
1549 |
apply(subgoal_tac "length (flts (bsimp a # map bsimp list)) = 0 \<or> |
|
1550 |
length (flts (bsimp a # map bsimp list)) = 1") |
|
1551 |
prefer 2 |
|
1552 |
apply(auto)[1] |
|
1553 |
using le_SucE apply blast |
|
1554 |
apply(erule disjE) |
|
1555 |
apply(simp) |
|
1556 |
apply(simp) |
|
1557 |
apply(subst k0) |
|
1558 |
apply(subst (2) k0) |
|
1559 |
apply(subst (asm) k0) |
|
1560 |
apply(simp) |
|
1561 |
apply(subgoal_tac "length (flts [bsimp a]) = 1 \<or> |
|
1562 |
length (flts (map bsimp list)) = 1") |
|
1563 |
prefer 2 |
|
1564 |
apply linarith |
|
1565 |
apply(erule disjE) |
|
1566 |
apply(simp) |
|
1567 |
prefer 2 |
|
1568 |
apply(simp) |
|
1569 |
apply(drule_tac x="AALTs x51 list" in spec) |
|
1570 |
apply(drule mp) |
|
1571 |
apply(simp) |
|
1572 |
using asize0 apply blast |
|
1573 |
apply(simp) |
|
1574 |
apply(frule_tac x="a" in spec) |
|
1575 |
apply(drule mp) |
|
1576 |
apply(simp) |
|
1577 |
apply(subgoal_tac "\<exists>r. flts [bsimp a] = [r]") |
|
1578 |
prefer 2 |
|
1579 |
apply (simp add: length_Suc_conv) |
|
1580 |
apply(clarify) |
|
1581 |
apply(simp only: ) |
|
1582 |
apply(case_tac "bsimp a = AZERO") |
|
1583 |
apply simp |
|
1584 |
apply(case_tac "\<exists>bs rs. bsimp a = AALTs bs rs") |
|
1585 |
apply(clarify) |
|
1586 |
apply(simp) |
|
1587 |
apply(drule_tac x="AALTs bs rs" in spec) |
|
1588 |
apply(drule mp) |
|
1589 |
apply(simp) |
|
1590 |
apply (metis asize.simps(4) bsimp_size lessI less_le_trans trans_less_add1) |
|
1591 |
apply(simp) |
|
1592 |
||
1593 |
apply(subst ww) |
|
1594 |
apply(subst ww) |
|
1595 |
apply(frule_tac x="fuse x51 r" in spec) |
|
1596 |
apply(drule mp) |
|
1597 |
apply(simp) |
|
1598 |
apply (smt add.commute add_le_cancel_right fuse_size le_add2 le_trans list.map(1) list.simps(9) not_less not_less_eq rt sum_list.Cons) |
|
1599 |
apply(case_tac "bsimp a = AZERO") |
|
1600 |
apply simp |
|
1601 |
apply(case_tac "\<exists>bs rs. bsimp a = AALTs bs rs") |
|
1602 |
apply(clarify) |
|
1603 |
||
1604 |
defer |
|
1605 |
||
1606 |
apply( |
|
1607 |
apply(case_tac a) |
|
1608 |
apply(simp_all) |
|
1609 |
apply(subgoal_tac "\<exists>r. flts [bsimp a] = [r]") |
|
1610 |
prefer 2 |
|
1611 |
apply (simp add: length_Suc_conv) |
|
1612 |
apply auto[1] |
|
1613 |
apply(case_tac |
|
1614 |
apply(clarify) |
|
1615 |
||
1616 |
defer |
|
1617 |
apply(auto)[1] |
|
1618 |
||
1619 |
||
317 | 1620 |
apply(subst k0) |
1621 |
apply(subst (2) k0) |
|
1622 |
apply(case_tac "bsimp a = AZERO") |
|
1623 |
apply(simp) |
|
1624 |
apply(frule_tac x="AALTs x51 (flts (map bsimp list))" in spec) |
|
1625 |
apply(drule mp) |
|
1626 |
apply(simp) |
|
1627 |
apply (meson add_le_cancel_right asize0 le_trans not_le rt trans_le_add2) |
|
1628 |
apply(simp) |
|
1629 |
apply(subst (asm) flts_idem) |
|
1630 |
apply(auto)[1] |
|
1631 |
apply(drule_tac x="r" in spec) |
|
1632 |
apply (metis add.commute add_lessD1 not_add_less1 not_less_eq sum_list_map_remove1) |
|
1633 |
apply(simp) |
|
1634 |
apply(subst flts_idem) |
|
1635 |
apply(auto)[1] |
|
1636 |
apply(drule_tac x="r" in spec) |
|
1637 |
apply (metis add.commute add_lessD1 not_add_less1 not_less_eq sum_list_map_remove1) |
|
1638 |
apply(simp) |
|
1639 |
apply(case_tac "nonalt (bsimp a)") |
|
1640 |
apply(subst k0b) |
|
1641 |
apply(simp) |
|
1642 |
apply(simp) |
|
1643 |
apply(subst k0b) |
|
1644 |
apply(simp) |
|
1645 |
apply(simp) |
|
1646 |
apply(auto)[1] |
|
1647 |
apply(frule_tac x="AALTs x51 (bsimp a # flts (map bsimp list))" in spec) |
|
1648 |
apply(drule mp) |
|
1649 |
apply(simp) |
|
1650 |
prefer 2 |
|
1651 |
apply(simp) |
|
1652 |
apply(subst (asm) k0) |
|
1653 |
apply(subst (asm) flts_idem) |
|
1654 |
apply(auto)[1] |
|
1655 |
apply (simp add: sum_list_map_remove1) |
|
1656 |
apply(subst (asm) k0b) |
|
1657 |
apply(simp) |
|
1658 |
apply(simp) |
|
1659 |
apply(simp) |
|
1660 |
apply(subst k0) |
|
1661 |
apply(subst flts_idem) |
|
1662 |
apply(auto)[1] |
|
1663 |
apply (simp add: sum_list_map_remove1) |
|
1664 |
apply(subst k0b) |
|
1665 |
apply(simp) |
|
1666 |
apply(simp) |
|
1667 |
apply(simp) |
|
1668 |
lemma XX_bder: |
|
1669 |
shows "bsimp (bder c (bsimp r)) = (bsimp \<circ> bder c) r" |
|
1670 |
apply(induct r) |
|
1671 |
apply(simp) |
|
1672 |
apply(simp) |
|
1673 |
apply(simp) |
|
1674 |
prefer 3 |
|
1675 |
apply(simp) |
|
1676 |
prefer 2 |
|
1677 |
apply(simp) |
|
1678 |
apply(case_tac x2a) |
|
1679 |
apply(simp) |
|
1680 |
apply(simp) |
|
1681 |
apply(auto)[1] |
|
1682 |
||
1683 |
||
314 | 1684 |
lemma q3a: |
1685 |
assumes "\<exists>r \<in> set rs. bnullable r" |
|
1686 |
shows "bmkeps (AALTs bs (map (fuse bs1) rs)) = bmkeps (AALTs (bs@bs1) rs)" |
|
1687 |
using assms |
|
1688 |
apply(induct rs arbitrary: bs bs1) |
|
1689 |
apply(simp) |
|
1690 |
apply(simp) |
|
1691 |
apply(auto) |
|
1692 |
apply (metis append_assoc b2 bnullable_correctness erase_fuse r0) |
|
1693 |
apply(case_tac "bnullable a") |
|
1694 |
apply (metis append.assoc b2 bnullable_correctness erase_fuse r0) |
|
1695 |
apply(case_tac rs) |
|
1696 |
apply(simp) |
|
1697 |
apply(simp) |
|
1698 |
apply(auto)[1] |
|
1699 |
apply (metis bnullable_correctness erase_fuse)+ |
|
1700 |
done |
|
1701 |
||
1702 |
lemma qq4: |
|
1703 |
assumes "\<exists>x\<in>set list. bnullable x" |
|
1704 |
shows "\<exists>x\<in>set (flts list). bnullable x" |
|
1705 |
using assms |
|
1706 |
apply(induct list rule: flts.induct) |
|
1707 |
apply(auto) |
|
1708 |
by (metis UnCI bnullable_correctness erase_fuse imageI) |
|
1709 |
||
1710 |
||
1711 |
lemma qs3: |
|
1712 |
assumes "\<exists>r \<in> set rs. bnullable r" |
|
1713 |
shows "bmkeps (AALTs bs rs) = bmkeps (AALTs bs (flts rs))" |
|
1714 |
using assms |
|
1715 |
apply(induct rs arbitrary: bs taking: size rule: measure_induct) |
|
1716 |
apply(case_tac x) |
|
1717 |
apply(simp) |
|
1718 |
apply(simp) |
|
1719 |
apply(case_tac a) |
|
1720 |
apply(simp) |
|
1721 |
apply (simp add: r1) |
|
1722 |
apply(simp) |
|
1723 |
apply (simp add: r0) |
|
1724 |
apply(simp) |
|
1725 |
apply(case_tac "flts list") |
|
1726 |
apply(simp) |
|
1727 |
apply (metis L_erase_AALTs L_erase_flts L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(4) mkeps_nullable r2) |
|
1728 |
apply(simp) |
|
1729 |
apply (simp add: r1) |
|
1730 |
prefer 3 |
|
1731 |
apply(simp) |
|
1732 |
apply (simp add: r0) |
|
1733 |
prefer 2 |
|
1734 |
apply(simp) |
|
1735 |
apply(case_tac "\<exists>x\<in>set x52. bnullable x") |
|
1736 |
apply(case_tac "list") |
|
1737 |
apply(simp) |
|
1738 |
apply (metis b2 fuse.simps(4) q3a r2) |
|
1739 |
apply(erule disjE) |
|
1740 |
apply(subst qq1) |
|
1741 |
apply(auto)[1] |
|
1742 |
apply (metis bnullable_correctness erase_fuse) |
|
1743 |
apply(simp) |
|
1744 |
apply (metis b2 fuse.simps(4) q3a r2) |
|
1745 |
apply(simp) |
|
1746 |
apply(auto)[1] |
|
1747 |
apply(subst qq1) |
|
1748 |
apply (metis bnullable_correctness erase_fuse image_eqI set_map) |
|
1749 |
apply (metis b2 fuse.simps(4) q3a r2) |
|
1750 |
apply(subst qq1) |
|
1751 |
apply (metis bnullable_correctness erase_fuse image_eqI set_map) |
|
1752 |
apply (metis b2 fuse.simps(4) q3a r2) |
|
1753 |
apply(simp) |
|
1754 |
apply(subst qq2) |
|
1755 |
apply (metis bnullable_correctness erase_fuse imageE set_map) |
|
1756 |
prefer 2 |
|
1757 |
apply(case_tac "list") |
|
1758 |
apply(simp) |
|
1759 |
apply(simp) |
|
1760 |
apply (simp add: qq4) |
|
1761 |
apply(simp) |
|
1762 |
apply(auto) |
|
1763 |
apply(case_tac list) |
|
1764 |
apply(simp) |
|
1765 |
apply(simp) |
|
1766 |
apply (simp add: r0) |
|
1767 |
apply(case_tac "bnullable (ASEQ x41 x42 x43)") |
|
1768 |
apply(case_tac list) |
|
1769 |
apply(simp) |
|
1770 |
apply(simp) |
|
1771 |
apply (simp add: r0) |
|
1772 |
apply(simp) |
|
1773 |
using qq4 r1 r2 by auto |
|
1774 |
||
317 | 1775 |
|
314 | 1776 |
|
1777 |
lemma k1: |
|
1778 |
assumes "\<And>x2aa. \<lbrakk>x2aa \<in> set x2a; bnullable x2aa\<rbrakk> \<Longrightarrow> bmkeps x2aa = bmkeps (bsimp x2aa)" |
|
1779 |
"\<exists>x\<in>set x2a. bnullable x" |
|
1780 |
shows "bmkeps (AALTs x1 (flts x2a)) = bmkeps (AALTs x1 (flts (map bsimp x2a)))" |
|
1781 |
using assms |
|
1782 |
apply(induct x2a) |
|
1783 |
apply fastforce |
|
1784 |
apply(simp) |
|
1785 |
apply(subst k0) |
|
1786 |
apply(subst (2) k0) |
|
1787 |
apply(auto)[1] |
|
1788 |
apply (metis b3 k0 list.set_intros(1) qs3 r0) |
|
1789 |
by (smt b3 imageI insert_iff k0 list.set(2) qq3 qs3 r0 r1 set_map) |
|
1790 |
||
1791 |
||
1792 |
||
1793 |
lemma bmkeps_simp: |
|
1794 |
assumes "bnullable r" |
|
1795 |
shows "bmkeps r = bmkeps (bsimp r)" |
|
1796 |
using assms |
|
1797 |
apply(induct r) |
|
1798 |
apply(simp) |
|
1799 |
apply(simp) |
|
1800 |
apply(simp) |
|
1801 |
apply(simp) |
|
1802 |
prefer 3 |
|
1803 |
apply(simp) |
|
1804 |
apply(case_tac "bsimp r1 = AZERO") |
|
1805 |
apply(simp) |
|
1806 |
apply(auto)[1] |
|
1807 |
apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable) |
|
1808 |
apply(case_tac "bsimp r2 = AZERO") |
|
1809 |
apply(simp) |
|
1810 |
apply(auto)[1] |
|
1811 |
apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable) |
|
1812 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs") |
|
1813 |
apply(auto)[1] |
|
1814 |
apply(subst b1) |
|
1815 |
apply(subst b2) |
|
1816 |
apply(simp add: b3[symmetric]) |
|
1817 |
apply(simp) |
|
1818 |
apply(subgoal_tac "bsimp_ASEQ x1 (bsimp r1) (bsimp r2) = ASEQ x1 (bsimp r1) (bsimp r2)") |
|
1819 |
prefer 2 |
|
1820 |
apply (smt b3 bnullable.elims(2) bsimp_ASEQ.simps(17) bsimp_ASEQ.simps(19) bsimp_ASEQ.simps(20) bsimp_ASEQ.simps(21) bsimp_ASEQ.simps(22) bsimp_ASEQ.simps(24) bsimp_ASEQ.simps(25) bsimp_ASEQ.simps(26) bsimp_ASEQ.simps(27) bsimp_ASEQ.simps(29) bsimp_ASEQ.simps(30) bsimp_ASEQ.simps(31)) |
|
1821 |
apply(simp) |
|
1822 |
apply(simp) |
|
1823 |
apply(subst q3[symmetric]) |
|
1824 |
apply simp |
|
1825 |
using b3 qq4 apply auto[1] |
|
1826 |
apply(subst qs3) |
|
1827 |
apply simp |
|
1828 |
using k1 by blast |
|
1829 |
||
1830 |
thm bmkeps_retrieve bmkeps_simp bder_retrieve |
|
1831 |
||
1832 |
lemma bmkeps_bder_AALTs: |
|
1833 |
assumes "\<exists>r \<in> set rs. bnullable (bder c r)" |
|
1834 |
shows "bmkeps (bder c (bsimp_AALTs bs rs)) = bmkeps (bsimp_AALTs bs (map (bder c) rs))" |
|
1835 |
using assms |
|
1836 |
apply(induct rs) |
|
1837 |
apply(simp) |
|
1838 |
apply(simp) |
|
1839 |
apply(auto) |
|
1840 |
apply(case_tac rs) |
|
1841 |
apply(simp) |
|
1842 |
apply (metis (full_types) Prf_injval bder_retrieve bmkeps_retrieve bnullable_correctness erase_bder erase_fuse mkeps_nullable retrieve_fuse2) |
|
1843 |
apply(simp) |
|
1844 |
apply(case_tac rs) |
|
1845 |
apply(simp_all) |
|
1846 |
done |
|
1847 |
||
1848 |
||
317 | 1849 |
fun extr :: "arexp \<Rightarrow> (bit list) set" where |
1850 |
"extr (AONE bs) = {bs}" |
|
1851 |
| "extr (ACHAR bs c) = {bs}" |
|
1852 |
| "extr (AALTs bs (r#rs)) = |
|
1853 |
{bs @ bs' | bs'. bs' \<in> extr r} \<union> |
|
1854 |
{bs @ bs' | bs'. bs' \<in> extr (AALTs [] rs)}" |
|
1855 |
| "extr (ASEQ bs r1 r2) = |
|
1856 |
{bs @ bs1 @ bs2 | bs1 bs2. bs1 \<in> extr r1 \<and> bs2 \<in> extr r2}" |
|
1857 |
| "extr (ASTAR bs r) = {bs @ [S]} \<union> |
|
1858 |
{bs @ [Z] @ bs1 @ bs2 | bs1 bs2. bs1 \<in> extr r \<and> bs2 \<in> extr (ASTAR [] r)}" |
|
314 | 1859 |
|
1860 |
||
1861 |
lemma MAIN_decode: |
|
1862 |
assumes "\<Turnstile> v : ders s r" |
|
1863 |
shows "Some (flex r id s v) = decode (retrieve (bders_simp (intern r) s) v) r" |
|
1864 |
using assms |
|
1865 |
proof (induct s arbitrary: v rule: rev_induct) |
|
1866 |
case Nil |
|
1867 |
have "\<Turnstile> v : ders [] r" by fact |
|
1868 |
then have "\<Turnstile> v : r" by simp |
|
1869 |
then have "Some v = decode (retrieve (intern r) v) r" |
|
1870 |
using decode_code retrieve_code by auto |
|
1871 |
then show "Some (flex r id [] v) = decode (retrieve (bders_simp (intern r) []) v) r" |
|
1872 |
by simp |
|
1873 |
next |
|
1874 |
case (snoc c s v) |
|
1875 |
have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> |
|
1876 |
Some (flex r id s v) = decode (retrieve (bders_simp (intern r) s) v) r" by fact |
|
1877 |
have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact |
|
1878 |
then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" |
|
1879 |
by(simp add: Prf_injval ders_append) |
|
1880 |
have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))" |
|
1881 |
by (simp add: flex_append) |
|
1882 |
also have "... = decode (retrieve (bders_simp (intern r) s) (injval (ders s r) c v)) r" |
|
1883 |
using asm2 IH by simp |
|
1884 |
also have "... = decode (retrieve (bder c (bders_simp (intern r) s)) v) r" |
|
1885 |
using asm bder_retrieve ders_append |
|
1886 |
apply - |
|
1887 |
apply(drule_tac x="v" in meta_spec) |
|
1888 |
apply(drule_tac x="c" in meta_spec) |
|
1889 |
apply(drule_tac x="bders_simp (intern r) s" in meta_spec) |
|
1890 |
apply(drule_tac meta_mp) |
|
1891 |
apply(simp add: ders_append) |
|
1892 |
defer |
|
1893 |
apply(simp) |
|
1894 |
oops |
|
1895 |
||
316 | 1896 |
fun vsimp :: "arexp \<Rightarrow> val \<Rightarrow> val" |
1897 |
where |
|
1898 |
"vsimp (ASEQ _ (AONE _) r) (Seq v1 v2) = vsimp r v1" |
|
1899 |
| "vsimp _ v = v" |
|
1900 |
||
1901 |
lemma fuse_vsimp: |
|
1902 |
assumes "\<Turnstile> v : (erase r)" |
|
1903 |
shows "vsimp (fuse bs r) v = vsimp r v" |
|
1904 |
using assms |
|
1905 |
apply(induct r arbitrary: v bs) |
|
1906 |
apply(simp_all) |
|
1907 |
apply(case_tac "\<exists>bs. r1 = AONE bs") |
|
1908 |
apply(auto) |
|
1909 |
apply (metis Prf_elims(2) vsimp.simps(1)) |
|
1910 |
apply(erule Prf_elims) |
|
1911 |
apply(auto) |
|
1912 |
apply(case_tac r1) |
|
1913 |
apply(auto) |
|
1914 |
done |
|
1915 |
||
1916 |
||
1917 |
lemma retrieve_XXX0: |
|
1918 |
assumes "\<And>r v. \<lbrakk>r \<in> set rs; \<Turnstile> v : erase r\<rbrakk> \<Longrightarrow> |
|
1919 |
\<exists>v'. \<Turnstile> v' : erase (bsimp r) \<and> retrieve (bsimp r) v' = retrieve r v" |
|
1920 |
"\<Turnstile> v : erase (AALTs bs rs)" |
|
1921 |
shows "\<exists>v'. \<Turnstile> v' : erase (bsimp_AALTs bs (flts (map bsimp rs))) \<and> |
|
1922 |
retrieve (bsimp_AALTs bs (flts (map bsimp rs))) v' = retrieve (AALTs bs rs) v" |
|
1923 |
using assms |
|
1924 |
apply(induct rs arbitrary: bs v taking: size rule: measure_induct) |
|
1925 |
apply(case_tac x) |
|
1926 |
apply(simp) |
|
1927 |
using Prf_elims(1) apply blast |
|
1928 |
apply(simp) |
|
1929 |
apply(case_tac list) |
|
1930 |
apply(simp_all) |
|
1931 |
apply(case_tac a) |
|
1932 |
apply(simp_all) |
|
1933 |
using Prf_elims(1) apply blast |
|
1934 |
apply (metis erase.simps(2) fuse.simps(2) retrieve_fuse2) |
|
1935 |
using Prf_elims(5) apply force |
|
1936 |
apply(erule Prf_elims) |
|
1937 |
apply(auto)[1] |
|
1938 |
||
1939 |
||
1940 |
||
1941 |
||
1942 |
apply(simp) |
|
1943 |
apply(erule Prf_elims) |
|
1944 |
using Prf_elims(1) apply b last |
|
1945 |
apply(auto) |
|
1946 |
apply (metis append_Ni l2 erase_fuse fuse.simps(4) retrieve_fuse2) |
|
1947 |
apply(case_tac rs) |
|
1948 |
apply(auto) |
|
1949 |
||
1950 |
||
1951 |
oops |
|
1952 |
||
1953 |
fun get where |
|
1954 |
"get (Some v) = v" |
|
314 | 1955 |
|
316 | 1956 |
|
1957 |
lemma retrieve_XXX: |
|
1958 |
assumes "\<Turnstile> v : erase r" |
|
1959 |
shows "\<Turnstile> get (decode (code v) (erase (bsimp r))) : erase (bsimp r)" |
|
1960 |
using assms |
|
1961 |
apply(induct r arbitrary: v) |
|
1962 |
apply(simp) |
|
1963 |
using Prf_elims(1) apply auto[1] |
|
1964 |
apply(simp) |
|
1965 |
apply (simp add: decode_code) |
|
1966 |
apply(simp) |
|
1967 |
apply (simp add: decode_code) |
|
1968 |
apply(simp) |
|
1969 |
apply(erule Prf_elims) |
|
1970 |
apply(simp) |
|
1971 |
apply(case_tac "r1 = AZERO") |
|
1972 |
apply(simp) |
|
1973 |
apply (meson Prf_elims(1) Prf_elims(2)) |
|
1974 |
apply(case_tac "r2 = AZERO") |
|
1975 |
apply(simp) |
|
1976 |
apply (meson Prf_elims(1) Prf_elims(2)) |
|
1977 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs") |
|
1978 |
apply(clarify) |
|
1979 |
apply(simp) |
|
1980 |
apply(subst bsimp_ASEQ2) |
|
1981 |
apply(subst bsimp_ASEQ2) |
|
317 | 1982 |
apply(simp add: erase_fuse) |
1983 |
apply(case_tac r1) |
|
1984 |
apply(simp_all) |
|
1985 |
using Prf_elims(4) apply fastforce |
|
1986 |
apply(erule Prf_elims) |
|
1987 |
apply(simp) |
|
1988 |
||
1989 |
apply(simp) |
|
1990 |
||
1991 |
||
316 | 1992 |
defer |
1993 |
apply(subst bsimp_ASEQ1) |
|
318 | 1994 |
using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fast force |
316 | 1995 |
using L_bsimp_erase L_ |
314 | 1996 |
|
316 | 1997 |
lemma retrieve_XXX: |
1998 |
assumes "\<Turnstile> v : erase r" |
|
1999 |
shows "\<Turnstile> (vsimp (bsimp r) v : erase (bsimp r) \<and> retrieve (bsimp r) (vsimp (bsimp r) v) = retrieve r v" |
|
2000 |
using assms |
|
2001 |
apply(induct r arbitrary: v) |
|
2002 |
apply(simp) |
|
2003 |
using Prf_elims(1) apply blast |
|
2004 |
apply(simp) |
|
2005 |
using Prf_elims(4) apply fastforce |
|
2006 |
apply(simp) |
|
2007 |
apply blast |
|
2008 |
apply simp |
|
2009 |
apply(case_tac "r1 = AZERO") |
|
2010 |
apply(simp) |
|
2011 |
apply (meson Prf_elims(1) Prf_elims(2)) |
|
2012 |
apply(case_tac "r2 = AZERO") |
|
2013 |
apply(simp) |
|
2014 |
apply (meson Prf_elims(1) Prf_elims(2)) |
|
2015 |
apply(erule Prf_elims) |
|
2016 |
apply(simp) |
|
2017 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs") |
|
2018 |
apply(clarify) |
|
2019 |
apply(simp) |
|
2020 |
apply(subst bsimp_ASEQ2) |
|
2021 |
defer |
|
2022 |
apply(subst bsimp_ASEQ1) |
|
2023 |
using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce |
|
2024 |
using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce |
|
2025 |
apply(simp) |
|
2026 |
apply(simp) |
|
2027 |
apply(drule_tac x="v1" in meta_spec) |
|
2028 |
apply(drule_tac x="v2" in meta_spec) |
|
2029 |
apply(simp) |
|
2030 |
apply(clarify) |
|
2031 |
apply(rule_tac x="Seq v' v'a" in exI) |
|
2032 |
apply(simp) |
|
2033 |
apply (metis Prf.intros(1) Prf_elims(1) bsimp_ASEQ1 erase.simps(1) retrieve.simps(6)) |
|
2034 |
prefer 3 |
|
2035 |
apply(drule_tac x="v1" in meta_spec) |
|
2036 |
apply(drule_tac x="v2" in meta_spec) |
|
2037 |
apply(simp) |
|
2038 |
apply(clarify) |
|
2039 |
apply(rule_tac x="v'a" in exI) |
|
2040 |
apply(subst bsimp_ASEQ2) |
|
2041 |
apply (metis Prf_elims(4) append_assoc erase_fuse retrieve.simps(1) retrieve_fuse2) |
|
2042 |
prefer 2 |
|
2043 |
apply(auto) |
|
2044 |
apply(case_tac "x2a") |
|
2045 |
apply(simp) |
|
2046 |
using Prf_elims(1) apply blast |
|
2047 |
apply(simp) |
|
2048 |
apply(case_tac "list") |
|
2049 |
apply(simp) |
|
2050 |
sorry |
|
314 | 2051 |
|
2052 |
||
2053 |
lemma retrieve_XXX: |
|
2054 |
assumes "\<Turnstile> v : erase r" |
|
2055 |
shows "\<exists>v'. \<Turnstile> v' : erase (bsimp r) \<and> retrieve (bsimp r) v' = retrieve r v" |
|
2056 |
using assms |
|
2057 |
apply(induct r arbitrary: v) |
|
2058 |
apply(simp) |
|
2059 |
using Prf_elims(1) apply blast |
|
2060 |
apply(simp) |
|
2061 |
using Prf_elims(4) apply fastforce |
|
2062 |
apply(simp) |
|
2063 |
apply blast |
|
2064 |
apply simp |
|
2065 |
apply(case_tac "r1 = AZERO") |
|
2066 |
apply(simp) |
|
2067 |
apply (meson Prf_elims(1) Prf_elims(2)) |
|
2068 |
apply(case_tac "r2 = AZERO") |
|
2069 |
apply(simp) |
|
2070 |
apply (meson Prf_elims(1) Prf_elims(2)) |
|
2071 |
apply(erule Prf_elims) |
|
2072 |
apply(simp) |
|
2073 |
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs") |
|
2074 |
apply(clarify) |
|
2075 |
apply(simp) |
|
2076 |
apply(subst bsimp_ASEQ2) |
|
2077 |
defer |
|
2078 |
apply(subst bsimp_ASEQ1) |
|
2079 |
using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce |
|
2080 |
using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce |
|
2081 |
apply(simp) |
|
2082 |
apply(simp) |
|
2083 |
apply(drule_tac x="v1" in meta_spec) |
|
2084 |
apply(drule_tac x="v2" in meta_spec) |
|
2085 |
apply(simp) |
|
2086 |
apply(clarify) |
|
2087 |
apply(rule_tac x="Seq v' v'a" in exI) |
|
2088 |
apply(simp) |
|
2089 |
apply (metis Prf.intros(1) Prf_elims(1) bsimp_ASEQ1 erase.simps(1) retrieve.simps(6)) |
|
2090 |
prefer 3 |
|
2091 |
apply(drule_tac x="v1" in meta_spec) |
|
2092 |
apply(drule_tac x="v2" in meta_spec) |
|
2093 |
apply(simp) |
|
2094 |
apply(clarify) |
|
2095 |
apply(rule_tac x="v'a" in exI) |
|
2096 |
apply(subst bsimp_ASEQ2) |
|
2097 |
apply (metis Prf_elims(4) append_assoc erase_fuse retrieve.simps(1) retrieve_fuse2) |
|
2098 |
prefer 2 |
|
2099 |
apply(auto) |
|
2100 |
apply(case_tac "x2a") |
|
2101 |
apply(simp) |
|
2102 |
using Prf_elims(1) apply blast |
|
2103 |
apply(simp) |
|
2104 |
apply(case_tac "list") |
|
2105 |
apply(simp) |
|
2106 |
sorry |
|
2107 |
||
2108 |
||
2109 |
lemma TEST: |
|
2110 |
assumes "\<Turnstile> v : ders s r" |
|
316 | 2111 |
shows "\<exists>v'. retrieve (bders (intern r) s) v' = retrieve (bsimp (bders (intern r) s)) v" |
314 | 2112 |
using assms |
2113 |
apply(induct s arbitrary: r v rule: rev_induct) |
|
2114 |
apply(simp) |
|
316 | 2115 |
|
314 | 2116 |
defer |
2117 |
apply(simp add: ders_append) |
|
2118 |
apply(frule Prf_injval) |
|
2119 |
apply(drule_tac x="r" in meta_spec) |
|
2120 |
apply(drule_tac x="injval (ders xs r) x v" in meta_spec) |
|
2121 |
apply(simp) |
|
2122 |
apply(simp add: bders_append) |
|
2123 |
apply(subst bder_retrieve) |
|
2124 |
apply(simp) |
|
2125 |
apply(simp) |
|
2126 |
thm bder_retrieve |
|
2127 |
thm bmkeps_retrieve |
|
2128 |
||
2129 |
||
2130 |
lemma bmkeps_simp2: |
|
2131 |
assumes "bnullable (bder c r)" |
|
2132 |
shows "bmkeps (bder c (bsimp r)) = bmkeps (bder c r)" |
|
2133 |
using assms |
|
2134 |
apply(induct r) |
|
2135 |
apply(simp) |
|
2136 |
apply(simp) |
|
2137 |
apply(simp) |
|
2138 |
prefer 3 |
|
2139 |
apply(simp) |
|
2140 |
apply(simp) |
|
2141 |
apply(auto)[1] |
|
2142 |
prefer 2 |
|
2143 |
apply(case_tac "r1 = AZERO") |
|
2144 |
apply(simp) |
|
2145 |
apply(case_tac "r2 = AZERO") |
|
2146 |
apply(simp) |
|
2147 |
apply(case_tac "\<exists>bs. (bsimp r1) = AONE bs") |
|
2148 |
apply(clarify) |
|
2149 |
apply(simp) |
|
2150 |
apply(subst bsimp_ASEQ2) |
|
2151 |
||
2152 |
apply(simp add: bmkeps_simp) |
|
2153 |
apply(simp add: bders_append) |
|
2154 |
apply(drule_tac x="bder a r" in meta_spec) |
|
2155 |
apply(simp) |
|
2156 |
apply(simp) |
|
2157 |
apply(simp) |
|
2158 |
prefer 3 |
|
2159 |
apply(simp) |
|
2160 |
prefer 2 |
|
2161 |
apply(simp) |
|
2162 |
apply(case_tac x2a) |
|
2163 |
apply(simp) |
|
2164 |
apply(simp add: ) |
|
2165 |
apply(subst k0) |
|
2166 |
apply(auto)[1] |
|
2167 |
apply(case_tac list) |
|
2168 |
apply(simp) |
|
2169 |
||
2170 |
||
2171 |
apply(case_tac "r1=AZERO") |
|
2172 |
apply(simp) |
|
2173 |
apply(case_tac "r2=AZERO") |
|
2174 |
apply(simp) |
|
2175 |
apply(auto)[1] |
|
2176 |
apply(case_tac "\<exists>bs. r1=AONE bs") |
|
2177 |
apply(simp) |
|
2178 |
apply(auto)[1] |
|
2179 |
apply(subst bsimp_ASEQ2) |
|
2180 |
||
2181 |
||
2182 |
prefer 2 |
|
2183 |
apply(simp) |
|
2184 |
apply(subst bmkeps_bder_AALTs) |
|
2185 |
apply(case_tac x2a) |
|
2186 |
apply(simp) |
|
2187 |
apply(simp) |
|
2188 |
apply(auto)[1] |
|
2189 |
apply(subst bmkeps_bder_AALTs) |
|
2190 |
||
2191 |
apply(case_tac a) |
|
2192 |
apply(simp_all) |
|
2193 |
apply(auto)[1] |
|
2194 |
apply(case_tac list) |
|
2195 |
apply(simp) |
|
2196 |
apply(simp) |
|
2197 |
||
2198 |
prefer 2 |
|
2199 |
apply(simp) |
|
2200 |
||
2201 |
||
2202 |
lemma bbs0: |
|
2203 |
shows "blexer_simp r [] = blexer r []" |
|
2204 |
apply(simp add: blexer_def blexer_simp_def) |
|
2205 |
done |
|
2206 |
||
2207 |
lemma bbs1: |
|
2208 |
shows "blexer_simp r [c] = blexer r [c]" |
|
2209 |
apply(simp add: blexer_def blexer_simp_def) |
|
2210 |
apply(auto) |
|
2211 |
defer |
|
2212 |
using b3 apply auto[1] |
|
2213 |
using b3 apply auto[1] |
|
2214 |
apply(subst bmkeps_simp[symmetric]) |
|
2215 |
apply(simp) |
|
2216 |
apply(simp) |
|
2217 |
done |
|
2218 |
||
2219 |
lemma bbs1: |
|
2220 |
shows "blexer_simp r [c1, c2] = blexer r [c1, c2]" |
|
2221 |
apply(simp add: blexer_def blexer_simp_def) |
|
2222 |
apply(auto) |
|
2223 |
defer |
|
2224 |
apply (metis L_bsimp_erase bnullable_correctness der_correctness erase_bder lexer.simps(1) lexer_correct_None option.distinct(1)) |
|
2225 |
apply (metis L_bsimp_erase bnullable_correctness der_correctness erase_bder lexer.simps(1) lexer_correct_None option.distinct(1)) |
|
2226 |
apply(subst bmkeps_simp[symmetric]) |
|
2227 |
using b3 apply auto[1] |
|
2228 |
apply(subst bmkeps_retrieve) |
|
2229 |
using b3 bnullable_correctness apply blast |
|
2230 |
apply(subst bder_retrieve) |
|
2231 |
using b3 bnullable_correctness mkeps_nullable apply fastforce |
|
2232 |
apply(subst bmkeps_retrieve) |
|
2233 |
using bnullable_correctness apply blast |
|
2234 |
apply(subst bder_retrieve) |
|
2235 |
using bnullable_correctness mkeps_nullable apply force |
|
2236 |
||
2237 |
using bder_retrieve bmkeps_simp bmkeps_retrieve |
|
2238 |
||
2239 |
||
2240 |
||
2241 |
lemma bsimp_retrieve_bder: |
|
2242 |
assumes "\<Turnstile> v : der c (erase r)" |
|
2243 |
shows "retrieve (bder c r) v = retrieve (bsimp (bder c r)) v" |
|
2244 |
thm bder_retrieve bmkeps_simp |
|
2245 |
apply(induct r arbitrary: c v) |
|
2246 |
apply(simp) |
|
2247 |
apply(simp) |
|
2248 |
apply(simp) |
|
2249 |
apply(auto)[1] |
|
2250 |
apply(case_tac "bsimp (bder c r1) = AZERO") |
|
2251 |
apply(simp) |
|
2252 |
||
2253 |
prefer 3 |
|
2254 |
apply(simp) |
|
2255 |
apply(auto elim!: Prf_elims)[1] |
|
2256 |
apply(case_tac "(bsimp (fuse [Z] (bder c r))) = AZERO") |
|
2257 |
apply(simp) |
|
318 | 2258 |
apply (met is L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) erase.simps(1) erase_bder erase_fuse) |
314 | 2259 |
apply(case_tac "\<exists>bs. bsimp (fuse [Z] (bder c r)) = AONE bs") |
2260 |
apply(clarify) |
|
2261 |
apply(subgoal_tac "L (der c (erase r)) = {[]}") |
|
2262 |
prefer 2 |
|
2263 |
apply (metis L.simps(2) L_bsimp_erase erase.simps(2) erase_bder erase_fuse) |
|
2264 |
apply(simp) |
|
2265 |
||
2266 |
||
2267 |
||
2268 |
apply(subst bsimp_ASEQ1) |
|
2269 |
apply(simp) |
|
2270 |
apply(simp) |
|
2271 |
apply(auto)[1] |
|
2272 |
||
2273 |
prefer 2 |
|
2274 |
||
2275 |
||
2276 |
lemma oo: |
|
2277 |
shows "(case (blexer (der c r) s) of None \<Rightarrow> None | Some v \<Rightarrow> Some (injval r c v)) = blexer r (c # s)" |
|
2278 |
apply(simp add: blexer_correctness) |
|
2279 |
done |
|
2280 |
||
2281 |
lemma oo2a: |
|
2282 |
assumes "\<forall>r. bmkeps (bders_simp r s) = bmkeps (bders r s)" "c # s \<in> L r" |
|
2283 |
"bnullable (bders_simp (bsimp (bder c (intern r))) s)" |
|
2284 |
shows "(case (blexer_simp (der c r) s) of None \<Rightarrow> None | Some v \<Rightarrow> Some (injval r c v)) = blexer_simp r (c # s)" |
|
2285 |
using assms |
|
2286 |
apply(simp add: blexer_simp_def) |
|
2287 |
apply(auto split: option.split) |
|
2288 |
apply (metis blexer_correctness blexer_def lexer.simps(2) lexer_correct_None option.simps(4)) |
|
2289 |
prefer 2 |
|
2290 |
apply (metis L_bders_simp L_bsimp_erase Posix1(1) Posix_mkeps bnullable_correctness ders_correctness erase_bder erase_bders erase_intern lexer.simps(1) lexer_correct_None) |
|
2291 |
apply(subst bmkeps_retrieve) |
|
2292 |
using L_bders_simp bnullable_correctness nullable_correctness apply blast |
|
2293 |
||
2294 |
thm bder_retrieve |
|
2295 |
||
2296 |
||
2297 |
apply(subst bder_retrieve[symmetric]) |
|
2298 |
||
2299 |
||
2300 |
||
2301 |
apply(drule_tac x="bsimp (bder c (intern r))" in spec) |
|
2302 |
apply(drule sym) |
|
2303 |
apply(simp) |
|
2304 |
apply(subst blexer_simp_def) |
|
2305 |
apply(case_tac "bnullable (bders_simp (intern (der c r)) s)") |
|
2306 |
apply(simp) |
|
2307 |
apply(auto split: option.split) |
|
2308 |
apply(subst oo) |
|
2309 |
apply(simp) |
|
2310 |
done |
|
2311 |
||
2312 |
||
2313 |
||
2314 |
lemma oo3: |
|
2315 |
assumes "\<forall>r. bders r s = bders_simp r s" |
|
2316 |
shows "blexer_simp r (s @ [c]) = blexer r (s @ [c])" |
|
2317 |
using assms |
|
2318 |
apply(simp (no_asm) add: blexer_simp_def) |
|
2319 |
apply(auto) |
|
2320 |
prefer 2 |
|
2321 |
apply (metis L_bders_simp blexer_def bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1)) |
|
2322 |
apply(simp add: bders_simp_append) |
|
2323 |
apply(subst bmkeps_simp[symmetric]) |
|
2324 |
using b3 apply auto[1] |
|
2325 |
apply(simp add: blexer_def) |
|
2326 |
apply(auto)[1] |
|
2327 |
prefer 2 |
|
2328 |
apply (metis (mono_tags, lifting) L_bders_simp Posix_mkeps append.right_neutral bders_simp.simps(1) bders_simp.simps(2) bders_simp_append bnullable_correctness lexer.simps(1) lexer_correct_None lexer_correctness(1) option.distinct(1)) |
|
2329 |
apply(simp add: bders_append) |
|
2330 |
done |
|
2331 |
||
2332 |
lemma oo4: |
|
2333 |
assumes "\<forall>r. bmkeps (bders r s) = bmkeps (bders_simp r s)" "bnullable (bder c (bders r s))" |
|
2334 |
shows "bmkeps (bders_simp r (s @ [c])) = bmkeps (bders r (s @ [c]))" |
|
2335 |
using assms |
|
2336 |
apply(simp add: bders_simp_append) |
|
2337 |
apply(subst bmkeps_simp[symmetric]) |
|
2338 |
apply (metis L_bders_simp bnullable_correctness der_correctness erase_bder lexer.simps(1) lexer_correct_None option.distinct(1)) |
|
2339 |
apply(simp add: bders_append) |
|
2340 |
done |
|
2341 |
||
2342 |
lemma oo4: |
|
2343 |
shows "blexer_simp r s = blexer r s" |
|
2344 |
apply(induct s arbitrary: r rule: rev_induct) |
|
2345 |
apply(simp only: blexer_simp_def blexer_def) |
|
2346 |
apply(simp) |
|
2347 |
apply(simp only: blexer_simp_def blexer_def) |
|
2348 |
apply(subgoal_tac "bnullable (bders_simp (intern r) (xs @ [x])) = bnullable (bders (intern r) (xs @ [x]))") |
|
2349 |
prefer 2 |
|
2350 |
apply (simp add: b4) |
|
2351 |
apply(simp) |
|
2352 |
apply(rule impI) |
|
2353 |
apply(simp add: bders_simp_append) |
|
2354 |
apply(subst bmkeps_simp[symmetric]) |
|
2355 |
using b3 apply auto[1] |
|
2356 |
apply(subst bmkeps_retrieve) |
|
2357 |
using b3 bnullable_correctness apply blast |
|
2358 |
apply(subst bder_retrieve) |
|
2359 |
using b3 bnullable_correctness mkeps_nullable apply fastforce |
|
2360 |
apply(simp add: bders_append) |
|
2361 |
apply(subst bmkeps_retrieve) |
|
2362 |
using bnullable_correctness apply blast |
|
2363 |
apply(subst bder_retrieve) |
|
2364 |
using bnullable_correctness mkeps_nullable apply fastforce |
|
2365 |
apply(subst erase_bder) |
|
2366 |
apply(case_tac "xs \<in> L") |
|
2367 |
apply(subst (asm) (2) bmkeps_retrieve) |
|
2368 |
||
2369 |
||
2370 |
thm bmkeps_retrieve bmkeps_retrieve |
|
2371 |
apply(subst bmkeps_retrieve[symmetric]) |
|
2372 |
||
2373 |
apply (simp add: bnullable_correctness) |
|
2374 |
apply(simp add: bders_simp_append) |
|
2375 |
||
2376 |
||
2377 |
apply(induct s arbitrary: r rule: rev_induct) |
|
2378 |
apply(simp add: blexer_def blexer_simp_def) |
|
2379 |
apply(rule oo3) |
|
2380 |
apply(simp (no_asm) add: blexer_simp_def) |
|
2381 |
apply(auto) |
|
2382 |
prefer 2 |
|
2383 |
apply (metis L_bders_simp blexer_def bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1)) |
|
2384 |
apply(simp add: bders_simp_append) |
|
2385 |
apply(subst bmkeps_simp[symmetric]) |
|
2386 |
using b3 apply auto[1] |
|
2387 |
apply(simp add: blexer_def) |
|
2388 |
apply(auto)[1] |
|
2389 |
prefer 2 |
|
2390 |
apply (m etis (mono_tags, lifting) L_bders_simp Posix_mkeps append.right_neutral bders_simp.simps(1) bders_simp.simps(2) bders_simp_append bnullable_correctness lexer.simps(1) lexer_correct_None lexer_correctness(1) option.distinct(1)) |
|
2391 |
apply(simp add: bders_append) |
|
2392 |
oops |
|
2393 |
||
2394 |
||
2395 |
lemma bnullable_simp: |
|
2396 |
assumes "s \<in> L (erase r)" |
|
2397 |
shows "bmkeps (bders r s) = bmkeps (bders_simp r s)" |
|
2398 |
using assms |
|
2399 |
apply(induct s arbitrary: r rule: rev_induct) |
|
2400 |
apply(simp) |
|
2401 |
apply(simp add: bders_append bders_simp_append) |
|
2402 |
apply(subst bmkeps_simp[symmetric]) |
|
2403 |
apply (metis L_bders_simp b3 bders_simp.simps(1) bders_simp.simps(2) bders_simp_append blexer_correctness blexer_def bnullable_correctness erase_bders erase_intern lexer.simps(1) lexer_correct_None lexer_correct_Some lexer_correctness(1)) |
|
2404 |
apply(subst bmkeps_retrieve) |
|
2405 |
apply (metis bders.simps(1) bders.simps(2) bders_append blexer_correctness blexer_def bnullable_correctness erase_bders erase_intern lexer_correct_Some option.distinct(1)) |
|
2406 |
apply(subst bmkeps_retrieve) |
|
2407 |
apply (metis L_bders_simp L_bsimp_erase Posix_mkeps bders_simp.simps(1) bders_simp.simps(2) bders_simp_append blexer_correctness blexer_def bnullable_correctness erase_bders erase_intern lexer.simps(1) lexer_correct_None lexer_correctness(2)) |
|
2408 |
apply(subst bder_retrieve) |
|
2409 |
apply (metis bders.simps(1) bders.simps(2) bders_append blexer_correctness blexer_def bnullable_correctness erase_bder erase_bders erase_intern lexer_correct_Some mkeps_nullable option.distinct(1)) |
|
2410 |
apply(subst bder_retrieve) |
|
2411 |
apply (metis L_bders_simp L_bsimp_erase Posix_mkeps bders_simp.simps(1) bders_simp.simps(2) bders_simp_append blexer_correctness blexer_def bnullable_correctness erase_bder erase_bders erase_intern lexer.simps(1) lexer_correct_None lexer_correctness(2) mkeps_nullable) |
|
2412 |
||
2413 |
apply(drule_tac x="bder a r" in meta_spec) |
|
2414 |
apply(drule_tac meta_mp) |
|
2415 |
apply (me tis erase_bder lexer.simps(2) lexer_correct_None option.simps(4)) |
|
2416 |
apply(simp) |
|
2417 |
oops |
|
2418 |
||
2419 |
||
2420 |
lemma |
|
2421 |
shows "blexer r s = blexer_simp r s" |
|
2422 |
apply(induct s arbitrary: r rule: rev_induct) |
|
2423 |
apply(simp add: blexer_def blexer_simp_def) |
|
2424 |
apply(case_tac "xs @ [x] \<in> L r") |
|
2425 |
defer |
|
2426 |
apply(subgoal_tac "blexer (ders xs r) [x] = None") |
|
2427 |
prefer 2 |
|
2428 |
apply(subst blexer_correctness) |
|
2429 |
apply(simp (no_asm) add: lexer_correct_None) |
|
2430 |
apply(simp add: nullable_correctness) |
|
2431 |
apply(simp add: der_correctness ders_correctness) |
|
2432 |
apply(simp add: Der_def Ders_def) |
|
2433 |
apply(subgoal_tac "blexer r (xs @ [x]) = None") |
|
2434 |
prefer 2 |
|
2435 |
apply (simp add: blexer_correctness) |
|
2436 |
using lexer_correct_None apply auto[1] |
|
2437 |
apply(simp) |
|
2438 |
apply(subgoal_tac "blexer_simp (ders xs r) [x] = None") |
|
2439 |
prefer 2 |
|
2440 |
apply (metis L_bders_simp Posix_injval Posix_mkeps bders.simps(2) blexer_correctness blexer_simp_def bnullable_correctness ders.simps(1) erase_bder erase_bders erase_intern lexer_correct_None lexer_correctness(2)) |
|
2441 |
apply(subgoal_tac "[] \<notin> L (erase (bders_simp (intern r) (xs @ [x])))") |
|
2442 |
prefer 2 |
|
2443 |
apply(metis L_bders_simp Posix_injval bders.simps(2) blexer_correctness ders.simps(1) ders_append erase_bder erase_bders erase_intern lexer_correct_None lexer_correctness(2)) |
|
2444 |
using blexer_simp_def bnullable_correctness lexer_correct_None apply auto[1] |
|
2445 |
(* case xs @ [x] \<in> L r *) |
|
2446 |
apply(subgoal_tac "\<exists>v. blexer (ders xs r) [x] = Some v \<and> [x] \<in> (ders xs r) \<rightarrow> v") |
|
2447 |
prefer 2 |
|
2448 |
using blexer_correctness lexer_correct_Some apply auto[1] |
|
2449 |
apply (simp add: Posix_injval Posix_mkeps) |
|
2450 |
apply (metis ders.simps(1) ders.simps(2) ders_append lexer_correct_None lexer_flex) |
|
2451 |
apply(clarify) |
|
2452 |
apply(subgoal_tac "blexer_simp (ders xs r) [x] = Some v") |
|
2453 |
prefer 2 |
|
2454 |
apply(simp add: blexer_simp_def) |
|
2455 |
apply(auto)[1] |
|
2456 |
apply (metis bders.simps(1) bders.simps(2) blexer_def bmkeps_simp option.simps(3)) |
|
2457 |
using b3 blexer_def apply fastforce |
|
2458 |
apply(subgoal_tac "blexer_simp (ders xs r) [x] = blexer_simp r (xs @ [x])") |
|
2459 |
prefer 2 |
|
2460 |
apply(simp add: blexer_simp_def) |
|
2461 |
||
2462 |
apply(simp) |
|
2463 |
||
2464 |
||
2465 |
||
2466 |
apply(simp) |
|
2467 |
apply(subst blexer_simp_def) |
|
2468 |
apply(simp) |
|
2469 |
apply(auto) |
|
2470 |
apply(drule_tac x="der a r" in meta_spec) |
|
2471 |
apply(subst blexer_def) |
|
2472 |
apply(subgoal_tac "bnullable (bders (intern r) (a # s))") |
|
2473 |
prefer 2 |
|
318 | 2474 |
apply (me tis Posix_injval blexer_correctness blexer_def lexer_correctness(2)) |
314 | 2475 |
apply(simp) |
2476 |
||
2477 |
||
2478 |
||
2479 |
lemma |
|
2480 |
shows "blexer r s = blexer_simp r s" |
|
2481 |
apply(induct s arbitrary: r) |
|
2482 |
apply(simp add: blexer_def blexer_simp_def) |
|
2483 |
apply(case_tac "s \<in> L (der a r)") |
|
2484 |
defer |
|
2485 |
apply(subgoal_tac "blexer (der a r) s = None") |
|
2486 |
prefer 2 |
|
2487 |
apply (simp add: blexer_correctness lexer_correct_None) |
|
2488 |
apply(subgoal_tac "blexer r (a # s) = None") |
|
2489 |
prefer 2 |
|
2490 |
apply (simp add: blexer_correctness) |
|
2491 |
apply(simp) |
|
2492 |
||
2493 |
apply(subst blexer_simp_def) |
|
2494 |
apply(simp) |
|
2495 |
apply(drule_tac x="der a r" in meta_spec) |
|
2496 |
apply(subgoal_tac "s \<notin> L(erase (bder a (intern r)))") |
|
2497 |
prefer 2 |
|
2498 |
apply simp |
|
2499 |
||
2500 |
apply(simp only:) |
|
2501 |
apply(subst blexer_simp_def) |
|
2502 |
apply(subgoal_tac "\<not> bnullable (bders_simp (intern r) (a # s))") |
|
2503 |
apply(simp) |
|
2504 |
apply(subst bnullable_correctness[symmetric]) |
|
2505 |
apply(simp) |
|
318 | 2506 |
oops |
2507 |
||
2508 |
||
2509 |
lemma flts_bsimp: |
|
2510 |
"flts (map bsimp rs) = map bsimp (flts rs)" |
|
2511 |
apply(induct rs taking: size rule: measure_induct) |
|
2512 |
apply(case_tac x) |
|
2513 |
apply(simp) |
|
2514 |
apply(simp) |
|
2515 |
apply(induct rs rule: flts.induct) |
|
2516 |
apply(simp) |
|
2517 |
apply(simp) |
|
2518 |
defer |
|
2519 |
apply(simp) |
|
2520 |
apply(simp) |
|
2521 |
defer |
|
2522 |
apply(simp) |
|
2523 |
apply(subst List.list.map(2)) |
|
2524 |
apply(simp only: flts.simps) |
|
2525 |
apply(subst k0) |
|
2526 |
apply(subst map_append) |
|
2527 |
apply(simp only:) |
|
2528 |
apply(simp del: bsimp.simps) |
|
2529 |
apply(case_tac rs1) |
|
2530 |
apply(simp) |
|
2531 |
apply(simp) |
|
2532 |
apply(case_tac list) |
|
2533 |
apply(simp_all) |
|
2534 |
thm map |
|
2535 |
apply(subst map.simps) |
|
2536 |
apply(auto) |
|
2537 |
defer |
|
2538 |
apply(case_tac "(bsimp va) = AZERO") |
|
2539 |
apply(simp) |
|
2540 |
||
2541 |
using b3 apply for ce |
|
2542 |
apply(case_tac "(bsimp a2) = AZERO") |
|
2543 |
apply(simp) |
|
2544 |
apply (me tis bder.simps(1) bsimp.simps(3) bsimp_AALTs.simps(1) bsimp_ASEQ0 bsimp_fuse flts.simps(1) flts.simps(2) fuse.simps(1)) |
|
2545 |
apply(case_tac "\<exists>bs. (bsimp a1) = AONE bs") |
|
2546 |
apply(clarify) |
|
2547 |
apply(simp) |
|
2548 |
||
2549 |
||
2550 |
lemma XXX: |
|
2551 |
shows "bsimp (bsimp a) = bsimp a" |
|
2552 |
sorry |
|
2553 |
||
2554 |
lemma bder_fuse: |
|
2555 |
shows "bder c (fuse bs a) = fuse bs (bder c a)" |
|
2556 |
apply(induct a arbitrary: bs c) |
|
2557 |
apply(simp_all) |
|
2558 |
done |
|
2559 |
||
2560 |
lemma XXX2: |
|
2561 |
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)" |
|
2562 |
apply(induct a arbitrary: c) |
|
2563 |
apply(simp) |
|
2564 |
apply(simp) |
|
2565 |
apply(simp) |
|
2566 |
prefer 3 |
|
2567 |
apply(simp) |
|
2568 |
apply(auto)[1] |
|
2569 |
apply(case_tac "(bsimp a1) = AZERO") |
|
2570 |
apply(simp) |
|
2571 |
using b3 apply force |
|
2572 |
apply(case_tac "(bsimp a2) = AZERO") |
|
2573 |
apply(simp) |
|
2574 |
apply (metis bder.simps(1) bsimp.simps(3) bsimp_AALTs.simps(1) bsimp_ASEQ0 bsimp_fuse flts.simps(1) flts.simps(2) fuse.simps(1)) |
|
2575 |
apply(case_tac "\<exists>bs. (bsimp a1) = AONE bs") |
|
2576 |
apply(clarify) |
|
2577 |
apply(simp) |
|
2578 |
apply(subst bsimp_ASEQ2) |
|
2579 |
apply(subgoal_tac "bmkeps a1 = bs") |
|
2580 |
prefer 2 |
|
2581 |
apply (simp add: bmkeps_simp) |
|
2582 |
apply(simp) |
|
2583 |
apply(subst (1) bsimp_fuse[symmetric]) |
|
2584 |
defer |
|
2585 |
apply(subst bsimp_ASEQ1) |
|
2586 |
apply(simp) |
|
2587 |
apply(simp) |
|
2588 |
apply(simp) |
|
2589 |
apply(auto)[1] |
|
2590 |
apply (metis XXX bmkeps_simp bsimp_fuse) |
|
2591 |
using b3 apply blast |
|
2592 |
apply (smt XXX b3 bder.simps(1) bder.simps(5) bnullable.simps(2) bsimp.simps(1) bsimp_ASEQ.simps(1) bsimp_ASEQ0 bsimp_ASEQ1) |
|
2593 |
apply(simp) |
|
2594 |
prefer 2 |
|
2595 |
apply(subst bder_fuse) |
|
2596 |
apply(subst bsimp_fuse[symmetric]) |
|
2597 |
apply(simp) |
|
2598 |
sorry |
|
2599 |
||
2600 |
||
2601 |
thm bsimp_AALTs.simps |
|
2602 |
thm bsimp.simps |
|
2603 |
thm flts.simps |
|
2604 |
||
2605 |
lemma XXX3: |
|
2606 |
"bsimp (bders (bsimp r) s) = bsimp (bders r s)" |
|
2607 |
apply(induct s arbitrary: r rule: rev_induct) |
|
2608 |
apply(simp) |
|
2609 |
apply (simp add: XXX) |
|
2610 |
apply(simp add: bders_append) |
|
2611 |
apply(subst (2) XXX2[symmetric]) |
|
2612 |
apply(subst XXX2[symmetric]) |
|
2613 |
apply(drule_tac x="r" in meta_spec) |
|
2614 |
apply(simp) |
|
2615 |
done |
|
2616 |
||
2617 |
lemma XXX4: |
|
2618 |
"bders_simp (bsimp r) s = bsimp (bders r s)" |
|
2619 |
apply(induct s arbitrary: r) |
|
2620 |
apply(simp) |
|
2621 |
apply(simp) |
|
2622 |
by (metis XXX2) |
|
2623 |
||
2624 |
||
2625 |
lemma |
|
2626 |
assumes "bnullable (bder c r)" "bnullable (bder c (bsimp r))" |
|
2627 |
shows "bmkeps (bder c r) = bmkeps (bder c (bsimp r))" |
|
2628 |
using assms |
|
2629 |
apply(induct r arbitrary: c) |
|
2630 |
apply(simp) |
|
2631 |
apply(simp) |
|
2632 |
apply(simp) |
|
2633 |
prefer 3 |
|
2634 |
apply(simp) |
|
2635 |
apply(auto)[1] |
|
2636 |
apply(case_tac "(bsimp r1) = AZERO") |
|
2637 |
apply(simp) |
|
2638 |
apply(case_tac "(bsimp r2) = AZERO") |
|
2639 |
apply(simp) |
|
2640 |
apply (simp add: bsimp_ASEQ0) |
|
2641 |
apply(case_tac "\<exists>bs. (bsimp r1) = AONE bs") |
|
2642 |
apply(clarify) |
|
2643 |
apply(simp) |
|
2644 |
apply(subgoal_tac "bnullable r1") |
|
2645 |
prefer 2 |
|
2646 |
using b3 apply force |
|
2647 |
apply(simp) |
|
2648 |
apply(simp add: bsimp_ASEQ2) |
|
2649 |
prefer 2 |
|
2650 |
||
2651 |
||
2652 |
||
2653 |
apply(subst bsimp_ASEQ2) |
|
2654 |
||
2655 |
||
2656 |
||
2657 |
||
2658 |
||
2659 |
||
2660 |
lemma |
|
2661 |
assumes "bnullable (bders a (s1 @ s2))" "bnullable (bders (bsimp (bders a s1)) s2)" |
|
2662 |
shows "bmkeps (bders a (s1 @ s2)) = bmkeps (bders (bsimp (bders a s1)) s2)" |
|
2663 |
using assms |
|
2664 |
apply(induct s2 arbitrary: a s1) |
|
2665 |
apply(simp) |
|
2666 |
using bmkeps_simp apply blast |
|
2667 |
apply(simp add: bders_append) |
|
2668 |
apply(drule_tac x="aa" in meta_spec) |
|
2669 |
apply(drule_tac x="s1 @ [a]" in meta_spec) |
|
2670 |
apply(drule meta_mp) |
|
2671 |
apply(simp add: bders_append) |
|
2672 |
apply(simp add: bders_append) |
|
2673 |
apply(drule meta_mp) |
|
2674 |
apply (metis b4 bders.simps(2) bders_simp.simps(2)) |
|
2675 |
apply(simp) |
|
2676 |
||
2677 |
apply (met is b4 bders.simps(2) bders_simp.simps(2)) |
|
2678 |
||
2679 |
||
2680 |
||
2681 |
using b3 apply blast |
|
2682 |
using b3 apply auto[1] |
|
2683 |
apply(auto simp add: blex_def) |
|
2684 |
prefer 3 |
|
2685 |
||
2686 |
||
314 | 2687 |
|
2688 |
||
295 | 2689 |
|
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2690 |
end |