author | paulson |
Fri, 20 Jun 2003 12:10:45 +0200 | |
changeset 14060 | c0c4af41fa3b |
parent 14046 | 6616e6c53d48 |
permissions | -rw-r--r-- |
11479 | 1 |
(* Title: ZF/UNITY/UNITY.ML |
2 |
ID: $Id$ |
|
3 |
Author: Sidi O Ehmety, Computer Laboratory |
|
4 |
Copyright 2001 University of Cambridge |
|
5 |
||
6 |
The basic UNITY theory (revised version, based upon the "co" operator) |
|
7 |
From Misra, "A Logic for Concurrent Programming", 1994 |
|
8 |
||
9 |
Proofs ported from HOL |
|
10 |
*) |
|
11 |
||
12 |
(** SKIP **) |
|
12195 | 13 |
Goalw [SKIP_def] "SKIP:program"; |
14 |
by (rewrite_goal_tac [program_def, mk_program_def] 1); |
|
15 |
by Auto_tac; |
|
16 |
qed "SKIP_in_program"; |
|
17 |
AddIffs [SKIP_in_program]; |
|
18 |
AddTCs [SKIP_in_program]; |
|
11479 | 19 |
|
20 |
(** programify: coersion from anything to program **) |
|
21 |
||
22 |
Goalw [programify_def] |
|
23 |
"F:program ==> programify(F)=F"; |
|
24 |
by Auto_tac; |
|
25 |
qed "programify_program"; |
|
26 |
Addsimps [programify_program]; |
|
27 |
||
28 |
Goalw [programify_def] |
|
29 |
"programify(F):program"; |
|
30 |
by Auto_tac; |
|
31 |
qed "programify_in_program"; |
|
32 |
AddIffs [programify_in_program]; |
|
33 |
AddTCs [programify_in_program]; |
|
34 |
||
35 |
(** Collapsing rules: to remove programify from expressions **) |
|
36 |
Goalw [programify_def] |
|
37 |
"programify(programify(F))=programify(F)"; |
|
38 |
by Auto_tac; |
|
39 |
qed "programify_idem"; |
|
12195 | 40 |
AddIffs [programify_idem]; |
11479 | 41 |
|
42 |
Goal |
|
43 |
"Init(programify(F)) = Init(F)"; |
|
44 |
by (simp_tac (simpset() addsimps [Init_def]) 1); |
|
45 |
qed "Init_programify"; |
|
12195 | 46 |
AddIffs [Init_programify]; |
11479 | 47 |
|
48 |
Goal |
|
49 |
"Acts(programify(F)) = Acts(F)"; |
|
50 |
by (simp_tac (simpset() addsimps [Acts_def]) 1); |
|
51 |
qed "Acts_programify"; |
|
12195 | 52 |
AddIffs [Acts_programify]; |
11479 | 53 |
|
54 |
Goal |
|
55 |
"AllowedActs(programify(F)) = AllowedActs(F)"; |
|
56 |
by (simp_tac (simpset() addsimps [AllowedActs_def]) 1); |
|
57 |
qed "AllowedActs_programify"; |
|
12195 | 58 |
AddIffs [AllowedActs_programify]; |
11479 | 59 |
|
12195 | 60 |
(** program's inspectors **) |
11479 | 61 |
|
12195 | 62 |
Goal "F:program ==>id(state):RawActs(F)"; |
11479 | 63 |
by (auto_tac (claset(), simpset() |
64 |
addsimps [program_def, RawActs_def])); |
|
12195 | 65 |
qed "id_in_RawActs"; |
11479 | 66 |
|
12195 | 67 |
Goal "id(state):Acts(F)"; |
11479 | 68 |
by (simp_tac (simpset() |
12195 | 69 |
addsimps [id_in_RawActs, Acts_def]) 1); |
70 |
qed "id_in_Acts"; |
|
11479 | 71 |
|
12195 | 72 |
Goal "F:program ==>id(state):RawAllowedActs(F)"; |
11479 | 73 |
by (auto_tac (claset(), simpset() |
74 |
addsimps [program_def, RawAllowedActs_def])); |
|
12195 | 75 |
qed "id_in_RawAllowedActs"; |
11479 | 76 |
|
12195 | 77 |
Goal "id(state):AllowedActs(F)"; |
11479 | 78 |
by (simp_tac (simpset() |
12195 | 79 |
addsimps [id_in_RawAllowedActs, AllowedActs_def]) 1); |
80 |
qed "id_in_AllowedActs"; |
|
11479 | 81 |
|
12195 | 82 |
AddIffs [id_in_Acts, id_in_AllowedActs]; |
83 |
AddTCs [id_in_Acts, id_in_AllowedActs]; |
|
11479 | 84 |
|
12195 | 85 |
Goal "cons(id(state), Acts(F)) = Acts(F)"; |
11479 | 86 |
by (simp_tac (simpset() addsimps [cons_absorb]) 1); |
12195 | 87 |
qed "cons_id_Acts"; |
11479 | 88 |
|
12195 | 89 |
Goal "cons(id(state), AllowedActs(F)) = AllowedActs(F)"; |
11479 | 90 |
by (simp_tac (simpset() addsimps [cons_absorb]) 1); |
12195 | 91 |
qed "cons_id_AllowedActs"; |
11479 | 92 |
|
12195 | 93 |
AddIffs [cons_id_Acts, cons_id_AllowedActs]; |
11479 | 94 |
|
95 |
(** inspectors's types **) |
|
96 |
Goal |
|
12195 | 97 |
"F:program ==> RawInit(F)<=state"; |
11479 | 98 |
by (auto_tac (claset(), simpset() |
99 |
addsimps [program_def, RawInit_def])); |
|
100 |
qed "RawInit_type"; |
|
101 |
||
12195 | 102 |
Goal |
103 |
"F:program ==> RawActs(F)<=Pow(state*state)"; |
|
104 |
by (auto_tac (claset(), simpset() |
|
105 |
addsimps [program_def, RawActs_def])); |
|
106 |
qed "RawActs_type"; |
|
107 |
||
108 |
Goal |
|
109 |
"F:program ==> RawAllowedActs(F)<=Pow(state*state)"; |
|
110 |
by (auto_tac (claset(), simpset() |
|
111 |
addsimps [program_def, RawAllowedActs_def])); |
|
112 |
qed "RawAllowedActs_type"; |
|
113 |
||
114 |
Goal "Init(F)<=state"; |
|
11479 | 115 |
by (simp_tac (simpset() |
116 |
addsimps [RawInit_type, Init_def]) 1); |
|
117 |
qed "Init_type"; |
|
118 |
||
14046 | 119 |
bind_thm("InitD", Init_type RS subsetD); |
120 |
||
12195 | 121 |
Goalw [st_set_def] "st_set(Init(F))"; |
12484 | 122 |
by (rtac Init_type 1); |
12195 | 123 |
qed "st_set_Init"; |
124 |
AddIffs [st_set_Init]; |
|
11479 | 125 |
|
126 |
Goal |
|
12195 | 127 |
"Acts(F)<=Pow(state*state)"; |
11479 | 128 |
by (simp_tac (simpset() |
129 |
addsimps [RawActs_type, Acts_def]) 1); |
|
130 |
qed "Acts_type"; |
|
131 |
||
132 |
Goal |
|
12195 | 133 |
"AllowedActs(F)<=Pow(state*state)"; |
11479 | 134 |
by (simp_tac (simpset() |
135 |
addsimps [RawAllowedActs_type, AllowedActs_def]) 1); |
|
136 |
qed "AllowedActs_type"; |
|
137 |
||
14046 | 138 |
(* Needed in Behaviors *) |
139 |
Goal "[| act:Acts(F); <s,s'>:act |] ==> s:state & s':state"; |
|
140 |
by (blast_tac (claset() addDs [Acts_type RS subsetD]) 1); |
|
141 |
qed "ActsD"; |
|
142 |
||
143 |
Goal "[| act:AllowedActs(F); <s,s'>:act |] ==> s:state & s':state"; |
|
144 |
by (blast_tac (claset() addDs [AllowedActs_type RS subsetD]) 1); |
|
145 |
qed "AllowedActsD"; |
|
146 |
||
11479 | 147 |
(** More simplification rules involving state |
148 |
and Init, Acts, and AllowedActs **) |
|
149 |
||
150 |
Goal "state <= Init(F) <-> Init(F)=state"; |
|
151 |
by (cut_inst_tac [("F", "F")] Init_type 1); |
|
12195 | 152 |
by Auto_tac; |
153 |
qed "state_subset_is_Init_iff"; |
|
154 |
AddIffs [state_subset_is_Init_iff]; |
|
11479 | 155 |
|
12195 | 156 |
Goal "Pow(state*state) <= Acts(F) <-> Acts(F)=Pow(state*state)"; |
11479 | 157 |
by (cut_inst_tac [("F", "F")] Acts_type 1); |
12195 | 158 |
by Auto_tac; |
159 |
qed "Pow_state_times_state_is_subset_Acts_iff"; |
|
160 |
AddIffs [Pow_state_times_state_is_subset_Acts_iff]; |
|
11479 | 161 |
|
12195 | 162 |
Goal "Pow(state*state) <= AllowedActs(F) <-> AllowedActs(F)=Pow(state*state)"; |
11479 | 163 |
by (cut_inst_tac [("F", "F")] AllowedActs_type 1); |
12195 | 164 |
by Auto_tac; |
165 |
qed "Pow_state_times_state_is_subset_AllowedActs_iff"; |
|
166 |
AddIffs [Pow_state_times_state_is_subset_AllowedActs_iff]; |
|
11479 | 167 |
|
168 |
(** Eliminating `Int state' from expressions **) |
|
12195 | 169 |
Goal "Init(F) Int state = Init(F)"; |
11479 | 170 |
by (cut_inst_tac [("F", "F")] Init_type 1); |
12195 | 171 |
by (Blast_tac 1); |
11479 | 172 |
qed "Init_Int_state"; |
12195 | 173 |
AddIffs [Init_Int_state]; |
11479 | 174 |
|
12195 | 175 |
Goal "state Int Init(F) = Init(F)"; |
176 |
by (cut_inst_tac [("F", "F")] Init_type 1); |
|
177 |
by (Blast_tac 1); |
|
178 |
qed "state_Int_Init"; |
|
179 |
AddIffs [state_Int_Init]; |
|
11479 | 180 |
|
12195 | 181 |
Goal "Acts(F) Int Pow(state*state) = Acts(F)"; |
11479 | 182 |
by (cut_inst_tac [("F", "F")] Acts_type 1); |
12195 | 183 |
by (Blast_tac 1); |
184 |
qed "Acts_Int_Pow_state_times_state"; |
|
185 |
AddIffs [Acts_Int_Pow_state_times_state]; |
|
11479 | 186 |
|
12195 | 187 |
Goal "Pow(state*state) Int Acts(F) = Acts(F)"; |
188 |
by (cut_inst_tac [("F", "F")] Acts_type 1); |
|
189 |
by (Blast_tac 1); |
|
190 |
qed "state_times_state_Int_Acts"; |
|
191 |
AddIffs [state_times_state_Int_Acts]; |
|
11479 | 192 |
|
12195 | 193 |
Goal "AllowedActs(F) Int Pow(state*state) = AllowedActs(F)"; |
11479 | 194 |
by (cut_inst_tac [("F", "F")] AllowedActs_type 1); |
12195 | 195 |
by (Blast_tac 1); |
196 |
qed "AllowedActs_Int_Pow_state_times_state"; |
|
197 |
AddIffs [AllowedActs_Int_Pow_state_times_state]; |
|
11479 | 198 |
|
12195 | 199 |
Goal "Pow(state*state) Int AllowedActs(F) = AllowedActs(F)"; |
200 |
by (cut_inst_tac [("F", "F")] AllowedActs_type 1); |
|
201 |
by (Blast_tac 1); |
|
202 |
qed "state_times_state_Int_AllowedActs"; |
|
203 |
AddIffs [state_times_state_Int_AllowedActs]; |
|
11479 | 204 |
|
205 |
(** mk_program **) |
|
206 |
||
12195 | 207 |
Goalw [mk_program_def, program_def] "mk_program(init, acts, allowed):program"; |
208 |
by Auto_tac; |
|
209 |
qed "mk_program_in_program"; |
|
210 |
AddIffs [mk_program_in_program]; |
|
211 |
AddTCs [mk_program_in_program]; |
|
11479 | 212 |
|
12195 | 213 |
Goalw [RawInit_def, mk_program_def] |
214 |
"RawInit(mk_program(init, acts, allowed)) = init Int state"; |
|
215 |
by Auto_tac; |
|
11479 | 216 |
qed "RawInit_eq"; |
12195 | 217 |
AddIffs [RawInit_eq]; |
11479 | 218 |
|
12195 | 219 |
Goalw [RawActs_def, mk_program_def] |
220 |
"RawActs(mk_program(init, acts, allowed)) = cons(id(state), acts Int Pow(state*state))"; |
|
221 |
by Auto_tac; |
|
222 |
qed "RawActs_eq"; |
|
223 |
AddIffs [RawActs_eq]; |
|
11479 | 224 |
|
12195 | 225 |
Goalw [RawAllowedActs_def, mk_program_def] |
226 |
"RawAllowedActs(mk_program(init, acts, allowed)) = \ |
|
227 |
\ cons(id(state), allowed Int Pow(state*state))"; |
|
228 |
by Auto_tac; |
|
229 |
qed "RawAllowedActs_eq"; |
|
230 |
AddIffs [RawAllowedActs_eq]; |
|
11479 | 231 |
|
12195 | 232 |
Goalw [Init_def] "Init(mk_program(init, acts, allowed)) = init Int state"; |
233 |
by (Simp_tac 1); |
|
234 |
qed "Init_eq"; |
|
235 |
AddIffs [Init_eq]; |
|
236 |
||
237 |
Goalw [Acts_def] |
|
238 |
"Acts(mk_program(init, acts, allowed)) = cons(id(state), acts Int Pow(state*state))"; |
|
239 |
by (Simp_tac 1); |
|
11479 | 240 |
qed "Acts_eq"; |
12195 | 241 |
AddIffs [Acts_eq]; |
11479 | 242 |
|
243 |
Goalw [AllowedActs_def] |
|
12195 | 244 |
"AllowedActs(mk_program(init, acts, allowed))= \ |
245 |
\ cons(id(state), allowed Int Pow(state*state))"; |
|
246 |
by (Simp_tac 1); |
|
11479 | 247 |
qed "AllowedActs_eq"; |
12195 | 248 |
AddIffs [AllowedActs_eq]; |
11479 | 249 |
|
250 |
(**Init, Acts, and AlowedActs of SKIP **) |
|
251 |
||
12195 | 252 |
Goalw [SKIP_def] "RawInit(SKIP) = state"; |
253 |
by Auto_tac; |
|
11479 | 254 |
qed "RawInit_SKIP"; |
12195 | 255 |
AddIffs [RawInit_SKIP]; |
11479 | 256 |
|
12195 | 257 |
Goalw [SKIP_def] "RawAllowedActs(SKIP) = Pow(state*state)"; |
258 |
by Auto_tac; |
|
259 |
qed "RawAllowedActs_SKIP"; |
|
260 |
AddIffs [RawAllowedActs_SKIP]; |
|
11479 | 261 |
|
12195 | 262 |
Goalw [SKIP_def] "RawActs(SKIP) = {id(state)}"; |
263 |
by Auto_tac; |
|
11479 | 264 |
qed "RawActs_SKIP"; |
12195 | 265 |
AddIffs [RawActs_SKIP]; |
11479 | 266 |
|
12195 | 267 |
Goalw [Init_def] "Init(SKIP) = state"; |
268 |
by Auto_tac; |
|
269 |
qed "Init_SKIP"; |
|
270 |
AddIffs [Init_SKIP]; |
|
11479 | 271 |
|
12195 | 272 |
Goalw [Acts_def] "Acts(SKIP) = {id(state)}"; |
273 |
by Auto_tac; |
|
274 |
qed "Acts_SKIP"; |
|
275 |
AddIffs [Acts_SKIP]; |
|
11479 | 276 |
|
12195 | 277 |
Goalw [AllowedActs_def] "AllowedActs(SKIP) = Pow(state*state)"; |
278 |
by Auto_tac; |
|
11479 | 279 |
qed "AllowedActs_SKIP"; |
12195 | 280 |
AddIffs [AllowedActs_SKIP]; |
11479 | 281 |
|
12195 | 282 |
(** Equality of UNITY programs **) |
11479 | 283 |
|
284 |
Goal |
|
285 |
"F:program ==> mk_program(RawInit(F), RawActs(F), RawAllowedActs(F))=F"; |
|
12195 | 286 |
by (rewrite_goal_tac [program_def, mk_program_def,RawInit_def, |
287 |
RawActs_def, RawAllowedActs_def] 1); |
|
288 |
by Auto_tac; |
|
11479 | 289 |
by (REPEAT(Blast_tac 1)); |
290 |
qed "raw_surjective_mk_program"; |
|
12195 | 291 |
Addsimps [raw_surjective_mk_program]; |
11479 | 292 |
|
12195 | 293 |
Goalw [Init_def, Acts_def, AllowedActs_def] |
11479 | 294 |
"mk_program(Init(F), Acts(F), AllowedActs(F)) = programify(F)"; |
12195 | 295 |
by Auto_tac; |
11479 | 296 |
qed "surjective_mk_program"; |
12195 | 297 |
AddIffs [surjective_mk_program]; |
11479 | 298 |
|
299 |
Goal "[|Init(F) = Init(G); Acts(F) = Acts(G); \ |
|
300 |
\ AllowedActs(F) = AllowedActs(G); F:program; G:program |] ==> F = G"; |
|
301 |
by (stac (programify_program RS sym) 1); |
|
302 |
by (rtac sym 2); |
|
303 |
by (stac (programify_program RS sym) 2); |
|
304 |
by (stac (surjective_mk_program RS sym) 3); |
|
305 |
by (stac (surjective_mk_program RS sym) 3); |
|
306 |
by (ALLGOALS(Asm_simp_tac)); |
|
307 |
qed "program_equalityI"; |
|
308 |
||
309 |
val [major,minor] = |
|
310 |
Goal "[| F = G; \ |
|
311 |
\ [| Init(F) = Init(G); Acts(F) = Acts(G); AllowedActs(F) = AllowedActs(G) |]\ |
|
312 |
\ ==> P |] ==> P"; |
|
313 |
by (rtac minor 1); |
|
314 |
by (auto_tac (claset(), simpset() addsimps [major])); |
|
315 |
qed "program_equalityE"; |
|
316 |
||
317 |
||
318 |
Goal "[| F:program; G:program |] ==>(F=G) <-> \ |
|
319 |
\ (Init(F) = Init(G) & Acts(F) = Acts(G) & AllowedActs(F) = AllowedActs(G))"; |
|
320 |
by (blast_tac (claset() addIs [program_equalityI, program_equalityE]) 1); |
|
321 |
qed "program_equality_iff"; |
|
322 |
||
323 |
(*** These rules allow "lazy" definition expansion |
|
324 |
||
325 |
...skipping 1 line |
|
326 |
||
327 |
***) |
|
328 |
||
329 |
Goal "F == mk_program (init,acts,allowed) ==> Init(F) = init Int state"; |
|
330 |
by Auto_tac; |
|
331 |
qed "def_prg_Init"; |
|
332 |
||
333 |
||
12195 | 334 |
Goal "F == mk_program (init,acts,allowed) ==> \ |
335 |
\ Acts(F) = cons(id(state), acts Int Pow(state*state))"; |
|
11479 | 336 |
by Auto_tac; |
337 |
qed "def_prg_Acts"; |
|
338 |
||
339 |
||
340 |
Goal "F == mk_program (init,acts,allowed) ==> \ |
|
12195 | 341 |
\ AllowedActs(F) = cons(id(state), allowed Int Pow(state*state))"; |
11479 | 342 |
by Auto_tac; |
343 |
qed "def_prg_AllowedActs"; |
|
344 |
||
345 |
||
346 |
val [rew] = goal thy |
|
347 |
"[| F == mk_program (init,acts,allowed) |] \ |
|
12195 | 348 |
\ ==> Init(F) = init Int state & Acts(F) = cons(id(state), acts Int Pow(state*state)) & \ |
349 |
\ AllowedActs(F) = cons(id(state), allowed Int Pow(state*state)) "; |
|
11479 | 350 |
by (rewtac rew); |
351 |
by Auto_tac; |
|
352 |
qed "def_prg_simps"; |
|
353 |
||
354 |
||
355 |
(*An action is expanded only if a pair of states is being tested against it*) |
|
356 |
Goal "[| act == {<s,s'>:A*B. P(s, s')} |] ==> \ |
|
357 |
\ (<s,s'>:act) <-> (<s,s'>:A*B & P(s, s'))"; |
|
358 |
by Auto_tac; |
|
359 |
qed "def_act_simp"; |
|
360 |
||
361 |
fun simp_of_act def = def RS def_act_simp; |
|
362 |
||
363 |
(*A set is expanded only if an element is being tested against it*) |
|
364 |
Goal "A == B ==> (x : A) <-> (x : B)"; |
|
365 |
by Auto_tac; |
|
366 |
qed "def_set_simp"; |
|
367 |
||
368 |
fun simp_of_set def = def RS def_set_simp; |
|
369 |
||
370 |
(*** co ***) |
|
371 |
||
12195 | 372 |
Goalw [constrains_def] |
373 |
"A co B <= program"; |
|
374 |
by Auto_tac; |
|
375 |
qed "constrains_type"; |
|
376 |
||
377 |
||
11479 | 378 |
val prems = Goalw [constrains_def] |
379 |
"[|(!!act s s'. [| act: Acts(F); <s,s'>:act; s:A|] ==> s':A'); \ |
|
12195 | 380 |
\ F:program; st_set(A) |] ==> F:A co A'"; |
381 |
by (auto_tac (claset() delrules [subsetI], simpset())); |
|
382 |
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps prems))); |
|
383 |
by (Clarify_tac 1); |
|
11479 | 384 |
by (blast_tac(claset() addIs prems) 1); |
385 |
qed "constrainsI"; |
|
386 |
||
387 |
Goalw [constrains_def] |
|
388 |
"F:A co B ==> ALL act:Acts(F). act``A<=B"; |
|
389 |
by (Blast_tac 1); |
|
390 |
qed "constrainsD"; |
|
391 |
||
392 |
Goalw [constrains_def] |
|
12195 | 393 |
"F:A co B ==> F:program & st_set(A)"; |
11479 | 394 |
by (Blast_tac 1); |
12195 | 395 |
qed "constrainsD2"; |
11479 | 396 |
|
12195 | 397 |
Goalw [constrains_def, st_set_def] "F : 0 co B <-> F:program"; |
11479 | 398 |
by (Blast_tac 1); |
399 |
qed "constrains_empty"; |
|
400 |
||
12195 | 401 |
Goalw [constrains_def, st_set_def] |
402 |
"(F : A co 0) <-> (A=0 & F:program)"; |
|
403 |
by (cut_inst_tac [("F", "F")] Acts_type 1); |
|
404 |
by Auto_tac; |
|
405 |
by (Blast_tac 1); |
|
11479 | 406 |
qed "constrains_empty2"; |
407 |
||
12195 | 408 |
Goalw [constrains_def, st_set_def] |
409 |
"(F: state co B) <-> (state<=B & F:program)"; |
|
410 |
by (cut_inst_tac [("F", "F")] Acts_type 1); |
|
411 |
by (Blast_tac 1); |
|
11479 | 412 |
qed "constrains_state"; |
413 |
||
12195 | 414 |
Goalw [constrains_def, st_set_def] "F:A co state <-> (F:program & st_set(A))"; |
415 |
by (cut_inst_tac [("F", "F")] Acts_type 1); |
|
416 |
by (Blast_tac 1); |
|
11479 | 417 |
qed "constrains_state2"; |
418 |
||
12195 | 419 |
AddIffs [constrains_empty, constrains_empty2, |
11479 | 420 |
constrains_state, constrains_state2]; |
421 |
||
422 |
(*monotonic in 2nd argument*) |
|
423 |
Goalw [constrains_def] |
|
12195 | 424 |
"[| F:A co A'; A'<=B' |] ==> F : A co B'"; |
11479 | 425 |
by (Blast_tac 1); |
426 |
qed "constrains_weaken_R"; |
|
427 |
||
428 |
(*anti-monotonic in 1st argument*) |
|
12195 | 429 |
Goalw [constrains_def, st_set_def] |
11479 | 430 |
"[| F : A co A'; B<=A |] ==> F : B co A'"; |
431 |
by (Blast_tac 1); |
|
432 |
qed "constrains_weaken_L"; |
|
433 |
||
434 |
Goal |
|
12195 | 435 |
"[| F : A co A'; B<=A; A'<=B' |] ==> F : B co B'"; |
11479 | 436 |
by (dtac constrains_weaken_R 1); |
12195 | 437 |
by (dtac constrains_weaken_L 2); |
11479 | 438 |
by (REPEAT(Blast_tac 1)); |
439 |
qed "constrains_weaken"; |
|
440 |
||
441 |
(** Union **) |
|
442 |
||
12195 | 443 |
Goalw [constrains_def, st_set_def] |
11479 | 444 |
"[| F : A co A'; F:B co B' |] ==> F:(A Un B) co (A' Un B')"; |
445 |
by Auto_tac; |
|
12195 | 446 |
by (Force_tac 1); |
11479 | 447 |
qed "constrains_Un"; |
448 |
||
12195 | 449 |
val major::minor::_ = Goalw [constrains_def, st_set_def] |
450 |
"[|(!!i. i:I ==> F:A(i) co A'(i)); F:program |]==> F:(UN i:I. A(i)) co (UN i:I. A'(i))"; |
|
451 |
by (cut_facts_tac [minor] 1); |
|
452 |
by Safe_tac; |
|
12484 | 453 |
by (ALLGOALS(ftac major )); |
12195 | 454 |
by (ALLGOALS(Asm_full_simp_tac)); |
455 |
by (REPEAT(Blast_tac 1)); |
|
456 |
qed "constrains_UN"; |
|
11479 | 457 |
|
12195 | 458 |
Goalw [constrains_def, st_set_def] |
11479 | 459 |
"(A Un B) co C = (A co C) Int (B co C)"; |
12195 | 460 |
by Auto_tac; |
461 |
by (Force_tac 1); |
|
11479 | 462 |
qed "constrains_Un_distrib"; |
463 |
||
12195 | 464 |
Goalw [constrains_def, st_set_def] |
465 |
"i:I ==> (UN i:I. A(i)) co B = (INT i:I. A(i) co B)"; |
|
466 |
by (rtac equalityI 1); |
|
467 |
by (REPEAT(Force_tac 1)); |
|
468 |
qed "constrains_UN_distrib"; |
|
11479 | 469 |
|
12195 | 470 |
(** Intersection **) |
471 |
Goalw [constrains_def, st_set_def] |
|
472 |
"C co (A Int B) = (C co A) Int (C co B)"; |
|
473 |
by (rtac equalityI 1); |
|
474 |
by (ALLGOALS(Clarify_tac)); (* to speed up the proof *) |
|
475 |
by (REPEAT(Blast_tac 1)); |
|
476 |
qed "constrains_Int_distrib"; |
|
477 |
||
478 |
Goalw [constrains_def, st_set_def] |
|
479 |
"x:I ==> A co (INT i:I. B(i)) = (INT i:I. A co B(i))"; |
|
11479 | 480 |
by (rtac equalityI 1); |
481 |
by Safe_tac; |
|
12195 | 482 |
by (REPEAT(Blast_tac 1)); |
11479 | 483 |
qed "constrains_INT_distrib"; |
484 |
||
12195 | 485 |
Goalw [constrains_def, st_set_def] |
11479 | 486 |
"[| F : A co A'; F : B co B' |] ==> F : (A Int B) co (A' Int B')"; |
487 |
by (Clarify_tac 1); |
|
488 |
by (Blast_tac 1); |
|
489 |
qed "constrains_Int"; |
|
490 |
||
12195 | 491 |
val major::minor::_ = Goalw [constrains_def, st_set_def] |
492 |
"[| (!!i. i:I==>F:A(i) co A'(i)); F:program|]==> F:(INT i:I. A(i)) co (INT i:I. A'(i))"; |
|
493 |
by (cut_facts_tac [minor] 1); |
|
494 |
by (cut_inst_tac [("F", "F")] Acts_type 1); |
|
11479 | 495 |
by (case_tac "I=0" 1); |
496 |
by (asm_full_simp_tac (simpset() addsimps [Inter_def]) 1); |
|
497 |
by (etac not_emptyE 1); |
|
12195 | 498 |
by Safe_tac; |
499 |
by (forw_inst_tac [("i", "xd")] major 1); |
|
12484 | 500 |
by (ftac major 2); |
501 |
by (ftac major 3); |
|
12195 | 502 |
by (REPEAT(Force_tac 1)); |
503 |
qed "constrains_INT"; |
|
11479 | 504 |
|
12195 | 505 |
(* The rule below simulates the HOL's one for (INT z. A i) co (INT z. B i) *) |
506 |
Goalw [constrains_def] |
|
507 |
"[| ALL z. F:{s:state. P(s, z)} co {s:state. Q(s, z)}; F:program |]==>\ |
|
508 |
\ F:{s:state. ALL z. P(s, z)} co {s:state. ALL z. Q(s, z)}"; |
|
11479 | 509 |
by (Blast_tac 1); |
12195 | 510 |
qed "constrains_All"; |
11479 | 511 |
|
12195 | 512 |
Goalw [constrains_def, st_set_def] |
513 |
"[| F:A co A' |] ==> A <= A'"; |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
14046
diff
changeset
|
514 |
by (Force_tac 1); |
11479 | 515 |
qed "constrains_imp_subset"; |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
14046
diff
changeset
|
516 |
|
11479 | 517 |
(*The reasoning is by subsets since "co" refers to single actions |
518 |
only. So this rule isn't that useful.*) |
|
519 |
||
12195 | 520 |
Goalw [constrains_def, st_set_def] |
11479 | 521 |
"[| F : A co B; F : B co C |] ==> F : A co C"; |
522 |
by Auto_tac; |
|
12195 | 523 |
by (Blast_tac 1); |
11479 | 524 |
qed "constrains_trans"; |
525 |
||
12195 | 526 |
Goal |
527 |
"[| F : A co (A' Un B); F : B co B' |] ==> F:A co (A' Un B')"; |
|
528 |
by (dres_inst_tac [("A", "B")] constrains_imp_subset 1); |
|
529 |
by (blast_tac (claset() addIs [constrains_weaken_R]) 1); |
|
11479 | 530 |
qed "constrains_cancel"; |
531 |
||
532 |
(*** unless ***) |
|
533 |
||
12195 | 534 |
Goalw [unless_def, constrains_def] |
535 |
"A unless B <= program"; |
|
536 |
by Auto_tac; |
|
537 |
qed "unless_type"; |
|
538 |
||
539 |
Goalw [unless_def] "[| F:(A-B) co (A Un B) |] ==> F : A unless B"; |
|
540 |
by (blast_tac (claset() addDs [constrainsD2]) 1); |
|
11479 | 541 |
qed "unlessI"; |
542 |
||
543 |
Goalw [unless_def] "F :A unless B ==> F : (A-B) co (A Un B)"; |
|
12195 | 544 |
by Auto_tac; |
11479 | 545 |
qed "unlessD"; |
546 |
||
547 |
(*** initially ***) |
|
548 |
||
549 |
Goalw [initially_def] |
|
12195 | 550 |
"initially(A) <= program"; |
551 |
by (Blast_tac 1); |
|
552 |
qed "initially_type"; |
|
553 |
||
554 |
Goalw [initially_def] |
|
555 |
"[| F:program; Init(F)<=A |] ==> F:initially(A)"; |
|
11479 | 556 |
by (Blast_tac 1); |
557 |
qed "initiallyI"; |
|
558 |
||
559 |
Goalw [initially_def] |
|
560 |
"F:initially(A) ==> Init(F)<=A"; |
|
561 |
by (Blast_tac 1); |
|
562 |
qed "initiallyD"; |
|
563 |
||
12195 | 564 |
(*** stable ***) |
565 |
||
566 |
Goalw [stable_def, constrains_def] |
|
567 |
"stable(A)<=program"; |
|
11479 | 568 |
by (Blast_tac 1); |
12195 | 569 |
qed "stable_type"; |
11479 | 570 |
|
571 |
Goalw [stable_def] |
|
572 |
"F : A co A ==> F : stable(A)"; |
|
573 |
by (assume_tac 1); |
|
574 |
qed "stableI"; |
|
575 |
||
12195 | 576 |
Goalw [stable_def] "F:stable(A) ==> F : A co A"; |
11479 | 577 |
by (assume_tac 1); |
578 |
qed "stableD"; |
|
579 |
||
12195 | 580 |
Goalw [stable_def, constrains_def] "F:stable(A) ==> F:program & st_set(A)"; |
581 |
by Auto_tac; |
|
11479 | 582 |
qed "stableD2"; |
583 |
||
12195 | 584 |
Goalw [stable_def, constrains_def] "stable(state) = program"; |
585 |
by (auto_tac (claset() addDs [Acts_type RS subsetD], simpset())); |
|
11479 | 586 |
qed "stable_state"; |
12195 | 587 |
AddIffs [stable_state]; |
11479 | 588 |
|
14046 | 589 |
Goalw [unless_def, stable_def] |
590 |
"stable(A)= A unless 0"; |
|
591 |
by Auto_tac; |
|
592 |
qed "stable_unless"; |
|
593 |
||
594 |
||
11479 | 595 |
(** Union **) |
596 |
||
597 |
Goalw [stable_def] |
|
12195 | 598 |
"[| F : stable(A); F:stable(A') |] ==> F : stable(A Un A')"; |
11479 | 599 |
by (blast_tac (claset() addIs [constrains_Un]) 1); |
600 |
qed "stable_Un"; |
|
601 |
||
602 |
val [major, minor] = Goalw [stable_def] |
|
12195 | 603 |
"[|(!!i. i:I ==> F : stable(A(i))); F:program |] ==> F:stable (UN i:I. A(i))"; |
11479 | 604 |
by (cut_facts_tac [minor] 1); |
605 |
by (blast_tac (claset() addIs [constrains_UN, major]) 1); |
|
606 |
qed "stable_UN"; |
|
607 |
||
608 |
Goalw [stable_def] |
|
609 |
"[| F : stable(A); F : stable(A') |] ==> F : stable (A Int A')"; |
|
610 |
by (blast_tac (claset() addIs [constrains_Int]) 1); |
|
611 |
qed "stable_Int"; |
|
612 |
||
613 |
val [major, minor] = Goalw [stable_def] |
|
12195 | 614 |
"[| (!!i. i:I ==> F:stable(A(i))); F:program |] ==> F : stable (INT i:I. A(i))"; |
11479 | 615 |
by (cut_facts_tac [minor] 1); |
616 |
by (blast_tac (claset() addIs [constrains_INT, major]) 1); |
|
617 |
qed "stable_INT"; |
|
618 |
||
619 |
Goalw [stable_def] |
|
12195 | 620 |
"[|ALL z. F:stable({s:state. P(s, z)}); F:program|]==>F:stable({s:state. ALL z. P(s, z)})"; |
11479 | 621 |
by (rtac constrains_All 1); |
622 |
by Auto_tac; |
|
12195 | 623 |
qed "stable_All"; |
11479 | 624 |
|
12195 | 625 |
Goalw [stable_def, constrains_def, st_set_def] |
626 |
"[| F : stable(C); F : A co (C Un A') |] ==> F : (C Un A) co (C Un A')"; |
|
627 |
by Auto_tac; |
|
14046 | 628 |
by (blast_tac (claset() addSDs [bspec]) 1); |
11479 | 629 |
qed "stable_constrains_Un"; |
630 |
||
12195 | 631 |
Goalw [stable_def, constrains_def, st_set_def] |
11479 | 632 |
"[| F : stable(C); F : (C Int A) co A' |] ==> F : (C Int A) co (C Int A')"; |
633 |
by (Clarify_tac 1); |
|
634 |
by (Blast_tac 1); |
|
635 |
qed "stable_constrains_Int"; |
|
636 |
||
12195 | 637 |
(* [| F:stable(C); F :(C Int A) co A |] ==> F:stable(C Int A) *) |
11479 | 638 |
bind_thm ("stable_constrains_stable", stable_constrains_Int RS stableI); |
639 |
||
640 |
(** invariant **) |
|
641 |
||
12195 | 642 |
Goalw [invariant_def] |
643 |
"invariant(A) <= program"; |
|
644 |
by (blast_tac (claset() addDs [stable_type RS subsetD]) 1); |
|
645 |
qed "invariant_type"; |
|
11479 | 646 |
|
12195 | 647 |
Goalw [invariant_def, initially_def] |
11479 | 648 |
"[| Init(F)<=A; F:stable(A) |] ==> F : invariant(A)"; |
12195 | 649 |
by (forward_tac [stable_type RS subsetD] 1); |
650 |
by Auto_tac; |
|
11479 | 651 |
qed "invariantI"; |
652 |
||
12195 | 653 |
Goalw [invariant_def, initially_def] |
11479 | 654 |
"F:invariant(A) ==> Init(F)<=A & F:stable(A)"; |
655 |
by Auto_tac; |
|
656 |
qed "invariantD"; |
|
657 |
||
12195 | 658 |
Goalw [invariant_def] |
659 |
"F:invariant(A) ==> F:program & st_set(A)"; |
|
11479 | 660 |
by (blast_tac (claset() addDs [stableD2]) 1); |
661 |
qed "invariantD2"; |
|
662 |
||
663 |
(*Could also say "invariant A Int invariant B <= invariant (A Int B)"*) |
|
12195 | 664 |
Goalw [invariant_def, initially_def] |
11479 | 665 |
"[| F : invariant(A); F : invariant(B) |] ==> F : invariant(A Int B)"; |
666 |
by (asm_full_simp_tac (simpset() addsimps [stable_Int]) 1); |
|
667 |
by (Blast_tac 1); |
|
668 |
qed "invariant_Int"; |
|
669 |
||
670 |
(** The Elimination Theorem. The "free" m has become universally quantified! |
|
12195 | 671 |
Should the premise be !!m instead of ALL m ? Would make it harder |
672 |
to use in forward proof. **) |
|
11479 | 673 |
|
12195 | 674 |
(* The general case easier to prove that le special case! *) |
675 |
Goalw [constrains_def, st_set_def] |
|
676 |
"[| ALL m:M. F : {s:A. x(s) = m} co B(m); F:program |] \ |
|
677 |
\ ==> F:{s:A. x(s):M} co (UN m:M. B(m))"; |
|
11479 | 678 |
by Safe_tac; |
12195 | 679 |
by Auto_tac; |
11479 | 680 |
by (Blast_tac 1); |
681 |
qed "elimination"; |
|
682 |
||
12195 | 683 |
(* As above, but for the special case of A=state *) |
11479 | 684 |
Goal "[| ALL m:M. F : {s:state. x(s) = m} co B(m); F:program |] \ |
685 |
\ ==> F:{s:state. x(s):M} co (UN m:M. B(m))"; |
|
686 |
by (rtac elimination 1); |
|
687 |
by (ALLGOALS(Clarify_tac)); |
|
688 |
qed "eliminiation2"; |
|
689 |
||
12195 | 690 |
(** strongest_rhs **) |
11479 | 691 |
|
12195 | 692 |
Goalw [constrains_def, strongest_rhs_def, st_set_def] |
693 |
"[| F:program; st_set(A) |] ==> F:A co (strongest_rhs(F,A))"; |
|
694 |
by (auto_tac (claset() addDs [Acts_type RS subsetD], simpset())); |
|
11479 | 695 |
qed "constrains_strongest_rhs"; |
696 |
||
12195 | 697 |
Goalw [constrains_def, strongest_rhs_def, st_set_def] |
698 |
"[| F:A co B; st_set(B) |] ==> strongest_rhs(F,A) <= B"; |
|
11479 | 699 |
by Safe_tac; |
700 |
by (dtac InterD 1); |
|
12195 | 701 |
by Auto_tac; |
11479 | 702 |
qed "strongest_rhs_is_strongest"; |
703 |
||
12195 | 704 |
(* Used in WFair.thy *) |
705 |
Goal "A:Pow(Pow(B)) ==> Union(A):Pow(B)"; |
|
706 |
by Auto_tac; |
|
707 |
qed "Union_PowI"; |