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