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