|
11479
|
1 |
(* Title: ZF/UNITY/Comp.ML
|
|
|
2 |
ID: $Id$
|
|
|
3 |
Author: Sidi O Ehmety, Computer Laboratory
|
|
|
4 |
Copyright 1998 University of Cambridge
|
|
|
5 |
Composition
|
|
|
6 |
From Chandy and Sanders, "Reasoning About Program Composition"
|
|
|
7 |
|
|
|
8 |
Revised by Sidi Ehmety on January 2001
|
|
|
9 |
|
|
|
10 |
*)
|
|
|
11 |
|
|
|
12 |
(*** component and strict_component relations ***)
|
|
|
13 |
|
|
|
14 |
Goalw [component_def]
|
|
|
15 |
"H component F | H component G ==> H component (F Join G)";
|
|
|
16 |
by Auto_tac;
|
|
|
17 |
by (res_inst_tac [("x", "Ga Join G")] exI 1);
|
|
|
18 |
by (res_inst_tac [("x", "G Join F")] exI 2);
|
|
|
19 |
by (auto_tac (claset(), simpset() addsimps Join_ac));
|
|
|
20 |
qed "componentI";
|
|
|
21 |
|
|
|
22 |
Goalw [component_def]
|
|
|
23 |
"G:program ==> (F component G) <-> \
|
|
|
24 |
\ (Init(G) <= Init(F) & Acts(F) <= Acts(G) & AllowedActs(G) <= AllowedActs(F))";
|
|
|
25 |
by Auto_tac;
|
|
|
26 |
by (rtac exI 1);
|
|
|
27 |
by (rtac program_equalityI 1);
|
|
|
28 |
by Auto_tac;
|
|
|
29 |
qed "component_eq_subset";
|
|
|
30 |
|
|
|
31 |
Goalw [component_def]
|
|
|
32 |
"F:program ==> SKIP component F";
|
|
|
33 |
by (res_inst_tac [("x", "F")] exI 1);
|
|
|
34 |
by (force_tac (claset() addIs [Join_SKIP_left], simpset()) 1);
|
|
|
35 |
qed "component_SKIP";
|
|
|
36 |
|
|
|
37 |
Goalw [component_def]
|
|
|
38 |
"F:program ==> F component F";
|
|
|
39 |
by (res_inst_tac [("x", "F")] exI 1);
|
|
|
40 |
by (force_tac (claset() addIs [Join_SKIP_right], simpset()) 1);
|
|
|
41 |
qed "component_refl";
|
|
|
42 |
|
|
|
43 |
Addsimps [component_SKIP, component_refl];
|
|
|
44 |
|
|
|
45 |
Goal "F component SKIP ==> programify(F) = SKIP";
|
|
|
46 |
by (rtac program_equalityI 1);
|
|
|
47 |
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [component_eq_subset])));
|
|
|
48 |
by (Blast_tac 1);
|
|
|
49 |
qed "SKIP_minimal";
|
|
|
50 |
|
|
|
51 |
Goalw [component_def] "F component (F Join G)";
|
|
|
52 |
by (Blast_tac 1);
|
|
|
53 |
qed "component_Join1";
|
|
|
54 |
|
|
|
55 |
Goalw [component_def] "G component (F Join G)";
|
|
|
56 |
by (simp_tac (simpset() addsimps [Join_commute]) 1);
|
|
|
57 |
by (Blast_tac 1);
|
|
|
58 |
qed "component_Join2";
|
|
|
59 |
|
|
|
60 |
Goal "F component G ==> F Join G = G";
|
|
|
61 |
by (auto_tac (claset(), simpset()
|
|
|
62 |
addsimps [component_def, Join_left_absorb]));
|
|
|
63 |
qed "Join_absorb1";
|
|
|
64 |
|
|
|
65 |
Goal "G component F ==> F Join G = F";
|
|
|
66 |
by (auto_tac (claset(), simpset() addsimps Join_ac@[component_def]));
|
|
|
67 |
qed "Join_absorb2";
|
|
|
68 |
|
|
12220
|
69 |
Goal "H:program==>(JOIN(I,F) component H) <-> (ALL i:I. F(i) component H)";
|
|
11479
|
70 |
by (case_tac "I=0" 1);
|
|
|
71 |
by (Force_tac 1);
|
|
|
72 |
by (asm_simp_tac (simpset() addsimps [component_eq_subset]) 1);
|
|
|
73 |
by Auto_tac;
|
|
|
74 |
by (dres_inst_tac [("c", "xb"), ("A", "AllowedActs(H)")] subsetD 2);
|
|
|
75 |
by (REPEAT(blast_tac (claset() addSEs [not_emptyE]) 1));
|
|
|
76 |
qed "JN_component_iff";
|
|
|
77 |
|
|
12195
|
78 |
Goalw [component_def] "i:I ==> F(i) component (JN i:I. (F(i)))";
|
|
11479
|
79 |
by (blast_tac (claset() addIs [JN_absorb]) 1);
|
|
|
80 |
qed "component_JN";
|
|
|
81 |
|
|
|
82 |
Goalw [component_def] "[| F component G; G component H |] ==> F component H";
|
|
|
83 |
by (blast_tac (claset() addIs [Join_assoc RS sym]) 1);
|
|
|
84 |
qed "component_trans";
|
|
|
85 |
|
|
12195
|
86 |
Goal "[| F:program; G:program |] ==>(F component G & G component F) --> F = G";
|
|
11479
|
87 |
by (asm_simp_tac (simpset() addsimps [component_eq_subset]) 1);
|
|
|
88 |
by (Clarify_tac 1);
|
|
|
89 |
by (rtac program_equalityI 1);
|
|
|
90 |
by Auto_tac;
|
|
|
91 |
qed "component_antisym";
|
|
|
92 |
|
|
|
93 |
Goal "H:program ==> ((F Join G) component H) <-> (F component H & G component H)";
|
|
|
94 |
by (asm_simp_tac (simpset() addsimps [component_eq_subset]) 1);
|
|
|
95 |
by (Blast_tac 1);
|
|
|
96 |
qed "Join_component_iff";
|
|
|
97 |
|
|
|
98 |
Goal "[| F component G; G:A co B; F:program |] ==> F : A co B";
|
|
12484
|
99 |
by (ftac constrainsD2 1);
|
|
11479
|
100 |
by (rotate_tac ~1 1);
|
|
|
101 |
by (auto_tac (claset(),
|
|
|
102 |
simpset() addsimps [constrains_def, component_eq_subset]));
|
|
|
103 |
qed "component_constrains";
|
|
|
104 |
|
|
12195
|
105 |
(* Used in Guar.thy to show that programs are partially ordered*)
|
|
11479
|
106 |
(* bind_thm ("program_less_le", strict_component_def RS meta_eq_to_obj_eq);*)
|
|
|
107 |
|
|
|
108 |
(*** preserves ***)
|
|
|
109 |
|
|
12195
|
110 |
val prems = Goalw [preserves_def]
|
|
11479
|
111 |
"ALL z. F:stable({s:state. f(s) = z}) ==> F:preserves(f)";
|
|
|
112 |
by Auto_tac;
|
|
|
113 |
by (blast_tac (claset() addDs [stableD2]) 1);
|
|
12195
|
114 |
qed "preserves_aux";
|
|
|
115 |
bind_thm("preservesI", allI RS preserves_aux);
|
|
11479
|
116 |
|
|
|
117 |
Goalw [preserves_def, stable_def, constrains_def]
|
|
|
118 |
"[| F:preserves(f); act : Acts(F); <s,t> : act |] ==> f(s) = f(t)";
|
|
|
119 |
by (subgoal_tac "s:state & t:state" 1);
|
|
12195
|
120 |
by (blast_tac (claset() addSDs [Acts_type RS subsetD]) 2);
|
|
11479
|
121 |
by Auto_tac;
|
|
|
122 |
by (dres_inst_tac [("x", "f(s)")] spec 1);
|
|
|
123 |
by (dres_inst_tac [("x", "act")] bspec 1);
|
|
|
124 |
by Auto_tac;
|
|
|
125 |
qed "preserves_imp_eq";
|
|
|
126 |
|
|
|
127 |
Goalw [preserves_def]
|
|
|
128 |
"(F Join G : preserves(v)) <-> \
|
|
|
129 |
\ (programify(F) : preserves(v) & programify(G) : preserves(v))";
|
|
|
130 |
by (auto_tac (claset(), simpset() addsimps [INT_iff]));
|
|
|
131 |
qed "Join_preserves";
|
|
|
132 |
|
|
|
133 |
Goal "(JOIN(I,F): preserves(v)) <-> (ALL i:I. programify(F(i)):preserves(v))";
|
|
12195
|
134 |
by (auto_tac (claset(), simpset() addsimps [JN_stable, preserves_def, INT_iff]));
|
|
11479
|
135 |
qed "JN_preserves";
|
|
|
136 |
|
|
|
137 |
Goal "SKIP : preserves(v)";
|
|
12195
|
138 |
by (auto_tac (claset(), simpset() addsimps [preserves_def, INT_iff]));
|
|
11479
|
139 |
qed "SKIP_preserves";
|
|
|
140 |
|
|
|
141 |
AddIffs [Join_preserves, JN_preserves, SKIP_preserves];
|
|
|
142 |
|
|
12195
|
143 |
(** Added by Sidi **)
|
|
11479
|
144 |
(** component_of **)
|
|
|
145 |
|
|
|
146 |
(* component_of is stronger than component *)
|
|
|
147 |
Goalw [component_def, component_of_def]
|
|
|
148 |
"F component_of H ==> F component H";
|
|
|
149 |
by (Blast_tac 1);
|
|
|
150 |
qed "component_of_imp_component";
|
|
|
151 |
|
|
12195
|
152 |
(* component_of satisfies many of component's properties *)
|
|
11479
|
153 |
Goalw [component_of_def]
|
|
|
154 |
"F:program ==> F component_of F";
|
|
|
155 |
by (res_inst_tac [("x", "SKIP")] exI 1);
|
|
|
156 |
by Auto_tac;
|
|
|
157 |
qed "component_of_refl";
|
|
|
158 |
|
|
|
159 |
Goalw [component_of_def]
|
|
|
160 |
"F:program ==>SKIP component_of F";
|
|
|
161 |
by Auto_tac;
|
|
|
162 |
by (res_inst_tac [("x", "F")] exI 1);
|
|
|
163 |
by Auto_tac;
|
|
|
164 |
qed "component_of_SKIP";
|
|
|
165 |
Addsimps [component_of_refl, component_of_SKIP];
|
|
|
166 |
|
|
|
167 |
Goalw [component_of_def]
|
|
|
168 |
"[| F component_of G; G component_of H |] ==> F component_of H";
|
|
|
169 |
by (blast_tac (claset() addIs [Join_assoc RS sym]) 1);
|
|
|
170 |
qed "component_of_trans";
|
|
|
171 |
|
|
|
172 |
(** localize **)
|
|
|
173 |
Goalw [localize_def]
|
|
|
174 |
"Init(localize(v,F)) = Init(F)";
|
|
|
175 |
by (Simp_tac 1);
|
|
|
176 |
qed "localize_Init_eq";
|
|
|
177 |
|
|
|
178 |
Goalw [localize_def]
|
|
|
179 |
"Acts(localize(v,F)) = Acts(F)";
|
|
|
180 |
by (Simp_tac 1);
|
|
|
181 |
qed "localize_Acts_eq";
|
|
|
182 |
|
|
|
183 |
Goalw [localize_def]
|
|
12195
|
184 |
"AllowedActs(localize(v,F)) = AllowedActs(F) Int (UN G:preserves(v). Acts(G))";
|
|
|
185 |
by (rtac equalityI 1);
|
|
|
186 |
by (auto_tac (claset() addDs [Acts_type RS subsetD], simpset()));
|
|
11479
|
187 |
qed "localize_AllowedActs_eq";
|
|
|
188 |
|
|
12195
|
189 |
AddIffs [localize_Init_eq, localize_Acts_eq, localize_AllowedActs_eq];
|
|
|
190 |
|