3071
|
1 |
(* Title: HOLCF/IOA/meta_theory/Automata.ML
|
3275
|
2 |
ID: $Id$
|
3071
|
3 |
Author: Olaf Mueller, Tobias Nipkow, Konrad Slind
|
|
4 |
Copyright 1994, 1996 TU Muenchen
|
|
5 |
|
|
6 |
The I/O automata of Lynch and Tuttle.
|
|
7 |
*)
|
|
8 |
|
|
9 |
(* Has been removed from HOL-simpset, who knows why? *)
|
|
10 |
Addsimps [Let_def];
|
|
11 |
|
|
12 |
open reachable;
|
|
13 |
|
|
14 |
val ioa_projections = [asig_of_def, starts_of_def, trans_of_def];
|
|
15 |
|
|
16 |
(* ----------------------------------------------------------------------------------- *)
|
|
17 |
|
|
18 |
section "asig_of, starts_of, trans_of";
|
|
19 |
|
|
20 |
|
|
21 |
goal thy
|
|
22 |
"asig_of((x,y,z)) = x & starts_of((x,y,z)) = y & trans_of((x,y,z)) = z";
|
|
23 |
by (simp_tac (!simpset addsimps ioa_projections) 1);
|
|
24 |
qed "ioa_triple_proj";
|
|
25 |
|
|
26 |
goalw thy [ioa_def,state_trans_def,actions_def, is_asig_def]
|
|
27 |
"!!A. [| IOA(A); (s1,a,s2):trans_of(A) |] ==> a:act A";
|
|
28 |
by (REPEAT(etac conjE 1));
|
|
29 |
by (EVERY1[etac allE, etac impE, atac]);
|
|
30 |
by (Asm_full_simp_tac 1);
|
|
31 |
qed "trans_in_actions";
|
|
32 |
|
|
33 |
goal thy
|
|
34 |
"starts_of(A || B) = {p. fst(p):starts_of(A) & snd(p):starts_of(B)}";
|
|
35 |
by(simp_tac (!simpset addsimps (par_def::ioa_projections)) 1);
|
|
36 |
qed "starts_of_par";
|
|
37 |
|
|
38 |
|
|
39 |
(* ----------------------------------------------------------------------------------- *)
|
|
40 |
|
|
41 |
section "actions and par";
|
|
42 |
|
|
43 |
|
|
44 |
goal thy
|
|
45 |
"actions(asig_comp a b) = actions(a) Un actions(b)";
|
|
46 |
by(simp_tac (!simpset addsimps
|
|
47 |
([actions_def,asig_comp_def]@asig_projections)) 1);
|
|
48 |
by (fast_tac (set_cs addSIs [equalityI]) 1);
|
|
49 |
qed "actions_asig_comp";
|
|
50 |
|
|
51 |
|
|
52 |
goal thy "asig_of(A || B) = asig_comp (asig_of A) (asig_of B)";
|
|
53 |
by(simp_tac (!simpset addsimps (par_def::ioa_projections)) 1);
|
|
54 |
qed "asig_of_par";
|
|
55 |
|
|
56 |
|
|
57 |
goal thy "ext (A1||A2) = \
|
|
58 |
\ (ext A1) Un (ext A2)";
|
|
59 |
by (asm_full_simp_tac (!simpset addsimps [externals_def,asig_of_par,asig_comp_def,
|
|
60 |
asig_inputs_def,asig_outputs_def,Un_def,set_diff_def]) 1);
|
|
61 |
by (rtac set_ext 1);
|
|
62 |
by (fast_tac set_cs 1);
|
|
63 |
qed"externals_of_par";
|
|
64 |
|
|
65 |
goal thy "act (A1||A2) = \
|
|
66 |
\ (act A1) Un (act A2)";
|
|
67 |
by (asm_full_simp_tac (!simpset addsimps [actions_def,asig_of_par,asig_comp_def,
|
|
68 |
asig_inputs_def,asig_outputs_def,asig_internals_def,Un_def,set_diff_def]) 1);
|
|
69 |
by (rtac set_ext 1);
|
|
70 |
by (fast_tac set_cs 1);
|
|
71 |
qed"actions_of_par";
|
|
72 |
|
|
73 |
|
|
74 |
goal thy "inp (A1||A2) =\
|
|
75 |
\ ((inp A1) Un (inp A2)) - ((out A1) Un (out A2))";
|
|
76 |
by (asm_full_simp_tac (!simpset addsimps [actions_def,asig_of_par,asig_comp_def,
|
|
77 |
asig_inputs_def,asig_outputs_def,Un_def,set_diff_def]) 1);
|
|
78 |
qed"inputs_of_par";
|
|
79 |
|
|
80 |
goal thy "out (A1||A2) =\
|
|
81 |
\ (out A1) Un (out A2)";
|
|
82 |
by (asm_full_simp_tac (!simpset addsimps [actions_def,asig_of_par,asig_comp_def,
|
|
83 |
asig_outputs_def,Un_def,set_diff_def]) 1);
|
|
84 |
qed"outputs_of_par";
|
|
85 |
|
|
86 |
|
|
87 |
(* ---------------------------------------------------------------------------------- *)
|
|
88 |
|
|
89 |
section "actions and compatibility";
|
|
90 |
|
|
91 |
goal thy"compat_ioas A B = compat_ioas B A";
|
|
92 |
by (asm_full_simp_tac (!simpset addsimps [compat_ioas_def,compat_asigs_def,Int_commute]) 1);
|
|
93 |
auto();
|
|
94 |
qed"compat_commute";
|
|
95 |
|
|
96 |
goalw thy [externals_def,actions_def,compat_ioas_def,compat_asigs_def]
|
|
97 |
"!! a. [| compat_ioas A1 A2; a:ext A1|] ==> a~:int A2";
|
|
98 |
by (Asm_full_simp_tac 1);
|
|
99 |
by (best_tac (set_cs addEs [equalityCE]) 1);
|
|
100 |
qed"ext1_is_not_int2";
|
|
101 |
|
|
102 |
(* just commuting the previous one: better commute compat_ioas *)
|
|
103 |
goalw thy [externals_def,actions_def,compat_ioas_def,compat_asigs_def]
|
|
104 |
"!! a. [| compat_ioas A2 A1 ; a:ext A1|] ==> a~:int A2";
|
|
105 |
by (Asm_full_simp_tac 1);
|
|
106 |
by (best_tac (set_cs addEs [equalityCE]) 1);
|
|
107 |
qed"ext2_is_not_int1";
|
|
108 |
|
|
109 |
bind_thm("ext1_ext2_is_not_act2",ext1_is_not_int2 RS int_and_ext_is_act);
|
|
110 |
bind_thm("ext1_ext2_is_not_act1",ext2_is_not_int1 RS int_and_ext_is_act);
|
|
111 |
|
|
112 |
goalw thy [externals_def,actions_def,compat_ioas_def,compat_asigs_def]
|
|
113 |
"!! x. [| compat_ioas A B; x:int A |] ==> x~:ext B";
|
|
114 |
by (Asm_full_simp_tac 1);
|
|
115 |
by (best_tac (set_cs addEs [equalityCE]) 1);
|
|
116 |
qed"intA_is_not_extB";
|
|
117 |
|
|
118 |
goalw thy [externals_def,actions_def,compat_ioas_def,compat_asigs_def,is_asig_def,asig_of_def]
|
|
119 |
"!! a. [| compat_ioas A B; a:int A |] ==> a ~: act B";
|
|
120 |
by (Asm_full_simp_tac 1);
|
|
121 |
by (best_tac (set_cs addEs [equalityCE]) 1);
|
|
122 |
qed"intA_is_not_actB";
|
|
123 |
|
|
124 |
|
|
125 |
(* ---------------------------------------------------------------------------------- *)
|
|
126 |
|
|
127 |
section "invariants";
|
|
128 |
|
|
129 |
val [p1,p2] = goalw thy [invariant_def]
|
|
130 |
"[| !!s. s:starts_of(A) ==> P(s); \
|
|
131 |
\ !!s t a. [|reachable A s; P(s)|] ==> (s,a,t): trans_of(A) --> P(t) |] \
|
|
132 |
\ ==> invariant A P";
|
|
133 |
by (rtac allI 1);
|
|
134 |
by (rtac impI 1);
|
|
135 |
by (res_inst_tac [("za","s")] reachable.induct 1);
|
|
136 |
by (atac 1);
|
|
137 |
by (etac p1 1);
|
|
138 |
by (eres_inst_tac [("s1","sa")] (p2 RS mp) 1);
|
|
139 |
by (REPEAT (atac 1));
|
|
140 |
qed"invariantI";
|
|
141 |
|
|
142 |
|
|
143 |
val [p1,p2] = goal thy
|
|
144 |
"[| !!s. s : starts_of(A) ==> P(s); \
|
|
145 |
\ !!s t a. reachable A s ==> P(s) --> (s,a,t):trans_of(A) --> P(t) \
|
|
146 |
\ |] ==> invariant A P";
|
|
147 |
by (fast_tac (HOL_cs addSIs [invariantI] addSDs [p1,p2]) 1);
|
|
148 |
qed "invariantI1";
|
|
149 |
|
|
150 |
val [p1,p2] = goalw thy [invariant_def]
|
|
151 |
"[| invariant A P; reachable A s |] ==> P(s)";
|
|
152 |
br(p2 RS (p1 RS spec RS mp))1;
|
|
153 |
qed "invariantE";
|
|
154 |
|
|
155 |
(* ---------------------------------------------------------------------------------- *)
|
|
156 |
|
|
157 |
section "restrict";
|
|
158 |
|
|
159 |
|
|
160 |
goal thy "starts_of(restrict ioa acts) = starts_of(ioa) & \
|
|
161 |
\ trans_of(restrict ioa acts) = trans_of(ioa)";
|
|
162 |
by(simp_tac (!simpset addsimps ([restrict_def]@ioa_projections)) 1);
|
|
163 |
qed "cancel_restrict_a";
|
|
164 |
|
|
165 |
goal thy "reachable (restrict ioa acts) s = reachable ioa s";
|
|
166 |
by (rtac iffI 1);
|
|
167 |
be reachable.induct 1;
|
|
168 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a,reachable_0]) 1);
|
|
169 |
by (etac reachable_n 1);
|
|
170 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a]) 1);
|
|
171 |
(* <-- *)
|
|
172 |
be reachable.induct 1;
|
|
173 |
by (rtac reachable_0 1);
|
|
174 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a]) 1);
|
|
175 |
by (etac reachable_n 1);
|
|
176 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a]) 1);
|
|
177 |
qed "cancel_restrict_b";
|
|
178 |
|
|
179 |
goal thy "starts_of(restrict ioa acts) = starts_of(ioa) & \
|
|
180 |
\ trans_of(restrict ioa acts) = trans_of(ioa) & \
|
|
181 |
\ reachable (restrict ioa acts) s = reachable ioa s";
|
|
182 |
by (simp_tac (!simpset addsimps [cancel_restrict_a,cancel_restrict_b]) 1);
|
|
183 |
qed"cancel_restrict";
|
|
184 |
|
|
185 |
(* ---------------------------------------------------------------------------------- *)
|
|
186 |
|
|
187 |
section "rename";
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
goal thy "!!f. s -a--(rename C f)-> t ==> (? x. Some(x) = f(a) & s -x--C-> t)";
|
|
192 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,rename_def,trans_of_def]) 1);
|
|
193 |
qed"trans_rename";
|
|
194 |
|
|
195 |
|
|
196 |
goal thy "!!s.[| reachable (rename C g) s |] ==> reachable C s";
|
|
197 |
be reachable.induct 1;
|
|
198 |
br reachable_0 1;
|
|
199 |
by(asm_full_simp_tac (!simpset addsimps [rename_def]@ioa_projections) 1);
|
|
200 |
bd trans_rename 1;
|
|
201 |
be exE 1;
|
|
202 |
be conjE 1;
|
|
203 |
be reachable_n 1;
|
|
204 |
ba 1;
|
|
205 |
qed"reachable_rename";
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
(* ---------------------------------------------------------------------------------- *)
|
|
210 |
|
|
211 |
section "trans_of(A||B)";
|
|
212 |
|
|
213 |
|
|
214 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a:act A|] \
|
|
215 |
\ ==> (fst s,a,fst t):trans_of A";
|
|
216 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
217 |
qed"trans_A_proj";
|
|
218 |
|
|
219 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a:act B|] \
|
|
220 |
\ ==> (snd s,a,snd t):trans_of B";
|
|
221 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
222 |
qed"trans_B_proj";
|
|
223 |
|
|
224 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a~:act A|]\
|
|
225 |
\ ==> fst s = fst t";
|
|
226 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
227 |
qed"trans_A_proj2";
|
|
228 |
|
|
229 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a~:act B|]\
|
|
230 |
\ ==> snd s = snd t";
|
|
231 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
232 |
qed"trans_B_proj2";
|
|
233 |
|
|
234 |
goal thy "!!A.(s,a,t):trans_of (A||B) \
|
|
235 |
\ ==> a :act A | a :act B";
|
|
236 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
237 |
qed"trans_AB_proj";
|
|
238 |
|
|
239 |
goal thy "!!A. [|a:act A;a:act B;\
|
|
240 |
\ (fst s,a,fst t):trans_of A;(snd s,a,snd t):trans_of B|]\
|
|
241 |
\ ==> (s,a,t):trans_of (A||B)";
|
|
242 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
243 |
qed"trans_AB";
|
|
244 |
|
|
245 |
goal thy "!!A. [|a:act A;a~:act B;\
|
|
246 |
\ (fst s,a,fst t):trans_of A;snd s=snd t|]\
|
|
247 |
\ ==> (s,a,t):trans_of (A||B)";
|
|
248 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
249 |
qed"trans_A_notB";
|
|
250 |
|
|
251 |
goal thy "!!A. [|a~:act A;a:act B;\
|
|
252 |
\ (snd s,a,snd t):trans_of B;fst s=fst t|]\
|
|
253 |
\ ==> (s,a,t):trans_of (A||B)";
|
|
254 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1);
|
|
255 |
qed"trans_notA_B";
|
|
256 |
|
|
257 |
val trans_of_defs1 = [trans_AB,trans_A_notB,trans_notA_B];
|
|
258 |
val trans_of_defs2 = [trans_A_proj,trans_B_proj,trans_A_proj2,
|
|
259 |
trans_B_proj2,trans_AB_proj];
|
|
260 |
|
|
261 |
|
|
262 |
goal thy
|
|
263 |
"(s,a,t) : trans_of(A || B || C || D) = \
|
|
264 |
\ ((a:actions(asig_of(A)) | a:actions(asig_of(B)) | a:actions(asig_of(C)) | \
|
|
265 |
\ a:actions(asig_of(D))) & \
|
|
266 |
\ (if a:actions(asig_of(A)) then (fst(s),a,fst(t)):trans_of(A) \
|
|
267 |
\ else fst t=fst s) & \
|
|
268 |
\ (if a:actions(asig_of(B)) then (fst(snd(s)),a,fst(snd(t))):trans_of(B) \
|
|
269 |
\ else fst(snd(t))=fst(snd(s))) & \
|
|
270 |
\ (if a:actions(asig_of(C)) then \
|
|
271 |
\ (fst(snd(snd(s))),a,fst(snd(snd(t)))):trans_of(C) \
|
|
272 |
\ else fst(snd(snd(t)))=fst(snd(snd(s)))) & \
|
|
273 |
\ (if a:actions(asig_of(D)) then \
|
|
274 |
\ (snd(snd(snd(s))),a,snd(snd(snd(t)))):trans_of(D) \
|
|
275 |
\ else snd(snd(snd(t)))=snd(snd(snd(s)))))";
|
|
276 |
|
|
277 |
by(simp_tac (!simpset addsimps ([par_def,actions_asig_comp,Pair_fst_snd_eq,Let_def]@
|
|
278 |
ioa_projections)
|
|
279 |
setloop (split_tac [expand_if])) 1);
|
|
280 |
qed "trans_of_par4";
|
|
281 |
|
|
282 |
|
|
283 |
|