| author | blanchet |
| Wed, 09 Dec 2009 12:26:42 +0100 | |
| changeset 34042 | b174d384293e |
| parent 32960 | 69916a850301 |
| child 35416 | d8d7d1b785af |
| permissions | -rw-r--r-- |
| 5597 | 1 |
(* Title: HOL/UNITY/Comp.thy |
2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30952
diff
changeset
|
3 |
Author: Sidi Ehmety |
| 5597 | 4 |
|
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30952
diff
changeset
|
5 |
Composition. |
|
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30952
diff
changeset
|
6 |
|
| 11190 | 7 |
From Chandy and Sanders, "Reasoning About Program Composition", |
8 |
Technical Report 2000-003, University of Florida, 2000. |
|
| 5597 | 9 |
*) |
10 |
||
| 13798 | 11 |
header{*Composition: Basic Primitives*}
|
12 |
||
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
13 |
theory Comp |
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
14 |
imports Union |
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
15 |
begin |
| 5597 | 16 |
|
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
17 |
instantiation program :: (type) ord |
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
18 |
begin |
| 5597 | 19 |
|
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
20 |
definition |
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
21 |
component_def: "F \<le> H <-> (\<exists>G. F\<squnion>G = H)" |
|
5612
e981ca6f7332
Finished proofs to end of section 5.1 of Chandy and Sanders
paulson
parents:
5597
diff
changeset
|
22 |
|
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
23 |
definition |
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
24 |
strict_component_def: "F < (H::'a program) <-> (F \<le> H & F \<noteq> H)" |
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
25 |
|
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
26 |
instance .. |
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
27 |
|
|
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
28 |
end |
| 11190 | 29 |
|
|
8055
bb15396278fb
abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents:
7399
diff
changeset
|
30 |
constdefs |
| 13805 | 31 |
component_of :: "'a program =>'a program=> bool" |
| 11190 | 32 |
(infixl "component'_of" 50) |
| 13819 | 33 |
"F component_of H == \<exists>G. F ok G & F\<squnion>G = H" |
| 11190 | 34 |
|
| 13792 | 35 |
strict_component_of :: "'a program\<Rightarrow>'a program=> bool" |
| 11190 | 36 |
(infixl "strict'_component'_of" 50) |
| 13805 | 37 |
"F strict_component_of H == F component_of H & F\<noteq>H" |
| 13819 | 38 |
|
|
8055
bb15396278fb
abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents:
7399
diff
changeset
|
39 |
preserves :: "('a=>'b) => 'a program set"
|
| 13805 | 40 |
"preserves v == \<Inter>z. stable {s. v s = z}"
|
|
8055
bb15396278fb
abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents:
7399
diff
changeset
|
41 |
|
| 11190 | 42 |
localize :: "('a=>'b) => 'a program => 'a program"
|
43 |
"localize v F == mk_program(Init F, Acts F, |
|
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30952
diff
changeset
|
44 |
AllowedActs F \<inter> (\<Union>G \<in> preserves v. Acts G))" |
| 11190 | 45 |
|
|
8055
bb15396278fb
abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents:
7399
diff
changeset
|
46 |
funPair :: "['a => 'b, 'a => 'c, 'a] => 'b * 'c" |
| 11190 | 47 |
"funPair f g == %x. (f x, g x)" |
| 13792 | 48 |
|
49 |
||
| 13798 | 50 |
subsection{*The component relation*}
|
| 13819 | 51 |
lemma componentI: "H \<le> F | H \<le> G ==> H \<le> (F\<squnion>G)" |
| 13792 | 52 |
apply (unfold component_def, auto) |
| 13819 | 53 |
apply (rule_tac x = "G\<squnion>Ga" in exI) |
54 |
apply (rule_tac [2] x = "G\<squnion>F" in exI) |
|
| 13792 | 55 |
apply (auto simp add: Join_ac) |
56 |
done |
|
57 |
||
| 13819 | 58 |
lemma component_eq_subset: |
59 |
"(F \<le> G) = |
|
| 13805 | 60 |
(Init G \<subseteq> Init F & Acts F \<subseteq> Acts G & AllowedActs G \<subseteq> AllowedActs F)" |
| 13792 | 61 |
apply (unfold component_def) |
62 |
apply (force intro!: exI program_equalityI) |
|
63 |
done |
|
64 |
||
| 13805 | 65 |
lemma component_SKIP [iff]: "SKIP \<le> F" |
| 13792 | 66 |
apply (unfold component_def) |
67 |
apply (force intro: Join_SKIP_left) |
|
68 |
done |
|
69 |
||
| 13805 | 70 |
lemma component_refl [iff]: "F \<le> (F :: 'a program)" |
| 13792 | 71 |
apply (unfold component_def) |
72 |
apply (blast intro: Join_SKIP_right) |
|
73 |
done |
|
74 |
||
| 13805 | 75 |
lemma SKIP_minimal: "F \<le> SKIP ==> F = SKIP" |
| 13792 | 76 |
by (auto intro!: program_equalityI simp add: component_eq_subset) |
77 |
||
| 13819 | 78 |
lemma component_Join1: "F \<le> (F\<squnion>G)" |
| 13792 | 79 |
by (unfold component_def, blast) |
80 |
||
| 13819 | 81 |
lemma component_Join2: "G \<le> (F\<squnion>G)" |
| 13792 | 82 |
apply (unfold component_def) |
| 13798 | 83 |
apply (simp add: Join_commute, blast) |
| 13792 | 84 |
done |
85 |
||
| 13819 | 86 |
lemma Join_absorb1: "F \<le> G ==> F\<squnion>G = G" |
| 13792 | 87 |
by (auto simp add: component_def Join_left_absorb) |
88 |
||
| 13819 | 89 |
lemma Join_absorb2: "G \<le> F ==> F\<squnion>G = F" |
| 13792 | 90 |
by (auto simp add: Join_ac component_def) |
91 |
||
| 13805 | 92 |
lemma JN_component_iff: "((JOIN I F) \<le> H) = (\<forall>i \<in> I. F i \<le> H)" |
| 13798 | 93 |
by (simp add: component_eq_subset, blast) |
| 13792 | 94 |
|
| 13805 | 95 |
lemma component_JN: "i \<in> I ==> (F i) \<le> (\<Squnion>i \<in> I. (F i))" |
| 13792 | 96 |
apply (unfold component_def) |
97 |
apply (blast intro: JN_absorb) |
|
98 |
done |
|
99 |
||
| 13805 | 100 |
lemma component_trans: "[| F \<le> G; G \<le> H |] ==> F \<le> (H :: 'a program)" |
| 13792 | 101 |
apply (unfold component_def) |
102 |
apply (blast intro: Join_assoc [symmetric]) |
|
103 |
done |
|
104 |
||
| 13805 | 105 |
lemma component_antisym: "[| F \<le> G; G \<le> F |] ==> F = (G :: 'a program)" |
| 13792 | 106 |
apply (simp (no_asm_use) add: component_eq_subset) |
107 |
apply (blast intro!: program_equalityI) |
|
108 |
done |
|
109 |
||
| 13819 | 110 |
lemma Join_component_iff: "((F\<squnion>G) \<le> H) = (F \<le> H & G \<le> H)" |
| 13798 | 111 |
by (simp add: component_eq_subset, blast) |
| 13792 | 112 |
|
| 13805 | 113 |
lemma component_constrains: "[| F \<le> G; G \<in> A co B |] ==> F \<in> A co B" |
| 13792 | 114 |
by (auto simp add: constrains_def component_eq_subset) |
115 |
||
| 13874 | 116 |
lemma component_stable: "[| F \<le> G; G \<in> stable A |] ==> F \<in> stable A" |
117 |
by (auto simp add: stable_def component_constrains) |
|
118 |
||
| 13792 | 119 |
(*Used in Guar.thy to show that programs are partially ordered*) |
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
120 |
lemmas program_less_le = strict_component_def |
| 13792 | 121 |
|
122 |
||
| 13798 | 123 |
subsection{*The preserves property*}
|
| 13792 | 124 |
|
| 13805 | 125 |
lemma preservesI: "(!!z. F \<in> stable {s. v s = z}) ==> F \<in> preserves v"
|
| 13792 | 126 |
by (unfold preserves_def, blast) |
127 |
||
| 13819 | 128 |
lemma preserves_imp_eq: |
| 13805 | 129 |
"[| F \<in> preserves v; act \<in> Acts F; (s,s') \<in> act |] ==> v s = v s'" |
| 13819 | 130 |
by (unfold preserves_def stable_def constrains_def, force) |
| 13792 | 131 |
|
| 13819 | 132 |
lemma Join_preserves [iff]: |
133 |
"(F\<squnion>G \<in> preserves v) = (F \<in> preserves v & G \<in> preserves v)" |
|
134 |
by (unfold preserves_def, auto) |
|
| 13792 | 135 |
|
136 |
lemma JN_preserves [iff]: |
|
| 13805 | 137 |
"(JOIN I F \<in> preserves v) = (\<forall>i \<in> I. F i \<in> preserves v)" |
| 13819 | 138 |
by (simp add: JN_stable preserves_def, blast) |
| 13792 | 139 |
|
| 13805 | 140 |
lemma SKIP_preserves [iff]: "SKIP \<in> preserves v" |
| 13792 | 141 |
by (auto simp add: preserves_def) |
142 |
||
143 |
lemma funPair_apply [simp]: "(funPair f g) x = (f x, g x)" |
|
144 |
by (simp add: funPair_def) |
|
145 |
||
| 13805 | 146 |
lemma preserves_funPair: "preserves (funPair v w) = preserves v \<inter> preserves w" |
| 13792 | 147 |
by (auto simp add: preserves_def stable_def constrains_def, blast) |
148 |
||
| 13805 | 149 |
(* (F \<in> preserves (funPair v w)) = (F \<in> preserves v \<inter> preserves w) *) |
| 13792 | 150 |
declare preserves_funPair [THEN eqset_imp_iff, iff] |
151 |
||
152 |
||
153 |
lemma funPair_o_distrib: "(funPair f g) o h = funPair (f o h) (g o h)" |
|
| 13798 | 154 |
by (simp add: funPair_def o_def) |
| 13792 | 155 |
|
156 |
lemma fst_o_funPair [simp]: "fst o (funPair f g) = f" |
|
| 13798 | 157 |
by (simp add: funPair_def o_def) |
| 13792 | 158 |
|
159 |
lemma snd_o_funPair [simp]: "snd o (funPair f g) = g" |
|
| 13798 | 160 |
by (simp add: funPair_def o_def) |
| 13792 | 161 |
|
| 13805 | 162 |
lemma subset_preserves_o: "preserves v \<subseteq> preserves (w o v)" |
| 13792 | 163 |
by (force simp add: preserves_def stable_def constrains_def) |
164 |
||
| 13805 | 165 |
lemma preserves_subset_stable: "preserves v \<subseteq> stable {s. P (v s)}"
|
| 13792 | 166 |
apply (auto simp add: preserves_def stable_def constrains_def) |
167 |
apply (rename_tac s' s) |
|
168 |
apply (subgoal_tac "v s = v s'") |
|
169 |
apply (force+) |
|
170 |
done |
|
171 |
||
| 13805 | 172 |
lemma preserves_subset_increasing: "preserves v \<subseteq> increasing v" |
| 13792 | 173 |
by (auto simp add: preserves_subset_stable [THEN subsetD] increasing_def) |
174 |
||
| 13805 | 175 |
lemma preserves_id_subset_stable: "preserves id \<subseteq> stable A" |
| 13792 | 176 |
by (force simp add: preserves_def stable_def constrains_def) |
177 |
||
178 |
||
179 |
(** For use with def_UNION_ok_iff **) |
|
180 |
||
181 |
lemma safety_prop_preserves [iff]: "safety_prop (preserves v)" |
|
182 |
by (auto intro: safety_prop_INTER1 simp add: preserves_def) |
|
183 |
||
184 |
||
| 24147 | 185 |
(** Some lemmas used only in Client.thy **) |
| 13792 | 186 |
|
187 |
lemma stable_localTo_stable2: |
|
| 13819 | 188 |
"[| F \<in> stable {s. P (v s) (w s)};
|
189 |
G \<in> preserves v; G \<in> preserves w |] |
|
190 |
==> F\<squnion>G \<in> stable {s. P (v s) (w s)}"
|
|
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
191 |
apply simp |
| 13805 | 192 |
apply (subgoal_tac "G \<in> preserves (funPair v w) ") |
| 13819 | 193 |
prefer 2 apply simp |
194 |
apply (drule_tac P1 = "split ?Q" in preserves_subset_stable [THEN subsetD], |
|
195 |
auto) |
|
| 13792 | 196 |
done |
197 |
||
198 |
lemma Increasing_preserves_Stable: |
|
| 13819 | 199 |
"[| F \<in> stable {s. v s \<le> w s}; G \<in> preserves v; F\<squnion>G \<in> Increasing w |]
|
200 |
==> F\<squnion>G \<in> Stable {s. v s \<le> w s}"
|
|
| 13792 | 201 |
apply (auto simp add: stable_def Stable_def Increasing_def Constrains_def all_conj_distrib) |
202 |
apply (blast intro: constrains_weaken) |
|
203 |
(*The G case remains*) |
|
204 |
apply (auto simp add: preserves_def stable_def constrains_def) |
|
205 |
(*We have a G-action, so delete assumptions about F-actions*) |
|
| 13805 | 206 |
apply (erule_tac V = "\<forall>act \<in> Acts F. ?P act" in thin_rl) |
207 |
apply (erule_tac V = "\<forall>z. \<forall>act \<in> Acts F. ?P z act" in thin_rl) |
|
| 13792 | 208 |
apply (subgoal_tac "v x = v xa") |
| 13819 | 209 |
apply auto |
| 13792 | 210 |
apply (erule order_trans, blast) |
211 |
done |
|
212 |
||
213 |
(** component_of **) |
|
214 |
||
| 13805 | 215 |
(* component_of is stronger than \<le> *) |
216 |
lemma component_of_imp_component: "F component_of H ==> F \<le> H" |
|
| 13792 | 217 |
by (unfold component_def component_of_def, blast) |
218 |
||
219 |
||
| 13805 | 220 |
(* component_of satisfies many of the same properties as \<le> *) |
| 13792 | 221 |
lemma component_of_refl [simp]: "F component_of F" |
222 |
apply (unfold component_of_def) |
|
223 |
apply (rule_tac x = SKIP in exI, auto) |
|
224 |
done |
|
225 |
||
226 |
lemma component_of_SKIP [simp]: "SKIP component_of F" |
|
227 |
by (unfold component_of_def, auto) |
|
228 |
||
| 13819 | 229 |
lemma component_of_trans: |
| 13792 | 230 |
"[| F component_of G; G component_of H |] ==> F component_of H" |
231 |
apply (unfold component_of_def) |
|
232 |
apply (blast intro: Join_assoc [symmetric]) |
|
233 |
done |
|
234 |
||
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
24147
diff
changeset
|
235 |
lemmas strict_component_of_eq = strict_component_of_def |
| 13792 | 236 |
|
237 |
(** localize **) |
|
238 |
lemma localize_Init_eq [simp]: "Init (localize v F) = Init F" |
|
| 13798 | 239 |
by (simp add: localize_def) |
| 13792 | 240 |
|
241 |
lemma localize_Acts_eq [simp]: "Acts (localize v F) = Acts F" |
|
| 13798 | 242 |
by (simp add: localize_def) |
| 13792 | 243 |
|
| 13819 | 244 |
lemma localize_AllowedActs_eq [simp]: |
245 |
"AllowedActs (localize v F) = AllowedActs F \<inter> (\<Union>G \<in> preserves v. Acts G)" |
|
| 13798 | 246 |
by (unfold localize_def, auto) |
| 13792 | 247 |
|
| 5597 | 248 |
end |