| author | nipkow | 
| Fri, 06 Nov 2009 19:22:32 +0100 | |
| changeset 33492 | 4168294a9f96 | 
| parent 32960 | 69916a850301 | 
| child 35274 | 1cb90bbbf45e | 
| permissions | -rw-r--r-- | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32689diff
changeset | 1 | (* Title: HOL/UNITY/Follows.thy | 
| 6706 | 2 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | 
| 3 | Copyright 1998 University of Cambridge | |
| 13798 | 4 | *) | 
| 6706 | 5 | |
| 13798 | 6 | header{*The Follows Relation of Charpentier and Sivilotte*}
 | 
| 6706 | 7 | |
| 16417 | 8 | theory Follows imports SubstAx ListOrder Multiset begin | 
| 6706 | 9 | |
| 10 | constdefs | |
| 11 | ||
| 12 |   Follows :: "['a => 'b::{order}, 'a => 'b::{order}] => 'a program set"
 | |
| 6809 | 13 | (infixl "Fols" 65) | 
| 13805 | 14 | "f Fols g == Increasing g \<inter> Increasing f Int | 
| 15 |                 Always {s. f s \<le> g s} Int
 | |
| 16 |                 (\<Inter>k. {s. k \<le> g s} LeadsTo {s. k \<le> f s})"
 | |
| 6706 | 17 | |
| 18 | ||
| 13796 | 19 | (*Does this hold for "invariant"?*) | 
| 20 | lemma mono_Always_o: | |
| 13805 | 21 |      "mono h ==> Always {s. f s \<le> g s} \<subseteq> Always {s. h (f s) \<le> h (g s)}"
 | 
| 13796 | 22 | apply (simp add: Always_eq_includes_reachable) | 
| 23 | apply (blast intro: monoD) | |
| 24 | done | |
| 25 | ||
| 26 | lemma mono_LeadsTo_o: | |
| 27 | "mono (h::'a::order => 'b::order) | |
| 13805 | 28 |       ==> (\<Inter>j. {s. j \<le> g s} LeadsTo {s. j \<le> f s}) \<subseteq>  
 | 
| 29 |           (\<Inter>k. {s. k \<le> h (g s)} LeadsTo {s. k \<le> h (f s)})"
 | |
| 13796 | 30 | apply auto | 
| 31 | apply (rule single_LeadsTo_I) | |
| 32 | apply (drule_tac x = "g s" in spec) | |
| 33 | apply (erule LeadsTo_weaken) | |
| 34 | apply (blast intro: monoD order_trans)+ | |
| 35 | done | |
| 36 | ||
| 13805 | 37 | lemma Follows_constant [iff]: "F \<in> (%s. c) Fols (%s. c)" | 
| 15102 | 38 | by (simp add: Follows_def) | 
| 13796 | 39 | |
| 13805 | 40 | lemma mono_Follows_o: "mono h ==> f Fols g \<subseteq> (h o f) Fols (h o g)" | 
| 15102 | 41 | by (auto simp add: Follows_def mono_Increasing_o [THEN [2] rev_subsetD] | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32689diff
changeset | 42 | mono_Always_o [THEN [2] rev_subsetD] | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32689diff
changeset | 43 | mono_LeadsTo_o [THEN [2] rev_subsetD, THEN INT_D]) | 
| 13796 | 44 | |
| 45 | lemma mono_Follows_apply: | |
| 13805 | 46 | "mono h ==> f Fols g \<subseteq> (%x. h (f x)) Fols (%x. h (g x))" | 
| 13796 | 47 | apply (drule mono_Follows_o) | 
| 48 | apply (force simp add: o_def) | |
| 49 | done | |
| 50 | ||
| 51 | lemma Follows_trans: | |
| 13805 | 52 | "[| F \<in> f Fols g; F \<in> g Fols h |] ==> F \<in> f Fols h" | 
| 15102 | 53 | apply (simp add: Follows_def) | 
| 13796 | 54 | apply (simp add: Always_eq_includes_reachable) | 
| 55 | apply (blast intro: order_trans LeadsTo_Trans) | |
| 56 | done | |
| 57 | ||
| 58 | ||
| 13798 | 59 | subsection{*Destruction rules*}
 | 
| 13796 | 60 | |
| 13805 | 61 | lemma Follows_Increasing1: "F \<in> f Fols g ==> F \<in> Increasing f" | 
| 15102 | 62 | by (simp add: Follows_def) | 
| 13796 | 63 | |
| 13805 | 64 | lemma Follows_Increasing2: "F \<in> f Fols g ==> F \<in> Increasing g" | 
| 15102 | 65 | by (simp add: Follows_def) | 
| 13796 | 66 | |
| 21710 | 67 | lemma Follows_Bounded: "F \<in> f Fols g ==> F \<in> Always {s. f s \<le> g s}"
 | 
| 15102 | 68 | by (simp add: Follows_def) | 
| 13796 | 69 | |
| 70 | lemma Follows_LeadsTo: | |
| 13805 | 71 |      "F \<in> f Fols g ==> F \<in> {s. k \<le> g s} LeadsTo {s. k \<le> f s}"
 | 
| 15102 | 72 | by (simp add: Follows_def) | 
| 13796 | 73 | |
| 74 | lemma Follows_LeadsTo_pfixLe: | |
| 13805 | 75 |      "F \<in> f Fols g ==> F \<in> {s. k pfixLe g s} LeadsTo {s. k pfixLe f s}"
 | 
| 13796 | 76 | apply (rule single_LeadsTo_I, clarify) | 
| 77 | apply (drule_tac k="g s" in Follows_LeadsTo) | |
| 78 | apply (erule LeadsTo_weaken) | |
| 79 | apply blast | |
| 80 | apply (blast intro: pfixLe_trans prefix_imp_pfixLe) | |
| 81 | done | |
| 82 | ||
| 83 | lemma Follows_LeadsTo_pfixGe: | |
| 13805 | 84 |      "F \<in> f Fols g ==> F \<in> {s. k pfixGe g s} LeadsTo {s. k pfixGe f s}"
 | 
| 13796 | 85 | apply (rule single_LeadsTo_I, clarify) | 
| 86 | apply (drule_tac k="g s" in Follows_LeadsTo) | |
| 87 | apply (erule LeadsTo_weaken) | |
| 88 | apply blast | |
| 89 | apply (blast intro: pfixGe_trans prefix_imp_pfixGe) | |
| 90 | done | |
| 91 | ||
| 92 | ||
| 93 | lemma Always_Follows1: | |
| 13805 | 94 |      "[| F \<in> Always {s. f s = f' s}; F \<in> f Fols g |] ==> F \<in> f' Fols g"
 | 
| 13796 | 95 | |
| 15102 | 96 | apply (simp add: Follows_def Increasing_def Stable_def, auto) | 
| 13796 | 97 | apply (erule_tac [3] Always_LeadsTo_weaken) | 
| 13805 | 98 | apply (erule_tac A = "{s. z \<le> f s}" and A' = "{s. z \<le> f s}" 
 | 
| 13798 | 99 | in Always_Constrains_weaken, auto) | 
| 13796 | 100 | apply (drule Always_Int_I, assumption) | 
| 101 | apply (force intro: Always_weaken) | |
| 102 | done | |
| 103 | ||
| 104 | lemma Always_Follows2: | |
| 13805 | 105 |      "[| F \<in> Always {s. g s = g' s}; F \<in> f Fols g |] ==> F \<in> f Fols g'"
 | 
| 15102 | 106 | apply (simp add: Follows_def Increasing_def Stable_def, auto) | 
| 13796 | 107 | apply (erule_tac [3] Always_LeadsTo_weaken) | 
| 13805 | 108 | apply (erule_tac A = "{s. z \<le> g s}" and A' = "{s. z \<le> g s}"
 | 
| 13798 | 109 | in Always_Constrains_weaken, auto) | 
| 13796 | 110 | apply (drule Always_Int_I, assumption) | 
| 111 | apply (force intro: Always_weaken) | |
| 112 | done | |
| 113 | ||
| 114 | ||
| 13798 | 115 | subsection{*Union properties (with the subset ordering)*}
 | 
| 13796 | 116 | |
| 117 | (*Can replace "Un" by any sup. But existing max only works for linorders.*) | |
| 118 | lemma increasing_Un: | |
| 13805 | 119 | "[| F \<in> increasing f; F \<in> increasing g |] | 
| 120 | ==> F \<in> increasing (%s. (f s) \<union> (g s))" | |
| 15102 | 121 | apply (simp add: increasing_def stable_def constrains_def, auto) | 
| 13796 | 122 | apply (drule_tac x = "f xa" in spec) | 
| 123 | apply (drule_tac x = "g xa" in spec) | |
| 124 | apply (blast dest!: bspec) | |
| 125 | done | |
| 126 | ||
| 127 | lemma Increasing_Un: | |
| 13805 | 128 | "[| F \<in> Increasing f; F \<in> Increasing g |] | 
| 129 | ==> F \<in> Increasing (%s. (f s) \<union> (g s))" | |
| 13798 | 130 | apply (auto simp add: Increasing_def Stable_def Constrains_def | 
| 131 | stable_def constrains_def) | |
| 13796 | 132 | apply (drule_tac x = "f xa" in spec) | 
| 133 | apply (drule_tac x = "g xa" in spec) | |
| 134 | apply (blast dest!: bspec) | |
| 135 | done | |
| 136 | ||
| 137 | ||
| 138 | lemma Always_Un: | |
| 13805 | 139 |      "[| F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s} |]  
 | 
| 140 |       ==> F \<in> Always {s. f' s \<union> g' s \<le> f s \<union> g s}"
 | |
| 13798 | 141 | by (simp add: Always_eq_includes_reachable, blast) | 
| 13796 | 142 | |
| 143 | (*Lemma to re-use the argument that one variable increases (progress) | |
| 144 | while the other variable doesn't decrease (safety)*) | |
| 145 | lemma Follows_Un_lemma: | |
| 13805 | 146 | "[| F \<in> Increasing f; F \<in> Increasing g; | 
| 147 |          F \<in> Increasing g'; F \<in> Always {s. f' s \<le> f s}; 
 | |
| 148 |          \<forall>k. F \<in> {s. k \<le> f s} LeadsTo {s. k \<le> f' s} |] 
 | |
| 149 |       ==> F \<in> {s. k \<le> f s \<union> g s} LeadsTo {s. k \<le> f' s \<union> g s}"
 | |
| 13796 | 150 | apply (rule single_LeadsTo_I) | 
| 151 | apply (drule_tac x = "f s" in IncreasingD) | |
| 152 | apply (drule_tac x = "g s" in IncreasingD) | |
| 153 | apply (rule LeadsTo_weaken) | |
| 154 | apply (rule PSP_Stable) | |
| 155 | apply (erule_tac x = "f s" in spec) | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 156 | apply (erule Stable_Int, assumption, blast+) | 
| 13796 | 157 | done | 
| 158 | ||
| 159 | lemma Follows_Un: | |
| 13805 | 160 | "[| F \<in> f' Fols f; F \<in> g' Fols g |] | 
| 161 | ==> F \<in> (%s. (f' s) \<union> (g' s)) Fols (%s. (f s) \<union> (g s))" | |
| 32689 | 162 | apply (simp add: Follows_def Increasing_Un Always_Un del: Un_subset_iff le_sup_iff, auto) | 
| 13796 | 163 | apply (rule LeadsTo_Trans) | 
| 164 | apply (blast intro: Follows_Un_lemma) | |
| 165 | (*Weakening is used to exchange Un's arguments*) | |
| 166 | apply (blast intro: Follows_Un_lemma [THEN LeadsTo_weaken]) | |
| 167 | done | |
| 168 | ||
| 169 | ||
| 13798 | 170 | subsection{*Multiset union properties (with the multiset ordering)*}
 | 
| 13796 | 171 | |
| 172 | lemma increasing_union: | |
| 13805 | 173 | "[| F \<in> increasing f; F \<in> increasing g |] | 
| 174 |      ==> F \<in> increasing (%s. (f s) + (g s :: ('a::order) multiset))"
 | |
| 15102 | 175 | apply (simp add: increasing_def stable_def constrains_def, auto) | 
| 13796 | 176 | apply (drule_tac x = "f xa" in spec) | 
| 177 | apply (drule_tac x = "g xa" in spec) | |
| 178 | apply (drule bspec, assumption) | |
| 179 | apply (blast intro: union_le_mono order_trans) | |
| 180 | done | |
| 181 | ||
| 182 | lemma Increasing_union: | |
| 13805 | 183 | "[| F \<in> Increasing f; F \<in> Increasing g |] | 
| 184 |      ==> F \<in> Increasing (%s. (f s) + (g s :: ('a::order) multiset))"
 | |
| 13798 | 185 | apply (auto simp add: Increasing_def Stable_def Constrains_def | 
| 186 | stable_def constrains_def) | |
| 13796 | 187 | apply (drule_tac x = "f xa" in spec) | 
| 188 | apply (drule_tac x = "g xa" in spec) | |
| 189 | apply (drule bspec, assumption) | |
| 190 | apply (blast intro: union_le_mono order_trans) | |
| 191 | done | |
| 192 | ||
| 193 | lemma Always_union: | |
| 13805 | 194 |      "[| F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s} |]  
 | 
| 195 |       ==> F \<in> Always {s. f' s + g' s \<le> f s + (g s :: ('a::order) multiset)}"
 | |
| 13796 | 196 | apply (simp add: Always_eq_includes_reachable) | 
| 197 | apply (blast intro: union_le_mono) | |
| 198 | done | |
| 199 | ||
| 200 | (*Except the last line, IDENTICAL to the proof script for Follows_Un_lemma*) | |
| 201 | lemma Follows_union_lemma: | |
| 13805 | 202 | "[| F \<in> Increasing f; F \<in> Increasing g; | 
| 203 |          F \<in> Increasing g'; F \<in> Always {s. f' s \<le> f s}; 
 | |
| 204 |          \<forall>k::('a::order) multiset.  
 | |
| 205 |            F \<in> {s. k \<le> f s} LeadsTo {s. k \<le> f' s} |] 
 | |
| 206 |       ==> F \<in> {s. k \<le> f s + g s} LeadsTo {s. k \<le> f' s + g s}"
 | |
| 13796 | 207 | apply (rule single_LeadsTo_I) | 
| 208 | apply (drule_tac x = "f s" in IncreasingD) | |
| 209 | apply (drule_tac x = "g s" in IncreasingD) | |
| 210 | apply (rule LeadsTo_weaken) | |
| 211 | apply (rule PSP_Stable) | |
| 212 | apply (erule_tac x = "f s" in spec) | |
| 13812 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 paulson parents: 
13805diff
changeset | 213 | apply (erule Stable_Int, assumption, blast) | 
| 13796 | 214 | apply (blast intro: union_le_mono order_trans) | 
| 215 | done | |
| 216 | ||
| 217 | (*The !! is there to influence to effect of permutative rewriting at the end*) | |
| 218 | lemma Follows_union: | |
| 219 |      "!!g g' ::'b => ('a::order) multiset.  
 | |
| 13805 | 220 | [| F \<in> f' Fols f; F \<in> g' Fols g |] | 
| 221 | ==> F \<in> (%s. (f' s) + (g' s)) Fols (%s. (f s) + (g s))" | |
| 15102 | 222 | apply (simp add: Follows_def) | 
| 13796 | 223 | apply (simp add: Increasing_union Always_union, auto) | 
| 224 | apply (rule LeadsTo_Trans) | |
| 225 | apply (blast intro: Follows_union_lemma) | |
| 226 | (*now exchange union's arguments*) | |
| 227 | apply (simp add: union_commute) | |
| 228 | apply (blast intro: Follows_union_lemma) | |
| 229 | done | |
| 230 | ||
| 231 | lemma Follows_setsum: | |
| 232 |      "!!f ::['c,'b] => ('a::order) multiset.  
 | |
| 13805 | 233 | [| \<forall>i \<in> I. F \<in> f' i Fols f i; finite I |] | 
| 234 | ==> F \<in> (%s. \<Sum>i \<in> I. f' i s) Fols (%s. \<Sum>i \<in> I. f i s)" | |
| 13796 | 235 | apply (erule rev_mp) | 
| 236 | apply (erule finite_induct, simp) | |
| 237 | apply (simp add: Follows_union) | |
| 238 | done | |
| 239 | ||
| 240 | ||
| 241 | (*Currently UNUSED, but possibly of interest*) | |
| 242 | lemma Increasing_imp_Stable_pfixGe: | |
| 13805 | 243 |      "F \<in> Increasing func ==> F \<in> Stable {s. h pfixGe (func s)}"
 | 
| 13796 | 244 | apply (simp add: Increasing_def Stable_def Constrains_def constrains_def) | 
| 245 | apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD] | |
| 246 | prefix_imp_pfixGe) | |
| 247 | done | |
| 248 | ||
| 249 | (*Currently UNUSED, but possibly of interest*) | |
| 250 | lemma LeadsTo_le_imp_pfixGe: | |
| 13805 | 251 |      "\<forall>z. F \<in> {s. z \<le> f s} LeadsTo {s. z \<le> g s}  
 | 
| 252 |       ==> F \<in> {s. z pfixGe f s} LeadsTo {s. z pfixGe g s}"
 | |
| 13796 | 253 | apply (rule single_LeadsTo_I) | 
| 254 | apply (drule_tac x = "f s" in spec) | |
| 255 | apply (erule LeadsTo_weaken) | |
| 256 | prefer 2 | |
| 257 | apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD] | |
| 258 | prefix_imp_pfixGe, blast) | |
| 259 | done | |
| 260 | ||
| 6706 | 261 | end |