author | mueller |
Thu, 12 Jun 1997 16:47:15 +0200 | |
changeset 3433 | 2de17c994071 |
parent 3275 | 3f53f2c876f4 |
child 3457 | a8ab7c64817c |
permissions | -rw-r--r-- |
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 |
||
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
91 |
goal thy"compatible A B = compatible B A"; |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
92 |
by (asm_full_simp_tac (!simpset addsimps [compatible_def,Int_commute]) 1); |
3071 | 93 |
auto(); |
94 |
qed"compat_commute"; |
|
95 |
||
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
96 |
goalw thy [externals_def,actions_def,compatible_def] |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
97 |
"!! a. [| compatible A1 A2; a:ext A1|] ==> a~:int A2"; |
3071 | 98 |
by (Asm_full_simp_tac 1); |
99 |
by (best_tac (set_cs addEs [equalityCE]) 1); |
|
100 |
qed"ext1_is_not_int2"; |
|
101 |
||
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
102 |
(* just commuting the previous one: better commute compatible *) |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
103 |
goalw thy [externals_def,actions_def,compatible_def] |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
104 |
"!! a. [| compatible A2 A1 ; a:ext A1|] ==> a~:int A2"; |
3071 | 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 |
||
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
112 |
goalw thy [externals_def,actions_def,compatible_def] |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
113 |
"!! x. [| compatible A B; x:int A |] ==> x~:ext B"; |
3071 | 114 |
by (Asm_full_simp_tac 1); |
115 |
by (best_tac (set_cs addEs [equalityCE]) 1); |
|
116 |
qed"intA_is_not_extB"; |
|
117 |
||
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
118 |
goalw thy [externals_def,actions_def,compatible_def,is_asig_def,asig_of_def] |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
119 |
"!! a. [| compatible A B; a:int A |] ==> a ~: act B"; |
3071 | 120 |
by (Asm_full_simp_tac 1); |
121 |
by (best_tac (set_cs addEs [equalityCE]) 1); |
|
122 |
qed"intA_is_not_actB"; |
|
123 |
||
3433
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
124 |
goalw thy [asig_outputs_def,asig_internals_def,actions_def,asig_inputs_def, |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
125 |
compatible_def,is_asig_def,asig_of_def] |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
126 |
"!! a. [| compatible A B; a:out A ;a:act B|] ==> a : inp B"; |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
127 |
by (Asm_full_simp_tac 1); |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
128 |
by (best_tac (set_cs addEs [equalityCE]) 1); |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
129 |
qed"outAactB_is_inpB"; |
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
130 |
|
2de17c994071
added deadlock freedom, polished definitions and proofs
mueller
parents:
3275
diff
changeset
|
131 |
|
3071 | 132 |
|
133 |
(* ---------------------------------------------------------------------------------- *) |
|
134 |
||
135 |
section "invariants"; |
|
136 |
||
137 |
val [p1,p2] = goalw thy [invariant_def] |
|
138 |
"[| !!s. s:starts_of(A) ==> P(s); \ |
|
139 |
\ !!s t a. [|reachable A s; P(s)|] ==> (s,a,t): trans_of(A) --> P(t) |] \ |
|
140 |
\ ==> invariant A P"; |
|
141 |
by (rtac allI 1); |
|
142 |
by (rtac impI 1); |
|
143 |
by (res_inst_tac [("za","s")] reachable.induct 1); |
|
144 |
by (atac 1); |
|
145 |
by (etac p1 1); |
|
146 |
by (eres_inst_tac [("s1","sa")] (p2 RS mp) 1); |
|
147 |
by (REPEAT (atac 1)); |
|
148 |
qed"invariantI"; |
|
149 |
||
150 |
||
151 |
val [p1,p2] = goal thy |
|
152 |
"[| !!s. s : starts_of(A) ==> P(s); \ |
|
153 |
\ !!s t a. reachable A s ==> P(s) --> (s,a,t):trans_of(A) --> P(t) \ |
|
154 |
\ |] ==> invariant A P"; |
|
155 |
by (fast_tac (HOL_cs addSIs [invariantI] addSDs [p1,p2]) 1); |
|
156 |
qed "invariantI1"; |
|
157 |
||
158 |
val [p1,p2] = goalw thy [invariant_def] |
|
159 |
"[| invariant A P; reachable A s |] ==> P(s)"; |
|
160 |
br(p2 RS (p1 RS spec RS mp))1; |
|
161 |
qed "invariantE"; |
|
162 |
||
163 |
(* ---------------------------------------------------------------------------------- *) |
|
164 |
||
165 |
section "restrict"; |
|
166 |
||
167 |
||
168 |
goal thy "starts_of(restrict ioa acts) = starts_of(ioa) & \ |
|
169 |
\ trans_of(restrict ioa acts) = trans_of(ioa)"; |
|
170 |
by(simp_tac (!simpset addsimps ([restrict_def]@ioa_projections)) 1); |
|
171 |
qed "cancel_restrict_a"; |
|
172 |
||
173 |
goal thy "reachable (restrict ioa acts) s = reachable ioa s"; |
|
174 |
by (rtac iffI 1); |
|
175 |
be reachable.induct 1; |
|
176 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a,reachable_0]) 1); |
|
177 |
by (etac reachable_n 1); |
|
178 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a]) 1); |
|
179 |
(* <-- *) |
|
180 |
be reachable.induct 1; |
|
181 |
by (rtac reachable_0 1); |
|
182 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a]) 1); |
|
183 |
by (etac reachable_n 1); |
|
184 |
by(asm_full_simp_tac (!simpset addsimps [cancel_restrict_a]) 1); |
|
185 |
qed "cancel_restrict_b"; |
|
186 |
||
187 |
goal thy "starts_of(restrict ioa acts) = starts_of(ioa) & \ |
|
188 |
\ trans_of(restrict ioa acts) = trans_of(ioa) & \ |
|
189 |
\ reachable (restrict ioa acts) s = reachable ioa s"; |
|
190 |
by (simp_tac (!simpset addsimps [cancel_restrict_a,cancel_restrict_b]) 1); |
|
191 |
qed"cancel_restrict"; |
|
192 |
||
193 |
(* ---------------------------------------------------------------------------------- *) |
|
194 |
||
195 |
section "rename"; |
|
196 |
||
197 |
||
198 |
||
199 |
goal thy "!!f. s -a--(rename C f)-> t ==> (? x. Some(x) = f(a) & s -x--C-> t)"; |
|
200 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,rename_def,trans_of_def]) 1); |
|
201 |
qed"trans_rename"; |
|
202 |
||
203 |
||
204 |
goal thy "!!s.[| reachable (rename C g) s |] ==> reachable C s"; |
|
205 |
be reachable.induct 1; |
|
206 |
br reachable_0 1; |
|
207 |
by(asm_full_simp_tac (!simpset addsimps [rename_def]@ioa_projections) 1); |
|
208 |
bd trans_rename 1; |
|
209 |
be exE 1; |
|
210 |
be conjE 1; |
|
211 |
be reachable_n 1; |
|
212 |
ba 1; |
|
213 |
qed"reachable_rename"; |
|
214 |
||
215 |
||
216 |
||
217 |
(* ---------------------------------------------------------------------------------- *) |
|
218 |
||
219 |
section "trans_of(A||B)"; |
|
220 |
||
221 |
||
222 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a:act A|] \ |
|
223 |
\ ==> (fst s,a,fst t):trans_of A"; |
|
224 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
225 |
qed"trans_A_proj"; |
|
226 |
||
227 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a:act B|] \ |
|
228 |
\ ==> (snd s,a,snd t):trans_of B"; |
|
229 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
230 |
qed"trans_B_proj"; |
|
231 |
||
232 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a~:act A|]\ |
|
233 |
\ ==> fst s = fst t"; |
|
234 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
235 |
qed"trans_A_proj2"; |
|
236 |
||
237 |
goal thy "!!A.[|(s,a,t):trans_of (A||B); a~:act B|]\ |
|
238 |
\ ==> snd s = snd t"; |
|
239 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
240 |
qed"trans_B_proj2"; |
|
241 |
||
242 |
goal thy "!!A.(s,a,t):trans_of (A||B) \ |
|
243 |
\ ==> a :act A | a :act B"; |
|
244 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
245 |
qed"trans_AB_proj"; |
|
246 |
||
247 |
goal thy "!!A. [|a:act A;a:act B;\ |
|
248 |
\ (fst s,a,fst t):trans_of A;(snd s,a,snd t):trans_of B|]\ |
|
249 |
\ ==> (s,a,t):trans_of (A||B)"; |
|
250 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
251 |
qed"trans_AB"; |
|
252 |
||
253 |
goal thy "!!A. [|a:act A;a~:act B;\ |
|
254 |
\ (fst s,a,fst t):trans_of A;snd s=snd t|]\ |
|
255 |
\ ==> (s,a,t):trans_of (A||B)"; |
|
256 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
257 |
qed"trans_A_notB"; |
|
258 |
||
259 |
goal thy "!!A. [|a~:act A;a:act B;\ |
|
260 |
\ (snd s,a,snd t):trans_of B;fst s=fst t|]\ |
|
261 |
\ ==> (s,a,t):trans_of (A||B)"; |
|
262 |
by (asm_full_simp_tac (!simpset addsimps [Let_def,par_def,trans_of_def]) 1); |
|
263 |
qed"trans_notA_B"; |
|
264 |
||
265 |
val trans_of_defs1 = [trans_AB,trans_A_notB,trans_notA_B]; |
|
266 |
val trans_of_defs2 = [trans_A_proj,trans_B_proj,trans_A_proj2, |
|
267 |
trans_B_proj2,trans_AB_proj]; |
|
268 |
||
269 |
||
270 |
goal thy |
|
271 |
"(s,a,t) : trans_of(A || B || C || D) = \ |
|
272 |
\ ((a:actions(asig_of(A)) | a:actions(asig_of(B)) | a:actions(asig_of(C)) | \ |
|
273 |
\ a:actions(asig_of(D))) & \ |
|
274 |
\ (if a:actions(asig_of(A)) then (fst(s),a,fst(t)):trans_of(A) \ |
|
275 |
\ else fst t=fst s) & \ |
|
276 |
\ (if a:actions(asig_of(B)) then (fst(snd(s)),a,fst(snd(t))):trans_of(B) \ |
|
277 |
\ else fst(snd(t))=fst(snd(s))) & \ |
|
278 |
\ (if a:actions(asig_of(C)) then \ |
|
279 |
\ (fst(snd(snd(s))),a,fst(snd(snd(t)))):trans_of(C) \ |
|
280 |
\ else fst(snd(snd(t)))=fst(snd(snd(s)))) & \ |
|
281 |
\ (if a:actions(asig_of(D)) then \ |
|
282 |
\ (snd(snd(snd(s))),a,snd(snd(snd(t)))):trans_of(D) \ |
|
283 |
\ else snd(snd(snd(t)))=snd(snd(snd(s)))))"; |
|
284 |
||
285 |
by(simp_tac (!simpset addsimps ([par_def,actions_asig_comp,Pair_fst_snd_eq,Let_def]@ |
|
286 |
ioa_projections) |
|
287 |
setloop (split_tac [expand_if])) 1); |
|
288 |
qed "trans_of_par4"; |
|
289 |
||
290 |
||
291 |