5252
|
1 |
(* Title: HOL/UNITY/Union.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1998 University of Cambridge
|
|
5 |
|
|
6 |
Unions of programs
|
|
7 |
|
|
8 |
From Misra's Chapter 5: Asynchronous Compositions of Programs
|
|
9 |
|
|
10 |
NOT CLEAR WHETHER ALL THESE FORMS ARE NEEDED:
|
|
11 |
Maybe Join instead of Un, and JOIN for UNION
|
|
12 |
*)
|
|
13 |
|
|
14 |
(*** Safety: constrains, stable, FP ***)
|
|
15 |
|
|
16 |
Goalw [constrains_def]
|
|
17 |
"constrains (UN i:I. acts i) A B = (ALL i:I. constrains (acts i) A B)";
|
|
18 |
by (Blast_tac 1);
|
|
19 |
qed "constrains_UN";
|
|
20 |
|
|
21 |
Goalw [constrains_def]
|
|
22 |
"constrains (actsF Un actsG) A B = \
|
|
23 |
\ (constrains actsF A B & constrains actsG A B)";
|
|
24 |
by (simp_tac (simpset() addsimps [ball_Un]) 1);
|
|
25 |
qed "constrains_Un";
|
|
26 |
|
|
27 |
(*Provable by constrains_Un and constrains_weaken, but why bother?*)
|
|
28 |
Goalw [constrains_def]
|
|
29 |
"[| constrains actsF A A'; constrains actsG B B' |] \
|
|
30 |
\ ==> constrains (actsF Un actsG) (A Int B) (A' Un B')";
|
|
31 |
by (Blast_tac 1);
|
|
32 |
qed "constrains_Un_weaken";
|
|
33 |
|
|
34 |
Goalw [stable_def] "stable (UN i:I. acts i) A = (ALL i:I. stable (acts i) A)";
|
|
35 |
by (simp_tac (simpset() addsimps [constrains_UN]) 1);
|
|
36 |
qed "stable_UN";
|
|
37 |
|
|
38 |
Goalw [stable_def]
|
|
39 |
"stable (actsF Un actsG) A = (stable actsF A & stable actsG A)";
|
|
40 |
by (simp_tac (simpset() addsimps [constrains_Un]) 1);
|
|
41 |
qed "stable_Un";
|
|
42 |
|
|
43 |
Goal "stable (Acts (Join prgF prgG)) A = \
|
|
44 |
\ (stable (Acts prgF) A & stable (Acts prgG) A)";
|
|
45 |
by (simp_tac (simpset() addsimps [Join_def, stable_Un]) 1);
|
|
46 |
qed "stable_Join";
|
|
47 |
|
|
48 |
Goalw [FP_def] "FP (UN i:I. acts i) = (INT i:I. FP (acts i))";
|
|
49 |
by (simp_tac (simpset() addsimps [stable_UN, INTER_def]) 1);
|
|
50 |
qed "FP_UN";
|
|
51 |
|
|
52 |
|
|
53 |
(*** Progress: transient, ensures ***)
|
|
54 |
|
|
55 |
Goalw [transient_def]
|
|
56 |
"transient (UN i:I. acts i) A = (EX i:I. transient (acts i) A)";
|
|
57 |
by (Simp_tac 1);
|
|
58 |
qed "transient_UN";
|
|
59 |
|
|
60 |
Goalw [ensures_def,transient_def]
|
|
61 |
"ensures (UN i:I. acts i) A B = \
|
|
62 |
\ ((ALL i:I. constrains (acts i) (A-B) (A Un B)) & \
|
|
63 |
\ (EX i:I. ensures (acts i) A B))";
|
|
64 |
by (simp_tac (simpset() addsimps [constrains_UN]) 1);
|
|
65 |
by Auto_tac;
|
|
66 |
qed "ensures_UN";
|
|
67 |
|
|
68 |
(*Alternative proof: simplify using ensures_def,transient_def,constrains_Un*)
|
|
69 |
Goal "ensures (actsF Un actsG) A B = \
|
|
70 |
\ (constrains actsF (A-B) (A Un B) & \
|
|
71 |
\ constrains actsG (A-B) (A Un B) & \
|
|
72 |
\ (ensures actsF A B | ensures actsG A B))";
|
|
73 |
by (simp_tac (simpset() addcongs [conj_cong]
|
|
74 |
addsimps [ensures_UN, Un_eq_UN,
|
|
75 |
all_bool_eq, ex_bool_eq]) 1);
|
|
76 |
qed "ensures_Un";
|
|
77 |
|
|
78 |
(*Or a longer proof via constrains_imp_subset*)
|
|
79 |
Goalw [stable_def, constrains_def]
|
|
80 |
"[| stable actsF A; constrains actsG A A'; id: actsG |] \
|
|
81 |
\ ==> constrains (actsF Un actsG) A A'";
|
|
82 |
by (asm_simp_tac (simpset() addsimps [ball_Un]) 1);
|
|
83 |
by (Blast_tac 1);
|
|
84 |
qed "stable_constrains_Un";
|
|
85 |
|
|
86 |
Goalw [Join_def]
|
|
87 |
"[| stable (Acts prgF) A; invariant prgG A |] \
|
|
88 |
\ ==> invariant (Join prgF prgG) A";
|
|
89 |
by (asm_full_simp_tac (simpset() addsimps [invariant_def, stable_Un]) 1);
|
|
90 |
by (Blast_tac 1);
|
|
91 |
qed "stable_Join_invariant";
|
|
92 |
|
|
93 |
Goal "[| stable actsF A; ensures actsG A B |] \
|
|
94 |
\ ==> ensures (actsF Un actsG) A B";
|
|
95 |
by (asm_simp_tac (simpset() addsimps [ensures_Un]) 1);
|
|
96 |
by (asm_full_simp_tac (simpset() addsimps [stable_def, ensures_def]) 1);
|
|
97 |
by (etac constrains_weaken 1);
|
|
98 |
by Auto_tac;
|
|
99 |
qed "ensures_stable_Un1";
|
|
100 |
|
|
101 |
Goal "[| stable (Acts prgF) A; ensures (Acts prgG) A B |] \
|
|
102 |
\ ==> ensures (Acts (Join prgF prgG)) A B";
|
|
103 |
by (asm_simp_tac (simpset() addsimps [Join_def, ensures_stable_Un1]) 1);
|
|
104 |
qed "ensures_stable_Join1";
|
|
105 |
|
|
106 |
(*As above, but exchanging the roles of F and G*)
|
|
107 |
Goal "[| ensures actsF A B; stable actsG A |] \
|
|
108 |
\ ==> ensures (actsF Un actsG) A B";
|
|
109 |
by (stac Un_commute 1);
|
|
110 |
by (blast_tac (claset() addIs [ensures_stable_Un1]) 1);
|
|
111 |
qed "ensures_stable_Un2";
|
|
112 |
|
|
113 |
Goal "[| ensures (Acts prgF) A B; stable (Acts prgG) A |] \
|
|
114 |
\ ==> ensures (Acts (Join prgF prgG)) A B";
|
|
115 |
by (asm_simp_tac (simpset() addsimps [Join_def, ensures_stable_Un2]) 1);
|
|
116 |
qed "ensures_stable_Join2";
|
|
117 |
|