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