| author | huffman | 
| Tue, 02 Jun 2009 15:13:22 -0700 | |
| changeset 31390 | 1d0478b16613 | 
| parent 27682 | 25aceefd4786 | 
| child 32960 | 69916a850301 | 
| permissions | -rw-r--r-- | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
1  | 
(* Title: HOL/UNITY/Guar.thy  | 
| 
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
2  | 
ID: $Id$  | 
| 
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
3  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
| 
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
4  | 
Copyright 1999 University of Cambridge  | 
| 
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
5  | 
|
| 11190 | 6  | 
From Chandy and Sanders, "Reasoning About Program Composition",  | 
7  | 
Technical Report 2000-003, University of Florida, 2000.  | 
|
8  | 
||
9  | 
Revised by Sidi Ehmety on January 2001  | 
|
10  | 
||
11  | 
Added: Compatibility, weakest guarantees, etc.  | 
|
12  | 
||
13  | 
and Weakest existential property,  | 
|
14  | 
from Charpentier and Chandy "Theorems about Composition",  | 
|
15  | 
Fifth International Conference on Mathematics of Program, 2000.  | 
|
16  | 
||
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
17  | 
*)  | 
| 
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
18  | 
|
| 13798 | 19  | 
header{*Guarantees Specifications*}
 | 
20  | 
||
| 27682 | 21  | 
theory Guar  | 
22  | 
imports Comp  | 
|
23  | 
begin  | 
|
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
24  | 
|
| 
12338
 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
 
wenzelm 
parents: 
11190 
diff
changeset
 | 
25  | 
instance program :: (type) order  | 
| 27682 | 26  | 
proof qed (auto simp add: program_less_le dest: component_antisym intro: component_refl component_trans)  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
27  | 
|
| 14112 | 28  | 
text{*Existential and Universal properties.  I formalize the two-program
 | 
29  | 
case, proving equivalence with Chandy and Sanders's n-ary definitions*}  | 
|
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
30  | 
|
| 14112 | 31  | 
constdefs  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
32  | 
|
| 13792 | 33  | 
ex_prop :: "'a program set => bool"  | 
| 13819 | 34  | 
"ex_prop X == \<forall>F G. F ok G -->F \<in> X | G \<in> X --> (F\<squnion>G) \<in> X"  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
35  | 
|
| 13792 | 36  | 
strict_ex_prop :: "'a program set => bool"  | 
| 13819 | 37  | 
"strict_ex_prop X == \<forall>F G. F ok G --> (F \<in> X | G \<in> X) = (F\<squnion>G \<in> X)"  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
38  | 
|
| 13792 | 39  | 
uv_prop :: "'a program set => bool"  | 
| 13819 | 40  | 
"uv_prop X == SKIP \<in> X & (\<forall>F G. F ok G --> F \<in> X & G \<in> X --> (F\<squnion>G) \<in> X)"  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
41  | 
|
| 13792 | 42  | 
strict_uv_prop :: "'a program set => bool"  | 
43  | 
"strict_uv_prop X ==  | 
|
| 13819 | 44  | 
SKIP \<in> X & (\<forall>F G. F ok G --> (F \<in> X & G \<in> X) = (F\<squnion>G \<in> X))"  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
45  | 
|
| 14112 | 46  | 
|
47  | 
text{*Guarantees properties*}
 | 
|
48  | 
||
49  | 
constdefs  | 
|
50  | 
||
| 13792 | 51  | 
guar :: "['a program set, 'a program set] => 'a program set"  | 
| 
10064
 
1a77667b21ef
added compatibility relation: AllowedActs, Allowed, ok,
 
paulson 
parents: 
9337 
diff
changeset
 | 
52  | 
(infixl "guarantees" 55) (*higher than membership, lower than Co*)  | 
| 13819 | 53  | 
   "X guarantees Y == {F. \<forall>G. F ok G --> F\<squnion>G \<in> X --> F\<squnion>G \<in> Y}"
 | 
| 11190 | 54  | 
|
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
55  | 
|
| 11190 | 56  | 
(* Weakest guarantees *)  | 
| 13792 | 57  | 
wg :: "['a program, 'a program set] => 'a program set"  | 
| 13805 | 58  | 
  "wg F Y == Union({X. F \<in> X guarantees Y})"
 | 
| 11190 | 59  | 
|
60  | 
(* Weakest existential property stronger than X *)  | 
|
61  | 
   wx :: "('a program) set => ('a program)set"
 | 
|
| 13805 | 62  | 
   "wx X == Union({Y. Y \<subseteq> X & ex_prop Y})"
 | 
| 11190 | 63  | 
|
64  | 
(*Ill-defined programs can arise through "Join"*)  | 
|
| 13792 | 65  | 
welldef :: "'a program set"  | 
| 13805 | 66  | 
  "welldef == {F. Init F \<noteq> {}}"
 | 
| 11190 | 67  | 
|
| 13792 | 68  | 
refines :: "['a program, 'a program, 'a program set] => bool"  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
69  | 
			("(3_ refines _ wrt _)" [10,10,10] 10)
 | 
| 11190 | 70  | 
"G refines F wrt X ==  | 
| 14112 | 71  | 
\<forall>H. (F ok H & G ok H & F\<squnion>H \<in> welldef \<inter> X) -->  | 
| 13819 | 72  | 
(G\<squnion>H \<in> welldef \<inter> X)"  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
73  | 
|
| 13792 | 74  | 
iso_refines :: "['a program, 'a program, 'a program set] => bool"  | 
| 11190 | 75  | 
                              ("(3_ iso'_refines _ wrt _)" [10,10,10] 10)
 | 
76  | 
"G iso_refines F wrt X ==  | 
|
| 13805 | 77  | 
F \<in> welldef \<inter> X --> G \<in> welldef \<inter> X"  | 
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
78  | 
|
| 13792 | 79  | 
|
80  | 
lemma OK_insert_iff:  | 
|
81  | 
"(OK (insert i I) F) =  | 
|
| 13805 | 82  | 
(if i \<in> I then OK I F else OK I F & (F i ok JOIN I F))"  | 
| 13792 | 83  | 
by (auto intro: ok_sym simp add: OK_iff_ok)  | 
84  | 
||
85  | 
||
| 14112 | 86  | 
subsection{*Existential Properties*}
 | 
87  | 
||
| 13798 | 88  | 
lemma ex1 [rule_format]:  | 
| 13792 | 89  | 
"[| ex_prop X; finite GG |] ==>  | 
| 13805 | 90  | 
     GG \<inter> X \<noteq> {}--> OK GG (%G. G) --> (\<Squnion>G \<in> GG. G) \<in> X"
 | 
| 13792 | 91  | 
apply (unfold ex_prop_def)  | 
92  | 
apply (erule finite_induct)  | 
|
93  | 
apply (auto simp add: OK_insert_iff Int_insert_left)  | 
|
94  | 
done  | 
|
95  | 
||
96  | 
||
97  | 
lemma ex2:  | 
|
| 13805 | 98  | 
     "\<forall>GG. finite GG & GG \<inter> X \<noteq> {} --> OK GG (%G. G) -->(\<Squnion>G \<in> GG. G):X 
 | 
| 13792 | 99  | 
==> ex_prop X"  | 
100  | 
apply (unfold ex_prop_def, clarify)  | 
|
101  | 
apply (drule_tac x = "{F,G}" in spec)
 | 
|
102  | 
apply (auto dest: ok_sym simp add: OK_iff_ok)  | 
|
103  | 
done  | 
|
104  | 
||
105  | 
||
106  | 
(*Chandy & Sanders take this as a definition*)  | 
|
107  | 
lemma ex_prop_finite:  | 
|
108  | 
"ex_prop X =  | 
|
| 13805 | 109  | 
      (\<forall>GG. finite GG & GG \<inter> X \<noteq> {} & OK GG (%G. G)--> (\<Squnion>G \<in> GG. G) \<in> X)"
 | 
| 13792 | 110  | 
by (blast intro: ex1 ex2)  | 
111  | 
||
112  | 
||
113  | 
(*Their "equivalent definition" given at the end of section 3*)  | 
|
114  | 
lemma ex_prop_equiv:  | 
|
| 13805 | 115  | 
"ex_prop X = (\<forall>G. G \<in> X = (\<forall>H. (G component_of H) --> H \<in> X))"  | 
| 13792 | 116  | 
apply auto  | 
| 14112 | 117  | 
apply (unfold ex_prop_def component_of_def, safe, blast, blast)  | 
| 13792 | 118  | 
apply (subst Join_commute)  | 
119  | 
apply (drule ok_sym, blast)  | 
|
120  | 
done  | 
|
121  | 
||
122  | 
||
| 14112 | 123  | 
subsection{*Universal Properties*}
 | 
124  | 
||
| 13792 | 125  | 
lemma uv1 [rule_format]:  | 
126  | 
"[| uv_prop X; finite GG |]  | 
|
| 13805 | 127  | 
==> GG \<subseteq> X & OK GG (%G. G) --> (\<Squnion>G \<in> GG. G) \<in> X"  | 
| 13792 | 128  | 
apply (unfold uv_prop_def)  | 
129  | 
apply (erule finite_induct)  | 
|
130  | 
apply (auto simp add: Int_insert_left OK_insert_iff)  | 
|
131  | 
done  | 
|
132  | 
||
133  | 
lemma uv2:  | 
|
| 13805 | 134  | 
"\<forall>GG. finite GG & GG \<subseteq> X & OK GG (%G. G) --> (\<Squnion>G \<in> GG. G) \<in> X  | 
| 13792 | 135  | 
==> uv_prop X"  | 
136  | 
apply (unfold uv_prop_def)  | 
|
137  | 
apply (rule conjI)  | 
|
138  | 
 apply (drule_tac x = "{}" in spec)
 | 
|
139  | 
prefer 2  | 
|
140  | 
apply clarify  | 
|
141  | 
 apply (drule_tac x = "{F,G}" in spec)
 | 
|
142  | 
apply (auto dest: ok_sym simp add: OK_iff_ok)  | 
|
143  | 
done  | 
|
144  | 
||
145  | 
(*Chandy & Sanders take this as a definition*)  | 
|
146  | 
lemma uv_prop_finite:  | 
|
147  | 
"uv_prop X =  | 
|
| 13805 | 148  | 
(\<forall>GG. finite GG & GG \<subseteq> X & OK GG (%G. G) --> (\<Squnion>G \<in> GG. G): X)"  | 
| 13792 | 149  | 
by (blast intro: uv1 uv2)  | 
150  | 
||
| 14112 | 151  | 
subsection{*Guarantees*}
 | 
| 13792 | 152  | 
|
153  | 
lemma guaranteesI:  | 
|
| 14112 | 154  | 
"(!!G. [| F ok G; F\<squnion>G \<in> X |] ==> F\<squnion>G \<in> Y) ==> F \<in> X guarantees Y"  | 
| 13792 | 155  | 
by (simp add: guar_def component_def)  | 
156  | 
||
157  | 
lemma guaranteesD:  | 
|
| 14112 | 158  | 
"[| F \<in> X guarantees Y; F ok G; F\<squnion>G \<in> X |] ==> F\<squnion>G \<in> Y"  | 
| 13792 | 159  | 
by (unfold guar_def component_def, blast)  | 
160  | 
||
161  | 
(*This version of guaranteesD matches more easily in the conclusion  | 
|
| 13805 | 162  | 
The major premise can no longer be F \<subseteq> H since we need to reason about G*)  | 
| 13792 | 163  | 
lemma component_guaranteesD:  | 
| 14112 | 164  | 
"[| F \<in> X guarantees Y; F\<squnion>G = H; H \<in> X; F ok G |] ==> H \<in> Y"  | 
| 13792 | 165  | 
by (unfold guar_def, blast)  | 
166  | 
||
167  | 
lemma guarantees_weaken:  | 
|
| 13805 | 168  | 
"[| F \<in> X guarantees X'; Y \<subseteq> X; X' \<subseteq> Y' |] ==> F \<in> Y guarantees Y'"  | 
| 13792 | 169  | 
by (unfold guar_def, blast)  | 
170  | 
||
| 13805 | 171  | 
lemma subset_imp_guarantees_UNIV: "X \<subseteq> Y ==> X guarantees Y = UNIV"  | 
| 13792 | 172  | 
by (unfold guar_def, blast)  | 
173  | 
||
174  | 
(*Equivalent to subset_imp_guarantees_UNIV but more intuitive*)  | 
|
| 13805 | 175  | 
lemma subset_imp_guarantees: "X \<subseteq> Y ==> F \<in> X guarantees Y"  | 
| 13792 | 176  | 
by (unfold guar_def, blast)  | 
177  | 
||
178  | 
(*Remark at end of section 4.1 *)  | 
|
179  | 
||
180  | 
lemma ex_prop_imp: "ex_prop Y ==> (Y = UNIV guarantees Y)"  | 
|
181  | 
apply (simp (no_asm_use) add: guar_def ex_prop_equiv)  | 
|
182  | 
apply safe  | 
|
183  | 
apply (drule_tac x = x in spec)  | 
|
184  | 
apply (drule_tac [2] x = x in spec)  | 
|
185  | 
apply (drule_tac [2] sym)  | 
|
186  | 
apply (auto simp add: component_of_def)  | 
|
187  | 
done  | 
|
188  | 
||
189  | 
lemma guarantees_imp: "(Y = UNIV guarantees Y) ==> ex_prop(Y)"  | 
|
| 14112 | 190  | 
by (auto simp add: guar_def ex_prop_equiv component_of_def dest: sym)  | 
| 13792 | 191  | 
|
192  | 
lemma ex_prop_equiv2: "(ex_prop Y) = (Y = UNIV guarantees Y)"  | 
|
193  | 
apply (rule iffI)  | 
|
194  | 
apply (rule ex_prop_imp)  | 
|
195  | 
apply (auto simp add: guarantees_imp)  | 
|
196  | 
done  | 
|
197  | 
||
198  | 
||
| 14112 | 199  | 
subsection{*Distributive Laws.  Re-Orient to Perform Miniscoping*}
 | 
| 13792 | 200  | 
|
201  | 
lemma guarantees_UN_left:  | 
|
| 13805 | 202  | 
"(\<Union>i \<in> I. X i) guarantees Y = (\<Inter>i \<in> I. X i guarantees Y)"  | 
| 13792 | 203  | 
by (unfold guar_def, blast)  | 
204  | 
||
205  | 
lemma guarantees_Un_left:  | 
|
| 13805 | 206  | 
"(X \<union> Y) guarantees Z = (X guarantees Z) \<inter> (Y guarantees Z)"  | 
| 13792 | 207  | 
by (unfold guar_def, blast)  | 
208  | 
||
209  | 
lemma guarantees_INT_right:  | 
|
| 13805 | 210  | 
"X guarantees (\<Inter>i \<in> I. Y i) = (\<Inter>i \<in> I. X guarantees Y i)"  | 
| 13792 | 211  | 
by (unfold guar_def, blast)  | 
212  | 
||
213  | 
lemma guarantees_Int_right:  | 
|
| 13805 | 214  | 
"Z guarantees (X \<inter> Y) = (Z guarantees X) \<inter> (Z guarantees Y)"  | 
| 13792 | 215  | 
by (unfold guar_def, blast)  | 
216  | 
||
217  | 
lemma guarantees_Int_right_I:  | 
|
| 13805 | 218  | 
"[| F \<in> Z guarantees X; F \<in> Z guarantees Y |]  | 
219  | 
==> F \<in> Z guarantees (X \<inter> Y)"  | 
|
| 13792 | 220  | 
by (simp add: guarantees_Int_right)  | 
221  | 
||
222  | 
lemma guarantees_INT_right_iff:  | 
|
| 13805 | 223  | 
"(F \<in> X guarantees (INTER I Y)) = (\<forall>i\<in>I. F \<in> X guarantees (Y i))"  | 
| 13792 | 224  | 
by (simp add: guarantees_INT_right)  | 
225  | 
||
| 13805 | 226  | 
lemma shunting: "(X guarantees Y) = (UNIV guarantees (-X \<union> Y))"  | 
| 13792 | 227  | 
by (unfold guar_def, blast)  | 
228  | 
||
229  | 
lemma contrapositive: "(X guarantees Y) = -Y guarantees -X"  | 
|
230  | 
by (unfold guar_def, blast)  | 
|
231  | 
||
232  | 
(** The following two can be expressed using intersection and subset, which  | 
|
233  | 
is more faithful to the text but looks cryptic.  | 
|
234  | 
**)  | 
|
235  | 
||
236  | 
lemma combining1:  | 
|
| 13805 | 237  | 
"[| F \<in> V guarantees X; F \<in> (X \<inter> Y) guarantees Z |]  | 
238  | 
==> F \<in> (V \<inter> Y) guarantees Z"  | 
|
| 13792 | 239  | 
by (unfold guar_def, blast)  | 
240  | 
||
241  | 
lemma combining2:  | 
|
| 13805 | 242  | 
"[| F \<in> V guarantees (X \<union> Y); F \<in> Y guarantees Z |]  | 
243  | 
==> F \<in> V guarantees (X \<union> Z)"  | 
|
| 13792 | 244  | 
by (unfold guar_def, blast)  | 
245  | 
||
246  | 
(** The following two follow Chandy-Sanders, but the use of object-quantifiers  | 
|
247  | 
does not suit Isabelle... **)  | 
|
248  | 
||
| 13805 | 249  | 
(*Premise should be (!!i. i \<in> I ==> F \<in> X guarantees Y i) *)  | 
| 13792 | 250  | 
lemma all_guarantees:  | 
| 13805 | 251  | 
"\<forall>i\<in>I. F \<in> X guarantees (Y i) ==> F \<in> X guarantees (\<Inter>i \<in> I. Y i)"  | 
| 13792 | 252  | 
by (unfold guar_def, blast)  | 
253  | 
||
| 13805 | 254  | 
(*Premises should be [| F \<in> X guarantees Y i; i \<in> I |] *)  | 
| 13792 | 255  | 
lemma ex_guarantees:  | 
| 13805 | 256  | 
"\<exists>i\<in>I. F \<in> X guarantees (Y i) ==> F \<in> X guarantees (\<Union>i \<in> I. Y i)"  | 
| 13792 | 257  | 
by (unfold guar_def, blast)  | 
258  | 
||
259  | 
||
| 14112 | 260  | 
subsection{*Guarantees: Additional Laws (by lcp)*}
 | 
| 13792 | 261  | 
|
262  | 
lemma guarantees_Join_Int:  | 
|
| 13805 | 263  | 
"[| F \<in> U guarantees V; G \<in> X guarantees Y; F ok G |]  | 
| 13819 | 264  | 
==> F\<squnion>G \<in> (U \<inter> X) guarantees (V \<inter> Y)"  | 
| 14112 | 265  | 
apply (simp add: guar_def, safe)  | 
266  | 
apply (simp add: Join_assoc)  | 
|
| 13819 | 267  | 
apply (subgoal_tac "F\<squnion>G\<squnion>Ga = G\<squnion>(F\<squnion>Ga) ")  | 
| 14112 | 268  | 
apply (simp add: ok_commute)  | 
269  | 
apply (simp add: Join_ac)  | 
|
| 13792 | 270  | 
done  | 
271  | 
||
272  | 
lemma guarantees_Join_Un:  | 
|
| 13805 | 273  | 
"[| F \<in> U guarantees V; G \<in> X guarantees Y; F ok G |]  | 
| 13819 | 274  | 
==> F\<squnion>G \<in> (U \<union> X) guarantees (V \<union> Y)"  | 
| 14112 | 275  | 
apply (simp add: guar_def, safe)  | 
276  | 
apply (simp add: Join_assoc)  | 
|
| 13819 | 277  | 
apply (subgoal_tac "F\<squnion>G\<squnion>Ga = G\<squnion>(F\<squnion>Ga) ")  | 
| 14112 | 278  | 
apply (simp add: ok_commute)  | 
279  | 
apply (simp add: Join_ac)  | 
|
| 13792 | 280  | 
done  | 
281  | 
||
282  | 
lemma guarantees_JN_INT:  | 
|
| 13805 | 283  | 
"[| \<forall>i\<in>I. F i \<in> X i guarantees Y i; OK I F |]  | 
284  | 
==> (JOIN I F) \<in> (INTER I X) guarantees (INTER I Y)"  | 
|
| 13792 | 285  | 
apply (unfold guar_def, auto)  | 
286  | 
apply (drule bspec, assumption)  | 
|
287  | 
apply (rename_tac "i")  | 
|
| 13819 | 288  | 
apply (drule_tac x = "JOIN (I-{i}) F\<squnion>G" in spec)
 | 
| 13792 | 289  | 
apply (auto intro: OK_imp_ok  | 
290  | 
simp add: Join_assoc [symmetric] JN_Join_diff JN_absorb)  | 
|
291  | 
done  | 
|
292  | 
||
293  | 
lemma guarantees_JN_UN:  | 
|
| 13805 | 294  | 
"[| \<forall>i\<in>I. F i \<in> X i guarantees Y i; OK I F |]  | 
295  | 
==> (JOIN I F) \<in> (UNION I X) guarantees (UNION I Y)"  | 
|
| 13792 | 296  | 
apply (unfold guar_def, auto)  | 
297  | 
apply (drule bspec, assumption)  | 
|
298  | 
apply (rename_tac "i")  | 
|
| 13819 | 299  | 
apply (drule_tac x = "JOIN (I-{i}) F\<squnion>G" in spec)
 | 
| 13792 | 300  | 
apply (auto intro: OK_imp_ok  | 
301  | 
simp add: Join_assoc [symmetric] JN_Join_diff JN_absorb)  | 
|
302  | 
done  | 
|
303  | 
||
304  | 
||
| 14112 | 305  | 
subsection{*Guarantees Laws for Breaking Down the Program (by lcp)*}
 | 
| 13792 | 306  | 
|
307  | 
lemma guarantees_Join_I1:  | 
|
| 13819 | 308  | 
"[| F \<in> X guarantees Y; F ok G |] ==> F\<squnion>G \<in> X guarantees Y"  | 
| 14112 | 309  | 
by (simp add: guar_def Join_assoc)  | 
| 13792 | 310  | 
|
| 14112 | 311  | 
lemma guarantees_Join_I2:  | 
| 13819 | 312  | 
"[| G \<in> X guarantees Y; F ok G |] ==> F\<squnion>G \<in> X guarantees Y"  | 
| 13792 | 313  | 
apply (simp add: Join_commute [of _ G] ok_commute [of _ G])  | 
314  | 
apply (blast intro: guarantees_Join_I1)  | 
|
315  | 
done  | 
|
316  | 
||
317  | 
lemma guarantees_JN_I:  | 
|
| 13805 | 318  | 
"[| i \<in> I; F i \<in> X guarantees Y; OK I F |]  | 
319  | 
==> (\<Squnion>i \<in> I. (F i)) \<in> X guarantees Y"  | 
|
| 13792 | 320  | 
apply (unfold guar_def, clarify)  | 
| 13819 | 321  | 
apply (drule_tac x = "JOIN (I-{i}) F\<squnion>G" in spec)
 | 
| 14112 | 322  | 
apply (auto intro: OK_imp_ok  | 
323  | 
simp add: JN_Join_diff JN_Join_diff Join_assoc [symmetric])  | 
|
| 13792 | 324  | 
done  | 
325  | 
||
326  | 
||
327  | 
(*** well-definedness ***)  | 
|
328  | 
||
| 13819 | 329  | 
lemma Join_welldef_D1: "F\<squnion>G \<in> welldef ==> F \<in> welldef"  | 
| 13792 | 330  | 
by (unfold welldef_def, auto)  | 
331  | 
||
| 13819 | 332  | 
lemma Join_welldef_D2: "F\<squnion>G \<in> welldef ==> G \<in> welldef"  | 
| 13792 | 333  | 
by (unfold welldef_def, auto)  | 
334  | 
||
335  | 
(*** refinement ***)  | 
|
336  | 
||
337  | 
lemma refines_refl: "F refines F wrt X"  | 
|
338  | 
by (unfold refines_def, blast)  | 
|
339  | 
||
| 14112 | 340  | 
(*We'd like transitivity, but how do we get it?*)  | 
341  | 
lemma refines_trans:  | 
|
| 13792 | 342  | 
"[| H refines G wrt X; G refines F wrt X |] ==> H refines F wrt X"  | 
| 14112 | 343  | 
apply (simp add: refines_def)  | 
344  | 
oops  | 
|
| 13792 | 345  | 
|
346  | 
||
347  | 
lemma strict_ex_refine_lemma:  | 
|
348  | 
"strict_ex_prop X  | 
|
| 13819 | 349  | 
==> (\<forall>H. F ok H & G ok H & F\<squnion>H \<in> X --> G\<squnion>H \<in> X)  | 
| 13805 | 350  | 
= (F \<in> X --> G \<in> X)"  | 
| 13792 | 351  | 
by (unfold strict_ex_prop_def, auto)  | 
352  | 
||
353  | 
lemma strict_ex_refine_lemma_v:  | 
|
354  | 
"strict_ex_prop X  | 
|
| 13819 | 355  | 
==> (\<forall>H. F ok H & G ok H & F\<squnion>H \<in> welldef & F\<squnion>H \<in> X --> G\<squnion>H \<in> X) =  | 
| 13805 | 356  | 
(F \<in> welldef \<inter> X --> G \<in> X)"  | 
| 13792 | 357  | 
apply (unfold strict_ex_prop_def, safe)  | 
358  | 
apply (erule_tac x = SKIP and P = "%H. ?PP H --> ?RR H" in allE)  | 
|
359  | 
apply (auto dest: Join_welldef_D1 Join_welldef_D2)  | 
|
360  | 
done  | 
|
361  | 
||
362  | 
lemma ex_refinement_thm:  | 
|
363  | 
"[| strict_ex_prop X;  | 
|
| 13819 | 364  | 
\<forall>H. F ok H & G ok H & F\<squnion>H \<in> welldef \<inter> X --> G\<squnion>H \<in> welldef |]  | 
| 13792 | 365  | 
==> (G refines F wrt X) = (G iso_refines F wrt X)"  | 
366  | 
apply (rule_tac x = SKIP in allE, assumption)  | 
|
367  | 
apply (simp add: refines_def iso_refines_def strict_ex_refine_lemma_v)  | 
|
368  | 
done  | 
|
369  | 
||
370  | 
||
371  | 
lemma strict_uv_refine_lemma:  | 
|
372  | 
"strict_uv_prop X ==>  | 
|
| 13819 | 373  | 
(\<forall>H. F ok H & G ok H & F\<squnion>H \<in> X --> G\<squnion>H \<in> X) = (F \<in> X --> G \<in> X)"  | 
| 13792 | 374  | 
by (unfold strict_uv_prop_def, blast)  | 
375  | 
||
376  | 
lemma strict_uv_refine_lemma_v:  | 
|
377  | 
"strict_uv_prop X  | 
|
| 13819 | 378  | 
==> (\<forall>H. F ok H & G ok H & F\<squnion>H \<in> welldef & F\<squnion>H \<in> X --> G\<squnion>H \<in> X) =  | 
| 13805 | 379  | 
(F \<in> welldef \<inter> X --> G \<in> X)"  | 
| 13792 | 380  | 
apply (unfold strict_uv_prop_def, safe)  | 
381  | 
apply (erule_tac x = SKIP and P = "%H. ?PP H --> ?RR H" in allE)  | 
|
382  | 
apply (auto dest: Join_welldef_D1 Join_welldef_D2)  | 
|
383  | 
done  | 
|
384  | 
||
385  | 
lemma uv_refinement_thm:  | 
|
386  | 
"[| strict_uv_prop X;  | 
|
| 13819 | 387  | 
\<forall>H. F ok H & G ok H & F\<squnion>H \<in> welldef \<inter> X -->  | 
388  | 
G\<squnion>H \<in> welldef |]  | 
|
| 13792 | 389  | 
==> (G refines F wrt X) = (G iso_refines F wrt X)"  | 
390  | 
apply (rule_tac x = SKIP in allE, assumption)  | 
|
391  | 
apply (simp add: refines_def iso_refines_def strict_uv_refine_lemma_v)  | 
|
392  | 
done  | 
|
393  | 
||
394  | 
(* Added by Sidi Ehmety from Chandy & Sander, section 6 *)  | 
|
395  | 
lemma guarantees_equiv:  | 
|
| 13805 | 396  | 
"(F \<in> X guarantees Y) = (\<forall>H. H \<in> X \<longrightarrow> (F component_of H \<longrightarrow> H \<in> Y))"  | 
| 13792 | 397  | 
by (unfold guar_def component_of_def, auto)  | 
398  | 
||
| 14112 | 399  | 
lemma wg_weakest: "!!X. F\<in> (X guarantees Y) ==> X \<subseteq> (wg F Y)"  | 
| 13792 | 400  | 
by (unfold wg_def, auto)  | 
401  | 
||
| 14112 | 402  | 
lemma wg_guarantees: "F\<in> ((wg F Y) guarantees Y)"  | 
| 13792 | 403  | 
by (unfold wg_def guar_def, blast)  | 
404  | 
||
| 14112 | 405  | 
lemma wg_equiv: "(H \<in> wg F X) = (F component_of H --> H \<in> X)"  | 
406  | 
by (simp add: guarantees_equiv wg_def, blast)  | 
|
| 13792 | 407  | 
|
| 13805 | 408  | 
lemma component_of_wg: "F component_of H ==> (H \<in> wg F X) = (H \<in> X)"  | 
| 13792 | 409  | 
by (simp add: wg_equiv)  | 
410  | 
||
411  | 
lemma wg_finite:  | 
|
| 13805 | 412  | 
    "\<forall>FF. finite FF & FF \<inter> X \<noteq> {} --> OK FF (%F. F)  
 | 
413  | 
--> (\<forall>F\<in>FF. ((\<Squnion>F \<in> FF. F): wg F X) = ((\<Squnion>F \<in> FF. F):X))"  | 
|
| 13792 | 414  | 
apply clarify  | 
| 13805 | 415  | 
apply (subgoal_tac "F component_of (\<Squnion>F \<in> FF. F) ")  | 
| 13792 | 416  | 
apply (drule_tac X = X in component_of_wg, simp)  | 
417  | 
apply (simp add: component_of_def)  | 
|
| 13805 | 418  | 
apply (rule_tac x = "\<Squnion>F \<in> (FF-{F}) . F" in exI)
 | 
| 13792 | 419  | 
apply (auto intro: JN_Join_diff dest: ok_sym simp add: OK_iff_ok)  | 
420  | 
done  | 
|
421  | 
||
| 13805 | 422  | 
lemma wg_ex_prop: "ex_prop X ==> (F \<in> X) = (\<forall>H. H \<in> wg F X)"  | 
| 13792 | 423  | 
apply (simp (no_asm_use) add: ex_prop_equiv wg_equiv)  | 
424  | 
apply blast  | 
|
425  | 
done  | 
|
426  | 
||
427  | 
(** From Charpentier and Chandy "Theorems About Composition" **)  | 
|
428  | 
(* Proposition 2 *)  | 
|
429  | 
lemma wx_subset: "(wx X)<=X"  | 
|
430  | 
by (unfold wx_def, auto)  | 
|
431  | 
||
432  | 
lemma wx_ex_prop: "ex_prop (wx X)"  | 
|
| 
16647
 
c6d81ddebb0e
Proof of wx_ex_prop must now use old bex_cong to prevent simplifier from looping.
 
berghofe 
parents: 
16417 
diff
changeset
 | 
433  | 
apply (simp add: wx_def ex_prop_equiv cong: bex_cong, safe, blast)  | 
| 14112 | 434  | 
apply force  | 
| 13792 | 435  | 
done  | 
436  | 
||
| 13805 | 437  | 
lemma wx_weakest: "\<forall>Z. Z<= X --> ex_prop Z --> Z \<subseteq> wx X"  | 
| 14112 | 438  | 
by (auto simp add: wx_def)  | 
| 13792 | 439  | 
|
440  | 
(* Proposition 6 *)  | 
|
| 13819 | 441  | 
lemma wx'_ex_prop: "ex_prop({F. \<forall>G. F ok G --> F\<squnion>G \<in> X})"
 | 
| 13792 | 442  | 
apply (unfold ex_prop_def, safe)  | 
| 14112 | 443  | 
apply (drule_tac x = "G\<squnion>Ga" in spec)  | 
444  | 
apply (force simp add: ok_Join_iff1 Join_assoc)  | 
|
| 13819 | 445  | 
apply (drule_tac x = "F\<squnion>Ga" in spec)  | 
| 14112 | 446  | 
apply (simp add: ok_Join_iff1 ok_commute Join_ac)  | 
| 13792 | 447  | 
done  | 
448  | 
||
| 14112 | 449  | 
text{* Equivalence with the other definition of wx *}
 | 
| 13792 | 450  | 
|
| 14112 | 451  | 
lemma wx_equiv: "wx X = {F. \<forall>G. F ok G --> (F\<squnion>G) \<in> X}"
 | 
| 13792 | 452  | 
apply (unfold wx_def, safe)  | 
| 14112 | 453  | 
apply (simp add: ex_prop_def, blast)  | 
| 13792 | 454  | 
apply (simp (no_asm))  | 
| 13819 | 455  | 
apply (rule_tac x = "{F. \<forall>G. F ok G --> F\<squnion>G \<in> X}" in exI, safe)
 | 
| 13792 | 456  | 
apply (rule_tac [2] wx'_ex_prop)  | 
| 14112 | 457  | 
apply (drule_tac x = SKIP in spec)+  | 
458  | 
apply auto  | 
|
| 13792 | 459  | 
done  | 
460  | 
||
461  | 
||
| 14112 | 462  | 
text{* Propositions 7 to 11 are about this second definition of wx. 
 | 
463  | 
They are the same as the ones proved for the first definition of wx,  | 
|
464  | 
by equivalence *}  | 
|
| 13792 | 465  | 
|
466  | 
(* Proposition 12 *)  | 
|
467  | 
(* Main result of the paper *)  | 
|
| 14112 | 468  | 
lemma guarantees_wx_eq: "(X guarantees Y) = wx(-X \<union> Y)"  | 
469  | 
by (simp add: guar_def wx_equiv)  | 
|
| 13792 | 470  | 
|
471  | 
||
472  | 
(* Rules given in section 7 of Chandy and Sander's  | 
|
473  | 
Reasoning About Program composition paper *)  | 
|
474  | 
lemma stable_guarantees_Always:  | 
|
| 14112 | 475  | 
"Init F \<subseteq> A ==> F \<in> (stable A) guarantees (Always A)"  | 
| 13792 | 476  | 
apply (rule guaranteesI)  | 
| 14112 | 477  | 
apply (simp add: Join_commute)  | 
| 13792 | 478  | 
apply (rule stable_Join_Always1)  | 
| 14112 | 479  | 
apply (simp_all add: invariant_def Join_stable)  | 
| 13792 | 480  | 
done  | 
481  | 
||
482  | 
lemma constrains_guarantees_leadsTo:  | 
|
| 13805 | 483  | 
"F \<in> transient A ==> F \<in> (A co A \<union> B) guarantees (A leadsTo (B-A))"  | 
| 13792 | 484  | 
apply (rule guaranteesI)  | 
485  | 
apply (rule leadsTo_Basis')  | 
|
| 14112 | 486  | 
apply (drule constrains_weaken_R)  | 
487  | 
prefer 2 apply assumption  | 
|
488  | 
apply blast  | 
|
| 13792 | 489  | 
apply (blast intro: Join_transient_I1)  | 
490  | 
done  | 
|
491  | 
||
| 
7400
 
fbd5582761e6
new files HOL/UNITY/Guar.{thy,ML}: theory file gets the instance declaration
 
paulson 
parents:  
diff
changeset
 | 
492  | 
end  |