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