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