src/HOL/Analysis/Bounded_Continuous_Function.thy
author immler
Fri Mar 10 23:16:40 2017 +0100 (2017-03-10)
changeset 65204 d23eded35a33
parent 65036 ab7e11730ad8
child 65205 f435640193b6
permissions -rw-r--r--
modernized construction of type bcontfun; base explicit theorems on Uniform_Limit.thy; added some lemmas
wenzelm@60420
     1
section \<open>Bounded Continuous Functions\<close>
wenzelm@60421
     2
hoelzl@59453
     3
theory Bounded_Continuous_Function
immler@65204
     4
  imports
immler@65204
     5
    Henstock_Kurzweil_Integration
hoelzl@59453
     6
begin
hoelzl@59453
     7
wenzelm@60421
     8
subsection \<open>Definition\<close>
hoelzl@59453
     9
wenzelm@60421
    10
definition bcontfun :: "('a::topological_space \<Rightarrow> 'b::metric_space) set"
wenzelm@60421
    11
  where "bcontfun = {f. continuous_on UNIV f \<and> bounded (range f)}"
hoelzl@59453
    12
immler@65204
    13
typedef (overloaded) ('a, 'b) bcontfun ("(_ \<Rightarrow>\<^sub>C /_)" [22, 21] 21) =
immler@65204
    14
    "{f::'a::topological_space \<Rightarrow> 'b::metric_space. continuous_on UNIV f \<and> bounded (range f)}"
immler@65204
    15
  morphisms apply_bcontfun Bcontfun
immler@65204
    16
  by (auto intro: continuous_intros simp: bounded_def)
immler@65204
    17
immler@65204
    18
declare [[coercion "apply_bcontfun :: ('a::topological_space \<Rightarrow>\<^sub>C'b::metric_space) \<Rightarrow> 'a \<Rightarrow> 'b"]]
immler@65204
    19
immler@65204
    20
setup_lifting type_definition_bcontfun
immler@65204
    21
immler@65204
    22
lemma continuous_on_apply_bcontfun[intro, simp]: "continuous_on T (apply_bcontfun x)"
immler@65204
    23
  and bounded_apply_bcontfun[intro, simp]: "bounded (range (apply_bcontfun x))"
immler@65204
    24
  using apply_bcontfun[of x]
immler@65204
    25
  by (auto simp: intro: continuous_on_subset)
immler@65204
    26
immler@65204
    27
lemma bcontfun_eqI: "(\<And>x. apply_bcontfun f x = apply_bcontfun g x) \<Longrightarrow> f = g"
immler@65204
    28
  by transfer auto
hoelzl@59453
    29
hoelzl@59453
    30
lemma bcontfunE:
immler@65204
    31
  assumes "continuous_on UNIV f" "bounded (range f)"
immler@65204
    32
  obtains g where "f = apply_bcontfun g"
immler@65204
    33
  by (blast intro: apply_bcontfun_cases assms)
hoelzl@59453
    34
immler@65204
    35
lift_definition const_bcontfun::"'b::metric_space \<Rightarrow> ('a::topological_space \<Rightarrow>\<^sub>C 'b)" is "\<lambda>c _. c"
immler@65204
    36
  by (auto intro!: continuous_intros simp: image_def)
hoelzl@59453
    37
hoelzl@62101
    38
(* TODO: Generalize to uniform spaces? *)
hoelzl@59453
    39
instantiation bcontfun :: (topological_space, metric_space) metric_space
hoelzl@59453
    40
begin
hoelzl@59453
    41
immler@65204
    42
lift_definition dist_bcontfun :: "'a \<Rightarrow>\<^sub>C 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>C 'b \<Rightarrow> real"
immler@65204
    43
  is "\<lambda>f g. (SUP x. dist (f x) (g x))" .
hoelzl@59453
    44
immler@65204
    45
definition uniformity_bcontfun :: "('a \<Rightarrow>\<^sub>C 'b \<times> 'a \<Rightarrow>\<^sub>C 'b) filter"
hoelzl@62101
    46
  where "uniformity_bcontfun = (INF e:{0 <..}. principal {(x, y). dist x y < e})"
hoelzl@62101
    47
immler@65204
    48
definition open_bcontfun :: "('a \<Rightarrow>\<^sub>C 'b) set \<Rightarrow> bool"
hoelzl@62101
    49
  where "open_bcontfun S = (\<forall>x\<in>S. \<forall>\<^sub>F (x', y) in uniformity. x' = x \<longrightarrow> y \<in> S)"
hoelzl@59453
    50
immler@65204
    51
lemma bounded_dist_le_SUP_dist:
immler@65204
    52
  "bounded (range f) \<Longrightarrow> bounded (range g) \<Longrightarrow> dist (f x) (g x) \<le> (SUP x. dist (f x) (g x))"
immler@65204
    53
  by (auto intro!: cSUP_upper bounded_imp_bdd_above bounded_dist_comp)
immler@65204
    54
hoelzl@59453
    55
lemma dist_bounded:
immler@65204
    56
  fixes f g :: "'a \<Rightarrow>\<^sub>C 'b"
immler@65204
    57
  shows "dist (f x) (g x) \<le> dist f g"
immler@65204
    58
  by transfer (auto intro!: bounded_dist_le_SUP_dist)
hoelzl@59453
    59
hoelzl@59453
    60
lemma dist_bound:
immler@65204
    61
  fixes f g :: "'a \<Rightarrow>\<^sub>C 'b"
immler@65204
    62
  assumes "\<And>x. dist (f x) (g x) \<le> b"
hoelzl@59453
    63
  shows "dist f g \<le> b"
immler@65204
    64
  using assms
immler@65204
    65
  by transfer (auto intro!: cSUP_least)
hoelzl@59453
    66
hoelzl@59453
    67
lemma dist_fun_lt_imp_dist_val_lt:
immler@65204
    68
  fixes f g :: "'a \<Rightarrow>\<^sub>C 'b"
hoelzl@59453
    69
  assumes "dist f g < e"
immler@65204
    70
  shows "dist (f x) (g x) < e"
hoelzl@59453
    71
  using dist_bounded assms by (rule le_less_trans)
hoelzl@59453
    72
hoelzl@59453
    73
instance
hoelzl@59453
    74
proof
immler@65204
    75
  fix f g h :: "'a \<Rightarrow>\<^sub>C 'b"
hoelzl@59453
    76
  show "dist f g = 0 \<longleftrightarrow> f = g"
hoelzl@59453
    77
  proof
immler@65204
    78
    have "\<And>x. dist (f x) (g x) \<le> dist f g"
wenzelm@60421
    79
      by (rule dist_bounded)
hoelzl@59453
    80
    also assume "dist f g = 0"
wenzelm@60421
    81
    finally show "f = g"
immler@65204
    82
      by (auto simp: apply_bcontfun_inject[symmetric])
haftmann@62343
    83
  qed (auto simp: dist_bcontfun_def intro!: cSup_eq)
hoelzl@59453
    84
  show "dist f g \<le> dist f h + dist g h"
immler@65204
    85
  proof (rule dist_bound)
hoelzl@59453
    86
    fix x
immler@65204
    87
    have "dist (f x) (g x) \<le> dist (f x) (h x) + dist (g x) (h x)"
hoelzl@59453
    88
      by (rule dist_triangle2)
immler@65204
    89
    also have "dist (f x) (h x) \<le> dist f h"
wenzelm@60421
    90
      by (rule dist_bounded)
immler@65204
    91
    also have "dist (g x) (h x) \<le> dist g h"
wenzelm@60421
    92
      by (rule dist_bounded)
immler@65204
    93
    finally show "dist (f x) (g x) \<le> dist f h + dist g h"
wenzelm@60421
    94
      by simp
hoelzl@59453
    95
  qed
hoelzl@62101
    96
qed (rule open_bcontfun_def uniformity_bcontfun_def)+
wenzelm@60421
    97
hoelzl@59453
    98
end
hoelzl@59453
    99
immler@65204
   100
lift_definition PiC::"'a::topological_space set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> ('a \<Rightarrow>\<^sub>C 'b::metric_space) set"
immler@65204
   101
  is "\<lambda>I X. Pi I X \<inter> {f. continuous_on UNIV f \<and> bounded (range f)}"
immler@65204
   102
  by auto
immler@65204
   103
immler@65204
   104
lemma mem_PiC_iff: "x \<in> PiC I X \<longleftrightarrow> apply_bcontfun x \<in> Pi I X"
immler@65204
   105
  by transfer simp
immler@65204
   106
immler@65204
   107
lemmas mem_PiCD = mem_PiC_iff[THEN iffD1]
immler@65204
   108
  and mem_PiCI = mem_PiC_iff[THEN iffD2]
immler@65204
   109
immler@65204
   110
lemma tendsto_bcontfun_uniform_limit:
immler@65204
   111
  fixes f::"'i \<Rightarrow> 'a::topological_space \<Rightarrow>\<^sub>C 'b::metric_space"
immler@65204
   112
  assumes "(f \<longlongrightarrow> l) F"
immler@65204
   113
  shows "uniform_limit UNIV f l F"
immler@65204
   114
proof (rule uniform_limitI)
immler@65204
   115
  fix e::real assume "e > 0"
immler@65204
   116
  from tendstoD[OF assms this] have "\<forall>\<^sub>F x in F. dist (f x) l < e" .
immler@65204
   117
  then show "\<forall>\<^sub>F n in F. \<forall>x\<in>UNIV. dist ((f n) x) (l x) < e"
immler@65204
   118
    by eventually_elim (auto simp: dist_fun_lt_imp_dist_val_lt)
immler@65204
   119
qed
immler@65204
   120
immler@65204
   121
lemma uniform_limit_tendsto_bcontfun:
immler@65204
   122
  fixes f::"'i \<Rightarrow> 'a::topological_space \<Rightarrow>\<^sub>C 'b::metric_space"
immler@65204
   123
    and l::"'a::topological_space \<Rightarrow>\<^sub>C 'b::metric_space"
immler@65204
   124
  assumes "uniform_limit UNIV f l F"
immler@65204
   125
  shows "(f \<longlongrightarrow> l) F"
immler@65204
   126
proof (rule tendstoI)
immler@65204
   127
  fix e::real assume "e > 0"
immler@65204
   128
  then have "e / 2 > 0" by simp
immler@65204
   129
  from uniform_limitD[OF assms this]
immler@65204
   130
  have "\<forall>\<^sub>F i in F. \<forall>x. dist (f i x) (l x) < e / 2" by simp
immler@65204
   131
  then have "\<forall>\<^sub>F x in F. dist (f x) l \<le> e / 2"
immler@65204
   132
    by eventually_elim (blast intro: dist_bound less_imp_le)
immler@65204
   133
  then show "\<forall>\<^sub>F x in F. dist (f x) l < e"
immler@65204
   134
    by eventually_elim (use \<open>0 < e\<close> in auto)
immler@65204
   135
qed
immler@65204
   136
immler@65204
   137
lemma uniform_limit_bcontfunE:
immler@65204
   138
  fixes f::"'i \<Rightarrow> 'a::topological_space \<Rightarrow>\<^sub>C 'b::metric_space"
immler@65204
   139
    and l::"'a::topological_space \<Rightarrow> 'b::metric_space"
immler@65204
   140
  assumes "uniform_limit UNIV f l F" "F \<noteq> bot"
immler@65204
   141
  obtains l'::"'a::topological_space \<Rightarrow>\<^sub>C 'b::metric_space"
immler@65204
   142
  where "l = l'" "(f \<longlongrightarrow> l') F"
immler@65204
   143
  by (metis (mono_tags, lifting) always_eventually apply_bcontfun apply_bcontfun_cases assms
immler@65204
   144
      mem_Collect_eq uniform_limit_bounded uniform_limit_tendsto_bcontfun uniform_limit_theorem)
immler@65204
   145
immler@65204
   146
lemma closed_PiC:
wenzelm@60421
   147
  fixes I :: "'a::metric_space set"
wenzelm@60421
   148
    and X :: "'a \<Rightarrow> 'b::complete_space set"
hoelzl@59453
   149
  assumes "\<And>i. i \<in> I \<Longrightarrow> closed (X i)"
immler@65204
   150
  shows "closed (PiC I X)"
hoelzl@59453
   151
  unfolding closed_sequential_limits
hoelzl@59453
   152
proof safe
hoelzl@59453
   153
  fix f l
immler@65204
   154
  assume seq: "\<forall>n. f n \<in> PiC I X" and lim: "f \<longlonglongrightarrow> l"
immler@65204
   155
  show "l \<in> PiC I X"
immler@65204
   156
  proof (safe intro!: mem_PiCI)
hoelzl@59453
   157
    fix x assume "x \<in> I"
wenzelm@60421
   158
    then have "closed (X x)"
wenzelm@60421
   159
      using assms by simp
immler@65204
   160
    moreover have "eventually (\<lambda>i. f i x \<in> X x) sequentially"
immler@65204
   161
      using seq \<open>x \<in> I\<close>
immler@65204
   162
      by (auto intro!: eventuallyI dest!: mem_PiCD simp: Pi_iff)
hoelzl@59453
   163
    moreover note sequentially_bot
immler@65204
   164
    moreover have "(\<lambda>n. (f n) x) \<longlonglongrightarrow> l x"
immler@65204
   165
      using tendsto_bcontfun_uniform_limit[OF lim]
immler@65204
   166
      by (rule tendsto_uniform_limitI) simp
immler@65204
   167
    ultimately show "l x \<in> X x"
hoelzl@59453
   168
      by (rule Lim_in_closed_set)
immler@65204
   169
  qed
hoelzl@59453
   170
qed
hoelzl@59453
   171
wenzelm@60421
   172
wenzelm@60420
   173
subsection \<open>Complete Space\<close>
hoelzl@59453
   174
hoelzl@59453
   175
instance bcontfun :: (metric_space, complete_space) complete_space
hoelzl@59453
   176
proof
wenzelm@60421
   177
  fix f :: "nat \<Rightarrow> ('a, 'b) bcontfun"
wenzelm@61808
   178
  assume "Cauchy f"  \<comment> \<open>Cauchy equals uniform convergence\<close>
immler@65204
   179
  then obtain g where "uniform_limit UNIV f g sequentially"
immler@65204
   180
    using uniformly_convergent_eq_cauchy[of "\<lambda>_. True" f]
immler@65204
   181
    unfolding Cauchy_def uniform_limit_sequentially_iff
wenzelm@60421
   182
    by (metis dist_fun_lt_imp_dist_val_lt)
hoelzl@59453
   183
immler@65204
   184
  from uniform_limit_bcontfunE[OF this sequentially_bot]
immler@65204
   185
  obtain l' where "g = apply_bcontfun l'" "(f \<longlonglongrightarrow> l')" by metis
immler@65204
   186
  then show "convergent f"
immler@65204
   187
    by (intro convergentI)
hoelzl@59453
   188
qed
hoelzl@59453
   189
wenzelm@60421
   190
wenzelm@60421
   191
subsection \<open>Supremum norm for a normed vector space\<close>
hoelzl@59453
   192
hoelzl@59453
   193
instantiation bcontfun :: (topological_space, real_normed_vector) real_vector
hoelzl@59453
   194
begin
hoelzl@59453
   195
immler@65204
   196
lift_definition uminus_bcontfun::"('a \<Rightarrow>\<^sub>C 'b) \<Rightarrow> 'a \<Rightarrow>\<^sub>C 'b" is "\<lambda>f x. - f x"
immler@65204
   197
  by (auto intro!: continuous_intros)
hoelzl@59453
   198
immler@65204
   199
lift_definition plus_bcontfun::"('a \<Rightarrow>\<^sub>C 'b) \<Rightarrow> ('a \<Rightarrow>\<^sub>C 'b) \<Rightarrow> 'a \<Rightarrow>\<^sub>C 'b"  is "\<lambda>f g x. f x + g x"
immler@65204
   200
  by (auto simp: intro!: continuous_intros bounded_plus_comp)
hoelzl@59453
   201
immler@65204
   202
lift_definition minus_bcontfun::"('a \<Rightarrow>\<^sub>C 'b) \<Rightarrow> ('a \<Rightarrow>\<^sub>C 'b) \<Rightarrow> 'a \<Rightarrow>\<^sub>C 'b"  is "\<lambda>f g x. f x - g x"
immler@65204
   203
  by (auto simp: intro!: continuous_intros bounded_minus_comp)
hoelzl@59453
   204
immler@65204
   205
lift_definition zero_bcontfun::"'a \<Rightarrow>\<^sub>C 'b" is "\<lambda>_. 0"
immler@65204
   206
  by (auto intro!: continuous_intros simp: image_def)
hoelzl@59453
   207
immler@65204
   208
lemma const_bcontfun_0_eq_0[simp]: "const_bcontfun 0 = 0"
immler@65204
   209
  by transfer simp
hoelzl@59453
   210
immler@65204
   211
lift_definition scaleR_bcontfun::"real \<Rightarrow> ('a \<Rightarrow>\<^sub>C 'b) \<Rightarrow> 'a \<Rightarrow>\<^sub>C 'b"  is "\<lambda>r g x. r *\<^sub>R g x"
immler@65204
   212
  by (auto simp: intro!: continuous_intros bounded_scaleR_comp)
hoelzl@59453
   213
immler@65204
   214
lemmas [simp] =
immler@65204
   215
  const_bcontfun.rep_eq
immler@65204
   216
  uminus_bcontfun.rep_eq
immler@65204
   217
  plus_bcontfun.rep_eq
immler@65204
   218
  minus_bcontfun.rep_eq
immler@65204
   219
  zero_bcontfun.rep_eq
immler@65204
   220
  scaleR_bcontfun.rep_eq
hoelzl@59453
   221
hoelzl@59453
   222
hoelzl@59453
   223
instance
immler@65204
   224
  by standard (auto intro!: bcontfun_eqI simp: algebra_simps)
wenzelm@60421
   225
hoelzl@59453
   226
end
hoelzl@59453
   227
immler@65204
   228
lemma bounded_norm_le_SUP_norm:
immler@65204
   229
  "bounded (range f) \<Longrightarrow> norm (f x) \<le> (SUP x. norm (f x))"
immler@65204
   230
  by (auto intro!: cSUP_upper bounded_imp_bdd_above simp: bounded_norm_comp)
immler@65204
   231
hoelzl@59453
   232
instantiation bcontfun :: (topological_space, real_normed_vector) real_normed_vector
hoelzl@59453
   233
begin
hoelzl@59453
   234
wenzelm@60421
   235
definition norm_bcontfun :: "('a, 'b) bcontfun \<Rightarrow> real"
wenzelm@60421
   236
  where "norm_bcontfun f = dist f 0"
hoelzl@59453
   237
hoelzl@59453
   238
definition "sgn (f::('a,'b) bcontfun) = f /\<^sub>R norm f"
hoelzl@59453
   239
hoelzl@59453
   240
instance
hoelzl@59453
   241
proof
wenzelm@60421
   242
  fix a :: real
wenzelm@60421
   243
  fix f g :: "('a, 'b) bcontfun"
hoelzl@59453
   244
  show "dist f g = norm (f - g)"
immler@65204
   245
    unfolding norm_bcontfun_def
immler@65204
   246
    by transfer (simp add: dist_norm)
hoelzl@59453
   247
  show "norm (f + g) \<le> norm f + norm g"
hoelzl@59453
   248
    unfolding norm_bcontfun_def
immler@65204
   249
    by transfer
immler@65204
   250
      (auto intro!: cSUP_least norm_triangle_le add_mono bounded_norm_le_SUP_norm simp: dist_norm)
hoelzl@59453
   251
  show "norm (a *\<^sub>R f) = \<bar>a\<bar> * norm f"
immler@65204
   252
    unfolding norm_bcontfun_def
immler@65204
   253
    apply transfer
immler@65204
   254
    by (rule trans[OF _ continuous_at_Sup_mono[symmetric]])
immler@65204
   255
      (auto intro!: monoI mult_left_mono continuous_intros bounded_imp_bdd_above
immler@65204
   256
        simp: bounded_norm_comp)
hoelzl@59453
   257
qed (auto simp: norm_bcontfun_def sgn_bcontfun_def)
hoelzl@59453
   258
hoelzl@59453
   259
end
hoelzl@59453
   260
hoelzl@59453
   261
lemma norm_bounded:
wenzelm@60421
   262
  fixes f :: "('a::topological_space, 'b::real_normed_vector) bcontfun"
immler@65204
   263
  shows "norm (apply_bcontfun f x) \<le> norm f"
hoelzl@59453
   264
  using dist_bounded[of f x 0]
immler@65204
   265
  by (simp add: dist_norm)
hoelzl@59453
   266
hoelzl@59453
   267
lemma norm_bound:
wenzelm@60421
   268
  fixes f :: "('a::topological_space, 'b::real_normed_vector) bcontfun"
immler@65204
   269
  assumes "\<And>x. norm (apply_bcontfun f x) \<le> b"
hoelzl@59453
   270
  shows "norm f \<le> b"
hoelzl@59453
   271
  using dist_bound[of f 0 b] assms
immler@65204
   272
  by (simp add: dist_norm)
hoelzl@59453
   273
immler@65204
   274
subsection \<open>(bounded) continuous extenstion\<close>
hoelzl@59453
   275
hoelzl@59453
   276
lemma integral_clamp:
hoelzl@59453
   277
  "integral {t0::real..clamp t0 t1 x} f =
hoelzl@59453
   278
    (if x < t0 then 0 else if x \<le> t1 then integral {t0..x} f else integral {t0..t1} f)"
hoelzl@59453
   279
  by (auto simp: clamp_def)
hoelzl@59453
   280
immler@65204
   281
lemma continuous_on_interval_bcontfunE:
immler@65204
   282
  fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::metric_space"
immler@65204
   283
  assumes "continuous_on {a .. b} f"
immler@65204
   284
  obtains g::"'a \<Rightarrow>\<^sub>C 'b" where
immler@65204
   285
    "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> g x = f x"
immler@65204
   286
    "\<And>x. g x = f (clamp a b x)"
immler@65204
   287
proof -
immler@65204
   288
  define g where "g \<equiv> ext_cont f a b"
immler@65204
   289
  have "continuous_on UNIV g"
immler@65204
   290
    using assms
immler@65204
   291
    by (auto intro!: continuous_on_ext_cont simp: g_def cbox_interval)
immler@65204
   292
  moreover
immler@65204
   293
  have "bounded (range g)"
immler@65204
   294
    by (auto simp: g_def ext_cont_def cbox_interval
immler@65204
   295
        intro!: compact_interval clamp_bounded compact_imp_bounded[OF compact_continuous_image] assms)
immler@65204
   296
  ultimately
immler@65204
   297
  obtain h where h: "g = apply_bcontfun h" by (rule bcontfunE)
immler@65204
   298
  then have "h x = f x" if "a \<le> x" "x \<le> b" for x
immler@65204
   299
    by (auto simp: h[symmetric] g_def cbox_interval that)
immler@65204
   300
  moreover
immler@65204
   301
  have "h x = f (clamp a b x)" for x
immler@65204
   302
    by (auto simp: h[symmetric] g_def ext_cont_def)
immler@65204
   303
  ultimately show ?thesis ..
immler@65204
   304
qed
hoelzl@59453
   305
immler@65204
   306
lifting_update bcontfun.lifting
immler@65204
   307
lifting_forget bcontfun.lifting
hoelzl@59453
   308
hoelzl@59453
   309
end