author | oheimb |
Fri, 23 Oct 1998 20:44:34 +0200 | |
changeset 5758 | 27a2b36efd95 |
parent 5608 | a82a038a3e7a |
child 7958 | f531589c9fc1 |
permissions | -rw-r--r-- |
4907 | 1 |
(* Title: HOL/Lex/RegExp2NAe.ML |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow |
|
4 |
Copyright 1998 TUM |
|
5 |
*) |
|
6 |
||
7 |
(******************************************************) |
|
8 |
(* atom *) |
|
9 |
(******************************************************) |
|
10 |
||
5069 | 11 |
Goalw [atom_def] "(fin (atom a) q) = (q = [False])"; |
5132 | 12 |
by (Simp_tac 1); |
4907 | 13 |
qed "fin_atom"; |
14 |
||
5069 | 15 |
Goalw [atom_def] "start (atom a) = [True]"; |
5132 | 16 |
by (Simp_tac 1); |
4907 | 17 |
qed "start_atom"; |
18 |
||
19 |
(* Use {x. False} = {}? *) |
|
20 |
||
5069 | 21 |
Goalw [atom_def,step_def] |
4907 | 22 |
"eps(atom a) = {}"; |
5132 | 23 |
by (Simp_tac 1); |
4907 | 24 |
by (Blast_tac 1); |
25 |
qed "eps_atom"; |
|
26 |
Addsimps [eps_atom]; |
|
27 |
||
5069 | 28 |
Goalw [atom_def,step_def] |
4907 | 29 |
"(p,q) : step (atom a) (Some b) = (p=[True] & q=[False] & b=a)"; |
5132 | 30 |
by (Simp_tac 1); |
4907 | 31 |
qed "in_step_atom_Some"; |
32 |
Addsimps [in_step_atom_Some]; |
|
33 |
||
5118 | 34 |
Goal "([False],[False]) : steps (atom a) w = (w = [])"; |
4907 | 35 |
by (induct_tac "w" 1); |
5132 | 36 |
by (Simp_tac 1); |
37 |
by (asm_simp_tac (simpset() addsimps [comp_def]) 1); |
|
4907 | 38 |
qed "False_False_in_steps_atom"; |
39 |
||
5118 | 40 |
Goal "(start (atom a), [False]) : steps (atom a) w = (w = [a])"; |
4907 | 41 |
by (induct_tac "w" 1); |
5132 | 42 |
by (asm_simp_tac (simpset() addsimps [start_atom,rtrancl_empty]) 1); |
43 |
by (asm_full_simp_tac (simpset() |
|
4907 | 44 |
addsimps [False_False_in_steps_atom,comp_def,start_atom]) 1); |
45 |
qed "start_fin_in_steps_atom"; |
|
46 |
||
5118 | 47 |
Goal "accepts (atom a) w = (w = [a])"; |
5132 | 48 |
by (simp_tac(simpset() addsimps |
4907 | 49 |
[accepts_def,start_fin_in_steps_atom,fin_atom]) 1); |
50 |
qed "accepts_atom"; |
|
51 |
||
52 |
||
53 |
(******************************************************) |
|
54 |
(* union *) |
|
55 |
(******************************************************) |
|
56 |
||
57 |
(***** True/False ueber fin anheben *****) |
|
58 |
||
5069 | 59 |
Goalw [union_def] |
4907 | 60 |
"!L R. fin (union L R) (True#p) = fin L p"; |
61 |
by (Simp_tac 1); |
|
62 |
qed_spec_mp "fin_union_True"; |
|
63 |
||
5069 | 64 |
Goalw [union_def] |
4907 | 65 |
"!L R. fin (union L R) (False#p) = fin R p"; |
66 |
by (Simp_tac 1); |
|
67 |
qed_spec_mp "fin_union_False"; |
|
68 |
||
69 |
AddIffs [fin_union_True,fin_union_False]; |
|
70 |
||
71 |
(***** True/False ueber step anheben *****) |
|
72 |
||
5069 | 73 |
Goalw [union_def,step_def] |
4907 | 74 |
"!L R. (True#p,q) : step (union L R) a = (? r. q = True#r & (p,r) : step L a)"; |
75 |
by (Simp_tac 1); |
|
5132 | 76 |
by (Blast_tac 1); |
4907 | 77 |
qed_spec_mp "True_in_step_union"; |
78 |
||
5069 | 79 |
Goalw [union_def,step_def] |
4907 | 80 |
"!L R. (False#p,q) : step (union L R) a = (? r. q = False#r & (p,r) : step R a)"; |
81 |
by (Simp_tac 1); |
|
5132 | 82 |
by (Blast_tac 1); |
4907 | 83 |
qed_spec_mp "False_in_step_union"; |
84 |
||
85 |
AddIffs [True_in_step_union,False_in_step_union]; |
|
86 |
||
87 |
(***** True/False ueber epsclosure anheben *****) |
|
88 |
||
5069 | 89 |
Goal |
5118 | 90 |
"(tp,tq) : (eps(union L R))^* ==> \ |
4907 | 91 |
\ !p. tp = True#p --> (? q. (p,q) : (eps L)^* & tq = True#q)"; |
5132 | 92 |
by (etac rtrancl_induct 1); |
93 |
by (Blast_tac 1); |
|
94 |
by (Clarify_tac 1); |
|
95 |
by (Asm_full_simp_tac 1); |
|
96 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 97 |
val lemma1a = result(); |
98 |
||
5069 | 99 |
Goal |
5118 | 100 |
"(tp,tq) : (eps(union L R))^* ==> \ |
4907 | 101 |
\ !p. tp = False#p --> (? q. (p,q) : (eps R)^* & tq = False#q)"; |
5132 | 102 |
by (etac rtrancl_induct 1); |
103 |
by (Blast_tac 1); |
|
104 |
by (Clarify_tac 1); |
|
105 |
by (Asm_full_simp_tac 1); |
|
106 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 107 |
val lemma1b = result(); |
108 |
||
5069 | 109 |
Goal |
5118 | 110 |
"(p,q) : (eps L)^* ==> (True#p, True#q) : (eps(union L R))^*"; |
5132 | 111 |
by (etac rtrancl_induct 1); |
112 |
by (Blast_tac 1); |
|
113 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 114 |
val lemma2a = result(); |
115 |
||
5069 | 116 |
Goal |
5118 | 117 |
"(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(union L R))^*"; |
5132 | 118 |
by (etac rtrancl_induct 1); |
119 |
by (Blast_tac 1); |
|
120 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 121 |
val lemma2b = result(); |
122 |
||
5069 | 123 |
Goal |
4907 | 124 |
"(True#p,q) : (eps(union L R))^* = (? r. q = True#r & (p,r) : (eps L)^*)"; |
5132 | 125 |
by (blast_tac (claset() addDs [lemma1a,lemma2a]) 1); |
4907 | 126 |
qed "True_epsclosure_union"; |
127 |
||
5069 | 128 |
Goal |
4907 | 129 |
"(False#p,q) : (eps(union L R))^* = (? r. q = False#r & (p,r) : (eps R)^*)"; |
5132 | 130 |
by (blast_tac (claset() addDs [lemma1b,lemma2b]) 1); |
4907 | 131 |
qed "False_epsclosure_union"; |
132 |
||
133 |
AddIffs [True_epsclosure_union,False_epsclosure_union]; |
|
134 |
||
135 |
(***** True/False ueber steps anheben *****) |
|
136 |
||
5069 | 137 |
Goal |
4907 | 138 |
"!p. (True#p,q):steps (union L R) w = (? r. q = True # r & (p,r):steps L w)"; |
139 |
by (induct_tac "w" 1); |
|
5758
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5608
diff
changeset
|
140 |
by Auto_tac; |
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5608
diff
changeset
|
141 |
by (Force_tac 1); |
4907 | 142 |
qed_spec_mp "lift_True_over_steps_union"; |
143 |
||
5069 | 144 |
Goal |
4907 | 145 |
"!p. (False#p,q):steps (union L R) w = (? r. q = False#r & (p,r):steps R w)"; |
146 |
by (induct_tac "w" 1); |
|
5758
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5608
diff
changeset
|
147 |
by Auto_tac; |
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5608
diff
changeset
|
148 |
by (Force_tac 1); |
4907 | 149 |
qed_spec_mp "lift_False_over_steps_union"; |
150 |
||
151 |
AddIffs [lift_True_over_steps_union,lift_False_over_steps_union]; |
|
152 |
||
153 |
||
154 |
(***** Epsilonhuelle des Startzustands *****) |
|
155 |
||
5069 | 156 |
Goal |
5608 | 157 |
"R^* = Id Un (R^* O R)"; |
5132 | 158 |
by (rtac set_ext 1); |
159 |
by (split_all_tac 1); |
|
160 |
by (rtac iffI 1); |
|
161 |
by (etac rtrancl_induct 1); |
|
162 |
by (Blast_tac 1); |
|
163 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
164 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl2]) 1); |
|
4907 | 165 |
qed "unfold_rtrancl2"; |
166 |
||
5069 | 167 |
Goal |
4907 | 168 |
"(p,q) : R^* = (q = p | (? r. (p,r) : R & (r,q) : R^*))"; |
5132 | 169 |
by (rtac (unfold_rtrancl2 RS equalityE) 1); |
170 |
by (Blast_tac 1); |
|
4907 | 171 |
qed "in_unfold_rtrancl2"; |
172 |
||
173 |
val epsclosure_start_step_union = |
|
174 |
read_instantiate [("p","start(union L R)")] in_unfold_rtrancl2; |
|
175 |
AddIffs [epsclosure_start_step_union]; |
|
176 |
||
5069 | 177 |
Goalw [union_def,step_def] |
4907 | 178 |
"!L R. (start(union L R),q) : eps(union L R) = \ |
179 |
\ (q = True#start L | q = False#start R)"; |
|
5132 | 180 |
by (Simp_tac 1); |
4907 | 181 |
qed_spec_mp "start_eps_union"; |
182 |
AddIffs [start_eps_union]; |
|
183 |
||
5069 | 184 |
Goalw [union_def,step_def] |
4907 | 185 |
"!L R. (start(union L R),q) ~: step (union L R) (Some a)"; |
5132 | 186 |
by (Simp_tac 1); |
4907 | 187 |
qed_spec_mp "not_start_step_union_Some"; |
188 |
AddIffs [not_start_step_union_Some]; |
|
189 |
||
5069 | 190 |
Goal |
4907 | 191 |
"(start(union L R), q) : steps (union L R) w = \ |
192 |
\ ( (w = [] & q = start(union L R)) | \ |
|
193 |
\ (? p. q = True # p & (start L,p) : steps L w | \ |
|
194 |
\ q = False # p & (start R,p) : steps R w) )"; |
|
195 |
by (exhaust_tac "w" 1); |
|
196 |
by (Asm_simp_tac 1); |
|
5457 | 197 |
by (Blast_tac 1); |
4907 | 198 |
by (Asm_simp_tac 1); |
5457 | 199 |
by (Blast_tac 1); |
4907 | 200 |
qed "steps_union"; |
201 |
||
5069 | 202 |
Goalw [union_def] |
4907 | 203 |
"!L R. ~ fin (union L R) (start(union L R))"; |
5132 | 204 |
by (Simp_tac 1); |
4907 | 205 |
qed_spec_mp "start_union_not_final"; |
206 |
AddIffs [start_union_not_final]; |
|
207 |
||
5069 | 208 |
Goalw [accepts_def] |
4907 | 209 |
"accepts (union L R) w = (accepts L w | accepts R w)"; |
210 |
by (simp_tac (simpset() addsimps [steps_union]) 1); |
|
5132 | 211 |
by Auto_tac; |
4907 | 212 |
qed "accepts_union"; |
213 |
||
214 |
||
215 |
(******************************************************) |
|
216 |
(* conc *) |
|
217 |
(******************************************************) |
|
218 |
||
219 |
(** True/False in fin **) |
|
220 |
||
5069 | 221 |
Goalw [conc_def] |
4907 | 222 |
"!L R. fin (conc L R) (True#p) = False"; |
223 |
by (Simp_tac 1); |
|
224 |
qed_spec_mp "fin_conc_True"; |
|
225 |
||
5069 | 226 |
Goalw [conc_def] |
4907 | 227 |
"!L R. fin (conc L R) (False#p) = fin R p"; |
228 |
by (Simp_tac 1); |
|
229 |
qed "fin_conc_False"; |
|
230 |
||
231 |
AddIffs [fin_conc_True,fin_conc_False]; |
|
232 |
||
233 |
(** True/False in step **) |
|
234 |
||
5069 | 235 |
Goalw [conc_def,step_def] |
4907 | 236 |
"!L R. (True#p,q) : step (conc L R) a = \ |
237 |
\ ((? r. q=True#r & (p,r): step L a) | \ |
|
238 |
\ (fin L p & a=None & q=False#start R))"; |
|
239 |
by (Simp_tac 1); |
|
5132 | 240 |
by (Blast_tac 1); |
4907 | 241 |
qed_spec_mp "True_step_conc"; |
242 |
||
5069 | 243 |
Goalw [conc_def,step_def] |
4907 | 244 |
"!L R. (False#p,q) : step (conc L R) a = \ |
245 |
\ (? r. q = False#r & (p,r) : step R a)"; |
|
246 |
by (Simp_tac 1); |
|
5132 | 247 |
by (Blast_tac 1); |
4907 | 248 |
qed_spec_mp "False_step_conc"; |
249 |
||
250 |
AddIffs [True_step_conc, False_step_conc]; |
|
251 |
||
252 |
(** False in epsclosure **) |
|
253 |
||
5069 | 254 |
Goal |
5118 | 255 |
"(tp,tq) : (eps(conc L R))^* ==> \ |
4907 | 256 |
\ !p. tp = False#p --> (? q. (p,q) : (eps R)^* & tq = False#q)"; |
5132 | 257 |
by (etac rtrancl_induct 1); |
258 |
by (Blast_tac 1); |
|
259 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 260 |
qed "lemma1b"; |
261 |
||
5069 | 262 |
Goal |
5118 | 263 |
"(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*"; |
5132 | 264 |
by (etac rtrancl_induct 1); |
265 |
by (Blast_tac 1); |
|
266 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 267 |
val lemma2b = result(); |
268 |
||
5069 | 269 |
Goal |
4907 | 270 |
"((False # p, q) : (eps (conc L R))^*) = \ |
271 |
\ (? r. q = False # r & (p, r) : (eps R)^*)"; |
|
272 |
by (rtac iffI 1); |
|
5132 | 273 |
by (blast_tac (claset() addDs [lemma1b]) 1); |
274 |
by (blast_tac (claset() addDs [lemma2b]) 1); |
|
4907 | 275 |
qed "False_epsclosure_conc"; |
276 |
AddIffs [False_epsclosure_conc]; |
|
277 |
||
278 |
(** False in steps **) |
|
279 |
||
5069 | 280 |
Goal |
4907 | 281 |
"!p. (False#p,q): steps (conc L R) w = (? r. q=False#r & (p,r): steps R w)"; |
282 |
by (induct_tac "w" 1); |
|
283 |
by (Simp_tac 1); |
|
284 |
by (Simp_tac 1); |
|
5457 | 285 |
by (Fast_tac 1); (*MUCH faster than Blast_tac*) |
4907 | 286 |
qed_spec_mp "False_steps_conc"; |
287 |
AddIffs [False_steps_conc]; |
|
288 |
||
289 |
(** True in epsclosure **) |
|
290 |
||
5069 | 291 |
Goal |
5118 | 292 |
"(p,q): (eps L)^* ==> (True#p,True#q) : (eps(conc L R))^*"; |
5132 | 293 |
by (etac rtrancl_induct 1); |
294 |
by (Blast_tac 1); |
|
295 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 296 |
qed "True_True_eps_concI"; |
297 |
||
5069 | 298 |
Goal |
5118 | 299 |
"!p. (p,q) : steps L w --> (True#p,True#q) : steps (conc L R) w"; |
5132 | 300 |
by (induct_tac "w" 1); |
4907 | 301 |
by (simp_tac (simpset() addsimps [True_True_eps_concI]) 1); |
302 |
by (Simp_tac 1); |
|
5132 | 303 |
by (blast_tac (claset() addIs [True_True_eps_concI]) 1); |
4907 | 304 |
qed_spec_mp "True_True_steps_concI"; |
305 |
||
5069 | 306 |
Goal |
5118 | 307 |
"(tp,tq) : (eps(conc L R))^* ==> \ |
4907 | 308 |
\ !p. tp = True#p --> \ |
309 |
\ (? q. tq = True#q & (p,q) : (eps L)^*) | \ |
|
310 |
\ (? q r. tq = False#q & (p,r):(eps L)^* & fin L r & (start R,q) : (eps R)^*)"; |
|
5132 | 311 |
by (etac rtrancl_induct 1); |
312 |
by (Blast_tac 1); |
|
313 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 314 |
val lemma1a = result(); |
315 |
||
5069 | 316 |
Goal |
5118 | 317 |
"(p, q) : (eps L)^* ==> (True#p, True#q) : (eps(conc L R))^*"; |
5132 | 318 |
by (etac rtrancl_induct 1); |
319 |
by (Blast_tac 1); |
|
320 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
|
4907 | 321 |
val lemma2a = result(); |
322 |
||
5069 | 323 |
Goalw [conc_def,step_def] |
4907 | 324 |
"!!L R. (p,q) : step R None ==> (False#p, False#q) : step (conc L R) None"; |
5132 | 325 |
by (split_all_tac 1); |
4907 | 326 |
by (Asm_full_simp_tac 1); |
327 |
val lemma = result(); |
|
328 |
||
5069 | 329 |
Goal |
5118 | 330 |
"(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*"; |
5132 | 331 |
by (etac rtrancl_induct 1); |
332 |
by (Blast_tac 1); |
|
4907 | 333 |
by (dtac lemma 1); |
5132 | 334 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
4907 | 335 |
val lemma2b = result(); |
336 |
||
5069 | 337 |
Goalw [conc_def,step_def] |
4907 | 338 |
"!!L R. fin L p ==> (True#p, False#start R) : eps(conc L R)"; |
5132 | 339 |
by (split_all_tac 1); |
340 |
by (Asm_full_simp_tac 1); |
|
4907 | 341 |
qed "True_False_eps_concI"; |
342 |
||
5069 | 343 |
Goal |
4907 | 344 |
"((True#p,q) : (eps(conc L R))^*) = \ |
345 |
\ ((? r. (p,r) : (eps L)^* & q = True#r) | \ |
|
346 |
\ (? r. (p,r) : (eps L)^* & fin L r & \ |
|
347 |
\ (? s. (start R, s) : (eps R)^* & q = False#s)))"; |
|
5132 | 348 |
by (rtac iffI 1); |
349 |
by (blast_tac (claset() addDs [lemma1a]) 1); |
|
350 |
by (etac disjE 1); |
|
351 |
by (blast_tac (claset() addIs [lemma2a]) 1); |
|
352 |
by (Clarify_tac 1); |
|
353 |
by (rtac (rtrancl_trans) 1); |
|
354 |
by (etac lemma2a 1); |
|
355 |
by (rtac (rtrancl_into_rtrancl2) 1); |
|
356 |
by (etac True_False_eps_concI 1); |
|
357 |
by (etac lemma2b 1); |
|
4907 | 358 |
qed "True_epsclosure_conc"; |
359 |
AddIffs [True_epsclosure_conc]; |
|
360 |
||
361 |
(** True in steps **) |
|
362 |
||
5069 | 363 |
Goal |
4907 | 364 |
"!p. (True#p,q) : steps (conc L R) w --> \ |
365 |
\ ((? r. (p,r) : steps L w & q = True#r) | \ |
|
366 |
\ (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \ |
|
367 |
\ (? s. (start R,s) : steps R v & q = False#s))))"; |
|
5132 | 368 |
by (induct_tac "w" 1); |
369 |
by (Simp_tac 1); |
|
370 |
by (Simp_tac 1); |
|
371 |
by (clarify_tac (claset() delrules [disjCI]) 1); |
|
372 |
by (etac disjE 1); |
|
373 |
by (clarify_tac (claset() delrules [disjCI]) 1); |
|
374 |
by (etac disjE 1); |
|
375 |
by (clarify_tac (claset() delrules [disjCI]) 1); |
|
376 |
by (etac allE 1 THEN mp_tac 1); |
|
377 |
by (etac disjE 1); |
|
4907 | 378 |
by (Blast_tac 1); |
5132 | 379 |
by (rtac disjI2 1); |
4907 | 380 |
by (Clarify_tac 1); |
5132 | 381 |
by (Simp_tac 1); |
382 |
by (res_inst_tac[("x","a#u")] exI 1); |
|
383 |
by (Simp_tac 1); |
|
4907 | 384 |
by (Blast_tac 1); |
385 |
by (Blast_tac 1); |
|
5132 | 386 |
by (rtac disjI2 1); |
4907 | 387 |
by (Clarify_tac 1); |
5132 | 388 |
by (Simp_tac 1); |
389 |
by (res_inst_tac[("x","[]")] exI 1); |
|
390 |
by (Simp_tac 1); |
|
4907 | 391 |
by (Blast_tac 1); |
392 |
qed_spec_mp "True_steps_concD"; |
|
393 |
||
5069 | 394 |
Goal |
4907 | 395 |
"(True#p,q) : steps (conc L R) w = \ |
396 |
\ ((? r. (p,r) : steps L w & q = True#r) | \ |
|
397 |
\ (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \ |
|
398 |
\ (? s. (start R,s) : steps R v & q = False#s))))"; |
|
5132 | 399 |
by (blast_tac (claset() addDs [True_steps_concD] |
4907 | 400 |
addIs [True_True_steps_concI,in_steps_epsclosure,r_into_rtrancl]) 1); |
401 |
qed "True_steps_conc"; |
|
402 |
||
403 |
(** starting from the start **) |
|
404 |
||
5069 | 405 |
Goalw [conc_def] |
4907 | 406 |
"!L R. start(conc L R) = True#start L"; |
5132 | 407 |
by (Simp_tac 1); |
4907 | 408 |
qed_spec_mp "start_conc"; |
409 |
||
5069 | 410 |
Goalw [conc_def] |
4907 | 411 |
"!L R. fin(conc L R) p = (? s. p = False#s & fin R s)"; |
5184 | 412 |
by (simp_tac (simpset() addsplits [list.split]) 1); |
4907 | 413 |
qed_spec_mp "final_conc"; |
414 |
||
5069 | 415 |
Goal |
4907 | 416 |
"accepts (conc L R) w = (? u v. w = u@v & accepts L u & accepts R v)"; |
417 |
by (simp_tac (simpset() addsimps |
|
418 |
[accepts_def,True_steps_conc,final_conc,start_conc]) 1); |
|
5132 | 419 |
by (Blast_tac 1); |
4907 | 420 |
qed "accepts_conc"; |
421 |
||
422 |
(******************************************************) |
|
423 |
(* star *) |
|
424 |
(******************************************************) |
|
425 |
||
5069 | 426 |
Goalw [star_def,step_def] |
4907 | 427 |
"!A. (True#p,q) : eps(star A) = \ |
428 |
\ ( (? r. q = True#r & (p,r) : eps A) | (fin A p & q = True#start A) )"; |
|
5132 | 429 |
by (Simp_tac 1); |
430 |
by (Blast_tac 1); |
|
4907 | 431 |
qed_spec_mp "True_in_eps_star"; |
432 |
AddIffs [True_in_eps_star]; |
|
433 |
||
5069 | 434 |
Goalw [star_def,step_def] |
4907 | 435 |
"!A. (p,q) : step A a --> (True#p, True#q) : step (star A) a"; |
5132 | 436 |
by (Simp_tac 1); |
4907 | 437 |
qed_spec_mp "True_True_step_starI"; |
438 |
||
5069 | 439 |
Goal |
5118 | 440 |
"(p,r) : (eps A)^* ==> (True#p, True#r) : (eps(star A))^*"; |
5132 | 441 |
by (etac rtrancl_induct 1); |
442 |
by (Blast_tac 1); |
|
443 |
by (blast_tac (claset() addIs [True_True_step_starI,rtrancl_into_rtrancl]) 1); |
|
4907 | 444 |
qed_spec_mp "True_True_eps_starI"; |
445 |
||
5069 | 446 |
Goalw [star_def,step_def] |
4907 | 447 |
"!A. fin A p --> (True#p,True#start A) : eps(star A)"; |
5132 | 448 |
by (Simp_tac 1); |
4907 | 449 |
qed_spec_mp "True_start_eps_starI"; |
450 |
||
5069 | 451 |
Goal |
5118 | 452 |
"(tp,s) : (eps(star A))^* ==> (! p. tp = True#p --> \ |
4907 | 453 |
\ (? r. ((p,r) : (eps A)^* | \ |
454 |
\ (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \ |
|
455 |
\ s = True#r))"; |
|
5132 | 456 |
by (etac rtrancl_induct 1); |
457 |
by (Simp_tac 1); |
|
4907 | 458 |
by (Clarify_tac 1); |
459 |
by (Asm_full_simp_tac 1); |
|
5132 | 460 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1); |
4907 | 461 |
val lemma = result(); |
462 |
||
5069 | 463 |
Goal |
4907 | 464 |
"((True#p,s) : (eps(star A))^*) = \ |
465 |
\ (? r. ((p,r) : (eps A)^* | \ |
|
466 |
\ (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \ |
|
467 |
\ s = True#r)"; |
|
5132 | 468 |
by (rtac iffI 1); |
469 |
by (dtac lemma 1); |
|
470 |
by (Blast_tac 1); |
|
4907 | 471 |
(* Why can't blast_tac do the rest? *) |
472 |
by (Clarify_tac 1); |
|
5132 | 473 |
by (etac disjE 1); |
474 |
by (etac True_True_eps_starI 1); |
|
4907 | 475 |
by (Clarify_tac 1); |
5132 | 476 |
by (rtac rtrancl_trans 1); |
477 |
by (etac True_True_eps_starI 1); |
|
478 |
by (rtac rtrancl_trans 1); |
|
479 |
by (rtac r_into_rtrancl 1); |
|
480 |
by (etac True_start_eps_starI 1); |
|
481 |
by (etac True_True_eps_starI 1); |
|
4907 | 482 |
qed "True_eps_star"; |
483 |
AddIffs [True_eps_star]; |
|
484 |
||
485 |
(** True in step Some **) |
|
486 |
||
5069 | 487 |
Goalw [star_def,step_def] |
4907 | 488 |
"!A. (True#p,r): step (star A) (Some a) = \ |
489 |
\ (? q. (p,q): step A (Some a) & r=True#q)"; |
|
5132 | 490 |
by (Simp_tac 1); |
491 |
by (Blast_tac 1); |
|
4907 | 492 |
qed_spec_mp "True_step_star"; |
493 |
AddIffs [True_step_star]; |
|
494 |
||
495 |
||
496 |
(** True in steps **) |
|
497 |
||
498 |
(* reverse list induction! Complicates matters for conc? *) |
|
5069 | 499 |
Goal |
4907 | 500 |
"!rr. (True#start A,rr) : steps (star A) w --> \ |
501 |
\ (? us v. w = concat us @ v & \ |
|
502 |
\ (!u:set us. accepts A u) & \ |
|
503 |
\ (? r. (start A,r) : steps A v & rr = True#r))"; |
|
5132 | 504 |
by (res_inst_tac [("xs","w")] rev_induct 1); |
4907 | 505 |
by (Asm_full_simp_tac 1); |
506 |
by (Clarify_tac 1); |
|
5132 | 507 |
by (res_inst_tac [("x","[]")] exI 1); |
508 |
by (etac disjE 1); |
|
4907 | 509 |
by (Asm_simp_tac 1); |
510 |
by (Clarify_tac 1); |
|
511 |
by (Asm_simp_tac 1); |
|
5132 | 512 |
by (simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1); |
4907 | 513 |
by (Clarify_tac 1); |
5132 | 514 |
by (etac allE 1 THEN mp_tac 1); |
4907 | 515 |
by (Clarify_tac 1); |
5132 | 516 |
by (etac disjE 1); |
517 |
by (res_inst_tac [("x","us")] exI 1); |
|
518 |
by (res_inst_tac [("x","v@[x]")] exI 1); |
|
519 |
by (asm_simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1); |
|
520 |
by (Blast_tac 1); |
|
4907 | 521 |
by (Clarify_tac 1); |
5132 | 522 |
by (res_inst_tac [("x","us@[v@[x]]")] exI 1); |
523 |
by (res_inst_tac [("x","[]")] exI 1); |
|
524 |
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1); |
|
525 |
by (Blast_tac 1); |
|
4907 | 526 |
qed_spec_mp "True_start_steps_starD"; |
527 |
||
5069 | 528 |
Goal "!p. (p,q) : steps A w --> (True#p,True#q) : steps (star A) w"; |
5132 | 529 |
by (induct_tac "w" 1); |
530 |
by (Simp_tac 1); |
|
531 |
by (Simp_tac 1); |
|
532 |
by (blast_tac (claset() addIs [True_True_eps_starI,True_True_step_starI]) 1); |
|
4907 | 533 |
qed_spec_mp "True_True_steps_starI"; |
534 |
||
5069 | 535 |
Goalw [accepts_def] |
4907 | 536 |
"(!u : set us. accepts A u) --> \ |
537 |
\ (True#start A,True#start A) : steps (star A) (concat us)"; |
|
5132 | 538 |
by (induct_tac "us" 1); |
539 |
by (Simp_tac 1); |
|
540 |
by (Simp_tac 1); |
|
541 |
by (blast_tac (claset() addIs [True_True_steps_starI,True_start_eps_starI,r_into_rtrancl,in_epsclosure_steps]) 1); |
|
4907 | 542 |
qed_spec_mp "steps_star_cycle"; |
543 |
||
544 |
(* Better stated directly with start(star A)? Loop in star A back to start(star A)?*) |
|
5069 | 545 |
Goal |
4907 | 546 |
"(True#start A,rr) : steps (star A) w = \ |
547 |
\ (? us v. w = concat us @ v & \ |
|
548 |
\ (!u:set us. accepts A u) & \ |
|
549 |
\ (? r. (start A,r) : steps A v & rr = True#r))"; |
|
5132 | 550 |
by (rtac iffI 1); |
551 |
by (etac True_start_steps_starD 1); |
|
4907 | 552 |
by (Clarify_tac 1); |
5132 | 553 |
by (Asm_simp_tac 1); |
554 |
by (blast_tac (claset() addIs [True_True_steps_starI,steps_star_cycle]) 1); |
|
4907 | 555 |
qed "True_start_steps_star"; |
556 |
||
557 |
(** the start state **) |
|
558 |
||
5069 | 559 |
Goalw [star_def,step_def] |
4907 | 560 |
"!A. (start(star A),r) : step (star A) a = (a=None & r = True#start A)"; |
5132 | 561 |
by (Simp_tac 1); |
4907 | 562 |
qed_spec_mp "start_step_star"; |
563 |
AddIffs [start_step_star]; |
|
564 |
||
565 |
val epsclosure_start_step_star = |
|
566 |
read_instantiate [("p","start(star A)")] in_unfold_rtrancl2; |
|
567 |
||
5069 | 568 |
Goal |
4907 | 569 |
"(start(star A),r) : steps (star A) w = \ |
570 |
\ ((w=[] & r= start(star A)) | (True#start A,r) : steps (star A) w)"; |
|
5132 | 571 |
by (rtac iffI 1); |
572 |
by (exhaust_tac "w" 1); |
|
573 |
by (asm_full_simp_tac (simpset() addsimps |
|
4907 | 574 |
[epsclosure_start_step_star]) 1); |
5132 | 575 |
by (Asm_full_simp_tac 1); |
4907 | 576 |
by (Clarify_tac 1); |
5132 | 577 |
by (asm_full_simp_tac (simpset() addsimps |
4907 | 578 |
[epsclosure_start_step_star]) 1); |
5132 | 579 |
by (Blast_tac 1); |
580 |
by (etac disjE 1); |
|
581 |
by (Asm_simp_tac 1); |
|
582 |
by (blast_tac (claset() addIs [in_steps_epsclosure,r_into_rtrancl]) 1); |
|
4907 | 583 |
qed "start_steps_star"; |
584 |
||
5069 | 585 |
Goalw [star_def] "!A. fin (star A) (True#p) = fin A p"; |
5132 | 586 |
by (Simp_tac 1); |
4907 | 587 |
qed_spec_mp "fin_star_True"; |
588 |
AddIffs [fin_star_True]; |
|
589 |
||
5069 | 590 |
Goalw [star_def] "!A. fin (star A) (start(star A))"; |
5132 | 591 |
by (Simp_tac 1); |
4907 | 592 |
qed_spec_mp "fin_star_start"; |
593 |
AddIffs [fin_star_start]; |
|
594 |
||
595 |
(* too complex! Simpler if loop back to start(star A)? *) |
|
5069 | 596 |
Goalw [accepts_def] |
4907 | 597 |
"accepts (star A) w = \ |
598 |
\ (? us. (!u : set(us). accepts A u) & (w = concat us) )"; |
|
5132 | 599 |
by (simp_tac (simpset() addsimps [start_steps_star,True_start_steps_star]) 1); |
600 |
by (rtac iffI 1); |
|
4907 | 601 |
by (Clarify_tac 1); |
5132 | 602 |
by (etac disjE 1); |
4907 | 603 |
by (Clarify_tac 1); |
5132 | 604 |
by (Simp_tac 1); |
605 |
by (res_inst_tac [("x","[]")] exI 1); |
|
606 |
by (Simp_tac 1); |
|
4907 | 607 |
by (Clarify_tac 1); |
5132 | 608 |
by (res_inst_tac [("x","us@[v]")] exI 1); |
609 |
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1); |
|
610 |
by (Blast_tac 1); |
|
4907 | 611 |
by (Clarify_tac 1); |
5132 | 612 |
by (res_inst_tac [("xs","us")] rev_exhaust 1); |
613 |
by (Asm_simp_tac 1); |
|
614 |
by (Blast_tac 1); |
|
4907 | 615 |
by (Clarify_tac 1); |
5132 | 616 |
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1); |
617 |
by (Blast_tac 1); |
|
4907 | 618 |
qed "accepts_star"; |
619 |
||
620 |
||
621 |
(***** Correctness of r2n *****) |
|
622 |
||
5069 | 623 |
Goal |
4907 | 624 |
"!w. accepts (rexp2nae r) w = (w : lang r)"; |
5132 | 625 |
by (induct_tac "r" 1); |
626 |
by (simp_tac (simpset() addsimps [accepts_def]) 1); |
|
627 |
by (simp_tac(simpset() addsimps [accepts_atom]) 1); |
|
628 |
by (asm_simp_tac (simpset() addsimps [accepts_union]) 1); |
|
629 |
by (asm_simp_tac (simpset() addsimps [accepts_conc,RegSet.conc_def]) 1); |
|
630 |
by (asm_simp_tac (simpset() addsimps [accepts_star,in_star]) 1); |
|
4907 | 631 |
qed "accepts_rexp2nae"; |