author | cu |
Tue, 10 Oct 2017 10:40:44 +0100 | |
changeset 278 | 424bdcd01016 |
parent 277 | 42268a284ea6 |
child 397 | e1b74d618f1b |
permissions | -rw-r--r-- |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
|
220 | 2 |
theory LexerExt |
276 | 3 |
imports SpecExt |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
begin |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
276 | 7 |
section {* The Lexer Functions by Sulzmann and Lu *} |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
mkeps :: "rexp \<Rightarrow> val" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
12 |
"mkeps(ONE) = Void" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)" |
276 | 14 |
| "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))" |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
15 |
| "mkeps(STAR r) = Stars []" |
220 | 16 |
| "mkeps(UPNTIMES r n) = Stars []" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
17 |
| "mkeps(NTIMES r n) = Stars (replicate n (mkeps r))" |
223 | 18 |
| "mkeps(FROMNTIMES r n) = Stars (replicate n (mkeps r))" |
227 | 19 |
| "mkeps(NMTIMES r n m) = Stars (replicate n (mkeps r))" |
276 | 20 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
where |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
23 |
"injval (CHAR d) c Void = Char d" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
| "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
| "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)" |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
29 |
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
276 | 30 |
| "injval (NTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
31 |
| "injval (FROMNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
|
32 |
| "injval (UPNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
|
33 |
| "injval (NMTIMES r n m) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
|
34 |
||
35 |
fun |
|
36 |
lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option" |
|
37 |
where |
|
38 |
"lexer r [] = (if nullable r then Some(mkeps r) else None)" |
|
39 |
| "lexer r (c#s) = (case (lexer (der c r) s) of |
|
40 |
None \<Rightarrow> None |
|
41 |
| Some(v) \<Rightarrow> Some(injval r c v))" |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
42 |
|
276 | 43 |
|
44 |
||
45 |
section {* Mkeps, Injval Properties *} |
|
243 | 46 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
lemma mkeps_flat: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
assumes "nullable(r)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
shows "flat (mkeps r) = []" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
using assms |
276 | 51 |
apply(induct rule: nullable.induct) |
52 |
apply(auto) |
|
53 |
by presburger |
|
54 |
||
55 |
||
56 |
lemma mkeps_nullable: |
|
57 |
assumes "nullable(r)" |
|
58 |
shows "\<Turnstile> mkeps r : r" |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
using assms |
276 | 60 |
apply(induct rule: nullable.induct) |
61 |
apply(auto intro: Prf.intros split: if_splits) |
|
62 |
using Prf.intros(8) apply force |
|
63 |
apply(subst append.simps(1)[symmetric]) |
|
64 |
apply(rule Prf.intros) |
|
65 |
apply(simp) |
|
66 |
apply(simp) |
|
67 |
apply (simp add: mkeps_flat) |
|
68 |
apply(simp) |
|
69 |
using Prf.intros(9) apply force |
|
70 |
apply(subst append.simps(1)[symmetric]) |
|
71 |
apply(rule Prf.intros) |
|
72 |
apply(simp) |
|
73 |
apply(simp) |
|
74 |
apply (simp add: mkeps_flat) |
|
75 |
apply(simp) |
|
76 |
using Prf.intros(11) apply force |
|
77 |
apply(subst append.simps(1)[symmetric]) |
|
78 |
apply(rule Prf.intros) |
|
79 |
apply(simp) |
|
80 |
apply(simp) |
|
81 |
apply (simp add: mkeps_flat) |
|
82 |
apply(simp) |
|
83 |
apply(simp) |
|
227 | 84 |
done |
276 | 85 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
|
243 | 87 |
lemma Prf_injval_flat: |
276 | 88 |
assumes "\<Turnstile> v : der c r" |
243 | 89 |
shows "flat (injval r c v) = c # (flat v)" |
90 |
using assms |
|
91 |
apply(induct arbitrary: v rule: der.induct) |
|
276 | 92 |
apply(auto elim!: Prf_elims intro: mkeps_flat split: if_splits) |
93 |
done |
|
94 |
||
95 |
lemma Prf_injval: |
|
96 |
assumes "\<Turnstile> v : der c r" |
|
97 |
shows "\<Turnstile> (injval r c v) : r" |
|
98 |
using assms |
|
99 |
apply(induct r arbitrary: c v rule: rexp.induct) |
|
100 |
apply(auto intro!: Prf.intros mkeps_nullable elim!: Prf_elims split: if_splits)[6] |
|
101 |
apply(simp add: Prf_injval_flat) |
|
102 |
apply(simp) |
|
103 |
apply(case_tac x2) |
|
104 |
apply(simp) |
|
105 |
apply(erule Prf_elims) |
|
106 |
apply(simp) |
|
107 |
apply(erule Prf_elims) |
|
108 |
apply(simp) |
|
109 |
apply(erule Prf_elims) |
|
110 |
apply(simp) |
|
111 |
using Prf.intros(7) Prf_injval_flat apply auto[1] |
|
112 |
apply(simp) |
|
113 |
apply(case_tac x2) |
|
114 |
apply(simp) |
|
115 |
apply(erule Prf_elims) |
|
116 |
apply(simp) |
|
117 |
apply(erule Prf_elims) |
|
118 |
apply(simp) |
|
119 |
apply(erule Prf_elims) |
|
120 |
apply(simp) |
|
121 |
apply(subst append.simps(2)[symmetric]) |
|
122 |
apply(rule Prf.intros) |
|
123 |
apply(simp add: Prf_injval_flat) |
|
124 |
apply(simp) |
|
125 |
apply(simp) |
|
126 |
prefer 2 |
|
127 |
apply(simp) |
|
128 |
apply(case_tac "x3a < x2") |
|
129 |
apply(simp) |
|
130 |
apply(erule Prf_elims) |
|
131 |
apply(simp) |
|
132 |
apply(case_tac x2) |
|
133 |
apply(simp) |
|
134 |
apply(case_tac x3a) |
|
135 |
apply(simp) |
|
136 |
apply(erule Prf_elims) |
|
137 |
apply(simp) |
|
138 |
apply(erule Prf_elims) |
|
139 |
apply(simp) |
|
140 |
apply(erule Prf_elims) |
|
141 |
apply(simp) |
|
142 |
using Prf.intros(12) Prf_injval_flat apply auto[1] |
|
143 |
apply(simp) |
|
144 |
apply(erule Prf_elims) |
|
145 |
apply(simp) |
|
146 |
apply(erule Prf_elims) |
|
147 |
apply(simp) |
|
148 |
apply(subst append.simps(2)[symmetric]) |
|
149 |
apply(rule Prf.intros) |
|
150 |
apply(simp add: Prf_injval_flat) |
|
151 |
apply(simp) |
|
152 |
apply(simp) |
|
153 |
apply(simp) |
|
154 |
apply(simp) |
|
155 |
using Prf.intros(12) Prf_injval_flat apply auto[1] |
|
156 |
apply(case_tac x2) |
|
157 |
apply(simp) |
|
158 |
apply(erule Prf_elims) |
|
159 |
apply(simp) |
|
160 |
apply(erule Prf_elims) |
|
161 |
apply(simp_all) |
|
162 |
apply (simp add: Prf.intros(10) Prf_injval_flat) |
|
163 |
using Prf.intros(10) Prf_injval_flat apply auto[1] |
|
164 |
apply(erule Prf_elims) |
|
165 |
apply(simp) |
|
166 |
apply(erule Prf_elims) |
|
167 |
apply(simp_all) |
|
168 |
apply(subst append.simps(2)[symmetric]) |
|
169 |
apply(rule Prf.intros) |
|
170 |
apply(simp add: Prf_injval_flat) |
|
171 |
apply(simp) |
|
172 |
apply(simp) |
|
243 | 173 |
done |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
174 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
175 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
|
276 | 177 |
text {* |
178 |
Mkeps and injval produce, or preserve, Posix values. |
|
179 |
*} |
|
223 | 180 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
181 |
lemma Posix_mkeps: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
assumes "nullable r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
shows "[] \<in> r \<rightarrow> mkeps r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
184 |
using assms |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
185 |
apply(induct r rule: nullable.induct) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
186 |
apply(auto intro: Posix.intros simp add: nullable_correctness Sequ_def) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
187 |
apply(subst append.simps(1)[symmetric]) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
188 |
apply(rule Posix.intros) |
276 | 189 |
apply(auto) |
190 |
done |
|
191 |
||
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
192 |
|
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
193 |
lemma Posix_injval: |
276 | 194 |
assumes "s \<in> (der c r) \<rightarrow> v" |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
195 |
shows "(c # s) \<in> r \<rightarrow> (injval r c v)" |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
196 |
using assms |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
197 |
proof(induct r arbitrary: s v rule: rexp.induct) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
198 |
case ZERO |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
199 |
have "s \<in> der c ZERO \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
200 |
then have "s \<in> ZERO \<rightarrow> v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
201 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
202 |
then show "(c # s) \<in> ZERO \<rightarrow> (injval ZERO c v)" by simp |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
203 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
204 |
case ONE |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
205 |
have "s \<in> der c ONE \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
206 |
then have "s \<in> ZERO \<rightarrow> v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
207 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
208 |
then show "(c # s) \<in> ONE \<rightarrow> (injval ONE c v)" by simp |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
209 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
210 |
case (CHAR d) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
211 |
consider (eq) "c = d" | (ineq) "c \<noteq> d" by blast |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
212 |
then show "(c # s) \<in> (CHAR d) \<rightarrow> (injval (CHAR d) c v)" |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
213 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
214 |
case eq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
215 |
have "s \<in> der c (CHAR d) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
216 |
then have "s \<in> ONE \<rightarrow> v" using eq by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
217 |
then have eqs: "s = [] \<and> v = Void" by cases simp |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
218 |
show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" using eq eqs |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
219 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
220 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
221 |
case ineq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
222 |
have "s \<in> der c (CHAR d) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
223 |
then have "s \<in> ZERO \<rightarrow> v" using ineq by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
224 |
then have "False" by cases |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
225 |
then show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
226 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
227 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
228 |
case (ALT r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
229 |
have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
230 |
have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
231 |
have "s \<in> der c (ALT r1 r2) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
232 |
then have "s \<in> ALT (der c r1) (der c r2) \<rightarrow> v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
233 |
then consider (left) v' where "v = Left v'" "s \<in> der c r1 \<rightarrow> v'" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
234 |
| (right) v' where "v = Right v'" "s \<notin> L (der c r1)" "s \<in> der c r2 \<rightarrow> v'" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
235 |
by cases auto |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
236 |
then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
237 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
238 |
case left |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
239 |
have "s \<in> der c r1 \<rightarrow> v'" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
240 |
then have "(c # s) \<in> r1 \<rightarrow> injval r1 c v'" using IH1 by simp |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
241 |
then have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Left v')" by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
242 |
then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using left by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
243 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
244 |
case right |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
245 |
have "s \<notin> L (der c r1)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
246 |
then have "c # s \<notin> L r1" by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
247 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
248 |
have "s \<in> der c r2 \<rightarrow> v'" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
249 |
then have "(c # s) \<in> r2 \<rightarrow> injval r2 c v'" using IH2 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
250 |
ultimately have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Right v')" |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
251 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
252 |
then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using right by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
253 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
254 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
255 |
case (SEQ r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
256 |
have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
257 |
have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
258 |
have "s \<in> der c (SEQ r1 r2) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
259 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
260 |
(left_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
261 |
"v = Left (Seq v1 v2)" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
262 |
"s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "nullable r1" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
263 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
264 |
| (right_nullable) v1 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
265 |
"v = Right v1" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
266 |
"s \<in> der c r2 \<rightarrow> v1" "nullable r1" "s1 @ s2 \<notin> L (SEQ (der c r1) r2)" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
267 |
| (not_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
268 |
"v = Seq v1 v2" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
269 |
"s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "\<not>nullable r1" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
270 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
271 |
by (force split: if_splits elim!: Posix_elims simp add: Sequ_def der_correctness Der_def) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
272 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
273 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
274 |
case left_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
275 |
have "s1 \<in> der c r1 \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
276 |
then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
277 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
278 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
279 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
280 |
ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using left_nullable by (rule_tac Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
281 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using left_nullable by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
282 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
283 |
case right_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
284 |
have "nullable r1" by fact |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
285 |
then have "[] \<in> r1 \<rightarrow> (mkeps r1)" by (rule Posix_mkeps) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
286 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
287 |
have "s \<in> der c r2 \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
288 |
then have "(c # s) \<in> r2 \<rightarrow> (injval r2 c v1)" using IH2 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
289 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
290 |
have "s1 @ s2 \<notin> L (SEQ (der c r1) r2)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
291 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = c # s \<and> [] @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" using right_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
292 |
by(auto simp add: der_correctness Der_def append_eq_Cons_conv Sequ_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
293 |
ultimately have "([] @ (c # s)) \<in> SEQ r1 r2 \<rightarrow> Seq (mkeps r1) (injval r2 c v1)" |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
294 |
by(rule Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
295 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using right_nullable by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
296 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
297 |
case not_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
298 |
have "s1 \<in> der c r1 \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
299 |
then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
300 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
301 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
302 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
303 |
ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using not_nullable |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
304 |
by (rule_tac Posix.intros) (simp_all) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
305 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using not_nullable by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
306 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
307 |
next |
276 | 308 |
case (UPNTIMES r n s v) |
309 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
310 |
have "s \<in> der c (UPNTIMES r n) \<rightarrow> v" by fact |
|
311 |
then consider |
|
312 |
(cons) v1 vs s1 s2 where |
|
313 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
|
314 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (UPNTIMES r (n - 1)) \<rightarrow> (Stars vs)" "0 < n" |
|
315 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))" |
|
316 |
(* here *) |
|
317 |
apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits) |
|
318 |
apply(erule Posix_elims) |
|
319 |
apply(simp) |
|
320 |
apply(subgoal_tac "\<exists>vss. v2 = Stars vss") |
|
321 |
apply(clarify) |
|
322 |
apply(drule_tac x="v1" in meta_spec) |
|
323 |
apply(drule_tac x="vss" in meta_spec) |
|
324 |
apply(drule_tac x="s1" in meta_spec) |
|
325 |
apply(drule_tac x="s2" in meta_spec) |
|
326 |
apply(simp add: der_correctness Der_def) |
|
327 |
apply(erule Posix_elims) |
|
328 |
apply(auto) |
|
329 |
done |
|
330 |
then show "(c # s) \<in> (UPNTIMES r n) \<rightarrow> injval (UPNTIMES r n) c v" |
|
331 |
proof (cases) |
|
332 |
case cons |
|
333 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
334 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
335 |
moreover |
|
336 |
have "s2 \<in> (UPNTIMES r (n - 1)) \<rightarrow> Stars vs" by fact |
|
337 |
moreover |
|
338 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
|
339 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
340 |
then have "flat (injval r c v1) \<noteq> []" by simp |
|
341 |
moreover |
|
342 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))" by fact |
|
343 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))" |
|
344 |
by (simp add: der_correctness Der_def) |
|
345 |
ultimately |
|
346 |
have "((c # s1) @ s2) \<in> UPNTIMES r n \<rightarrow> Stars (injval r c v1 # vs)" |
|
347 |
thm Posix.intros |
|
348 |
apply (rule_tac Posix.intros) |
|
349 |
apply(simp_all) |
|
350 |
apply(case_tac n) |
|
351 |
apply(simp) |
|
352 |
using Posix_elims(1) UPNTIMES.prems apply auto[1] |
|
353 |
apply(simp) |
|
354 |
done |
|
355 |
then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" using cons by(simp) |
|
356 |
qed |
|
357 |
next |
|
358 |
case (STAR r) |
|
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
359 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
360 |
have "s \<in> der c (STAR r) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
361 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
362 |
(cons) v1 vs s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
363 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
364 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (STAR r) \<rightarrow> (Stars vs)" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
365 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
366 |
apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
367 |
apply(rotate_tac 3) |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
368 |
apply(erule_tac Posix_elims(6)) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
369 |
apply (simp add: Posix.intros(6)) |
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
370 |
using Posix.intros(7) by blast |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
371 |
then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
372 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
373 |
case cons |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
374 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
375 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
376 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
377 |
have "s2 \<in> STAR r \<rightarrow> Stars vs" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
378 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
379 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
380 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
381 |
then have "flat (injval r c v1) \<noteq> []" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
382 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
383 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
384 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
385 |
by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
386 |
ultimately |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
387 |
have "((c # s1) @ s2) \<in> STAR r \<rightarrow> Stars (injval r c v1 # vs)" by (rule Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
388 |
then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" using cons by(simp) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
389 |
qed |
276 | 390 |
next |
391 |
case (NTIMES r n s v) |
|
392 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
393 |
have "s \<in> der c (NTIMES r n) \<rightarrow> v" by fact |
|
220 | 394 |
then consider |
276 | 395 |
(cons) v1 vs s1 s2 where |
220 | 396 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
276 | 397 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (NTIMES r (n - 1)) \<rightarrow> (Stars vs)" "0 < n" |
398 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))" |
|
399 |
apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits) |
|
400 |
apply(erule Posix_elims) |
|
401 |
apply(simp) |
|
402 |
apply(subgoal_tac "\<exists>vss. v2 = Stars vss") |
|
403 |
apply(clarify) |
|
404 |
apply(drule_tac x="v1" in meta_spec) |
|
405 |
apply(drule_tac x="vss" in meta_spec) |
|
406 |
apply(drule_tac x="s1" in meta_spec) |
|
407 |
apply(drule_tac x="s2" in meta_spec) |
|
408 |
apply(simp add: der_correctness Der_def) |
|
409 |
apply(erule Posix_elims) |
|
410 |
apply(auto) |
|
411 |
done |
|
412 |
then show "(c # s) \<in> (NTIMES r n) \<rightarrow> injval (NTIMES r n) c v" |
|
220 | 413 |
proof (cases) |
414 |
case cons |
|
415 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
416 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
417 |
moreover |
|
276 | 418 |
have "s2 \<in> (NTIMES r (n - 1)) \<rightarrow> Stars vs" by fact |
220 | 419 |
moreover |
420 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
|
421 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
422 |
then have "flat (injval r c v1) \<noteq> []" by simp |
|
423 |
moreover |
|
276 | 424 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))" by fact |
425 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))" |
|
220 | 426 |
by (simp add: der_correctness Der_def) |
427 |
ultimately |
|
276 | 428 |
have "((c # s1) @ s2) \<in> NTIMES r n \<rightarrow> Stars (injval r c v1 # vs)" |
429 |
apply (rule_tac Posix.intros) |
|
430 |
apply(simp_all) |
|
431 |
apply(case_tac n) |
|
432 |
apply(simp) |
|
433 |
using Posix_elims(1) NTIMES.prems apply auto[1] |
|
434 |
apply(simp) |
|
435 |
done |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
436 |
then show "(c # s) \<in> NTIMES r n \<rightarrow> injval (NTIMES r n) c v" using cons by(simp) |
276 | 437 |
qed |
438 |
next |
|
439 |
case (FROMNTIMES r n s v) |
|
223 | 440 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
441 |
have "s \<in> der c (FROMNTIMES r n) \<rightarrow> v" by fact |
|
442 |
then consider |
|
276 | 443 |
(cons) v1 vs s1 s2 where |
223 | 444 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
276 | 445 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r (n - 1)) \<rightarrow> (Stars vs)" "0 < n" |
446 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))" |
|
277 | 447 |
| (null) v1 vs s1 s2 where |
448 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" "s2 \<in> (STAR r) \<rightarrow> (Stars vs)" |
|
449 |
"s1 \<in> der c r \<rightarrow> v1" "n = 0" |
|
278 | 450 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" |
276 | 451 |
apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits) |
277 | 452 |
prefer 2 |
276 | 453 |
apply(erule Posix_elims) |
454 |
apply(simp) |
|
455 |
apply(subgoal_tac "\<exists>vss. v2 = Stars vss") |
|
456 |
apply(clarify) |
|
457 |
apply(drule_tac x="v1" in meta_spec) |
|
458 |
apply(drule_tac x="vss" in meta_spec) |
|
459 |
apply(drule_tac x="s1" in meta_spec) |
|
460 |
apply(drule_tac x="s2" in meta_spec) |
|
461 |
apply(simp add: der_correctness Der_def) |
|
277 | 462 |
apply(rotate_tac 5) |
276 | 463 |
apply(erule Posix_elims) |
464 |
apply(auto)[2] |
|
277 | 465 |
apply(erule Posix_elims) |
466 |
apply(simp) |
|
467 |
apply blast |
|
468 |
apply(erule Posix_elims) |
|
469 |
apply(auto) |
|
470 |
apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits) |
|
471 |
apply(subgoal_tac "\<exists>vss. v2 = Stars vss") |
|
472 |
apply(clarify) |
|
473 |
apply simp |
|
474 |
apply(rotate_tac 6) |
|
475 |
apply(erule Posix_elims) |
|
476 |
apply(auto)[2] |
|
477 |
done |
|
276 | 478 |
then show "(c # s) \<in> (FROMNTIMES r n) \<rightarrow> injval (FROMNTIMES r n) c v" |
223 | 479 |
proof (cases) |
480 |
case cons |
|
481 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
482 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
483 |
moreover |
|
276 | 484 |
have "s2 \<in> (FROMNTIMES r (n - 1)) \<rightarrow> Stars vs" by fact |
223 | 485 |
moreover |
276 | 486 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
487 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
488 |
then have "flat (injval r c v1) \<noteq> []" by simp |
|
489 |
moreover |
|
490 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))" by fact |
|
491 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))" |
|
223 | 492 |
by (simp add: der_correctness Der_def) |
493 |
ultimately |
|
276 | 494 |
have "((c # s1) @ s2) \<in> FROMNTIMES r n \<rightarrow> Stars (injval r c v1 # vs)" |
495 |
apply (rule_tac Posix.intros) |
|
496 |
apply(simp_all) |
|
497 |
apply(case_tac n) |
|
498 |
apply(simp) |
|
499 |
using Posix_elims(1) FROMNTIMES.prems apply auto[1] |
|
500 |
using cons(5) apply blast |
|
501 |
apply(simp) |
|
502 |
done |
|
223 | 503 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using cons by(simp) |
276 | 504 |
next |
505 |
case null |
|
277 | 506 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
507 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
508 |
moreover |
|
509 |
have "s2 \<in> STAR r \<rightarrow> Stars vs" by fact |
|
510 |
moreover |
|
511 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
|
512 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
276 | 513 |
then have "flat (injval r c v1) \<noteq> []" by simp |
277 | 514 |
moreover |
515 |
moreover |
|
516 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" by fact |
|
517 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" |
|
518 |
by (simp add: der_correctness Der_def) |
|
276 | 519 |
ultimately |
277 | 520 |
have "((c # s1) @ s2) \<in> FROMNTIMES r 0 \<rightarrow> Stars (injval r c v1 # vs)" |
521 |
apply (rule_tac Posix.intros) back |
|
522 |
apply(simp_all) |
|
276 | 523 |
done |
524 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using null |
|
525 |
apply(simp) |
|
277 | 526 |
done |
276 | 527 |
qed |
528 |
next |
|
278 | 529 |
case (NMTIMES r n m s v) |
530 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
531 |
have "s \<in> der c (NMTIMES r n m) \<rightarrow> v" by fact |
|
532 |
then consider |
|
533 |
(cons) v1 vs s1 s2 where |
|
534 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
|
535 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (NMTIMES r (n - 1) (m - 1)) \<rightarrow> (Stars vs)" "0 < n" "n \<le> m" |
|
536 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))" |
|
537 |
| (null) v1 vs s1 s2 where |
|
538 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" "s2 \<in> (UPNTIMES r (m - 1)) \<rightarrow> (Stars vs)" |
|
539 |
"s1 \<in> der c r \<rightarrow> v1" "n = 0" "0 < m" |
|
540 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))" |
|
541 |
apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits) |
|
542 |
prefer 2 |
|
543 |
apply(erule Posix_elims) |
|
544 |
apply(simp) |
|
545 |
apply(subgoal_tac "\<exists>vss. v2 = Stars vss") |
|
546 |
apply(clarify) |
|
547 |
apply(drule_tac x="v1" in meta_spec) |
|
548 |
apply(drule_tac x="vss" in meta_spec) |
|
549 |
apply(drule_tac x="s1" in meta_spec) |
|
550 |
apply(drule_tac x="s2" in meta_spec) |
|
551 |
apply(simp add: der_correctness Der_def) |
|
552 |
apply(rotate_tac 5) |
|
553 |
apply(erule Posix_elims) |
|
554 |
apply(auto)[2] |
|
555 |
apply(erule Posix_elims) |
|
556 |
apply(simp) |
|
557 |
apply blast |
|
558 |
||
559 |
apply(erule Posix_elims) |
|
560 |
apply(auto) |
|
561 |
apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits) |
|
562 |
apply(subgoal_tac "\<exists>vss. v2 = Stars vss") |
|
563 |
apply(clarify) |
|
564 |
apply simp |
|
565 |
apply(rotate_tac 6) |
|
566 |
apply(erule Posix_elims) |
|
567 |
apply(auto)[2] |
|
568 |
done |
|
569 |
then show "(c # s) \<in> (NMTIMES r n m) \<rightarrow> injval (NMTIMES r n m) c v" |
|
570 |
proof (cases) |
|
571 |
case cons |
|
572 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
573 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
574 |
moreover |
|
575 |
have "s2 \<in> (NMTIMES r (n - 1) (m - 1)) \<rightarrow> Stars vs" by fact |
|
576 |
moreover |
|
577 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
|
578 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
579 |
then have "flat (injval r c v1) \<noteq> []" by simp |
|
580 |
moreover |
|
581 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))" by fact |
|
582 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))" |
|
583 |
by (simp add: der_correctness Der_def) |
|
584 |
ultimately |
|
585 |
have "((c # s1) @ s2) \<in> NMTIMES r n m \<rightarrow> Stars (injval r c v1 # vs)" |
|
586 |
apply (rule_tac Posix.intros) |
|
587 |
apply(simp_all) |
|
588 |
apply(case_tac n) |
|
589 |
apply(simp) |
|
590 |
using Posix_elims(1) NMTIMES.prems apply auto[1] |
|
591 |
using cons(5) apply blast |
|
592 |
apply(simp) |
|
593 |
apply(rule cons) |
|
594 |
done |
|
595 |
then show "(c # s) \<in> NMTIMES r n m \<rightarrow> injval (NMTIMES r n m) c v" using cons by(simp) |
|
596 |
next |
|
597 |
case null |
|
598 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
599 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
600 |
moreover |
|
601 |
have "s2 \<in> UPNTIMES r (m - 1) \<rightarrow> Stars vs" by fact |
|
602 |
moreover |
|
603 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
|
604 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
605 |
then have "flat (injval r c v1) \<noteq> []" by simp |
|
606 |
moreover |
|
607 |
moreover |
|
608 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))" by fact |
|
609 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))" |
|
610 |
by (simp add: der_correctness Der_def) |
|
611 |
ultimately |
|
612 |
have "((c # s1) @ s2) \<in> NMTIMES r 0 m \<rightarrow> Stars (injval r c v1 # vs)" |
|
613 |
apply (rule_tac Posix.intros) back |
|
614 |
apply(simp_all) |
|
615 |
apply(rule null) |
|
616 |
done |
|
617 |
then show "(c # s) \<in> NMTIMES r n m \<rightarrow> injval (NMTIMES r n m) c v" using null |
|
618 |
apply(simp) |
|
619 |
done |
|
620 |
qed |
|
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
621 |
qed |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
622 |
|
276 | 623 |
section {* Lexer Correctness *} |
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
624 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
625 |
lemma lexer_correct_None: |
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
626 |
shows "s \<notin> L r \<longleftrightarrow> lexer r s = None" |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
627 |
apply(induct s arbitrary: r) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
628 |
apply(simp add: nullable_correctness) |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
629 |
apply(drule_tac x="der a r" in meta_spec) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
630 |
apply(auto simp add: der_correctness Der_def) |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
631 |
done |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
632 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
633 |
lemma lexer_correct_Some: |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
634 |
shows "s \<in> L r \<longleftrightarrow> (\<exists>v. lexer r s = Some(v) \<and> s \<in> r \<rightarrow> v)" |
124
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
635 |
apply(induct s arbitrary: r) |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
636 |
apply(auto simp add: Posix_mkeps nullable_correctness)[1] |
124
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
637 |
apply(drule_tac x="der a r" in meta_spec) |
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
638 |
apply(simp add: der_correctness Der_def) |
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
639 |
apply(rule iffI) |
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
640 |
apply(auto intro: Posix_injval simp add: Posix1(1)) |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
641 |
done |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
642 |
|
186
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
643 |
lemma lexer_correctness: |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
644 |
shows "(lexer r s = Some v) \<longleftrightarrow> s \<in> r \<rightarrow> v" |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
645 |
and "(lexer r s = None) \<longleftrightarrow> \<not>(\<exists>v. s \<in> r \<rightarrow> v)" |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
646 |
using Posix1(1) Posix_determ lexer_correct_None lexer_correct_Some apply fastforce |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
647 |
using Posix1(1) lexer_correct_None lexer_correct_Some by blast |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
648 |
|
95
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
649 |
end |