| author | huffman | 
| Fri, 11 Mar 2005 00:43:52 +0100 | |
| changeset 15601 | 2de79f493856 | 
| parent 15045 | d59f7e2e18d3 | 
| child 16417 | 9bc16273c2d4 | 
| permissions | -rw-r--r-- | 
| 4776 | 1 | (* Title: HOL/UNITY/WFair | 
| 2 | ID: $Id$ | |
| 3 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | |
| 4 | Copyright 1998 University of Cambridge | |
| 5 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 6 | Conditional Fairness versions of transient, ensures, leadsTo. | 
| 4776 | 7 | |
| 8 | From Misra, "A Logic for Concurrent Programming", 1994 | |
| 9 | *) | |
| 10 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 11 | header{*Progress*}
 | 
| 13798 | 12 | |
| 13797 | 13 | theory WFair = UNITY: | 
| 4776 | 14 | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 15 | text{*The original version of this theory was based on weak fairness.  (Thus,
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 16 | the entire UNITY development embodied this assumption, until February 2003.) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 17 | Weak fairness states that if a command is enabled continuously, then it is | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 18 | eventually executed. Ernie Cohen suggested that I instead adopt unconditional | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 19 | fairness: every command is executed infinitely often. | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 20 | |
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 21 | In fact, Misra's paper on "Progress" seems to be ambiguous about the correct | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 22 | interpretation, and says that the two forms of fairness are equivalent. They | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 23 | differ only on their treatment of partial transitions, which under | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 24 | unconditional fairness behave magically. That is because if there are partial | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 25 | transitions then there may be no fair executions, making all leads-to | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 26 | properties hold vacuously. | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 27 | |
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 28 | Unconditional fairness has some great advantages. By distinguishing partial | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 29 | transitions from total ones that are the identity on part of their domain, it | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 30 | is more expressive. Also, by simplifying the definition of the transient | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 31 | property, it simplifies many proofs. A drawback is that some laws only hold | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 32 | under the assumption that all transitions are total. The best-known of these | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 33 | is the impossibility law for leads-to. | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 34 | *} | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 35 | |
| 4776 | 36 | constdefs | 
| 37 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 38 |   --{*This definition specifies conditional fairness.  The rest of the theory
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 39 | is generic to all forms of fairness. To get weak fairness, conjoin | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 40 |       the inclusion below with @{term "A \<subseteq> Domain act"}, which specifies 
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 41 |       that the action is enabled over all of @{term A}.*}
 | 
| 5648 | 42 | transient :: "'a set => 'a program set" | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 43 |     "transient A == {F. \<exists>act\<in>Acts F. act``A \<subseteq> -A}"
 | 
| 4776 | 44 | |
| 13797 | 45 | ensures :: "['a set, 'a set] => 'a program set" (infixl "ensures" 60) | 
| 13805 | 46 | "A ensures B == (A-B co A \<union> B) \<inter> transient (A-B)" | 
| 8006 | 47 | |
| 6536 | 48 | |
| 49 | consts | |
| 50 | ||
| 6801 
9e0037839d63
renamed the underlying relation of leadsTo from "leadsto"
 paulson parents: 
6536diff
changeset | 51 |   leads :: "'a program => ('a set * 'a set) set"
 | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 52 |     --{*LEADS-TO constant for the inductive definition*}
 | 
| 5648 | 53 | |
| 6801 
9e0037839d63
renamed the underlying relation of leadsTo from "leadsto"
 paulson parents: 
6536diff
changeset | 54 | |
| 
9e0037839d63
renamed the underlying relation of leadsTo from "leadsto"
 paulson parents: 
6536diff
changeset | 55 | inductive "leads F" | 
| 13797 | 56 | intros | 
| 4776 | 57 | |
| 13805 | 58 | Basis: "F \<in> A ensures B ==> (A,B) \<in> leads F" | 
| 4776 | 59 | |
| 13805 | 60 | Trans: "[| (A,B) \<in> leads F; (B,C) \<in> leads F |] ==> (A,C) \<in> leads F" | 
| 4776 | 61 | |
| 13805 | 62 | Union: "\<forall>A \<in> S. (A,B) \<in> leads F ==> (Union S, B) \<in> leads F" | 
| 4776 | 63 | |
| 5155 | 64 | |
| 8006 | 65 | constdefs | 
| 6536 | 66 | |
| 13797 | 67 | leadsTo :: "['a set, 'a set] => 'a program set" (infixl "leadsTo" 60) | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 68 |      --{*visible version of the LEADS-TO relation*}
 | 
| 13805 | 69 |     "A leadsTo B == {F. (A,B) \<in> leads F}"
 | 
| 5648 | 70 | |
| 71 | wlt :: "['a program, 'a set] => 'a set" | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 72 |      --{*predicate transformer: the largest set that leads to @{term B}*}
 | 
| 13805 | 73 |     "wlt F B == Union {A. F \<in> A leadsTo B}"
 | 
| 4776 | 74 | |
| 9685 | 75 | syntax (xsymbols) | 
| 13797 | 76 | "op leadsTo" :: "['a set, 'a set] => 'a program set" (infixl "\<longmapsto>" 60) | 
| 77 | ||
| 78 | ||
| 13798 | 79 | subsection{*transient*}
 | 
| 13797 | 80 | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 81 | lemma stable_transient: | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 82 | "[| F \<in> stable A; F \<in> transient A |] ==> \<exists>act\<in>Acts F. A \<subseteq> - (Domain act)" | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 83 | apply (simp add: stable_def constrains_def transient_def, clarify) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 84 | apply (rule rev_bexI, auto) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 85 | done | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 86 | |
| 13797 | 87 | lemma stable_transient_empty: | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 88 |     "[| F \<in> stable A; F \<in> transient A; all_total F |] ==> A = {}"
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 89 | apply (drule stable_transient, assumption) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 90 | apply (simp add: all_total_def) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 91 | done | 
| 13797 | 92 | |
| 93 | lemma transient_strengthen: | |
| 13805 | 94 | "[| F \<in> transient A; B \<subseteq> A |] ==> F \<in> transient B" | 
| 13797 | 95 | apply (unfold transient_def, clarify) | 
| 96 | apply (blast intro!: rev_bexI) | |
| 97 | done | |
| 98 | ||
| 99 | lemma transientI: | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 100 | "[| act: Acts F; act``A \<subseteq> -A |] ==> F \<in> transient A" | 
| 13797 | 101 | by (unfold transient_def, blast) | 
| 102 | ||
| 103 | lemma transientE: | |
| 13805 | 104 | "[| F \<in> transient A; | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 105 | !!act. [| act: Acts F; act``A \<subseteq> -A |] ==> P |] | 
| 13797 | 106 | ==> P" | 
| 107 | by (unfold transient_def, blast) | |
| 108 | ||
| 109 | lemma transient_empty [simp]: "transient {} = UNIV"
 | |
| 110 | by (unfold transient_def, auto) | |
| 111 | ||
| 112 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 113 | text{*This equation recovers the notion of weak fairness.  A totalized
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 114 | program satisfies a transient assertion just if the original program | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 115 | contains a suitable action that is also enabled.*} | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 116 | lemma totalize_transient_iff: | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 117 | "(totalize F \<in> transient A) = (\<exists>act\<in>Acts F. A \<subseteq> Domain act & act``A \<subseteq> -A)" | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 118 | apply (simp add: totalize_def totalize_act_def transient_def | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 119 | Un_Image Un_subset_iff, safe) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 120 | apply (blast intro!: rev_bexI)+ | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 121 | done | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 122 | |
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 123 | lemma totalize_transientI: | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 124 | "[| act: Acts F; A \<subseteq> Domain act; act``A \<subseteq> -A |] | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 125 | ==> totalize F \<in> transient A" | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 126 | by (simp add: totalize_transient_iff, blast) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 127 | |
| 13798 | 128 | subsection{*ensures*}
 | 
| 13797 | 129 | |
| 130 | lemma ensuresI: | |
| 13805 | 131 | "[| F \<in> (A-B) co (A \<union> B); F \<in> transient (A-B) |] ==> F \<in> A ensures B" | 
| 13797 | 132 | by (unfold ensures_def, blast) | 
| 133 | ||
| 134 | lemma ensuresD: | |
| 13805 | 135 | "F \<in> A ensures B ==> F \<in> (A-B) co (A \<union> B) & F \<in> transient (A-B)" | 
| 13797 | 136 | by (unfold ensures_def, blast) | 
| 137 | ||
| 138 | lemma ensures_weaken_R: | |
| 13805 | 139 | "[| F \<in> A ensures A'; A'<=B' |] ==> F \<in> A ensures B'" | 
| 13797 | 140 | apply (unfold ensures_def) | 
| 141 | apply (blast intro: constrains_weaken transient_strengthen) | |
| 142 | done | |
| 143 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 144 | text{*The L-version (precondition strengthening) fails, but we have this*}
 | 
| 13797 | 145 | lemma stable_ensures_Int: | 
| 13805 | 146 | "[| F \<in> stable C; F \<in> A ensures B |] | 
| 147 | ==> F \<in> (C \<inter> A) ensures (C \<inter> B)" | |
| 13797 | 148 | apply (unfold ensures_def) | 
| 149 | apply (auto simp add: ensures_def Int_Un_distrib [symmetric] Diff_Int_distrib [symmetric]) | |
| 150 | prefer 2 apply (blast intro: transient_strengthen) | |
| 151 | apply (blast intro: stable_constrains_Int constrains_weaken) | |
| 152 | done | |
| 153 | ||
| 154 | lemma stable_transient_ensures: | |
| 13805 | 155 | "[| F \<in> stable A; F \<in> transient C; A \<subseteq> B \<union> C |] ==> F \<in> A ensures B" | 
| 13797 | 156 | apply (simp add: ensures_def stable_def) | 
| 157 | apply (blast intro: constrains_weaken transient_strengthen) | |
| 158 | done | |
| 159 | ||
| 13805 | 160 | lemma ensures_eq: "(A ensures B) = (A unless B) \<inter> transient (A-B)" | 
| 13797 | 161 | by (simp (no_asm) add: ensures_def unless_def) | 
| 162 | ||
| 163 | ||
| 13798 | 164 | subsection{*leadsTo*}
 | 
| 13797 | 165 | |
| 13805 | 166 | lemma leadsTo_Basis [intro]: "F \<in> A ensures B ==> F \<in> A leadsTo B" | 
| 13797 | 167 | apply (unfold leadsTo_def) | 
| 168 | apply (blast intro: leads.Basis) | |
| 169 | done | |
| 170 | ||
| 171 | lemma leadsTo_Trans: | |
| 13805 | 172 | "[| F \<in> A leadsTo B; F \<in> B leadsTo C |] ==> F \<in> A leadsTo C" | 
| 13797 | 173 | apply (unfold leadsTo_def) | 
| 174 | apply (blast intro: leads.Trans) | |
| 175 | done | |
| 176 | ||
| 14112 | 177 | lemma leadsTo_Basis': | 
| 178 | "[| F \<in> A co A \<union> B; F \<in> transient A |] ==> F \<in> A leadsTo B" | |
| 179 | apply (drule_tac B = "A-B" in constrains_weaken_L) | |
| 180 | apply (drule_tac [2] B = "A-B" in transient_strengthen) | |
| 181 | apply (rule_tac [3] ensuresI [THEN leadsTo_Basis]) | |
| 182 | apply (blast+) | |
| 183 | done | |
| 184 | ||
| 13805 | 185 | lemma transient_imp_leadsTo: "F \<in> transient A ==> F \<in> A leadsTo (-A)" | 
| 13797 | 186 | by (simp (no_asm_simp) add: leadsTo_Basis ensuresI Compl_partition) | 
| 187 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 188 | text{*Useful with cancellation, disjunction*}
 | 
| 13805 | 189 | lemma leadsTo_Un_duplicate: "F \<in> A leadsTo (A' \<union> A') ==> F \<in> A leadsTo A'" | 
| 13797 | 190 | by (simp add: Un_ac) | 
| 191 | ||
| 192 | lemma leadsTo_Un_duplicate2: | |
| 13805 | 193 | "F \<in> A leadsTo (A' \<union> C \<union> C) ==> F \<in> A leadsTo (A' \<union> C)" | 
| 13797 | 194 | by (simp add: Un_ac) | 
| 195 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 196 | text{*The Union introduction rule as we should have liked to state it*}
 | 
| 13797 | 197 | lemma leadsTo_Union: | 
| 13805 | 198 | "(!!A. A \<in> S ==> F \<in> A leadsTo B) ==> F \<in> (Union S) leadsTo B" | 
| 13797 | 199 | apply (unfold leadsTo_def) | 
| 200 | apply (blast intro: leads.Union) | |
| 201 | done | |
| 202 | ||
| 203 | lemma leadsTo_Union_Int: | |
| 13805 | 204 | "(!!A. A \<in> S ==> F \<in> (A \<inter> C) leadsTo B) ==> F \<in> (Union S \<inter> C) leadsTo B" | 
| 13797 | 205 | apply (unfold leadsTo_def) | 
| 206 | apply (simp only: Int_Union_Union) | |
| 207 | apply (blast intro: leads.Union) | |
| 208 | done | |
| 209 | ||
| 210 | lemma leadsTo_UN: | |
| 13805 | 211 | "(!!i. i \<in> I ==> F \<in> (A i) leadsTo B) ==> F \<in> (\<Union>i \<in> I. A i) leadsTo B" | 
| 13797 | 212 | apply (subst Union_image_eq [symmetric]) | 
| 213 | apply (blast intro: leadsTo_Union) | |
| 214 | done | |
| 215 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 216 | text{*Binary union introduction rule*}
 | 
| 13797 | 217 | lemma leadsTo_Un: | 
| 13805 | 218 | "[| F \<in> A leadsTo C; F \<in> B leadsTo C |] ==> F \<in> (A \<union> B) leadsTo C" | 
| 13797 | 219 | apply (subst Un_eq_Union) | 
| 220 | apply (blast intro: leadsTo_Union) | |
| 221 | done | |
| 222 | ||
| 223 | lemma single_leadsTo_I: | |
| 13805 | 224 |      "(!!x. x \<in> A ==> F \<in> {x} leadsTo B) ==> F \<in> A leadsTo B"
 | 
| 13797 | 225 | by (subst UN_singleton [symmetric], rule leadsTo_UN, blast) | 
| 226 | ||
| 227 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 228 | text{*The INDUCTION rule as we should have liked to state it*}
 | 
| 13797 | 229 | lemma leadsTo_induct: | 
| 13805 | 230 | "[| F \<in> za leadsTo zb; | 
| 231 | !!A B. F \<in> A ensures B ==> P A B; | |
| 232 | !!A B C. [| F \<in> A leadsTo B; P A B; F \<in> B leadsTo C; P B C |] | |
| 13797 | 233 | ==> P A C; | 
| 13805 | 234 | !!B S. \<forall>A \<in> S. F \<in> A leadsTo B & P A B ==> P (Union S) B | 
| 13797 | 235 | |] ==> P za zb" | 
| 236 | apply (unfold leadsTo_def) | |
| 237 | apply (drule CollectD, erule leads.induct) | |
| 238 | apply (blast+) | |
| 239 | done | |
| 240 | ||
| 241 | ||
| 13805 | 242 | lemma subset_imp_ensures: "A \<subseteq> B ==> F \<in> A ensures B" | 
| 13797 | 243 | by (unfold ensures_def constrains_def transient_def, blast) | 
| 244 | ||
| 245 | lemmas subset_imp_leadsTo = subset_imp_ensures [THEN leadsTo_Basis, standard] | |
| 246 | ||
| 247 | lemmas leadsTo_refl = subset_refl [THEN subset_imp_leadsTo, standard] | |
| 248 | ||
| 249 | lemmas empty_leadsTo = empty_subsetI [THEN subset_imp_leadsTo, standard, simp] | |
| 250 | ||
| 251 | lemmas leadsTo_UNIV = subset_UNIV [THEN subset_imp_leadsTo, standard, simp] | |
| 252 | ||
| 253 | ||
| 254 | ||
| 255 | (** Variant induction rule: on the preconditions for B **) | |
| 256 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 257 | text{*Lemma is the weak version: can't see how to do it in one step*}
 | 
| 13797 | 258 | lemma leadsTo_induct_pre_lemma: | 
| 13805 | 259 | "[| F \<in> za leadsTo zb; | 
| 13797 | 260 | P zb; | 
| 13805 | 261 | !!A B. [| F \<in> A ensures B; P B |] ==> P A; | 
| 262 | !!S. \<forall>A \<in> S. P A ==> P (Union S) | |
| 13797 | 263 | |] ==> P za" | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 264 | txt{*by induction on this formula*}
 | 
| 13797 | 265 | apply (subgoal_tac "P zb --> P za") | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 266 | txt{*now solve first subgoal: this formula is sufficient*}
 | 
| 13797 | 267 | apply (blast intro: leadsTo_refl) | 
| 268 | apply (erule leadsTo_induct) | |
| 269 | apply (blast+) | |
| 270 | done | |
| 271 | ||
| 272 | lemma leadsTo_induct_pre: | |
| 13805 | 273 | "[| F \<in> za leadsTo zb; | 
| 13797 | 274 | P zb; | 
| 13805 | 275 | !!A B. [| F \<in> A ensures B; F \<in> B leadsTo zb; P B |] ==> P A; | 
| 276 | !!S. \<forall>A \<in> S. F \<in> A leadsTo zb & P A ==> P (Union S) | |
| 13797 | 277 | |] ==> P za" | 
| 13805 | 278 | apply (subgoal_tac "F \<in> za leadsTo zb & P za") | 
| 13797 | 279 | apply (erule conjunct2) | 
| 280 | apply (erule leadsTo_induct_pre_lemma) | |
| 281 | prefer 3 apply (blast intro: leadsTo_Union) | |
| 282 | prefer 2 apply (blast intro: leadsTo_Trans) | |
| 283 | apply (blast intro: leadsTo_refl) | |
| 284 | done | |
| 285 | ||
| 286 | ||
| 13805 | 287 | lemma leadsTo_weaken_R: "[| F \<in> A leadsTo A'; A'<=B' |] ==> F \<in> A leadsTo B'" | 
| 13797 | 288 | by (blast intro: subset_imp_leadsTo leadsTo_Trans) | 
| 289 | ||
| 13798 | 290 | lemma leadsTo_weaken_L [rule_format]: | 
| 13805 | 291 | "[| F \<in> A leadsTo A'; B \<subseteq> A |] ==> F \<in> B leadsTo A'" | 
| 13797 | 292 | by (blast intro: leadsTo_Trans subset_imp_leadsTo) | 
| 293 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 294 | text{*Distributes over binary unions*}
 | 
| 13797 | 295 | lemma leadsTo_Un_distrib: | 
| 13805 | 296 | "F \<in> (A \<union> B) leadsTo C = (F \<in> A leadsTo C & F \<in> B leadsTo C)" | 
| 13797 | 297 | by (blast intro: leadsTo_Un leadsTo_weaken_L) | 
| 298 | ||
| 299 | lemma leadsTo_UN_distrib: | |
| 13805 | 300 | "F \<in> (\<Union>i \<in> I. A i) leadsTo B = (\<forall>i \<in> I. F \<in> (A i) leadsTo B)" | 
| 13797 | 301 | by (blast intro: leadsTo_UN leadsTo_weaken_L) | 
| 302 | ||
| 303 | lemma leadsTo_Union_distrib: | |
| 13805 | 304 | "F \<in> (Union S) leadsTo B = (\<forall>A \<in> S. F \<in> A leadsTo B)" | 
| 13797 | 305 | by (blast intro: leadsTo_Union leadsTo_weaken_L) | 
| 306 | ||
| 307 | ||
| 308 | lemma leadsTo_weaken: | |
| 13805 | 309 | "[| F \<in> A leadsTo A'; B \<subseteq> A; A'<=B' |] ==> F \<in> B leadsTo B'" | 
| 13797 | 310 | by (blast intro: leadsTo_weaken_R leadsTo_weaken_L leadsTo_Trans) | 
| 311 | ||
| 312 | ||
| 14150 | 313 | text{*Set difference: maybe combine with @{text leadsTo_weaken_L}??*}
 | 
| 13797 | 314 | lemma leadsTo_Diff: | 
| 13805 | 315 | "[| F \<in> (A-B) leadsTo C; F \<in> B leadsTo C |] ==> F \<in> A leadsTo C" | 
| 13797 | 316 | by (blast intro: leadsTo_Un leadsTo_weaken) | 
| 317 | ||
| 318 | lemma leadsTo_UN_UN: | |
| 13805 | 319 | "(!! i. i \<in> I ==> F \<in> (A i) leadsTo (A' i)) | 
| 320 | ==> F \<in> (\<Union>i \<in> I. A i) leadsTo (\<Union>i \<in> I. A' i)" | |
| 13797 | 321 | apply (simp only: Union_image_eq [symmetric]) | 
| 322 | apply (blast intro: leadsTo_Union leadsTo_weaken_R) | |
| 323 | done | |
| 324 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 325 | text{*Binary union version*}
 | 
| 13797 | 326 | lemma leadsTo_Un_Un: | 
| 13805 | 327 | "[| F \<in> A leadsTo A'; F \<in> B leadsTo B' |] | 
| 328 | ==> F \<in> (A \<union> B) leadsTo (A' \<union> B')" | |
| 13797 | 329 | by (blast intro: leadsTo_Un leadsTo_weaken_R) | 
| 330 | ||
| 331 | ||
| 332 | (** The cancellation law **) | |
| 333 | ||
| 334 | lemma leadsTo_cancel2: | |
| 13805 | 335 | "[| F \<in> A leadsTo (A' \<union> B); F \<in> B leadsTo B' |] | 
| 336 | ==> F \<in> A leadsTo (A' \<union> B')" | |
| 13797 | 337 | by (blast intro: leadsTo_Un_Un subset_imp_leadsTo leadsTo_Trans) | 
| 338 | ||
| 339 | lemma leadsTo_cancel_Diff2: | |
| 13805 | 340 | "[| F \<in> A leadsTo (A' \<union> B); F \<in> (B-A') leadsTo B' |] | 
| 341 | ==> F \<in> A leadsTo (A' \<union> B')" | |
| 13797 | 342 | apply (rule leadsTo_cancel2) | 
| 343 | prefer 2 apply assumption | |
| 344 | apply (simp_all (no_asm_simp)) | |
| 345 | done | |
| 346 | ||
| 347 | lemma leadsTo_cancel1: | |
| 13805 | 348 | "[| F \<in> A leadsTo (B \<union> A'); F \<in> B leadsTo B' |] | 
| 349 | ==> F \<in> A leadsTo (B' \<union> A')" | |
| 13797 | 350 | apply (simp add: Un_commute) | 
| 351 | apply (blast intro!: leadsTo_cancel2) | |
| 352 | done | |
| 353 | ||
| 354 | lemma leadsTo_cancel_Diff1: | |
| 13805 | 355 | "[| F \<in> A leadsTo (B \<union> A'); F \<in> (B-A') leadsTo B' |] | 
| 356 | ==> F \<in> A leadsTo (B' \<union> A')" | |
| 13797 | 357 | apply (rule leadsTo_cancel1) | 
| 358 | prefer 2 apply assumption | |
| 359 | apply (simp_all (no_asm_simp)) | |
| 360 | done | |
| 361 | ||
| 362 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 363 | text{*The impossibility law*}
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 364 | lemma leadsTo_empty: "[|F \<in> A leadsTo {}; all_total F|] ==> A={}"
 | 
| 13797 | 365 | apply (erule leadsTo_induct_pre) | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 366 | apply (simp_all add: ensures_def constrains_def transient_def all_total_def, clarify) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 367 | apply (drule bspec, assumption)+ | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 368 | apply blast | 
| 13797 | 369 | done | 
| 370 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 371 | subsection{*PSP: Progress-Safety-Progress*}
 | 
| 13797 | 372 | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 373 | text{*Special case of PSP: Misra's "stable conjunction"*}
 | 
| 13797 | 374 | lemma psp_stable: | 
| 13805 | 375 | "[| F \<in> A leadsTo A'; F \<in> stable B |] | 
| 376 | ==> F \<in> (A \<inter> B) leadsTo (A' \<inter> B)" | |
| 13797 | 377 | apply (unfold stable_def) | 
| 378 | apply (erule leadsTo_induct) | |
| 379 | prefer 3 apply (blast intro: leadsTo_Union_Int) | |
| 380 | prefer 2 apply (blast intro: leadsTo_Trans) | |
| 381 | apply (rule leadsTo_Basis) | |
| 382 | apply (simp add: ensures_def Diff_Int_distrib2 [symmetric] Int_Un_distrib2 [symmetric]) | |
| 383 | apply (blast intro: transient_strengthen constrains_Int) | |
| 384 | done | |
| 385 | ||
| 386 | lemma psp_stable2: | |
| 13805 | 387 | "[| F \<in> A leadsTo A'; F \<in> stable B |] ==> F \<in> (B \<inter> A) leadsTo (B \<inter> A')" | 
| 13797 | 388 | by (simp add: psp_stable Int_ac) | 
| 389 | ||
| 390 | lemma psp_ensures: | |
| 13805 | 391 | "[| F \<in> A ensures A'; F \<in> B co B' |] | 
| 392 | ==> F \<in> (A \<inter> B') ensures ((A' \<inter> B) \<union> (B' - B))" | |
| 13797 | 393 | apply (unfold ensures_def constrains_def, clarify) (*speeds up the proof*) | 
| 394 | apply (blast intro: transient_strengthen) | |
| 395 | done | |
| 396 | ||
| 397 | lemma psp: | |
| 13805 | 398 | "[| F \<in> A leadsTo A'; F \<in> B co B' |] | 
| 399 | ==> F \<in> (A \<inter> B') leadsTo ((A' \<inter> B) \<union> (B' - B))" | |
| 13797 | 400 | apply (erule leadsTo_induct) | 
| 401 | prefer 3 apply (blast intro: leadsTo_Union_Int) | |
| 402 |  txt{*Basis case*}
 | |
| 403 | apply (blast intro: psp_ensures) | |
| 404 | txt{*Transitivity case has a delicate argument involving "cancellation"*}
 | |
| 405 | apply (rule leadsTo_Un_duplicate2) | |
| 406 | apply (erule leadsTo_cancel_Diff1) | |
| 407 | apply (simp add: Int_Diff Diff_triv) | |
| 408 | apply (blast intro: leadsTo_weaken_L dest: constrains_imp_subset) | |
| 409 | done | |
| 410 | ||
| 411 | lemma psp2: | |
| 13805 | 412 | "[| F \<in> A leadsTo A'; F \<in> B co B' |] | 
| 413 | ==> F \<in> (B' \<inter> A) leadsTo ((B \<inter> A') \<union> (B' - B))" | |
| 13797 | 414 | by (simp (no_asm_simp) add: psp Int_ac) | 
| 415 | ||
| 416 | lemma psp_unless: | |
| 13805 | 417 | "[| F \<in> A leadsTo A'; F \<in> B unless B' |] | 
| 418 | ==> F \<in> (A \<inter> B) leadsTo ((A' \<inter> B) \<union> B')" | |
| 13797 | 419 | |
| 420 | apply (unfold unless_def) | |
| 421 | apply (drule psp, assumption) | |
| 422 | apply (blast intro: leadsTo_weaken) | |
| 423 | done | |
| 424 | ||
| 425 | ||
| 13798 | 426 | subsection{*Proving the induction rules*}
 | 
| 13797 | 427 | |
| 428 | (** The most general rule: r is any wf relation; f is any variant function **) | |
| 429 | ||
| 430 | lemma leadsTo_wf_induct_lemma: | |
| 431 | "[| wf r; | |
| 13805 | 432 |          \<forall>m. F \<in> (A \<inter> f-`{m}) leadsTo                      
 | 
| 433 |                     ((A \<inter> f-`(r^-1 `` {m})) \<union> B) |]  
 | |
| 434 |       ==> F \<in> (A \<inter> f-`{m}) leadsTo B"
 | |
| 13797 | 435 | apply (erule_tac a = m in wf_induct) | 
| 13805 | 436 | apply (subgoal_tac "F \<in> (A \<inter> (f -` (r^-1 `` {x}))) leadsTo B")
 | 
| 13797 | 437 | apply (blast intro: leadsTo_cancel1 leadsTo_Un_duplicate) | 
| 438 | apply (subst vimage_eq_UN) | |
| 439 | apply (simp only: UN_simps [symmetric]) | |
| 440 | apply (blast intro: leadsTo_UN) | |
| 441 | done | |
| 442 | ||
| 443 | ||
| 444 | (** Meta or object quantifier ? **) | |
| 445 | lemma leadsTo_wf_induct: | |
| 446 | "[| wf r; | |
| 13805 | 447 |          \<forall>m. F \<in> (A \<inter> f-`{m}) leadsTo                      
 | 
| 448 |                     ((A \<inter> f-`(r^-1 `` {m})) \<union> B) |]  
 | |
| 449 | ==> F \<in> A leadsTo B" | |
| 13797 | 450 | apply (rule_tac t = A in subst) | 
| 451 | defer 1 | |
| 452 | apply (rule leadsTo_UN) | |
| 453 | apply (erule leadsTo_wf_induct_lemma) | |
| 454 | apply assumption | |
| 455 | apply fast (*Blast_tac: Function unknown's argument not a parameter*) | |
| 456 | done | |
| 457 | ||
| 458 | ||
| 459 | lemma bounded_induct: | |
| 460 | "[| wf r; | |
| 13805 | 461 |          \<forall>m \<in> I. F \<in> (A \<inter> f-`{m}) leadsTo                    
 | 
| 462 |                       ((A \<inter> f-`(r^-1 `` {m})) \<union> B) |]  
 | |
| 463 | ==> F \<in> A leadsTo ((A - (f-`I)) \<union> B)" | |
| 13797 | 464 | apply (erule leadsTo_wf_induct, safe) | 
| 13805 | 465 | apply (case_tac "m \<in> I") | 
| 13797 | 466 | apply (blast intro: leadsTo_weaken) | 
| 467 | apply (blast intro: subset_imp_leadsTo) | |
| 468 | done | |
| 469 | ||
| 470 | ||
| 13805 | 471 | (*Alternative proof is via the lemma F \<in> (A \<inter> f-`(lessThan m)) leadsTo B*) | 
| 13797 | 472 | lemma lessThan_induct: | 
| 15045 | 473 |      "[| !!m::nat. F \<in> (A \<inter> f-`{m}) leadsTo ((A \<inter> f-`{..<m}) \<union> B) |]  
 | 
| 13805 | 474 | ==> F \<in> A leadsTo B" | 
| 13797 | 475 | apply (rule wf_less_than [THEN leadsTo_wf_induct]) | 
| 476 | apply (simp (no_asm_simp)) | |
| 477 | apply blast | |
| 478 | done | |
| 479 | ||
| 480 | lemma lessThan_bounded_induct: | |
| 13805 | 481 | "!!l::nat. [| \<forall>m \<in> greaterThan l. | 
| 482 |             F \<in> (A \<inter> f-`{m}) leadsTo ((A \<inter> f-`(lessThan m)) \<union> B) |]  
 | |
| 483 | ==> F \<in> A leadsTo ((A \<inter> (f-`(atMost l))) \<union> B)" | |
| 13797 | 484 | apply (simp only: Diff_eq [symmetric] vimage_Compl Compl_greaterThan [symmetric]) | 
| 485 | apply (rule wf_less_than [THEN bounded_induct]) | |
| 486 | apply (simp (no_asm_simp)) | |
| 487 | done | |
| 488 | ||
| 489 | lemma greaterThan_bounded_induct: | |
| 13805 | 490 | "(!!l::nat. \<forall>m \<in> lessThan l. | 
| 491 |                  F \<in> (A \<inter> f-`{m}) leadsTo ((A \<inter> f-`(greaterThan m)) \<union> B))
 | |
| 492 | ==> F \<in> A leadsTo ((A \<inter> (f-`(atLeast l))) \<union> B)" | |
| 13797 | 493 | apply (rule_tac f = f and f1 = "%k. l - k" | 
| 494 | in wf_less_than [THEN wf_inv_image, THEN leadsTo_wf_induct]) | |
| 495 | apply (simp (no_asm) add: inv_image_def Image_singleton) | |
| 496 | apply clarify | |
| 497 | apply (case_tac "m<l") | |
| 13805 | 498 | apply (blast intro: leadsTo_weaken_R diff_less_mono2) | 
| 499 | apply (blast intro: not_leE subset_imp_leadsTo) | |
| 13797 | 500 | done | 
| 501 | ||
| 502 | ||
| 13798 | 503 | subsection{*wlt*}
 | 
| 13797 | 504 | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 505 | text{*Misra's property W3*}
 | 
| 13805 | 506 | lemma wlt_leadsTo: "F \<in> (wlt F B) leadsTo B" | 
| 13797 | 507 | apply (unfold wlt_def) | 
| 508 | apply (blast intro!: leadsTo_Union) | |
| 509 | done | |
| 510 | ||
| 13805 | 511 | lemma leadsTo_subset: "F \<in> A leadsTo B ==> A \<subseteq> wlt F B" | 
| 13797 | 512 | apply (unfold wlt_def) | 
| 513 | apply (blast intro!: leadsTo_Union) | |
| 514 | done | |
| 515 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 516 | text{*Misra's property W2*}
 | 
| 13805 | 517 | lemma leadsTo_eq_subset_wlt: "F \<in> A leadsTo B = (A \<subseteq> wlt F B)" | 
| 13797 | 518 | by (blast intro!: leadsTo_subset wlt_leadsTo [THEN leadsTo_weaken_L]) | 
| 519 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 520 | text{*Misra's property W4*}
 | 
| 13805 | 521 | lemma wlt_increasing: "B \<subseteq> wlt F B" | 
| 13797 | 522 | apply (simp (no_asm_simp) add: leadsTo_eq_subset_wlt [symmetric] subset_imp_leadsTo) | 
| 523 | done | |
| 524 | ||
| 525 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 526 | text{*Used in the Trans case below*}
 | 
| 13797 | 527 | lemma lemma1: | 
| 13805 | 528 | "[| B \<subseteq> A2; | 
| 529 | F \<in> (A1 - B) co (A1 \<union> B); | |
| 530 | F \<in> (A2 - C) co (A2 \<union> C) |] | |
| 531 | ==> F \<in> (A1 \<union> A2 - C) co (A1 \<union> A2 \<union> C)" | |
| 13797 | 532 | by (unfold constrains_def, clarify, blast) | 
| 533 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 534 | text{*Lemma (1,2,3) of Misra's draft book, Chapter 4, "Progress"*}
 | 
| 13797 | 535 | lemma leadsTo_123: | 
| 13805 | 536 | "F \<in> A leadsTo A' | 
| 537 | ==> \<exists>B. A \<subseteq> B & F \<in> B leadsTo A' & F \<in> (B-A') co (B \<union> A')" | |
| 13797 | 538 | apply (erule leadsTo_induct) | 
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 539 |   txt{*Basis*}
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 540 | apply (blast dest: ensuresD) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 541 |  txt{*Trans*}
 | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 542 | apply clarify | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 543 | apply (rule_tac x = "Ba \<union> Bb" in exI) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 544 | apply (blast intro: lemma1 leadsTo_Un_Un leadsTo_cancel1 leadsTo_Un_duplicate) | 
| 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 545 | txt{*Union*}
 | 
| 13797 | 546 | apply (clarify dest!: ball_conj_distrib [THEN iffD1] bchoice) | 
| 13805 | 547 | apply (rule_tac x = "\<Union>A \<in> S. f A" in exI) | 
| 13797 | 548 | apply (auto intro: leadsTo_UN) | 
| 549 | (*Blast_tac says PROOF FAILED*) | |
| 13805 | 550 | apply (rule_tac I1=S and A1="%i. f i - B" and A'1="%i. f i \<union> B" | 
| 13798 | 551 | in constrains_UN [THEN constrains_weaken], auto) | 
| 13797 | 552 | done | 
| 553 | ||
| 554 | ||
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 555 | text{*Misra's property W5*}
 | 
| 13805 | 556 | lemma wlt_constrains_wlt: "F \<in> (wlt F B - B) co (wlt F B)" | 
| 13798 | 557 | proof - | 
| 558 | from wlt_leadsTo [of F B, THEN leadsTo_123] | |
| 559 | show ?thesis | |
| 560 | proof (elim exE conjE) | |
| 561 | (* assumes have to be in exactly the form as in the goal displayed at | |
| 562 | this point. Isar doesn't give you any automation. *) | |
| 563 | fix C | |
| 564 | assume wlt: "wlt F B \<subseteq> C" | |
| 565 | and lt: "F \<in> C leadsTo B" | |
| 566 | and co: "F \<in> C - B co C \<union> B" | |
| 567 | have eq: "C = wlt F B" | |
| 568 | proof - | |
| 569 | from lt and wlt show ?thesis | |
| 570 | by (blast dest: leadsTo_eq_subset_wlt [THEN iffD1]) | |
| 571 | qed | |
| 572 | from co show ?thesis by (simp add: eq wlt_increasing Un_absorb2) | |
| 573 | qed | |
| 574 | qed | |
| 13797 | 575 | |
| 576 | ||
| 13798 | 577 | subsection{*Completion: Binary and General Finite versions*}
 | 
| 13797 | 578 | |
| 579 | lemma completion_lemma : | |
| 13805 | 580 | "[| W = wlt F (B' \<union> C); | 
| 581 | F \<in> A leadsTo (A' \<union> C); F \<in> A' co (A' \<union> C); | |
| 582 | F \<in> B leadsTo (B' \<union> C); F \<in> B' co (B' \<union> C) |] | |
| 583 | ==> F \<in> (A \<inter> B) leadsTo ((A' \<inter> B') \<union> C)" | |
| 584 | apply (subgoal_tac "F \<in> (W-C) co (W \<union> B' \<union> C) ") | |
| 13797 | 585 | prefer 2 | 
| 586 | apply (blast intro: wlt_constrains_wlt [THEN [2] constrains_Un, | |
| 587 | THEN constrains_weaken]) | |
| 13805 | 588 | apply (subgoal_tac "F \<in> (W-C) co W") | 
| 13797 | 589 | prefer 2 | 
| 590 | apply (simp add: wlt_increasing Un_assoc Un_absorb2) | |
| 13805 | 591 | apply (subgoal_tac "F \<in> (A \<inter> W - C) leadsTo (A' \<inter> W \<union> C) ") | 
| 13797 | 592 | prefer 2 apply (blast intro: wlt_leadsTo psp [THEN leadsTo_weaken]) | 
| 593 | (** LEVEL 6 **) | |
| 13805 | 594 | apply (subgoal_tac "F \<in> (A' \<inter> W \<union> C) leadsTo (A' \<inter> B' \<union> C) ") | 
| 13797 | 595 | prefer 2 | 
| 596 | apply (rule leadsTo_Un_duplicate2) | |
| 597 | apply (blast intro: leadsTo_Un_Un wlt_leadsTo | |
| 598 | [THEN psp2, THEN leadsTo_weaken] leadsTo_refl) | |
| 599 | apply (drule leadsTo_Diff) | |
| 600 | apply (blast intro: subset_imp_leadsTo) | |
| 13805 | 601 | apply (subgoal_tac "A \<inter> B \<subseteq> A \<inter> W") | 
| 13797 | 602 | prefer 2 | 
| 603 | apply (blast dest!: leadsTo_subset intro!: subset_refl [THEN Int_mono]) | |
| 604 | apply (blast intro: leadsTo_Trans subset_imp_leadsTo) | |
| 605 | done | |
| 606 | ||
| 607 | lemmas completion = completion_lemma [OF refl] | |
| 608 | ||
| 609 | lemma finite_completion_lemma: | |
| 13805 | 610 | "finite I ==> (\<forall>i \<in> I. F \<in> (A i) leadsTo (A' i \<union> C)) --> | 
| 611 | (\<forall>i \<in> I. F \<in> (A' i) co (A' i \<union> C)) --> | |
| 612 | F \<in> (\<Inter>i \<in> I. A i) leadsTo ((\<Inter>i \<in> I. A' i) \<union> C)" | |
| 13797 | 613 | apply (erule finite_induct, auto) | 
| 614 | apply (rule completion) | |
| 615 | prefer 4 | |
| 616 | apply (simp only: INT_simps [symmetric]) | |
| 617 | apply (rule constrains_INT, auto) | |
| 618 | done | |
| 619 | ||
| 620 | lemma finite_completion: | |
| 621 | "[| finite I; | |
| 13805 | 622 | !!i. i \<in> I ==> F \<in> (A i) leadsTo (A' i \<union> C); | 
| 623 | !!i. i \<in> I ==> F \<in> (A' i) co (A' i \<union> C) |] | |
| 624 | ==> F \<in> (\<Inter>i \<in> I. A i) leadsTo ((\<Inter>i \<in> I. A' i) \<union> C)" | |
| 13797 | 625 | by (blast intro: finite_completion_lemma [THEN mp, THEN mp]) | 
| 626 | ||
| 627 | lemma stable_completion: | |
| 13805 | 628 | "[| F \<in> A leadsTo A'; F \<in> stable A'; | 
| 629 | F \<in> B leadsTo B'; F \<in> stable B' |] | |
| 630 | ==> F \<in> (A \<inter> B) leadsTo (A' \<inter> B')" | |
| 13797 | 631 | apply (unfold stable_def) | 
| 632 | apply (rule_tac C1 = "{}" in completion [THEN leadsTo_weaken_R])
 | |
| 633 | apply (force+) | |
| 634 | done | |
| 635 | ||
| 636 | lemma finite_stable_completion: | |
| 637 | "[| finite I; | |
| 13805 | 638 | !!i. i \<in> I ==> F \<in> (A i) leadsTo (A' i); | 
| 639 | !!i. i \<in> I ==> F \<in> stable (A' i) |] | |
| 640 | ==> F \<in> (\<Inter>i \<in> I. A i) leadsTo (\<Inter>i \<in> I. A' i)" | |
| 13797 | 641 | apply (unfold stable_def) | 
| 642 | apply (rule_tac C1 = "{}" in finite_completion [THEN leadsTo_weaken_R])
 | |
| 643 | apply (simp_all (no_asm_simp)) | |
| 644 | apply blast+ | |
| 645 | done | |
| 9685 | 646 | |
| 4776 | 647 | end |