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