17 |
17 |
18 theory Comp imports Union Increasing begin |
18 theory Comp imports Union Increasing begin |
19 |
19 |
20 definition |
20 definition |
21 component :: "[i,i]=>o" (infixl "component" 65) where |
21 component :: "[i,i]=>o" (infixl "component" 65) where |
22 "F component H == (EX G. F Join G = H)" |
22 "F component H == (\<exists>G. F Join G = H)" |
23 |
23 |
24 definition |
24 definition |
25 strict_component :: "[i,i]=>o" (infixl "strict'_component" 65) where |
25 strict_component :: "[i,i]=>o" (infixl "strict'_component" 65) where |
26 "F strict_component H == F component H & F~=H" |
26 "F strict_component H == F component H & F\<noteq>H" |
27 |
27 |
28 definition |
28 definition |
29 (* A stronger form of the component relation *) |
29 (* A stronger form of the component relation *) |
30 component_of :: "[i,i]=>o" (infixl "component'_of" 65) where |
30 component_of :: "[i,i]=>o" (infixl "component'_of" 65) where |
31 "F component_of H == (EX G. F ok G & F Join G = H)" |
31 "F component_of H == (\<exists>G. F ok G & F Join G = H)" |
32 |
32 |
33 definition |
33 definition |
34 strict_component_of :: "[i,i]=>o" (infixl "strict'_component'_of" 65) where |
34 strict_component_of :: "[i,i]=>o" (infixl "strict'_component'_of" 65) where |
35 "F strict_component_of H == F component_of H & F~=H" |
35 "F strict_component_of H == F component_of H & F\<noteq>H" |
36 |
36 |
37 definition |
37 definition |
38 (* Preserves a state function f, in particular a variable *) |
38 (* Preserves a state function f, in particular a variable *) |
39 preserves :: "(i=>i)=>i" where |
39 preserves :: "(i=>i)=>i" where |
40 "preserves(f) == {F:program. ALL z. F: stable({s:state. f(s) = z})}" |
40 "preserves(f) == {F:program. \<forall>z. F: stable({s:state. f(s) = z})}" |
41 |
41 |
42 definition |
42 definition |
43 fun_pair :: "[i=>i, i =>i] =>(i=>i)" where |
43 fun_pair :: "[i=>i, i =>i] =>(i=>i)" where |
44 "fun_pair(f, g) == %x. <f(x), g(x)>" |
44 "fun_pair(f, g) == %x. <f(x), g(x)>" |
45 |
45 |
46 definition |
46 definition |
47 localize :: "[i=>i, i] => i" where |
47 localize :: "[i=>i, i] => i" where |
48 "localize(f,F) == mk_program(Init(F), Acts(F), |
48 "localize(f,F) == mk_program(Init(F), Acts(F), |
49 AllowedActs(F) Int (UN G:preserves(f). Acts(G)))" |
49 AllowedActs(F) \<inter> (\<Union>G\<in>preserves(f). Acts(G)))" |
50 |
50 |
51 |
51 |
52 (*** component and strict_component relations ***) |
52 (*** component and strict_component relations ***) |
53 |
53 |
54 lemma componentI: |
54 lemma componentI: |
58 apply (rule_tac [2] x = "G Join F" in exI) |
58 apply (rule_tac [2] x = "G Join F" in exI) |
59 apply (auto simp add: Join_ac) |
59 apply (auto simp add: Join_ac) |
60 done |
60 done |
61 |
61 |
62 lemma component_eq_subset: |
62 lemma component_eq_subset: |
63 "G \<in> program ==> (F component G) <-> |
63 "G \<in> program ==> (F component G) \<longleftrightarrow> |
64 (Init(G) <= Init(F) & Acts(F) <= Acts(G) & AllowedActs(G) <= AllowedActs(F))" |
64 (Init(G) \<subseteq> Init(F) & Acts(F) \<subseteq> Acts(G) & AllowedActs(G) \<subseteq> AllowedActs(F))" |
65 apply (unfold component_def, auto) |
65 apply (unfold component_def, auto) |
66 apply (rule exI) |
66 apply (rule exI) |
67 apply (rule program_equalityI, auto) |
67 apply (rule program_equalityI, auto) |
68 done |
68 done |
69 |
69 |
98 |
98 |
99 lemma Join_absorb2: "G component F ==> F Join G = F" |
99 lemma Join_absorb2: "G component F ==> F Join G = F" |
100 by (auto simp add: Join_ac component_def) |
100 by (auto simp add: Join_ac component_def) |
101 |
101 |
102 lemma JN_component_iff: |
102 lemma JN_component_iff: |
103 "H \<in> program==>(JOIN(I,F) component H) <-> (\<forall>i \<in> I. F(i) component H)" |
103 "H \<in> program==>(JOIN(I,F) component H) \<longleftrightarrow> (\<forall>i \<in> I. F(i) component H)" |
104 apply (case_tac "I=0", force) |
104 apply (case_tac "I=0", force) |
105 apply (simp (no_asm_simp) add: component_eq_subset) |
105 apply (simp (no_asm_simp) add: component_eq_subset) |
106 apply auto |
106 apply auto |
107 apply blast |
107 apply blast |
108 apply (rename_tac "y") |
108 apply (rename_tac "y") |
119 apply (unfold component_def) |
119 apply (unfold component_def) |
120 apply (blast intro: Join_assoc [symmetric]) |
120 apply (blast intro: Join_assoc [symmetric]) |
121 done |
121 done |
122 |
122 |
123 lemma component_antisym: |
123 lemma component_antisym: |
124 "[| F \<in> program; G \<in> program |] ==>(F component G & G component F) --> F = G" |
124 "[| F \<in> program; G \<in> program |] ==>(F component G & G component F) \<longrightarrow> F = G" |
125 apply (simp (no_asm_simp) add: component_eq_subset) |
125 apply (simp (no_asm_simp) add: component_eq_subset) |
126 apply clarify |
126 apply clarify |
127 apply (rule program_equalityI, auto) |
127 apply (rule program_equalityI, auto) |
128 done |
128 done |
129 |
129 |
130 lemma Join_component_iff: |
130 lemma Join_component_iff: |
131 "H \<in> program ==> |
131 "H \<in> program ==> |
132 ((F Join G) component H) <-> (F component H & G component H)" |
132 ((F Join G) component H) \<longleftrightarrow> (F component H & G component H)" |
133 apply (simp (no_asm_simp) add: component_eq_subset) |
133 apply (simp (no_asm_simp) add: component_eq_subset) |
134 apply blast |
134 apply blast |
135 done |
135 done |
136 |
136 |
137 lemma component_constrains: |
137 lemma component_constrains: |
161 apply (subgoal_tac "s \<in> state & t \<in> state") |
161 apply (subgoal_tac "s \<in> state & t \<in> state") |
162 prefer 2 apply (blast dest!: Acts_type [THEN subsetD], force) |
162 prefer 2 apply (blast dest!: Acts_type [THEN subsetD], force) |
163 done |
163 done |
164 |
164 |
165 lemma Join_preserves [iff]: |
165 lemma Join_preserves [iff]: |
166 "(F Join G \<in> preserves(v)) <-> |
166 "(F Join G \<in> preserves(v)) \<longleftrightarrow> |
167 (programify(F) \<in> preserves(v) & programify(G) \<in> preserves(v))" |
167 (programify(F) \<in> preserves(v) & programify(G) \<in> preserves(v))" |
168 by (auto simp add: preserves_def INT_iff) |
168 by (auto simp add: preserves_def INT_iff) |
169 |
169 |
170 lemma JN_preserves [iff]: |
170 lemma JN_preserves [iff]: |
171 "(JOIN(I,F): preserves(v)) <-> (\<forall>i \<in> I. programify(F(i)):preserves(v))" |
171 "(JOIN(I,F): preserves(v)) \<longleftrightarrow> (\<forall>i \<in> I. programify(F(i)):preserves(v))" |
172 by (auto simp add: JN_stable preserves_def INT_iff) |
172 by (auto simp add: JN_stable preserves_def INT_iff) |
173 |
173 |
174 lemma SKIP_preserves [iff]: "SKIP \<in> preserves(v)" |
174 lemma SKIP_preserves [iff]: "SKIP \<in> preserves(v)" |
175 by (auto simp add: preserves_def INT_iff) |
175 by (auto simp add: preserves_def INT_iff) |
176 |
176 |
178 apply (unfold fun_pair_def) |
178 apply (unfold fun_pair_def) |
179 apply (simp (no_asm)) |
179 apply (simp (no_asm)) |
180 done |
180 done |
181 |
181 |
182 lemma preserves_fun_pair: |
182 lemma preserves_fun_pair: |
183 "preserves(fun_pair(v,w)) = preserves(v) Int preserves(w)" |
183 "preserves(fun_pair(v,w)) = preserves(v) \<inter> preserves(w)" |
184 apply (rule equalityI) |
184 apply (rule equalityI) |
185 apply (auto simp add: preserves_def stable_def constrains_def, blast+) |
185 apply (auto simp add: preserves_def stable_def constrains_def, blast+) |
186 done |
186 done |
187 |
187 |
188 lemma preserves_fun_pair_iff [iff]: |
188 lemma preserves_fun_pair_iff [iff]: |
189 "F \<in> preserves(fun_pair(v, w)) <-> F \<in> preserves(v) Int preserves(w)" |
189 "F \<in> preserves(fun_pair(v, w)) \<longleftrightarrow> F \<in> preserves(v) \<inter> preserves(w)" |
190 by (simp add: preserves_fun_pair) |
190 by (simp add: preserves_fun_pair) |
191 |
191 |
192 lemma fun_pair_comp_distrib: |
192 lemma fun_pair_comp_distrib: |
193 "(fun_pair(f, g) comp h)(x) = fun_pair(f comp h, g comp h, x)" |
193 "(fun_pair(f, g) comp h)(x) = fun_pair(f comp h, g comp h, x)" |
194 by (simp add: fun_pair_def metacomp_def) |
194 by (simp add: fun_pair_def metacomp_def) |
200 by (unfold preserves_def, auto) |
200 by (unfold preserves_def, auto) |
201 |
201 |
202 lemma preserves_into_program [TC]: "F \<in> preserves(f) ==> F \<in> program" |
202 lemma preserves_into_program [TC]: "F \<in> preserves(f) ==> F \<in> program" |
203 by (blast intro: preserves_type [THEN subsetD]) |
203 by (blast intro: preserves_type [THEN subsetD]) |
204 |
204 |
205 lemma subset_preserves_comp: "preserves(f) <= preserves(g comp f)" |
205 lemma subset_preserves_comp: "preserves(f) \<subseteq> preserves(g comp f)" |
206 apply (auto simp add: preserves_def stable_def constrains_def) |
206 apply (auto simp add: preserves_def stable_def constrains_def) |
207 apply (drule_tac x = "f (xb)" in spec) |
207 apply (drule_tac x = "f (xb)" in spec) |
208 apply (drule_tac x = act in bspec, auto) |
208 apply (drule_tac x = act in bspec, auto) |
209 done |
209 done |
210 |
210 |
211 lemma imp_preserves_comp: "F \<in> preserves(f) ==> F \<in> preserves(g comp f)" |
211 lemma imp_preserves_comp: "F \<in> preserves(f) ==> F \<in> preserves(g comp f)" |
212 by (blast intro: subset_preserves_comp [THEN subsetD]) |
212 by (blast intro: subset_preserves_comp [THEN subsetD]) |
213 |
213 |
214 lemma preserves_subset_stable: "preserves(f) <= stable({s \<in> state. P(f(s))})" |
214 lemma preserves_subset_stable: "preserves(f) \<subseteq> stable({s \<in> state. P(f(s))})" |
215 apply (auto simp add: preserves_def stable_def constrains_def) |
215 apply (auto simp add: preserves_def stable_def constrains_def) |
216 apply (rename_tac s' s) |
216 apply (rename_tac s' s) |
217 apply (subgoal_tac "f (s) = f (s') ") |
217 apply (subgoal_tac "f (s) = f (s') ") |
218 apply (force+) |
218 apply (force+) |
219 done |
219 done |
228 apply (auto intro: preserves_into_program) |
228 apply (auto intro: preserves_into_program) |
229 apply (rule_tac P = "%x. <k, x>:r" in preserves_imp_stable, auto) |
229 apply (rule_tac P = "%x. <k, x>:r" in preserves_imp_stable, auto) |
230 done |
230 done |
231 |
231 |
232 lemma preserves_id_subset_stable: |
232 lemma preserves_id_subset_stable: |
233 "st_set(A) ==> preserves(%x. x) <= stable(A)" |
233 "st_set(A) ==> preserves(%x. x) \<subseteq> stable(A)" |
234 apply (unfold preserves_def stable_def constrains_def, auto) |
234 apply (unfold preserves_def stable_def constrains_def, auto) |
235 apply (drule_tac x = xb in spec) |
235 apply (drule_tac x = xb in spec) |
236 apply (drule_tac x = act in bspec) |
236 apply (drule_tac x = act in bspec) |
237 apply (auto dest: ActsD) |
237 apply (auto dest: ActsD) |
238 done |
238 done |
273 |
273 |
274 lemma localize_Acts_eq [simp]: "Acts(localize(v,F)) = Acts(F)" |
274 lemma localize_Acts_eq [simp]: "Acts(localize(v,F)) = Acts(F)" |
275 by (unfold localize_def, simp) |
275 by (unfold localize_def, simp) |
276 |
276 |
277 lemma localize_AllowedActs_eq [simp]: |
277 lemma localize_AllowedActs_eq [simp]: |
278 "AllowedActs(localize(v,F)) = AllowedActs(F) Int (\<Union>G \<in> preserves(v). Acts(G))" |
278 "AllowedActs(localize(v,F)) = AllowedActs(F) \<inter> (\<Union>G \<in> preserves(v). Acts(G))" |
279 apply (unfold localize_def) |
279 apply (unfold localize_def) |
280 apply (rule equalityI) |
280 apply (rule equalityI) |
281 apply (auto dest: Acts_type [THEN subsetD]) |
281 apply (auto dest: Acts_type [THEN subsetD]) |
282 done |
282 done |
283 |
283 |
323 "[| F \<in> stable({s \<in> state. P(f(s), g(s))}); |
323 "[| F \<in> stable({s \<in> state. P(f(s), g(s))}); |
324 \<forall>k \<in> A. F Join G \<in> Stable({s \<in> state. P(k, g(s))}); |
324 \<forall>k \<in> A. F Join G \<in> Stable({s \<in> state. P(k, g(s))}); |
325 G \<in> preserves(f); \<forall>s \<in> state. f(s):A|] |
325 G \<in> preserves(f); \<forall>s \<in> state. f(s):A|] |
326 ==> F Join G \<in> Stable({s \<in> state. P(f(s), g(s))})" |
326 ==> F Join G \<in> Stable({s \<in> state. P(f(s), g(s))})" |
327 apply (unfold stable_def Stable_def preserves_def) |
327 apply (unfold stable_def Stable_def preserves_def) |
328 apply (rule_tac A = "(\<Union>k \<in> A. {s \<in> state. f(s)=k} Int {s \<in> state. P (f (s), g (s))})" in Constrains_weaken_L) |
328 apply (rule_tac A = "(\<Union>k \<in> A. {s \<in> state. f(s)=k} \<inter> {s \<in> state. P (f (s), g (s))})" in Constrains_weaken_L) |
329 prefer 2 apply blast |
329 prefer 2 apply blast |
330 apply (rule Constrains_UN_left, auto) |
330 apply (rule Constrains_UN_left, auto) |
331 apply (rule_tac A = "{s \<in> state. f(s)=k} Int {s \<in> state. P (f (s), g (s))} Int {s \<in> state. P (k, g (s))}" and A' = "({s \<in> state. f(s)=k} Un {s \<in> state. P (f (s), g (s))}) Int {s \<in> state. P (k, g (s))}" in Constrains_weaken) |
331 apply (rule_tac A = "{s \<in> state. f(s)=k} \<inter> {s \<in> state. P (f (s), g (s))} \<inter> {s \<in> state. P (k, g (s))}" and A' = "({s \<in> state. f(s)=k} \<union> {s \<in> state. P (f (s), g (s))}) \<inter> {s \<in> state. P (k, g (s))}" in Constrains_weaken) |
332 prefer 2 apply blast |
332 prefer 2 apply blast |
333 prefer 2 apply blast |
333 prefer 2 apply blast |
334 apply (rule Constrains_Int) |
334 apply (rule Constrains_Int) |
335 apply (rule constrains_imp_Constrains) |
335 apply (rule constrains_imp_Constrains) |
336 apply (auto simp add: constrains_type [THEN subsetD]) |
336 apply (auto simp add: constrains_type [THEN subsetD]) |