src/HOL/Library/Continuity.thy
author nipkow
Mon Aug 16 14:22:27 2004 +0200 (2004-08-16)
changeset 15131 c69542757a4d
parent 14981 e73f8140af78
child 15140 322485b816ac
permissions -rw-r--r--
New theory header syntax.
     1 (*  Title:      HOL/Library/Continuity.thy
     2     ID:         $Id$
     3     Author:     David von Oheimb, TU Muenchen
     4 *)
     5 
     6 header {* Continuity and iterations (of set transformers) *}
     7 
     8 theory Continuity
     9 import Main
    10 begin
    11 
    12 subsection "Chains"
    13 
    14 constdefs
    15   up_chain :: "(nat => 'a set) => bool"
    16   "up_chain F == \<forall>i. F i \<subseteq> F (Suc i)"
    17 
    18 lemma up_chainI: "(!!i. F i \<subseteq> F (Suc i)) ==> up_chain F"
    19   by (simp add: up_chain_def)
    20 
    21 lemma up_chainD: "up_chain F ==> F i \<subseteq> F (Suc i)"
    22   by (simp add: up_chain_def)
    23 
    24 lemma up_chain_less_mono [rule_format]:
    25     "up_chain F ==> x < y --> F x \<subseteq> F y"
    26   apply (induct_tac y)
    27   apply (blast dest: up_chainD elim: less_SucE)+
    28   done
    29 
    30 lemma up_chain_mono: "up_chain F ==> x \<le> y ==> F x \<subseteq> F y"
    31   apply (drule le_imp_less_or_eq)
    32   apply (blast dest: up_chain_less_mono)
    33   done
    34 
    35 
    36 constdefs
    37   down_chain :: "(nat => 'a set) => bool"
    38   "down_chain F == \<forall>i. F (Suc i) \<subseteq> F i"
    39 
    40 lemma down_chainI: "(!!i. F (Suc i) \<subseteq> F i) ==> down_chain F"
    41   by (simp add: down_chain_def)
    42 
    43 lemma down_chainD: "down_chain F ==> F (Suc i) \<subseteq> F i"
    44   by (simp add: down_chain_def)
    45 
    46 lemma down_chain_less_mono [rule_format]:
    47     "down_chain F ==> x < y --> F y \<subseteq> F x"
    48   apply (induct_tac y)
    49   apply (blast dest: down_chainD elim: less_SucE)+
    50   done
    51 
    52 lemma down_chain_mono: "down_chain F ==> x \<le> y ==> F y \<subseteq> F x"
    53   apply (drule le_imp_less_or_eq)
    54   apply (blast dest: down_chain_less_mono)
    55   done
    56 
    57 
    58 subsection "Continuity"
    59 
    60 constdefs
    61   up_cont :: "('a set => 'a set) => bool"
    62   "up_cont f == \<forall>F. up_chain F --> f (\<Union>(range F)) = \<Union>(f ` range F)"
    63 
    64 lemma up_contI:
    65     "(!!F. up_chain F ==> f (\<Union>(range F)) = \<Union>(f ` range F)) ==> up_cont f"
    66   apply (unfold up_cont_def)
    67   apply blast
    68   done
    69 
    70 lemma up_contD:
    71     "up_cont f ==> up_chain F ==> f (\<Union>(range F)) = \<Union>(f ` range F)"
    72   apply (unfold up_cont_def)
    73   apply auto
    74   done
    75 
    76 
    77 lemma up_cont_mono: "up_cont f ==> mono f"
    78   apply (rule monoI)
    79   apply (drule_tac F = "\<lambda>i. if i = 0 then A else B" in up_contD)
    80    apply (rule up_chainI)
    81    apply  simp+
    82   apply (drule Un_absorb1)
    83   apply (auto simp add: nat_not_singleton)
    84   done
    85 
    86 
    87 constdefs
    88   down_cont :: "('a set => 'a set) => bool"
    89   "down_cont f ==
    90     \<forall>F. down_chain F --> f (Inter (range F)) = Inter (f ` range F)"
    91 
    92 lemma down_contI:
    93   "(!!F. down_chain F ==> f (Inter (range F)) = Inter (f ` range F)) ==>
    94     down_cont f"
    95   apply (unfold down_cont_def)
    96   apply blast
    97   done
    98 
    99 lemma down_contD: "down_cont f ==> down_chain F ==>
   100     f (Inter (range F)) = Inter (f ` range F)"
   101   apply (unfold down_cont_def)
   102   apply auto
   103   done
   104 
   105 lemma down_cont_mono: "down_cont f ==> mono f"
   106   apply (rule monoI)
   107   apply (drule_tac F = "\<lambda>i. if i = 0 then B else A" in down_contD)
   108    apply (rule down_chainI)
   109    apply simp+
   110   apply (drule Int_absorb1)
   111   apply (auto simp add: nat_not_singleton)
   112   done
   113 
   114 
   115 subsection "Iteration"
   116 
   117 constdefs
   118   up_iterate :: "('a set => 'a set) => nat => 'a set"
   119   "up_iterate f n == (f^n) {}"
   120 
   121 lemma up_iterate_0 [simp]: "up_iterate f 0 = {}"
   122   by (simp add: up_iterate_def)
   123 
   124 lemma up_iterate_Suc [simp]: "up_iterate f (Suc i) = f (up_iterate f i)"
   125   by (simp add: up_iterate_def)
   126 
   127 lemma up_iterate_chain: "mono F ==> up_chain (up_iterate F)"
   128   apply (rule up_chainI)
   129   apply (induct_tac i)
   130    apply simp+
   131   apply (erule (1) monoD)
   132   done
   133 
   134 lemma UNION_up_iterate_is_fp:
   135   "up_cont F ==>
   136     F (UNION UNIV (up_iterate F)) = UNION UNIV (up_iterate F)"
   137   apply (frule up_cont_mono [THEN up_iterate_chain])
   138   apply (drule (1) up_contD)
   139   apply simp
   140   apply (auto simp del: up_iterate_Suc simp add: up_iterate_Suc [symmetric])
   141   apply (case_tac xa)
   142    apply auto
   143   done
   144 
   145 lemma UNION_up_iterate_lowerbound:
   146     "mono F ==> F P = P ==> UNION UNIV (up_iterate F) \<subseteq> P"
   147   apply (subgoal_tac "(!!i. up_iterate F i \<subseteq> P)")
   148    apply fast
   149   apply (induct_tac i)
   150   prefer 2 apply (drule (1) monoD)
   151    apply auto
   152   done
   153 
   154 lemma UNION_up_iterate_is_lfp:
   155     "up_cont F ==> lfp F = UNION UNIV (up_iterate F)"
   156   apply (rule set_eq_subset [THEN iffD2])
   157   apply (rule conjI)
   158    prefer 2
   159    apply (drule up_cont_mono)
   160    apply (rule UNION_up_iterate_lowerbound)
   161     apply assumption
   162    apply (erule lfp_unfold [symmetric])
   163   apply (rule lfp_lowerbound)
   164   apply (rule set_eq_subset [THEN iffD1, THEN conjunct2])
   165   apply (erule UNION_up_iterate_is_fp [symmetric])
   166   done
   167 
   168 
   169 constdefs
   170   down_iterate :: "('a set => 'a set) => nat => 'a set"
   171   "down_iterate f n == (f^n) UNIV"
   172 
   173 lemma down_iterate_0 [simp]: "down_iterate f 0 = UNIV"
   174   by (simp add: down_iterate_def)
   175 
   176 lemma down_iterate_Suc [simp]:
   177     "down_iterate f (Suc i) = f (down_iterate f i)"
   178   by (simp add: down_iterate_def)
   179 
   180 lemma down_iterate_chain: "mono F ==> down_chain (down_iterate F)"
   181   apply (rule down_chainI)
   182   apply (induct_tac i)
   183    apply simp+
   184   apply (erule (1) monoD)
   185   done
   186 
   187 lemma INTER_down_iterate_is_fp:
   188   "down_cont F ==>
   189     F (INTER UNIV (down_iterate F)) = INTER UNIV (down_iterate F)"
   190   apply (frule down_cont_mono [THEN down_iterate_chain])
   191   apply (drule (1) down_contD)
   192   apply simp
   193   apply (auto simp del: down_iterate_Suc simp add: down_iterate_Suc [symmetric])
   194   apply (case_tac xa)
   195    apply auto
   196   done
   197 
   198 lemma INTER_down_iterate_upperbound:
   199     "mono F ==> F P = P ==> P \<subseteq> INTER UNIV (down_iterate F)"
   200   apply (subgoal_tac "(!!i. P \<subseteq> down_iterate F i)")
   201    apply fast
   202   apply (induct_tac i)
   203   prefer 2 apply (drule (1) monoD)
   204    apply auto
   205   done
   206 
   207 lemma INTER_down_iterate_is_gfp:
   208     "down_cont F ==> gfp F = INTER UNIV (down_iterate F)"
   209   apply (rule set_eq_subset [THEN iffD2])
   210   apply (rule conjI)
   211    apply (drule down_cont_mono)
   212    apply (rule INTER_down_iterate_upperbound)
   213     apply assumption
   214    apply (erule gfp_unfold [symmetric])
   215   apply (rule gfp_upperbound)
   216   apply (rule set_eq_subset [THEN iffD1, THEN conjunct2])
   217   apply (erule INTER_down_iterate_is_fp)
   218   done
   219 
   220 end