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);
|
5457
|
140 |
by Auto_tac;
|
4907
|
141 |
qed_spec_mp "lift_True_over_steps_union";
|
|
142 |
|
5069
|
143 |
Goal
|
4907
|
144 |
"!p. (False#p,q):steps (union L R) w = (? r. q = False#r & (p,r):steps R w)";
|
|
145 |
by (induct_tac "w" 1);
|
5457
|
146 |
by Auto_tac;
|
4907
|
147 |
qed_spec_mp "lift_False_over_steps_union";
|
|
148 |
|
|
149 |
AddIffs [lift_True_over_steps_union,lift_False_over_steps_union];
|
|
150 |
|
|
151 |
|
|
152 |
(***** Epsilonhuelle des Startzustands *****)
|
|
153 |
|
5069
|
154 |
Goal
|
4907
|
155 |
"R^* = id Un (R^* O R)";
|
5132
|
156 |
by (rtac set_ext 1);
|
|
157 |
by (split_all_tac 1);
|
|
158 |
by (rtac iffI 1);
|
|
159 |
by (etac rtrancl_induct 1);
|
|
160 |
by (Blast_tac 1);
|
|
161 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
|
162 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl2]) 1);
|
4907
|
163 |
qed "unfold_rtrancl2";
|
|
164 |
|
5069
|
165 |
Goal
|
4907
|
166 |
"(p,q) : R^* = (q = p | (? r. (p,r) : R & (r,q) : R^*))";
|
5132
|
167 |
by (rtac (unfold_rtrancl2 RS equalityE) 1);
|
|
168 |
by (Blast_tac 1);
|
4907
|
169 |
qed "in_unfold_rtrancl2";
|
|
170 |
|
|
171 |
val epsclosure_start_step_union =
|
|
172 |
read_instantiate [("p","start(union L R)")] in_unfold_rtrancl2;
|
|
173 |
AddIffs [epsclosure_start_step_union];
|
|
174 |
|
5069
|
175 |
Goalw [union_def,step_def]
|
4907
|
176 |
"!L R. (start(union L R),q) : eps(union L R) = \
|
|
177 |
\ (q = True#start L | q = False#start R)";
|
5132
|
178 |
by (Simp_tac 1);
|
4907
|
179 |
qed_spec_mp "start_eps_union";
|
|
180 |
AddIffs [start_eps_union];
|
|
181 |
|
5069
|
182 |
Goalw [union_def,step_def]
|
4907
|
183 |
"!L R. (start(union L R),q) ~: step (union L R) (Some a)";
|
5132
|
184 |
by (Simp_tac 1);
|
4907
|
185 |
qed_spec_mp "not_start_step_union_Some";
|
|
186 |
AddIffs [not_start_step_union_Some];
|
|
187 |
|
5069
|
188 |
Goal
|
4907
|
189 |
"(start(union L R), q) : steps (union L R) w = \
|
|
190 |
\ ( (w = [] & q = start(union L R)) | \
|
|
191 |
\ (? p. q = True # p & (start L,p) : steps L w | \
|
|
192 |
\ q = False # p & (start R,p) : steps R w) )";
|
|
193 |
by (exhaust_tac "w" 1);
|
|
194 |
by (Asm_simp_tac 1);
|
5457
|
195 |
by (Blast_tac 1);
|
4907
|
196 |
by (Asm_simp_tac 1);
|
5457
|
197 |
by (Blast_tac 1);
|
4907
|
198 |
qed "steps_union";
|
|
199 |
|
5069
|
200 |
Goalw [union_def]
|
4907
|
201 |
"!L R. ~ fin (union L R) (start(union L R))";
|
5132
|
202 |
by (Simp_tac 1);
|
4907
|
203 |
qed_spec_mp "start_union_not_final";
|
|
204 |
AddIffs [start_union_not_final];
|
|
205 |
|
5069
|
206 |
Goalw [accepts_def]
|
4907
|
207 |
"accepts (union L R) w = (accepts L w | accepts R w)";
|
|
208 |
by (simp_tac (simpset() addsimps [steps_union]) 1);
|
5132
|
209 |
by Auto_tac;
|
4907
|
210 |
qed "accepts_union";
|
|
211 |
|
|
212 |
|
|
213 |
(******************************************************)
|
|
214 |
(* conc *)
|
|
215 |
(******************************************************)
|
|
216 |
|
|
217 |
(** True/False in fin **)
|
|
218 |
|
5069
|
219 |
Goalw [conc_def]
|
4907
|
220 |
"!L R. fin (conc L R) (True#p) = False";
|
|
221 |
by (Simp_tac 1);
|
|
222 |
qed_spec_mp "fin_conc_True";
|
|
223 |
|
5069
|
224 |
Goalw [conc_def]
|
4907
|
225 |
"!L R. fin (conc L R) (False#p) = fin R p";
|
|
226 |
by (Simp_tac 1);
|
|
227 |
qed "fin_conc_False";
|
|
228 |
|
|
229 |
AddIffs [fin_conc_True,fin_conc_False];
|
|
230 |
|
|
231 |
(** True/False in step **)
|
|
232 |
|
5069
|
233 |
Goalw [conc_def,step_def]
|
4907
|
234 |
"!L R. (True#p,q) : step (conc L R) a = \
|
|
235 |
\ ((? r. q=True#r & (p,r): step L a) | \
|
|
236 |
\ (fin L p & a=None & q=False#start R))";
|
|
237 |
by (Simp_tac 1);
|
5132
|
238 |
by (Blast_tac 1);
|
4907
|
239 |
qed_spec_mp "True_step_conc";
|
|
240 |
|
5069
|
241 |
Goalw [conc_def,step_def]
|
4907
|
242 |
"!L R. (False#p,q) : step (conc L R) a = \
|
|
243 |
\ (? r. q = False#r & (p,r) : step R a)";
|
|
244 |
by (Simp_tac 1);
|
5132
|
245 |
by (Blast_tac 1);
|
4907
|
246 |
qed_spec_mp "False_step_conc";
|
|
247 |
|
|
248 |
AddIffs [True_step_conc, False_step_conc];
|
|
249 |
|
|
250 |
(** False in epsclosure **)
|
|
251 |
|
5069
|
252 |
Goal
|
5118
|
253 |
"(tp,tq) : (eps(conc L R))^* ==> \
|
4907
|
254 |
\ !p. tp = False#p --> (? q. (p,q) : (eps R)^* & tq = False#q)";
|
5132
|
255 |
by (etac rtrancl_induct 1);
|
|
256 |
by (Blast_tac 1);
|
|
257 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
4907
|
258 |
qed "lemma1b";
|
|
259 |
|
5069
|
260 |
Goal
|
5118
|
261 |
"(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*";
|
5132
|
262 |
by (etac rtrancl_induct 1);
|
|
263 |
by (Blast_tac 1);
|
|
264 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
4907
|
265 |
val lemma2b = result();
|
|
266 |
|
5069
|
267 |
Goal
|
4907
|
268 |
"((False # p, q) : (eps (conc L R))^*) = \
|
|
269 |
\ (? r. q = False # r & (p, r) : (eps R)^*)";
|
|
270 |
by (rtac iffI 1);
|
5132
|
271 |
by (blast_tac (claset() addDs [lemma1b]) 1);
|
|
272 |
by (blast_tac (claset() addDs [lemma2b]) 1);
|
4907
|
273 |
qed "False_epsclosure_conc";
|
|
274 |
AddIffs [False_epsclosure_conc];
|
|
275 |
|
|
276 |
(** False in steps **)
|
|
277 |
|
5069
|
278 |
Goal
|
4907
|
279 |
"!p. (False#p,q): steps (conc L R) w = (? r. q=False#r & (p,r): steps R w)";
|
|
280 |
by (induct_tac "w" 1);
|
|
281 |
by (Simp_tac 1);
|
|
282 |
by (Simp_tac 1);
|
5457
|
283 |
by (Fast_tac 1); (*MUCH faster than Blast_tac*)
|
4907
|
284 |
qed_spec_mp "False_steps_conc";
|
|
285 |
AddIffs [False_steps_conc];
|
|
286 |
|
|
287 |
(** True in epsclosure **)
|
|
288 |
|
5069
|
289 |
Goal
|
5118
|
290 |
"(p,q): (eps L)^* ==> (True#p,True#q) : (eps(conc L R))^*";
|
5132
|
291 |
by (etac rtrancl_induct 1);
|
|
292 |
by (Blast_tac 1);
|
|
293 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
4907
|
294 |
qed "True_True_eps_concI";
|
|
295 |
|
5069
|
296 |
Goal
|
5118
|
297 |
"!p. (p,q) : steps L w --> (True#p,True#q) : steps (conc L R) w";
|
5132
|
298 |
by (induct_tac "w" 1);
|
4907
|
299 |
by (simp_tac (simpset() addsimps [True_True_eps_concI]) 1);
|
|
300 |
by (Simp_tac 1);
|
5132
|
301 |
by (blast_tac (claset() addIs [True_True_eps_concI]) 1);
|
4907
|
302 |
qed_spec_mp "True_True_steps_concI";
|
|
303 |
|
5069
|
304 |
Goal
|
5118
|
305 |
"(tp,tq) : (eps(conc L R))^* ==> \
|
4907
|
306 |
\ !p. tp = True#p --> \
|
|
307 |
\ (? q. tq = True#q & (p,q) : (eps L)^*) | \
|
|
308 |
\ (? q r. tq = False#q & (p,r):(eps L)^* & fin L r & (start R,q) : (eps R)^*)";
|
5132
|
309 |
by (etac rtrancl_induct 1);
|
|
310 |
by (Blast_tac 1);
|
|
311 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
4907
|
312 |
val lemma1a = result();
|
|
313 |
|
5069
|
314 |
Goal
|
5118
|
315 |
"(p, q) : (eps L)^* ==> (True#p, True#q) : (eps(conc L R))^*";
|
5132
|
316 |
by (etac rtrancl_induct 1);
|
|
317 |
by (Blast_tac 1);
|
|
318 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
4907
|
319 |
val lemma2a = result();
|
|
320 |
|
5069
|
321 |
Goalw [conc_def,step_def]
|
4907
|
322 |
"!!L R. (p,q) : step R None ==> (False#p, False#q) : step (conc L R) None";
|
5132
|
323 |
by (split_all_tac 1);
|
4907
|
324 |
by (Asm_full_simp_tac 1);
|
|
325 |
val lemma = result();
|
|
326 |
|
5069
|
327 |
Goal
|
5118
|
328 |
"(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*";
|
5132
|
329 |
by (etac rtrancl_induct 1);
|
|
330 |
by (Blast_tac 1);
|
4907
|
331 |
by (dtac lemma 1);
|
5132
|
332 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
4907
|
333 |
val lemma2b = result();
|
|
334 |
|
5069
|
335 |
Goalw [conc_def,step_def]
|
4907
|
336 |
"!!L R. fin L p ==> (True#p, False#start R) : eps(conc L R)";
|
5132
|
337 |
by (split_all_tac 1);
|
|
338 |
by (Asm_full_simp_tac 1);
|
4907
|
339 |
qed "True_False_eps_concI";
|
|
340 |
|
5069
|
341 |
Goal
|
4907
|
342 |
"((True#p,q) : (eps(conc L R))^*) = \
|
|
343 |
\ ((? r. (p,r) : (eps L)^* & q = True#r) | \
|
|
344 |
\ (? r. (p,r) : (eps L)^* & fin L r & \
|
|
345 |
\ (? s. (start R, s) : (eps R)^* & q = False#s)))";
|
5132
|
346 |
by (rtac iffI 1);
|
|
347 |
by (blast_tac (claset() addDs [lemma1a]) 1);
|
|
348 |
by (etac disjE 1);
|
|
349 |
by (blast_tac (claset() addIs [lemma2a]) 1);
|
|
350 |
by (Clarify_tac 1);
|
|
351 |
by (rtac (rtrancl_trans) 1);
|
|
352 |
by (etac lemma2a 1);
|
|
353 |
by (rtac (rtrancl_into_rtrancl2) 1);
|
|
354 |
by (etac True_False_eps_concI 1);
|
|
355 |
by (etac lemma2b 1);
|
4907
|
356 |
qed "True_epsclosure_conc";
|
|
357 |
AddIffs [True_epsclosure_conc];
|
|
358 |
|
|
359 |
(** True in steps **)
|
|
360 |
|
5069
|
361 |
Goal
|
4907
|
362 |
"!p. (True#p,q) : steps (conc L R) w --> \
|
|
363 |
\ ((? r. (p,r) : steps L w & q = True#r) | \
|
|
364 |
\ (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \
|
|
365 |
\ (? s. (start R,s) : steps R v & q = False#s))))";
|
5132
|
366 |
by (induct_tac "w" 1);
|
|
367 |
by (Simp_tac 1);
|
|
368 |
by (Simp_tac 1);
|
|
369 |
by (clarify_tac (claset() delrules [disjCI]) 1);
|
|
370 |
by (etac disjE 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 allE 1 THEN mp_tac 1);
|
|
375 |
by (etac disjE 1);
|
4907
|
376 |
by (Blast_tac 1);
|
5132
|
377 |
by (rtac disjI2 1);
|
4907
|
378 |
by (Clarify_tac 1);
|
5132
|
379 |
by (Simp_tac 1);
|
|
380 |
by (res_inst_tac[("x","a#u")] exI 1);
|
|
381 |
by (Simp_tac 1);
|
4907
|
382 |
by (Blast_tac 1);
|
|
383 |
by (Blast_tac 1);
|
5132
|
384 |
by (rtac disjI2 1);
|
4907
|
385 |
by (Clarify_tac 1);
|
5132
|
386 |
by (Simp_tac 1);
|
|
387 |
by (res_inst_tac[("x","[]")] exI 1);
|
|
388 |
by (Simp_tac 1);
|
4907
|
389 |
by (Blast_tac 1);
|
|
390 |
qed_spec_mp "True_steps_concD";
|
|
391 |
|
5069
|
392 |
Goal
|
4907
|
393 |
"(True#p,q) : steps (conc L R) w = \
|
|
394 |
\ ((? r. (p,r) : steps L w & q = True#r) | \
|
|
395 |
\ (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \
|
|
396 |
\ (? s. (start R,s) : steps R v & q = False#s))))";
|
5132
|
397 |
by (blast_tac (claset() addDs [True_steps_concD]
|
4907
|
398 |
addIs [True_True_steps_concI,in_steps_epsclosure,r_into_rtrancl]) 1);
|
|
399 |
qed "True_steps_conc";
|
|
400 |
|
|
401 |
(** starting from the start **)
|
|
402 |
|
5069
|
403 |
Goalw [conc_def]
|
4907
|
404 |
"!L R. start(conc L R) = True#start L";
|
5132
|
405 |
by (Simp_tac 1);
|
4907
|
406 |
qed_spec_mp "start_conc";
|
|
407 |
|
5069
|
408 |
Goalw [conc_def]
|
4907
|
409 |
"!L R. fin(conc L R) p = (? s. p = False#s & fin R s)";
|
5184
|
410 |
by (simp_tac (simpset() addsplits [list.split]) 1);
|
4907
|
411 |
qed_spec_mp "final_conc";
|
|
412 |
|
5069
|
413 |
Goal
|
4907
|
414 |
"accepts (conc L R) w = (? u v. w = u@v & accepts L u & accepts R v)";
|
|
415 |
by (simp_tac (simpset() addsimps
|
|
416 |
[accepts_def,True_steps_conc,final_conc,start_conc]) 1);
|
5132
|
417 |
by (Blast_tac 1);
|
4907
|
418 |
qed "accepts_conc";
|
|
419 |
|
|
420 |
(******************************************************)
|
|
421 |
(* star *)
|
|
422 |
(******************************************************)
|
|
423 |
|
5069
|
424 |
Goalw [star_def,step_def]
|
4907
|
425 |
"!A. (True#p,q) : eps(star A) = \
|
|
426 |
\ ( (? r. q = True#r & (p,r) : eps A) | (fin A p & q = True#start A) )";
|
5132
|
427 |
by (Simp_tac 1);
|
|
428 |
by (Blast_tac 1);
|
4907
|
429 |
qed_spec_mp "True_in_eps_star";
|
|
430 |
AddIffs [True_in_eps_star];
|
|
431 |
|
5069
|
432 |
Goalw [star_def,step_def]
|
4907
|
433 |
"!A. (p,q) : step A a --> (True#p, True#q) : step (star A) a";
|
5132
|
434 |
by (Simp_tac 1);
|
4907
|
435 |
qed_spec_mp "True_True_step_starI";
|
|
436 |
|
5069
|
437 |
Goal
|
5118
|
438 |
"(p,r) : (eps A)^* ==> (True#p, True#r) : (eps(star A))^*";
|
5132
|
439 |
by (etac rtrancl_induct 1);
|
|
440 |
by (Blast_tac 1);
|
|
441 |
by (blast_tac (claset() addIs [True_True_step_starI,rtrancl_into_rtrancl]) 1);
|
4907
|
442 |
qed_spec_mp "True_True_eps_starI";
|
|
443 |
|
5069
|
444 |
Goalw [star_def,step_def]
|
4907
|
445 |
"!A. fin A p --> (True#p,True#start A) : eps(star A)";
|
5132
|
446 |
by (Simp_tac 1);
|
4907
|
447 |
qed_spec_mp "True_start_eps_starI";
|
|
448 |
|
5069
|
449 |
Goal
|
5118
|
450 |
"(tp,s) : (eps(star A))^* ==> (! p. tp = True#p --> \
|
4907
|
451 |
\ (? r. ((p,r) : (eps A)^* | \
|
|
452 |
\ (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \
|
|
453 |
\ s = True#r))";
|
5132
|
454 |
by (etac rtrancl_induct 1);
|
|
455 |
by (Simp_tac 1);
|
4907
|
456 |
by (Clarify_tac 1);
|
|
457 |
by (Asm_full_simp_tac 1);
|
5132
|
458 |
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
|
4907
|
459 |
val lemma = result();
|
|
460 |
|
5069
|
461 |
Goal
|
4907
|
462 |
"((True#p,s) : (eps(star A))^*) = \
|
|
463 |
\ (? r. ((p,r) : (eps A)^* | \
|
|
464 |
\ (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \
|
|
465 |
\ s = True#r)";
|
5132
|
466 |
by (rtac iffI 1);
|
|
467 |
by (dtac lemma 1);
|
|
468 |
by (Blast_tac 1);
|
4907
|
469 |
(* Why can't blast_tac do the rest? *)
|
|
470 |
by (Clarify_tac 1);
|
5132
|
471 |
by (etac disjE 1);
|
|
472 |
by (etac True_True_eps_starI 1);
|
4907
|
473 |
by (Clarify_tac 1);
|
5132
|
474 |
by (rtac rtrancl_trans 1);
|
|
475 |
by (etac True_True_eps_starI 1);
|
|
476 |
by (rtac rtrancl_trans 1);
|
|
477 |
by (rtac r_into_rtrancl 1);
|
|
478 |
by (etac True_start_eps_starI 1);
|
|
479 |
by (etac True_True_eps_starI 1);
|
4907
|
480 |
qed "True_eps_star";
|
|
481 |
AddIffs [True_eps_star];
|
|
482 |
|
|
483 |
(** True in step Some **)
|
|
484 |
|
5069
|
485 |
Goalw [star_def,step_def]
|
4907
|
486 |
"!A. (True#p,r): step (star A) (Some a) = \
|
|
487 |
\ (? q. (p,q): step A (Some a) & r=True#q)";
|
5132
|
488 |
by (Simp_tac 1);
|
|
489 |
by (Blast_tac 1);
|
4907
|
490 |
qed_spec_mp "True_step_star";
|
|
491 |
AddIffs [True_step_star];
|
|
492 |
|
|
493 |
|
|
494 |
(** True in steps **)
|
|
495 |
|
|
496 |
(* reverse list induction! Complicates matters for conc? *)
|
5069
|
497 |
Goal
|
4907
|
498 |
"!rr. (True#start A,rr) : steps (star A) w --> \
|
|
499 |
\ (? us v. w = concat us @ v & \
|
|
500 |
\ (!u:set us. accepts A u) & \
|
|
501 |
\ (? r. (start A,r) : steps A v & rr = True#r))";
|
5132
|
502 |
by (res_inst_tac [("xs","w")] rev_induct 1);
|
4907
|
503 |
by (Asm_full_simp_tac 1);
|
|
504 |
by (Clarify_tac 1);
|
5132
|
505 |
by (res_inst_tac [("x","[]")] exI 1);
|
|
506 |
by (etac disjE 1);
|
4907
|
507 |
by (Asm_simp_tac 1);
|
|
508 |
by (Clarify_tac 1);
|
|
509 |
by (Asm_simp_tac 1);
|
5132
|
510 |
by (simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1);
|
4907
|
511 |
by (Clarify_tac 1);
|
5132
|
512 |
by (etac allE 1 THEN mp_tac 1);
|
4907
|
513 |
by (Clarify_tac 1);
|
5132
|
514 |
by (etac disjE 1);
|
|
515 |
by (res_inst_tac [("x","us")] exI 1);
|
|
516 |
by (res_inst_tac [("x","v@[x]")] exI 1);
|
|
517 |
by (asm_simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1);
|
|
518 |
by (Blast_tac 1);
|
4907
|
519 |
by (Clarify_tac 1);
|
5132
|
520 |
by (res_inst_tac [("x","us@[v@[x]]")] exI 1);
|
|
521 |
by (res_inst_tac [("x","[]")] exI 1);
|
|
522 |
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
|
|
523 |
by (Blast_tac 1);
|
4907
|
524 |
qed_spec_mp "True_start_steps_starD";
|
|
525 |
|
5069
|
526 |
Goal "!p. (p,q) : steps A w --> (True#p,True#q) : steps (star A) w";
|
5132
|
527 |
by (induct_tac "w" 1);
|
|
528 |
by (Simp_tac 1);
|
|
529 |
by (Simp_tac 1);
|
|
530 |
by (blast_tac (claset() addIs [True_True_eps_starI,True_True_step_starI]) 1);
|
4907
|
531 |
qed_spec_mp "True_True_steps_starI";
|
|
532 |
|
5069
|
533 |
Goalw [accepts_def]
|
4907
|
534 |
"(!u : set us. accepts A u) --> \
|
|
535 |
\ (True#start A,True#start A) : steps (star A) (concat us)";
|
5132
|
536 |
by (induct_tac "us" 1);
|
|
537 |
by (Simp_tac 1);
|
|
538 |
by (Simp_tac 1);
|
|
539 |
by (blast_tac (claset() addIs [True_True_steps_starI,True_start_eps_starI,r_into_rtrancl,in_epsclosure_steps]) 1);
|
4907
|
540 |
qed_spec_mp "steps_star_cycle";
|
|
541 |
|
|
542 |
(* Better stated directly with start(star A)? Loop in star A back to start(star A)?*)
|
5069
|
543 |
Goal
|
4907
|
544 |
"(True#start A,rr) : steps (star A) w = \
|
|
545 |
\ (? us v. w = concat us @ v & \
|
|
546 |
\ (!u:set us. accepts A u) & \
|
|
547 |
\ (? r. (start A,r) : steps A v & rr = True#r))";
|
5132
|
548 |
by (rtac iffI 1);
|
|
549 |
by (etac True_start_steps_starD 1);
|
4907
|
550 |
by (Clarify_tac 1);
|
5132
|
551 |
by (Asm_simp_tac 1);
|
|
552 |
by (blast_tac (claset() addIs [True_True_steps_starI,steps_star_cycle]) 1);
|
4907
|
553 |
qed "True_start_steps_star";
|
|
554 |
|
|
555 |
(** the start state **)
|
|
556 |
|
5069
|
557 |
Goalw [star_def,step_def]
|
4907
|
558 |
"!A. (start(star A),r) : step (star A) a = (a=None & r = True#start A)";
|
5132
|
559 |
by (Simp_tac 1);
|
4907
|
560 |
qed_spec_mp "start_step_star";
|
|
561 |
AddIffs [start_step_star];
|
|
562 |
|
|
563 |
val epsclosure_start_step_star =
|
|
564 |
read_instantiate [("p","start(star A)")] in_unfold_rtrancl2;
|
|
565 |
|
5069
|
566 |
Goal
|
4907
|
567 |
"(start(star A),r) : steps (star A) w = \
|
|
568 |
\ ((w=[] & r= start(star A)) | (True#start A,r) : steps (star A) w)";
|
5132
|
569 |
by (rtac iffI 1);
|
|
570 |
by (exhaust_tac "w" 1);
|
|
571 |
by (asm_full_simp_tac (simpset() addsimps
|
4907
|
572 |
[epsclosure_start_step_star]) 1);
|
5132
|
573 |
by (Asm_full_simp_tac 1);
|
4907
|
574 |
by (Clarify_tac 1);
|
5132
|
575 |
by (asm_full_simp_tac (simpset() addsimps
|
4907
|
576 |
[epsclosure_start_step_star]) 1);
|
5132
|
577 |
by (Blast_tac 1);
|
|
578 |
by (etac disjE 1);
|
|
579 |
by (Asm_simp_tac 1);
|
|
580 |
by (blast_tac (claset() addIs [in_steps_epsclosure,r_into_rtrancl]) 1);
|
4907
|
581 |
qed "start_steps_star";
|
|
582 |
|
5069
|
583 |
Goalw [star_def] "!A. fin (star A) (True#p) = fin A p";
|
5132
|
584 |
by (Simp_tac 1);
|
4907
|
585 |
qed_spec_mp "fin_star_True";
|
|
586 |
AddIffs [fin_star_True];
|
|
587 |
|
5069
|
588 |
Goalw [star_def] "!A. fin (star A) (start(star A))";
|
5132
|
589 |
by (Simp_tac 1);
|
4907
|
590 |
qed_spec_mp "fin_star_start";
|
|
591 |
AddIffs [fin_star_start];
|
|
592 |
|
|
593 |
(* too complex! Simpler if loop back to start(star A)? *)
|
5069
|
594 |
Goalw [accepts_def]
|
4907
|
595 |
"accepts (star A) w = \
|
|
596 |
\ (? us. (!u : set(us). accepts A u) & (w = concat us) )";
|
5132
|
597 |
by (simp_tac (simpset() addsimps [start_steps_star,True_start_steps_star]) 1);
|
|
598 |
by (rtac iffI 1);
|
4907
|
599 |
by (Clarify_tac 1);
|
5132
|
600 |
by (etac disjE 1);
|
4907
|
601 |
by (Clarify_tac 1);
|
5132
|
602 |
by (Simp_tac 1);
|
|
603 |
by (res_inst_tac [("x","[]")] exI 1);
|
|
604 |
by (Simp_tac 1);
|
4907
|
605 |
by (Clarify_tac 1);
|
5132
|
606 |
by (res_inst_tac [("x","us@[v]")] exI 1);
|
|
607 |
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
|
|
608 |
by (Blast_tac 1);
|
4907
|
609 |
by (Clarify_tac 1);
|
5132
|
610 |
by (res_inst_tac [("xs","us")] rev_exhaust 1);
|
|
611 |
by (Asm_simp_tac 1);
|
|
612 |
by (Blast_tac 1);
|
4907
|
613 |
by (Clarify_tac 1);
|
5132
|
614 |
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
|
|
615 |
by (Blast_tac 1);
|
4907
|
616 |
qed "accepts_star";
|
|
617 |
|
|
618 |
|
|
619 |
(***** Correctness of r2n *****)
|
|
620 |
|
5069
|
621 |
Goal
|
4907
|
622 |
"!w. accepts (rexp2nae r) w = (w : lang r)";
|
5132
|
623 |
by (induct_tac "r" 1);
|
|
624 |
by (simp_tac (simpset() addsimps [accepts_def]) 1);
|
|
625 |
by (simp_tac(simpset() addsimps [accepts_atom]) 1);
|
|
626 |
by (asm_simp_tac (simpset() addsimps [accepts_union]) 1);
|
|
627 |
by (asm_simp_tac (simpset() addsimps [accepts_conc,RegSet.conc_def]) 1);
|
|
628 |
by (asm_simp_tac (simpset() addsimps [accepts_star,in_star]) 1);
|
4907
|
629 |
qed "accepts_rexp2nae";
|