author | Christian Urban <urbanc@in.tum.de> |
Sat, 23 Feb 2019 21:52:06 +0000 | |
changeset 313 | 3b8e3a156200 |
parent 311 | 8b8db9558ecf |
child 314 | 20a57552d722 |
permissions | -rw-r--r-- |
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
|
311 | 2 |
theory BitCoded |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
3 |
imports "Lexer" |
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
begin |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
6 |
section {* Bit-Encodings *} |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
7 |
|
289 | 8 |
datatype bit = Z | S |
9 |
||
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
10 |
fun |
289 | 11 |
code :: "val \<Rightarrow> bit list" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
12 |
where |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
13 |
"code Void = []" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
14 |
| "code (Char c) = []" |
289 | 15 |
| "code (Left v) = Z # (code v)" |
16 |
| "code (Right v) = S # (code v)" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
17 |
| "code (Seq v1 v2) = (code v1) @ (code v2)" |
289 | 18 |
| "code (Stars []) = [S]" |
19 |
| "code (Stars (v # vs)) = (Z # code v) @ code (Stars vs)" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
20 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
21 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
22 |
fun |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
23 |
Stars_add :: "val \<Rightarrow> val \<Rightarrow> val" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
24 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
25 |
"Stars_add v (Stars vs) = Stars (v # vs)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
26 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
27 |
function |
289 | 28 |
decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
29 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
30 |
"decode' ds ZERO = (Void, [])" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
31 |
| "decode' ds ONE = (Void, ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
32 |
| "decode' ds (CHAR d) = (Char d, ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
33 |
| "decode' [] (ALT r1 r2) = (Void, [])" |
289 | 34 |
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))" |
35 |
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))" |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
36 |
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
37 |
let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
38 |
| "decode' [] (STAR r) = (Void, [])" |
289 | 39 |
| "decode' (S # ds) (STAR r) = (Stars [], ds)" |
40 |
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
41 |
let (vs, ds'') = decode' ds' (STAR r) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
42 |
in (Stars_add v vs, ds''))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
43 |
by pat_completeness auto |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
44 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
45 |
lemma decode'_smaller: |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
46 |
assumes "decode'_dom (ds, r)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
47 |
shows "length (snd (decode' ds r)) \<le> length ds" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
48 |
using assms |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
49 |
apply(induct ds r) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
50 |
apply(auto simp add: decode'.psimps split: prod.split) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
51 |
using dual_order.trans apply blast |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
52 |
by (meson dual_order.trans le_SucI) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
53 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
54 |
termination "decode'" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
55 |
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
56 |
apply(auto dest!: decode'_smaller) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
57 |
by (metis less_Suc_eq_le snd_conv) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
58 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
59 |
definition |
289 | 60 |
decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
61 |
where |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
62 |
"decode ds r \<equiv> (let (v, ds') = decode' ds r |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
63 |
in (if ds' = [] then Some v else None))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
64 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
65 |
lemma decode'_code_Stars: |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
66 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
67 |
shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
68 |
using assms |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
69 |
apply(induct vs) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
70 |
apply(auto) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
71 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
72 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
73 |
lemma decode'_code: |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
74 |
assumes "\<Turnstile> v : r" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
75 |
shows "decode' ((code v) @ ds) r = (v, ds)" |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
76 |
using assms |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
77 |
apply(induct v r arbitrary: ds) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
78 |
apply(auto) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
79 |
using decode'_code_Stars by blast |
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
80 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
81 |
lemma decode_code: |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
82 |
assumes "\<Turnstile> v : r" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
83 |
shows "decode (code v) r = Some v" |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
84 |
using assms unfolding decode_def |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
85 |
by (smt append_Nil2 decode'_code old.prod.case) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
86 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
87 |
|
311 | 88 |
section {* Annotated Regular Expressions *} |
89 |
||
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
90 |
datatype arexp = |
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 |
||
101 |
||
289 | 102 |
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
|
103 |
"fuse bs AZERO = AZERO" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
104 |
| "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
|
105 |
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c" |
311 | 106 |
| "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
|
107 |
| "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
|
108 |
| "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
|
109 |
|
289 | 110 |
fun intern :: "rexp \<Rightarrow> arexp" where |
111 |
"intern ZERO = AZERO" |
|
112 |
| "intern ONE = AONE []" |
|
113 |
| "intern (CHAR c) = ACHAR [] c" |
|
114 |
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1)) |
|
295 | 115 |
(fuse [S] (intern r2))" |
289 | 116 |
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)" |
117 |
| "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
|
118 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
119 |
|
289 | 120 |
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
|
121 |
"retrieve (AONE bs) Void = bs" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
122 |
| "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
|
123 |
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v" |
311 | 124 |
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v" |
125 |
| "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
|
126 |
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2" |
289 | 127 |
| "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
|
128 |
| "retrieve (ASTAR bs r) (Stars (v#vs)) = |
289 | 129 |
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
|
130 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
131 |
fun |
289 | 132 |
erase :: "arexp \<Rightarrow> rexp" |
133 |
where |
|
134 |
"erase AZERO = ZERO" |
|
135 |
| "erase (AONE _) = ONE" |
|
136 |
| "erase (ACHAR _ c) = CHAR c" |
|
311 | 137 |
| "erase (AALTs _ []) = ZERO" |
138 |
| "erase (AALTs _ [r]) = (erase r)" |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
139 |
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))" |
289 | 140 |
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)" |
141 |
| "erase (ASTAR _ r) = STAR (erase r)" |
|
142 |
||
143 |
fun |
|
144 |
bnullable :: "arexp \<Rightarrow> bool" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
145 |
where |
289 | 146 |
"bnullable (AZERO) = False" |
147 |
| "bnullable (AONE bs) = True" |
|
148 |
| "bnullable (ACHAR bs c) = False" |
|
311 | 149 |
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)" |
289 | 150 |
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)" |
151 |
| "bnullable (ASTAR bs r) = True" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
152 |
|
289 | 153 |
fun |
154 |
bmkeps :: "arexp \<Rightarrow> bit list" |
|
155 |
where |
|
156 |
"bmkeps(AONE bs) = bs" |
|
157 |
| "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
|
158 |
| "bmkeps(AALTs bs [r]) = bs @ (bmkeps r)" |
311 | 159 |
| "bmkeps(AALTs bs (r#rs)) = (if bnullable(r) then bs @ (bmkeps r) else (bmkeps (AALTs bs rs)))" |
289 | 160 |
| "bmkeps(ASTAR bs r) = bs @ [S]" |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
161 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
162 |
|
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
163 |
fun |
289 | 164 |
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
|
165 |
where |
289 | 166 |
"bder c (AZERO) = AZERO" |
167 |
| "bder c (AONE bs) = AZERO" |
|
168 |
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)" |
|
311 | 169 |
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)" |
289 | 170 |
| "bder c (ASEQ bs r1 r2) = |
171 |
(if bnullable r1 |
|
172 |
then AALT bs (ASEQ [] (bder c r1) r2) (fuse (bmkeps r1) (bder c r2)) |
|
173 |
else ASEQ bs (bder c r1) r2)" |
|
174 |
| "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
|
175 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
176 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
177 |
fun |
289 | 178 |
bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp" |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
179 |
where |
289 | 180 |
"bders r [] = r" |
181 |
| "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
|
182 |
|
289 | 183 |
lemma bders_append: |
184 |
"bders r (s1 @ s2) = bders (bders r s1) s2" |
|
287 | 185 |
apply(induct s1 arbitrary: r s2) |
186 |
apply(simp_all) |
|
187 |
done |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
188 |
|
289 | 189 |
lemma bnullable_correctness: |
190 |
shows "nullable (erase r) = bnullable r" |
|
311 | 191 |
apply(induct r rule: erase.induct) |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
192 |
apply(simp_all) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
193 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
194 |
|
289 | 195 |
lemma erase_fuse: |
196 |
shows "erase (fuse bs r) = erase r" |
|
311 | 197 |
apply(induct r rule: erase.induct) |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
198 |
apply(simp_all) |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
199 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
200 |
|
311 | 201 |
lemma erase_intern [simp]: |
289 | 202 |
shows "erase (intern r) = r" |
287 | 203 |
apply(induct r) |
289 | 204 |
apply(simp_all add: erase_fuse) |
287 | 205 |
done |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
206 |
|
311 | 207 |
lemma erase_bder [simp]: |
289 | 208 |
shows "erase (bder a r) = der a (erase r)" |
311 | 209 |
apply(induct r rule: erase.induct) |
289 | 210 |
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
|
211 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
212 |
|
311 | 213 |
lemma erase_bders [simp]: |
289 | 214 |
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
|
215 |
apply(induct s arbitrary: r ) |
289 | 216 |
apply(simp_all) |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
217 |
done |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
218 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
219 |
lemma retrieve_encode_STARS: |
289 | 220 |
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v" |
221 |
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
|
222 |
using assms |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
223 |
apply(induct vs) |
289 | 224 |
apply(simp_all) |
225 |
done |
|
226 |
||
227 |
lemma retrieve_fuse2: |
|
228 |
assumes "\<Turnstile> v : (erase r)" |
|
229 |
shows "retrieve (fuse bs r) v = bs @ retrieve r v" |
|
230 |
using assms |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
231 |
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
|
232 |
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
|
233 |
defer |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
234 |
using retrieve_encode_STARS |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
235 |
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
|
236 |
apply(case_tac vs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
237 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
238 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
239 |
(* AALTs case *) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
240 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
241 |
apply(case_tac x2a) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
242 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
243 |
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
|
244 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
245 |
apply(case_tac list) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
246 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
247 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
248 |
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
|
249 |
done |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
250 |
|
289 | 251 |
lemma retrieve_fuse: |
252 |
assumes "\<Turnstile> v : r" |
|
253 |
shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v" |
|
254 |
using assms |
|
255 |
by (simp_all add: retrieve_fuse2) |
|
256 |
||
257 |
||
258 |
lemma retrieve_code: |
|
259 |
assumes "\<Turnstile> v : r" |
|
260 |
shows "code v = retrieve (intern r) v" |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
261 |
using assms |
311 | 262 |
apply(induct v r ) |
289 | 263 |
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
|
264 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
265 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
266 |
lemma r: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
267 |
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
|
268 |
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
|
269 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
270 |
apply(induct rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
271 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
272 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
273 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
274 |
lemma r0: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
275 |
assumes "bnullable a" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
276 |
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
|
277 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
278 |
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
|
279 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
280 |
lemma r1: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
281 |
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
|
282 |
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
|
283 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
284 |
apply(induct rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
285 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
286 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
287 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
288 |
lemma r2: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
289 |
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
|
290 |
shows "bnullable (AALTs bs rs)" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
291 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
292 |
apply(induct rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
293 |
apply(auto) |
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 |
|
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
296 |
lemma r3: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
297 |
assumes "\<not> bnullable r" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
298 |
" \<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
|
299 |
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
|
300 |
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
|
301 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
302 |
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
|
303 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
304 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
305 |
using bnullable_correctness apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
306 |
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
|
307 |
apply(subst retrieve_fuse2[symmetric]) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
308 |
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
|
309 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
310 |
apply(case_tac "bnullable a") |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
315 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
316 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
317 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
318 |
apply(subst retrieve_fuse2[symmetric]) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
319 |
apply(case_tac rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
320 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
321 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
322 |
apply (simp add: bnullable_correctness) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
323 |
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
|
324 |
apply (simp add: bnullable_correctness) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
325 |
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
|
326 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
327 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
328 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
329 |
|
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
330 |
lemma t: |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
331 |
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
|
332 |
"nullable (erase (AALTs bs rs))" |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
333 |
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
|
334 |
using assms |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
335 |
apply(induct rs arbitrary: bs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
336 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
337 |
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
|
338 |
apply(case_tac rs) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
339 |
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
|
340 |
apply(subst r1) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
341 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
342 |
apply(rule r2) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
343 |
apply(assumption) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
344 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
345 |
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
|
346 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
347 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
348 |
prefer 2 |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
349 |
apply(case_tac "bnullable a") |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
350 |
apply(subst r0) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
351 |
apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
352 |
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
|
353 |
prefer 2 |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
354 |
using bnullable_correctness apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
355 |
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
|
356 |
apply(subst r1) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
357 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
358 |
using r2 apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
359 |
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
|
360 |
apply(drule meta_mp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
361 |
apply(auto)[1] |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
362 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
363 |
using r3 apply blast |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
364 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
365 |
using r3 by blast |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
366 |
|
289 | 367 |
lemma bmkeps_retrieve: |
368 |
assumes "nullable (erase r)" |
|
369 |
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
|
370 |
using assms |
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
371 |
apply(induct r) |
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
372 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
373 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
374 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
375 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
376 |
defer |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
377 |
apply(simp) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
378 |
apply(rule t) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
379 |
apply(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
380 |
done |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
381 |
|
289 | 382 |
lemma bder_retrieve: |
383 |
assumes "\<Turnstile> v : der c (erase r)" |
|
384 |
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
|
385 |
using assms |
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
386 |
apply(induct r arbitrary: v rule: erase.induct) |
289 | 387 |
apply(auto elim!: Prf_elims simp add: retrieve_fuse2 bnullable_correctness bmkeps_retrieve) |
313
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
388 |
apply(case_tac va) |
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(auto) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
391 |
by (smt Prf_elims(3) injval.simps(2) injval.simps(3) retrieve.simps(4) retrieve.simps(5) same_append_eq) |
3b8e3a156200
adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
392 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
393 |
|
289 | 394 |
lemma MAIN_decode: |
395 |
assumes "\<Turnstile> v : ders s r" |
|
396 |
shows "Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" |
|
397 |
using assms |
|
398 |
proof (induct s arbitrary: v rule: rev_induct) |
|
399 |
case Nil |
|
400 |
have "\<Turnstile> v : ders [] r" by fact |
|
401 |
then have "\<Turnstile> v : r" by simp |
|
402 |
then have "Some v = decode (retrieve (intern r) v) r" |
|
403 |
using decode_code retrieve_code by auto |
|
404 |
then show "Some (flex r id [] v) = decode (retrieve (bders (intern r) []) v) r" |
|
405 |
by simp |
|
406 |
next |
|
407 |
case (snoc c s v) |
|
408 |
have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> |
|
409 |
Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" by fact |
|
410 |
have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact |
|
411 |
then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" |
|
412 |
by(simp add: Prf_injval ders_append) |
|
413 |
have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))" |
|
414 |
by (simp add: flex_append) |
|
415 |
also have "... = decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r" |
|
416 |
using asm2 IH by simp |
|
417 |
also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r" |
|
418 |
using asm by(simp_all add: bder_retrieve ders_append) |
|
419 |
finally show "Some (flex r id (s @ [c]) v) = |
|
420 |
decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append) |
|
421 |
qed |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
422 |
|
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
423 |
|
289 | 424 |
definition blexer where |
425 |
"blexer r s \<equiv> if bnullable (bders (intern r) s) then |
|
426 |
decode (bmkeps (bders (intern r) s)) r else None" |
|
427 |
||
428 |
lemma blexer_correctness: |
|
429 |
shows "blexer r s = lexer r s" |
|
430 |
proof - |
|
431 |
{ define bds where "bds \<equiv> bders (intern r) s" |
|
432 |
define ds where "ds \<equiv> ders s r" |
|
433 |
assume asm: "nullable ds" |
|
434 |
have era: "erase bds = ds" |
|
435 |
unfolding ds_def bds_def by simp |
|
436 |
have mke: "\<Turnstile> mkeps ds : ds" |
|
437 |
using asm by (simp add: mkeps_nullable) |
|
438 |
have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r" |
|
439 |
using bmkeps_retrieve |
|
440 |
using asm era by (simp add: bmkeps_retrieve) |
|
441 |
also have "... = Some (flex r id s (mkeps ds))" |
|
442 |
using mke by (simp_all add: MAIN_decode ds_def bds_def) |
|
443 |
finally have "decode (bmkeps bds) r = Some (flex r id s (mkeps ds))" |
|
444 |
unfolding bds_def ds_def . |
|
445 |
} |
|
446 |
then show "blexer r s = lexer r s" |
|
447 |
unfolding blexer_def lexer_flex |
|
293 | 448 |
apply(subst bnullable_correctness[symmetric]) |
449 |
apply(simp) |
|
450 |
done |
|
289 | 451 |
qed |
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
256
diff
changeset
|
452 |
|
295 | 453 |
|
454 |
||
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
455 |
end |