| author | bulwahn | 
| Thu, 21 Jan 2010 12:18:41 +0100 | |
| changeset 34954 | b206c70ea6f0 | 
| parent 33057 | 764547b68538 | 
| child 36866 | 426d5781bb25 | 
| permissions | -rw-r--r-- | 
| 6297 | 1 | (* Title: HOL/UNITY/Extend.thy | 
| 2 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | |
| 3 | Copyright 1998 University of Cambridge | |
| 4 | ||
| 13798 | 5 | Extending of state setsExtending of state sets | 
| 6297 | 6 | function f (forget) maps the extended state to the original state | 
| 7 | function g (forgotten) maps the extended state to the "extending part" | |
| 8 | *) | |
| 9 | ||
| 13798 | 10 | header{*Extending State Sets*}
 | 
| 11 | ||
| 16417 | 12 | theory Extend imports Guar begin | 
| 6297 | 13 | |
| 14 | constdefs | |
| 15 | ||
| 8948 
b797cfa3548d
restructuring: LessThan.ML mostly moved to HOL/SetInterval.ML
 paulson parents: 
8703diff
changeset | 16 | (*MOVE to Relation.thy?*) | 
| 
b797cfa3548d
restructuring: LessThan.ML mostly moved to HOL/SetInterval.ML
 paulson parents: 
8703diff
changeset | 17 |   Restrict :: "[ 'a set, ('a*'b) set] => ('a*'b) set"
 | 
| 13805 | 18 | "Restrict A r == r \<inter> (A <*> UNIV)" | 
| 8948 
b797cfa3548d
restructuring: LessThan.ML mostly moved to HOL/SetInterval.ML
 paulson parents: 
8703diff
changeset | 19 | |
| 7482 | 20 | good_map :: "['a*'b => 'c] => bool" | 
| 13805 | 21 | "good_map h == surj h & (\<forall>x y. fst (inv h (h (x,y))) = x)" | 
| 7482 | 22 | (*Using the locale constant "f", this is f (h (x,y))) = x*) | 
| 23 | ||
| 6297 | 24 | extend_set :: "['a*'b => 'c, 'a set] => 'c set" | 
| 10834 | 25 | "extend_set h A == h ` (A <*> UNIV)" | 
| 6297 | 26 | |
| 7342 | 27 | project_set :: "['a*'b => 'c, 'c set] => 'a set" | 
| 13805 | 28 |     "project_set h C == {x. \<exists>y. h(x,y) \<in> C}"
 | 
| 7342 | 29 | |
| 30 |   extend_act :: "['a*'b => 'c, ('a*'a) set] => ('c*'c) set"
 | |
| 13805 | 31 |     "extend_act h == %act. \<Union>(s,s') \<in> act. \<Union>y. {(h(s,y), h(s',y))}"
 | 
| 6297 | 32 | |
| 7878 
43b03d412b82
working version with localTo[C] instead of localTo
 paulson parents: 
7826diff
changeset | 33 |   project_act :: "['a*'b => 'c, ('c*'c) set] => ('a*'a) set"
 | 
| 13805 | 34 |     "project_act h act == {(x,x'). \<exists>y y'. (h(x,y), h(x',y')) \<in> act}"
 | 
| 7342 | 35 | |
| 6297 | 36 | extend :: "['a*'b => 'c, 'a program] => 'c program" | 
| 37 | "extend h F == mk_program (extend_set h (Init F), | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
16417diff
changeset | 38 | extend_act h ` Acts F, | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
16417diff
changeset | 39 | project_act h -` AllowedActs F)" | 
| 6297 | 40 | |
| 7878 
43b03d412b82
working version with localTo[C] instead of localTo
 paulson parents: 
7826diff
changeset | 41 | (*Argument C allows weak safety laws to be projected*) | 
| 7880 
62fb24e28e5e
exchanged the first two args of "project" and "drop_prog"
 paulson parents: 
7878diff
changeset | 42 | project :: "['a*'b => 'c, 'c set, 'c program] => 'a program" | 
| 10064 
1a77667b21ef
added compatibility relation: AllowedActs, Allowed, ok,
 paulson parents: 
8948diff
changeset | 43 | "project h C F == | 
| 
1a77667b21ef
added compatibility relation: AllowedActs, Allowed, ok,
 paulson parents: 
8948diff
changeset | 44 | mk_program (project_set h (Init F), | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
16417diff
changeset | 45 | project_act h ` Restrict C ` Acts F, | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
16417diff
changeset | 46 |                    {act. Restrict (project_set h C) act :
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
16417diff
changeset | 47 | project_act h ` Restrict C ` AllowedActs F})" | 
| 7342 | 48 | |
| 6297 | 49 | locale Extend = | 
| 13790 | 50 | fixes f :: "'c => 'a" | 
| 51 | and g :: "'c => 'b" | |
| 52 | and h :: "'a*'b => 'c" (*isomorphism between 'a * 'b and 'c *) | |
| 53 | and slice :: "['c set, 'b] => 'a set" | |
| 54 | assumes | |
| 55 | good_h: "good_map h" | |
| 56 | defines f_def: "f z == fst (inv h z)" | |
| 57 | and g_def: "g z == snd (inv h z)" | |
| 13805 | 58 |       and slice_def: "slice Z y == {x. h(x,y) \<in> Z}"
 | 
| 13790 | 59 | |
| 60 | ||
| 61 | (** These we prove OUTSIDE the locale. **) | |
| 62 | ||
| 63 | ||
| 13798 | 64 | subsection{*Restrict*}
 | 
| 65 | (*MOVE to Relation.thy?*) | |
| 13790 | 66 | |
| 13805 | 67 | lemma Restrict_iff [iff]: "((x,y): Restrict A r) = ((x,y): r & x \<in> A)" | 
| 13790 | 68 | by (unfold Restrict_def, blast) | 
| 69 | ||
| 70 | lemma Restrict_UNIV [simp]: "Restrict UNIV = id" | |
| 71 | apply (rule ext) | |
| 72 | apply (auto simp add: Restrict_def) | |
| 73 | done | |
| 74 | ||
| 75 | lemma Restrict_empty [simp]: "Restrict {} r = {}"
 | |
| 76 | by (auto simp add: Restrict_def) | |
| 77 | ||
| 13805 | 78 | lemma Restrict_Int [simp]: "Restrict A (Restrict B r) = Restrict (A \<inter> B) r" | 
| 13790 | 79 | by (unfold Restrict_def, blast) | 
| 80 | ||
| 13805 | 81 | lemma Restrict_triv: "Domain r \<subseteq> A ==> Restrict A r = r" | 
| 13790 | 82 | by (unfold Restrict_def, auto) | 
| 83 | ||
| 13805 | 84 | lemma Restrict_subset: "Restrict A r \<subseteq> r" | 
| 13790 | 85 | by (unfold Restrict_def, auto) | 
| 86 | ||
| 87 | lemma Restrict_eq_mono: | |
| 13805 | 88 | "[| A \<subseteq> B; Restrict B r = Restrict B s |] | 
| 13790 | 89 | ==> Restrict A r = Restrict A s" | 
| 90 | by (unfold Restrict_def, blast) | |
| 91 | ||
| 92 | lemma Restrict_imageI: | |
| 13805 | 93 | "[| s \<in> RR; Restrict A r = Restrict A s |] | 
| 94 | ==> Restrict A r \<in> Restrict A ` RR" | |
| 13790 | 95 | by (unfold Restrict_def image_def, auto) | 
| 96 | ||
| 13805 | 97 | lemma Domain_Restrict [simp]: "Domain (Restrict A r) = A \<inter> Domain r" | 
| 13790 | 98 | by blast | 
| 99 | ||
| 13805 | 100 | lemma Image_Restrict [simp]: "(Restrict A r) `` B = r `` (A \<inter> B)" | 
| 13790 | 101 | by blast | 
| 102 | ||
| 103 | (*Possibly easier than reasoning about "inv h"*) | |
| 104 | lemma good_mapI: | |
| 105 | assumes surj_h: "surj h" | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
16417diff
changeset | 106 | and prem: "!! x x' y y'. h(x,y) = h(x',y') ==> x=x'" | 
| 13790 | 107 | shows "good_map h" | 
| 108 | apply (simp add: good_map_def) | |
| 109 | apply (safe intro!: surj_h) | |
| 110 | apply (rule prem) | |
| 111 | apply (subst surjective_pairing [symmetric]) | |
| 112 | apply (subst surj_h [THEN surj_f_inv_f]) | |
| 113 | apply (rule refl) | |
| 114 | done | |
| 115 | ||
| 116 | lemma good_map_is_surj: "good_map h ==> surj h" | |
| 117 | by (unfold good_map_def, auto) | |
| 118 | ||
| 119 | (*A convenient way of finding a closed form for inv h*) | |
| 120 | lemma fst_inv_equalityI: | |
| 121 | assumes surj_h: "surj h" | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
16417diff
changeset | 122 | and prem: "!! x y. g (h(x,y)) = x" | 
| 13790 | 123 | shows "fst (inv h z) = g z" | 
| 33057 | 124 | by (metis UNIV_I f_inv_into_f pair_collapse prem surj_h surj_range) | 
| 13790 | 125 | |
| 126 | ||
| 13798 | 127 | subsection{*Trivial properties of f, g, h*}
 | 
| 13790 | 128 | |
| 129 | lemma (in Extend) f_h_eq [simp]: "f(h(x,y)) = x" | |
| 130 | by (simp add: f_def good_h [unfolded good_map_def, THEN conjunct2]) | |
| 131 | ||
| 132 | lemma (in Extend) h_inject1 [dest]: "h(x,y) = h(x',y') ==> x=x'" | |
| 133 | apply (drule_tac f = f in arg_cong) | |
| 134 | apply (simp add: f_def good_h [unfolded good_map_def, THEN conjunct2]) | |
| 135 | done | |
| 136 | ||
| 137 | lemma (in Extend) h_f_g_equiv: "h(f z, g z) == z" | |
| 138 | by (simp add: f_def g_def | |
| 139 | good_h [unfolded good_map_def, THEN conjunct1, THEN surj_f_inv_f]) | |
| 140 | ||
| 141 | lemma (in Extend) h_f_g_eq: "h(f z, g z) = z" | |
| 142 | by (simp add: h_f_g_equiv) | |
| 143 | ||
| 144 | ||
| 145 | lemma (in Extend) split_extended_all: | |
| 146 | "(!!z. PROP P z) == (!!u y. PROP P (h (u, y)))" | |
| 147 | proof | |
| 148 | assume allP: "\<And>z. PROP P z" | |
| 149 | fix u y | |
| 150 | show "PROP P (h (u, y))" by (rule allP) | |
| 151 | next | |
| 152 | assume allPh: "\<And>u y. PROP P (h(u,y))" | |
| 153 | fix z | |
| 154 | have Phfgz: "PROP P (h (f z, g z))" by (rule allPh) | |
| 155 | show "PROP P z" by (rule Phfgz [unfolded h_f_g_equiv]) | |
| 156 | qed | |
| 157 | ||
| 158 | ||
| 159 | ||
| 13798 | 160 | subsection{*@{term extend_set}: basic properties*}
 | 
| 13790 | 161 | |
| 162 | lemma project_set_iff [iff]: | |
| 13805 | 163 | "(x \<in> project_set h C) = (\<exists>y. h(x,y) \<in> C)" | 
| 13790 | 164 | by (simp add: project_set_def) | 
| 165 | ||
| 13805 | 166 | lemma extend_set_mono: "A \<subseteq> B ==> extend_set h A \<subseteq> extend_set h B" | 
| 13790 | 167 | by (unfold extend_set_def, blast) | 
| 168 | ||
| 13805 | 169 | lemma (in Extend) mem_extend_set_iff [iff]: "z \<in> extend_set h A = (f z \<in> A)" | 
| 13790 | 170 | apply (unfold extend_set_def) | 
| 171 | apply (force intro: h_f_g_eq [symmetric]) | |
| 172 | done | |
| 173 | ||
| 174 | lemma (in Extend) extend_set_strict_mono [iff]: | |
| 13805 | 175 | "(extend_set h A \<subseteq> extend_set h B) = (A \<subseteq> B)" | 
| 13790 | 176 | by (unfold extend_set_def, force) | 
| 177 | ||
| 178 | lemma extend_set_empty [simp]: "extend_set h {} = {}"
 | |
| 179 | by (unfold extend_set_def, auto) | |
| 180 | ||
| 181 | lemma (in Extend) extend_set_eq_Collect: "extend_set h {s. P s} = {s. P(f s)}"
 | |
| 182 | by auto | |
| 183 | ||
| 184 | lemma (in Extend) extend_set_sing: "extend_set h {x} = {s. f s = x}"
 | |
| 185 | by auto | |
| 186 | ||
| 187 | lemma (in Extend) extend_set_inverse [simp]: | |
| 188 | "project_set h (extend_set h C) = C" | |
| 189 | by (unfold extend_set_def, auto) | |
| 190 | ||
| 191 | lemma (in Extend) extend_set_project_set: | |
| 13805 | 192 | "C \<subseteq> extend_set h (project_set h C)" | 
| 13790 | 193 | apply (unfold extend_set_def) | 
| 194 | apply (auto simp add: split_extended_all, blast) | |
| 195 | done | |
| 196 | ||
| 197 | lemma (in Extend) inj_extend_set: "inj (extend_set h)" | |
| 198 | apply (rule inj_on_inverseI) | |
| 199 | apply (rule extend_set_inverse) | |
| 200 | done | |
| 201 | ||
| 202 | lemma (in Extend) extend_set_UNIV_eq [simp]: "extend_set h UNIV = UNIV" | |
| 203 | apply (unfold extend_set_def) | |
| 204 | apply (auto simp add: split_extended_all) | |
| 205 | done | |
| 206 | ||
| 13798 | 207 | subsection{*@{term project_set}: basic properties*}
 | 
| 13790 | 208 | |
| 209 | (*project_set is simply image!*) | |
| 210 | lemma (in Extend) project_set_eq: "project_set h C = f ` C" | |
| 211 | by (auto intro: f_h_eq [symmetric] simp add: split_extended_all) | |
| 212 | ||
| 213 | (*Converse appears to fail*) | |
| 13805 | 214 | lemma (in Extend) project_set_I: "!!z. z \<in> C ==> f z \<in> project_set h C" | 
| 13790 | 215 | by (auto simp add: split_extended_all) | 
| 216 | ||
| 217 | ||
| 13798 | 218 | subsection{*More laws*}
 | 
| 13790 | 219 | |
| 220 | (*Because A and B could differ on the "other" part of the state, | |
| 221 | cannot generalize to | |
| 13805 | 222 | project_set h (A \<inter> B) = project_set h A \<inter> project_set h B | 
| 13790 | 223 | *) | 
| 224 | lemma (in Extend) project_set_extend_set_Int: | |
| 13805 | 225 | "project_set h ((extend_set h A) \<inter> B) = A \<inter> (project_set h B)" | 
| 13790 | 226 | by auto | 
| 227 | ||
| 228 | (*Unused, but interesting?*) | |
| 229 | lemma (in Extend) project_set_extend_set_Un: | |
| 13805 | 230 | "project_set h ((extend_set h A) \<union> B) = A \<union> (project_set h B)" | 
| 13790 | 231 | by auto | 
| 232 | ||
| 233 | lemma project_set_Int_subset: | |
| 13805 | 234 | "project_set h (A \<inter> B) \<subseteq> (project_set h A) \<inter> (project_set h B)" | 
| 13790 | 235 | by auto | 
| 236 | ||
| 237 | lemma (in Extend) extend_set_Un_distrib: | |
| 13805 | 238 | "extend_set h (A \<union> B) = extend_set h A \<union> extend_set h B" | 
| 13790 | 239 | by auto | 
| 240 | ||
| 241 | lemma (in Extend) extend_set_Int_distrib: | |
| 13805 | 242 | "extend_set h (A \<inter> B) = extend_set h A \<inter> extend_set h B" | 
| 13790 | 243 | by auto | 
| 244 | ||
| 245 | lemma (in Extend) extend_set_INT_distrib: | |
| 13805 | 246 | "extend_set h (INTER A B) = (\<Inter>x \<in> A. extend_set h (B x))" | 
| 13790 | 247 | by auto | 
| 248 | ||
| 249 | lemma (in Extend) extend_set_Diff_distrib: | |
| 250 | "extend_set h (A - B) = extend_set h A - extend_set h B" | |
| 251 | by auto | |
| 252 | ||
| 253 | lemma (in Extend) extend_set_Union: | |
| 13805 | 254 | "extend_set h (Union A) = (\<Union>X \<in> A. extend_set h X)" | 
| 13790 | 255 | by blast | 
| 256 | ||
| 257 | lemma (in Extend) extend_set_subset_Compl_eq: | |
| 13805 | 258 | "(extend_set h A \<subseteq> - extend_set h B) = (A \<subseteq> - B)" | 
| 13790 | 259 | by (unfold extend_set_def, auto) | 
| 260 | ||
| 261 | ||
| 13798 | 262 | subsection{*@{term extend_act}*}
 | 
| 13790 | 263 | |
| 264 | (*Can't strengthen it to | |
| 13805 | 265 | ((h(s,y), h(s',y')) \<in> extend_act h act) = ((s, s') \<in> act & y=y') | 
| 13790 | 266 | because h doesn't have to be injective in the 2nd argument*) | 
| 267 | lemma (in Extend) mem_extend_act_iff [iff]: | |
| 13805 | 268 | "((h(s,y), h(s',y)) \<in> extend_act h act) = ((s, s') \<in> act)" | 
| 13790 | 269 | by (unfold extend_act_def, auto) | 
| 270 | ||
| 271 | (*Converse fails: (z,z') would include actions that changed the g-part*) | |
| 272 | lemma (in Extend) extend_act_D: | |
| 13805 | 273 | "(z, z') \<in> extend_act h act ==> (f z, f z') \<in> act" | 
| 13790 | 274 | by (unfold extend_act_def, auto) | 
| 275 | ||
| 276 | lemma (in Extend) extend_act_inverse [simp]: | |
| 277 | "project_act h (extend_act h act) = act" | |
| 278 | by (unfold extend_act_def project_act_def, blast) | |
| 279 | ||
| 280 | lemma (in Extend) project_act_extend_act_restrict [simp]: | |
| 281 | "project_act h (Restrict C (extend_act h act)) = | |
| 282 | Restrict (project_set h C) act" | |
| 283 | by (unfold extend_act_def project_act_def, blast) | |
| 284 | ||
| 285 | lemma (in Extend) subset_extend_act_D: | |
| 13805 | 286 | "act' \<subseteq> extend_act h act ==> project_act h act' \<subseteq> act" | 
| 13790 | 287 | by (unfold extend_act_def project_act_def, force) | 
| 288 | ||
| 289 | lemma (in Extend) inj_extend_act: "inj (extend_act h)" | |
| 290 | apply (rule inj_on_inverseI) | |
| 291 | apply (rule extend_act_inverse) | |
| 292 | done | |
| 293 | ||
| 294 | lemma (in Extend) extend_act_Image [simp]: | |
| 295 | "extend_act h act `` (extend_set h A) = extend_set h (act `` A)" | |
| 296 | by (unfold extend_set_def extend_act_def, force) | |
| 297 | ||
| 298 | lemma (in Extend) extend_act_strict_mono [iff]: | |
| 13805 | 299 | "(extend_act h act' \<subseteq> extend_act h act) = (act'<=act)" | 
| 13790 | 300 | by (unfold extend_act_def, auto) | 
| 301 | ||
| 302 | declare (in Extend) inj_extend_act [THEN inj_eq, iff] | |
| 303 | (*This theorem is (extend_act h act' = extend_act h act) = (act'=act) *) | |
| 304 | ||
| 305 | lemma Domain_extend_act: | |
| 306 | "Domain (extend_act h act) = extend_set h (Domain act)" | |
| 307 | by (unfold extend_set_def extend_act_def, force) | |
| 308 | ||
| 309 | lemma (in Extend) extend_act_Id [simp]: | |
| 310 | "extend_act h Id = Id" | |
| 311 | apply (unfold extend_act_def) | |
| 312 | apply (force intro: h_f_g_eq [symmetric]) | |
| 313 | done | |
| 314 | ||
| 315 | lemma (in Extend) project_act_I: | |
| 13805 | 316 | "!!z z'. (z, z') \<in> act ==> (f z, f z') \<in> project_act h act" | 
| 13790 | 317 | apply (unfold project_act_def) | 
| 318 | apply (force simp add: split_extended_all) | |
| 319 | done | |
| 320 | ||
| 321 | lemma (in Extend) project_act_Id [simp]: "project_act h Id = Id" | |
| 322 | by (unfold project_act_def, force) | |
| 323 | ||
| 324 | lemma (in Extend) Domain_project_act: | |
| 325 | "Domain (project_act h act) = project_set h (Domain act)" | |
| 326 | apply (unfold project_act_def) | |
| 327 | apply (force simp add: split_extended_all) | |
| 328 | done | |
| 329 | ||
| 330 | ||
| 331 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 332 | subsection{*extend*}
 | 
| 13790 | 333 | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 334 | text{*Basic properties*}
 | 
| 13790 | 335 | |
| 336 | lemma Init_extend [simp]: | |
| 337 | "Init (extend h F) = extend_set h (Init F)" | |
| 338 | by (unfold extend_def, auto) | |
| 339 | ||
| 340 | lemma Init_project [simp]: | |
| 341 | "Init (project h C F) = project_set h (Init F)" | |
| 342 | by (unfold project_def, auto) | |
| 343 | ||
| 344 | lemma (in Extend) Acts_extend [simp]: | |
| 345 | "Acts (extend h F) = (extend_act h ` Acts F)" | |
| 346 | by (simp add: extend_def insert_Id_image_Acts) | |
| 347 | ||
| 348 | lemma (in Extend) AllowedActs_extend [simp]: | |
| 349 | "AllowedActs (extend h F) = project_act h -` AllowedActs F" | |
| 350 | by (simp add: extend_def insert_absorb) | |
| 351 | ||
| 352 | lemma Acts_project [simp]: | |
| 353 | "Acts(project h C F) = insert Id (project_act h ` Restrict C ` Acts F)" | |
| 354 | by (auto simp add: project_def image_iff) | |
| 355 | ||
| 356 | lemma (in Extend) AllowedActs_project [simp]: | |
| 357 | "AllowedActs(project h C F) = | |
| 358 |         {act. Restrict (project_set h C) act  
 | |
| 13805 | 359 | \<in> project_act h ` Restrict C ` AllowedActs F}" | 
| 13790 | 360 | apply (simp (no_asm) add: project_def image_iff) | 
| 361 | apply (subst insert_absorb) | |
| 362 | apply (auto intro!: bexI [of _ Id] simp add: project_act_def) | |
| 363 | done | |
| 364 | ||
| 365 | lemma (in Extend) Allowed_extend: | |
| 366 | "Allowed (extend h F) = project h UNIV -` Allowed F" | |
| 367 | apply (simp (no_asm) add: AllowedActs_extend Allowed_def) | |
| 368 | apply blast | |
| 369 | done | |
| 370 | ||
| 371 | lemma (in Extend) extend_SKIP [simp]: "extend h SKIP = SKIP" | |
| 372 | apply (unfold SKIP_def) | |
| 373 | apply (rule program_equalityI, auto) | |
| 374 | done | |
| 375 | ||
| 376 | lemma project_set_UNIV [simp]: "project_set h UNIV = UNIV" | |
| 377 | by auto | |
| 378 | ||
| 379 | lemma project_set_Union: | |
| 13805 | 380 | "project_set h (Union A) = (\<Union>X \<in> A. project_set h X)" | 
| 13790 | 381 | by blast | 
| 382 | ||
| 6297 | 383 | |
| 13790 | 384 | (*Converse FAILS: the extended state contributing to project_set h C | 
| 385 | may not coincide with the one contributing to project_act h act*) | |
| 386 | lemma (in Extend) project_act_Restrict_subset: | |
| 13805 | 387 | "project_act h (Restrict C act) \<subseteq> | 
| 13790 | 388 | Restrict (project_set h C) (project_act h act)" | 
| 389 | by (auto simp add: project_act_def) | |
| 390 | ||
| 391 | lemma (in Extend) project_act_Restrict_Id_eq: | |
| 392 | "project_act h (Restrict C Id) = Restrict (project_set h C) Id" | |
| 393 | by (auto simp add: project_act_def) | |
| 394 | ||
| 395 | lemma (in Extend) project_extend_eq: | |
| 396 | "project h C (extend h F) = | |
| 397 | mk_program (Init F, Restrict (project_set h C) ` Acts F, | |
| 398 |                   {act. Restrict (project_set h C) act 
 | |
| 13805 | 399 | \<in> project_act h ` Restrict C ` | 
| 13790 | 400 | (project_act h -` AllowedActs F)})" | 
| 401 | apply (rule program_equalityI) | |
| 402 | apply simp | |
| 403 | apply (simp add: image_eq_UN) | |
| 404 | apply (simp add: project_def) | |
| 405 | done | |
| 406 | ||
| 407 | lemma (in Extend) extend_inverse [simp]: | |
| 408 | "project h UNIV (extend h F) = F" | |
| 409 | apply (simp (no_asm_simp) add: project_extend_eq image_eq_UN | |
| 410 | subset_UNIV [THEN subset_trans, THEN Restrict_triv]) | |
| 411 | apply (rule program_equalityI) | |
| 412 | apply (simp_all (no_asm)) | |
| 413 | apply (subst insert_absorb) | |
| 414 | apply (simp (no_asm) add: bexI [of _ Id]) | |
| 415 | apply auto | |
| 416 | apply (rename_tac "act") | |
| 417 | apply (rule_tac x = "extend_act h act" in bexI, auto) | |
| 418 | done | |
| 419 | ||
| 420 | lemma (in Extend) inj_extend: "inj (extend h)" | |
| 421 | apply (rule inj_on_inverseI) | |
| 422 | apply (rule extend_inverse) | |
| 423 | done | |
| 424 | ||
| 425 | lemma (in Extend) extend_Join [simp]: | |
| 13819 | 426 | "extend h (F\<squnion>G) = extend h F\<squnion>extend h G" | 
| 13790 | 427 | apply (rule program_equalityI) | 
| 428 | apply (simp (no_asm) add: extend_set_Int_distrib) | |
| 429 | apply (simp add: image_Un, auto) | |
| 430 | done | |
| 431 | ||
| 432 | lemma (in Extend) extend_JN [simp]: | |
| 13805 | 433 | "extend h (JOIN I F) = (\<Squnion>i \<in> I. extend h (F i))" | 
| 13790 | 434 | apply (rule program_equalityI) | 
| 435 | apply (simp (no_asm) add: extend_set_INT_distrib) | |
| 436 | apply (simp add: image_UN, auto) | |
| 437 | done | |
| 438 | ||
| 439 | (** These monotonicity results look natural but are UNUSED **) | |
| 440 | ||
| 13805 | 441 | lemma (in Extend) extend_mono: "F \<le> G ==> extend h F \<le> extend h G" | 
| 13790 | 442 | by (force simp add: component_eq_subset) | 
| 443 | ||
| 13805 | 444 | lemma (in Extend) project_mono: "F \<le> G ==> project h C F \<le> project h C G" | 
| 13790 | 445 | by (simp add: component_eq_subset, blast) | 
| 446 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 447 | lemma (in Extend) all_total_extend: "all_total F ==> all_total (extend h F)" | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 448 | by (simp add: all_total_def Domain_extend_act) | 
| 13790 | 449 | |
| 13798 | 450 | subsection{*Safety: co, stable*}
 | 
| 13790 | 451 | |
| 452 | lemma (in Extend) extend_constrains: | |
| 13805 | 453 | "(extend h F \<in> (extend_set h A) co (extend_set h B)) = | 
| 454 | (F \<in> A co B)" | |
| 13790 | 455 | by (simp add: constrains_def) | 
| 456 | ||
| 457 | lemma (in Extend) extend_stable: | |
| 13805 | 458 | "(extend h F \<in> stable (extend_set h A)) = (F \<in> stable A)" | 
| 13790 | 459 | by (simp add: stable_def extend_constrains) | 
| 460 | ||
| 461 | lemma (in Extend) extend_invariant: | |
| 13805 | 462 | "(extend h F \<in> invariant (extend_set h A)) = (F \<in> invariant A)" | 
| 13790 | 463 | by (simp add: invariant_def extend_stable) | 
| 464 | ||
| 465 | (*Projects the state predicates in the property satisfied by extend h F. | |
| 466 | Converse fails: A and B may differ in their extra variables*) | |
| 467 | lemma (in Extend) extend_constrains_project_set: | |
| 13805 | 468 | "extend h F \<in> A co B ==> F \<in> (project_set h A) co (project_set h B)" | 
| 13790 | 469 | by (auto simp add: constrains_def, force) | 
| 470 | ||
| 471 | lemma (in Extend) extend_stable_project_set: | |
| 13805 | 472 | "extend h F \<in> stable A ==> F \<in> stable (project_set h A)" | 
| 13790 | 473 | by (simp add: stable_def extend_constrains_project_set) | 
| 474 | ||
| 475 | ||
| 13798 | 476 | subsection{*Weak safety primitives: Co, Stable*}
 | 
| 13790 | 477 | |
| 478 | lemma (in Extend) reachable_extend_f: | |
| 13805 | 479 | "p \<in> reachable (extend h F) ==> f p \<in> reachable F" | 
| 13790 | 480 | apply (erule reachable.induct) | 
| 481 | apply (auto intro: reachable.intros simp add: extend_act_def image_iff) | |
| 482 | done | |
| 483 | ||
| 484 | lemma (in Extend) h_reachable_extend: | |
| 13805 | 485 | "h(s,y) \<in> reachable (extend h F) ==> s \<in> reachable F" | 
| 13790 | 486 | by (force dest!: reachable_extend_f) | 
| 487 | ||
| 488 | lemma (in Extend) reachable_extend_eq: | |
| 489 | "reachable (extend h F) = extend_set h (reachable F)" | |
| 490 | apply (unfold extend_set_def) | |
| 491 | apply (rule equalityI) | |
| 492 | apply (force intro: h_f_g_eq [symmetric] dest!: reachable_extend_f, clarify) | |
| 493 | apply (erule reachable.induct) | |
| 494 | apply (force intro: reachable.intros)+ | |
| 495 | done | |
| 496 | ||
| 497 | lemma (in Extend) extend_Constrains: | |
| 13805 | 498 | "(extend h F \<in> (extend_set h A) Co (extend_set h B)) = | 
| 499 | (F \<in> A Co B)" | |
| 13790 | 500 | by (simp add: Constrains_def reachable_extend_eq extend_constrains | 
| 501 | extend_set_Int_distrib [symmetric]) | |
| 502 | ||
| 503 | lemma (in Extend) extend_Stable: | |
| 13805 | 504 | "(extend h F \<in> Stable (extend_set h A)) = (F \<in> Stable A)" | 
| 13790 | 505 | by (simp add: Stable_def extend_Constrains) | 
| 506 | ||
| 507 | lemma (in Extend) extend_Always: | |
| 13805 | 508 | "(extend h F \<in> Always (extend_set h A)) = (F \<in> Always A)" | 
| 13790 | 509 | by (simp (no_asm_simp) add: Always_def extend_Stable) | 
| 510 | ||
| 511 | ||
| 512 | (** Safety and "project" **) | |
| 513 | ||
| 514 | (** projection: monotonicity for safety **) | |
| 515 | ||
| 516 | lemma project_act_mono: | |
| 13805 | 517 | "D \<subseteq> C ==> | 
| 518 | project_act h (Restrict D act) \<subseteq> project_act h (Restrict C act)" | |
| 13790 | 519 | by (auto simp add: project_act_def) | 
| 520 | ||
| 521 | lemma (in Extend) project_constrains_mono: | |
| 13805 | 522 | "[| D \<subseteq> C; project h C F \<in> A co B |] ==> project h D F \<in> A co B" | 
| 13790 | 523 | apply (auto simp add: constrains_def) | 
| 524 | apply (drule project_act_mono, blast) | |
| 525 | done | |
| 526 | ||
| 527 | lemma (in Extend) project_stable_mono: | |
| 13805 | 528 | "[| D \<subseteq> C; project h C F \<in> stable A |] ==> project h D F \<in> stable A" | 
| 13790 | 529 | by (simp add: stable_def project_constrains_mono) | 
| 530 | ||
| 531 | (*Key lemma used in several proofs about project and co*) | |
| 532 | lemma (in Extend) project_constrains: | |
| 13805 | 533 | "(project h C F \<in> A co B) = | 
| 534 | (F \<in> (C \<inter> extend_set h A) co (extend_set h B) & A \<subseteq> B)" | |
| 13790 | 535 | apply (unfold constrains_def) | 
| 536 | apply (auto intro!: project_act_I simp add: ball_Un) | |
| 537 | apply (force intro!: project_act_I dest!: subsetD) | |
| 538 | (*the <== direction*) | |
| 539 | apply (unfold project_act_def) | |
| 540 | apply (force dest!: subsetD) | |
| 541 | done | |
| 542 | ||
| 543 | lemma (in Extend) project_stable: | |
| 13805 | 544 | "(project h UNIV F \<in> stable A) = (F \<in> stable (extend_set h A))" | 
| 13790 | 545 | apply (unfold stable_def) | 
| 546 | apply (simp (no_asm) add: project_constrains) | |
| 547 | done | |
| 548 | ||
| 549 | lemma (in Extend) project_stable_I: | |
| 13805 | 550 | "F \<in> stable (extend_set h A) ==> project h C F \<in> stable A" | 
| 13790 | 551 | apply (drule project_stable [THEN iffD2]) | 
| 552 | apply (blast intro: project_stable_mono) | |
| 553 | done | |
| 554 | ||
| 555 | lemma (in Extend) Int_extend_set_lemma: | |
| 13805 | 556 | "A \<inter> extend_set h ((project_set h A) \<inter> B) = A \<inter> extend_set h B" | 
| 13790 | 557 | by (auto simp add: split_extended_all) | 
| 558 | ||
| 559 | (*Strange (look at occurrences of C) but used in leadsETo proofs*) | |
| 560 | lemma project_constrains_project_set: | |
| 13805 | 561 | "G \<in> C co B ==> project h C G \<in> project_set h C co project_set h B" | 
| 13790 | 562 | by (simp add: constrains_def project_def project_act_def, blast) | 
| 563 | ||
| 564 | lemma project_stable_project_set: | |
| 13805 | 565 | "G \<in> stable C ==> project h C G \<in> stable (project_set h C)" | 
| 13790 | 566 | by (simp add: stable_def project_constrains_project_set) | 
| 567 | ||
| 568 | ||
| 13798 | 569 | subsection{*Progress: transient, ensures*}
 | 
| 13790 | 570 | |
| 571 | lemma (in Extend) extend_transient: | |
| 13805 | 572 | "(extend h F \<in> transient (extend_set h A)) = (F \<in> transient A)" | 
| 13790 | 573 | by (auto simp add: transient_def extend_set_subset_Compl_eq Domain_extend_act) | 
| 574 | ||
| 575 | lemma (in Extend) extend_ensures: | |
| 13805 | 576 | "(extend h F \<in> (extend_set h A) ensures (extend_set h B)) = | 
| 577 | (F \<in> A ensures B)" | |
| 13790 | 578 | by (simp add: ensures_def extend_constrains extend_transient | 
| 579 | extend_set_Un_distrib [symmetric] extend_set_Diff_distrib [symmetric]) | |
| 580 | ||
| 581 | lemma (in Extend) leadsTo_imp_extend_leadsTo: | |
| 13805 | 582 | "F \<in> A leadsTo B | 
| 583 | ==> extend h F \<in> (extend_set h A) leadsTo (extend_set h B)" | |
| 13790 | 584 | apply (erule leadsTo_induct) | 
| 585 | apply (simp add: leadsTo_Basis extend_ensures) | |
| 586 | apply (blast intro: leadsTo_Trans) | |
| 587 | apply (simp add: leadsTo_UN extend_set_Union) | |
| 588 | done | |
| 589 | ||
| 13798 | 590 | subsection{*Proving the converse takes some doing!*}
 | 
| 13790 | 591 | |
| 13805 | 592 | lemma (in Extend) slice_iff [iff]: "(x \<in> slice C y) = (h(x,y) \<in> C)" | 
| 13790 | 593 | by (simp (no_asm) add: slice_def) | 
| 594 | ||
| 13805 | 595 | lemma (in Extend) slice_Union: "slice (Union S) y = (\<Union>x \<in> S. slice x y)" | 
| 13790 | 596 | by auto | 
| 597 | ||
| 598 | lemma (in Extend) slice_extend_set: "slice (extend_set h A) y = A" | |
| 599 | by auto | |
| 600 | ||
| 601 | lemma (in Extend) project_set_is_UN_slice: | |
| 13805 | 602 | "project_set h A = (\<Union>y. slice A y)" | 
| 13790 | 603 | by auto | 
| 604 | ||
| 605 | lemma (in Extend) extend_transient_slice: | |
| 13805 | 606 | "extend h F \<in> transient A ==> F \<in> transient (slice A y)" | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 607 | by (unfold transient_def, auto) | 
| 13790 | 608 | |
| 609 | (*Converse?*) | |
| 610 | lemma (in Extend) extend_constrains_slice: | |
| 13805 | 611 | "extend h F \<in> A co B ==> F \<in> (slice A y) co (slice B y)" | 
| 13790 | 612 | by (auto simp add: constrains_def) | 
| 613 | ||
| 614 | lemma (in Extend) extend_ensures_slice: | |
| 13805 | 615 | "extend h F \<in> A ensures B ==> F \<in> (slice A y) ensures (project_set h B)" | 
| 13790 | 616 | apply (auto simp add: ensures_def extend_constrains extend_transient) | 
| 617 | apply (erule_tac [2] extend_transient_slice [THEN transient_strengthen]) | |
| 618 | apply (erule extend_constrains_slice [THEN constrains_weaken], auto) | |
| 619 | done | |
| 620 | ||
| 621 | lemma (in Extend) leadsTo_slice_project_set: | |
| 13805 | 622 | "\<forall>y. F \<in> (slice B y) leadsTo CU ==> F \<in> (project_set h B) leadsTo CU" | 
| 13790 | 623 | apply (simp (no_asm) add: project_set_is_UN_slice) | 
| 624 | apply (blast intro: leadsTo_UN) | |
| 625 | done | |
| 626 | ||
| 13798 | 627 | lemma (in Extend) extend_leadsTo_slice [rule_format]: | 
| 13805 | 628 | "extend h F \<in> AU leadsTo BU | 
| 629 | ==> \<forall>y. F \<in> (slice AU y) leadsTo (project_set h BU)" | |
| 13790 | 630 | apply (erule leadsTo_induct) | 
| 631 | apply (blast intro: extend_ensures_slice leadsTo_Basis) | |
| 632 | apply (blast intro: leadsTo_slice_project_set leadsTo_Trans) | |
| 633 | apply (simp add: leadsTo_UN slice_Union) | |
| 634 | done | |
| 635 | ||
| 636 | lemma (in Extend) extend_leadsTo: | |
| 13805 | 637 | "(extend h F \<in> (extend_set h A) leadsTo (extend_set h B)) = | 
| 638 | (F \<in> A leadsTo B)" | |
| 13790 | 639 | apply safe | 
| 640 | apply (erule_tac [2] leadsTo_imp_extend_leadsTo) | |
| 641 | apply (drule extend_leadsTo_slice) | |
| 642 | apply (simp add: slice_extend_set) | |
| 643 | done | |
| 644 | ||
| 645 | lemma (in Extend) extend_LeadsTo: | |
| 13805 | 646 | "(extend h F \<in> (extend_set h A) LeadsTo (extend_set h B)) = | 
| 647 | (F \<in> A LeadsTo B)" | |
| 13790 | 648 | by (simp add: LeadsTo_def reachable_extend_eq extend_leadsTo | 
| 649 | extend_set_Int_distrib [symmetric]) | |
| 650 | ||
| 651 | ||
| 13798 | 652 | subsection{*preserves*}
 | 
| 13790 | 653 | |
| 654 | lemma (in Extend) project_preserves_I: | |
| 13805 | 655 | "G \<in> preserves (v o f) ==> project h C G \<in> preserves v" | 
| 13790 | 656 | by (auto simp add: preserves_def project_stable_I extend_set_eq_Collect) | 
| 657 | ||
| 658 | (*to preserve f is to preserve the whole original state*) | |
| 659 | lemma (in Extend) project_preserves_id_I: | |
| 13805 | 660 | "G \<in> preserves f ==> project h C G \<in> preserves id" | 
| 13790 | 661 | by (simp add: project_preserves_I) | 
| 662 | ||
| 663 | lemma (in Extend) extend_preserves: | |
| 13805 | 664 | "(extend h G \<in> preserves (v o f)) = (G \<in> preserves v)" | 
| 13790 | 665 | by (auto simp add: preserves_def extend_stable [symmetric] | 
| 666 | extend_set_eq_Collect) | |
| 667 | ||
| 13805 | 668 | lemma (in Extend) inj_extend_preserves: "inj h ==> (extend h G \<in> preserves g)" | 
| 13790 | 669 | by (auto simp add: preserves_def extend_def extend_act_def stable_def | 
| 670 | constrains_def g_def) | |
| 671 | ||
| 672 | ||
| 13798 | 673 | subsection{*Guarantees*}
 | 
| 13790 | 674 | |
| 675 | lemma (in Extend) project_extend_Join: | |
| 13819 | 676 | "project h UNIV ((extend h F)\<squnion>G) = F\<squnion>(project h UNIV G)" | 
| 13790 | 677 | apply (rule program_equalityI) | 
| 678 | apply (simp add: project_set_extend_set_Int) | |
| 679 | apply (simp add: image_eq_UN UN_Un, auto) | |
| 680 | done | |
| 681 | ||
| 682 | lemma (in Extend) extend_Join_eq_extend_D: | |
| 13819 | 683 | "(extend h F)\<squnion>G = extend h H ==> H = F\<squnion>(project h UNIV G)" | 
| 13790 | 684 | apply (drule_tac f = "project h UNIV" in arg_cong) | 
| 685 | apply (simp add: project_extend_Join) | |
| 686 | done | |
| 687 | ||
| 688 | (** Strong precondition and postcondition; only useful when | |
| 689 | the old and new state sets are in bijection **) | |
| 690 | ||
| 691 | ||
| 692 | lemma (in Extend) ok_extend_imp_ok_project: | |
| 693 | "extend h F ok G ==> F ok project h UNIV G" | |
| 694 | apply (auto simp add: ok_def) | |
| 695 | apply (drule subsetD) | |
| 696 | apply (auto intro!: rev_image_eqI) | |
| 697 | done | |
| 698 | ||
| 699 | lemma (in Extend) ok_extend_iff: "(extend h F ok extend h G) = (F ok G)" | |
| 700 | apply (simp add: ok_def, safe) | |
| 701 | apply (force+) | |
| 702 | done | |
| 703 | ||
| 704 | lemma (in Extend) OK_extend_iff: "OK I (%i. extend h (F i)) = (OK I F)" | |
| 705 | apply (unfold OK_def, safe) | |
| 706 | apply (drule_tac x = i in bspec) | |
| 707 | apply (drule_tac [2] x = j in bspec) | |
| 708 | apply (force+) | |
| 709 | done | |
| 710 | ||
| 711 | lemma (in Extend) guarantees_imp_extend_guarantees: | |
| 13805 | 712 | "F \<in> X guarantees Y ==> | 
| 713 | extend h F \<in> (extend h ` X) guarantees (extend h ` Y)" | |
| 13790 | 714 | apply (rule guaranteesI, clarify) | 
| 715 | apply (blast dest: ok_extend_imp_ok_project extend_Join_eq_extend_D | |
| 716 | guaranteesD) | |
| 717 | done | |
| 718 | ||
| 719 | lemma (in Extend) extend_guarantees_imp_guarantees: | |
| 13805 | 720 | "extend h F \<in> (extend h ` X) guarantees (extend h ` Y) | 
| 721 | ==> F \<in> X guarantees Y" | |
| 13790 | 722 | apply (auto simp add: guar_def) | 
| 723 | apply (drule_tac x = "extend h G" in spec) | |
| 724 | apply (simp del: extend_Join | |
| 725 | add: extend_Join [symmetric] ok_extend_iff | |
| 726 | inj_extend [THEN inj_image_mem_iff]) | |
| 727 | done | |
| 728 | ||
| 729 | lemma (in Extend) extend_guarantees_eq: | |
| 13805 | 730 | "(extend h F \<in> (extend h ` X) guarantees (extend h ` Y)) = | 
| 731 | (F \<in> X guarantees Y)" | |
| 13790 | 732 | by (blast intro: guarantees_imp_extend_guarantees | 
| 733 | extend_guarantees_imp_guarantees) | |
| 6297 | 734 | |
| 735 | end |