src/HOL/Multivariate_Analysis/Bounded_Continuous_Function.thy
author paulson
Mon, 21 Sep 2015 19:52:13 +0100
changeset 61204 3e491e34a62e
parent 61169 4de9ff3ea29a
child 61260 e6f03fae14d5
permissions -rw-r--r--
new lemmas and movement of lemmas into place
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60017
diff changeset
     1
section \<open>Bounded Continuous Functions\<close>
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
     2
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
     3
theory Bounded_Continuous_Function
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
     4
imports Integration
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
     5
begin
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
     6
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
     7
subsection \<open>Definition\<close>
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
     8
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
     9
definition bcontfun :: "('a::topological_space \<Rightarrow> 'b::metric_space) set"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    10
  where "bcontfun = {f. continuous_on UNIV f \<and> bounded (range f)}"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    11
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    12
typedef ('a, 'b) bcontfun = "bcontfun :: ('a::topological_space \<Rightarrow> 'b::metric_space) set"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    13
  by (auto simp: bcontfun_def intro: continuous_intros simp: bounded_def)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    14
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    15
lemma bcontfunE:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    16
  assumes "f \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    17
  obtains y where "continuous_on UNIV f" "\<And>x. dist (f x) u \<le> y"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    18
  using assms unfolding bcontfun_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    19
  by (metis (lifting) bounded_any_center dist_commute mem_Collect_eq rangeI)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    20
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    21
lemma bcontfunE':
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    22
  assumes "f \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    23
  obtains y where "continuous_on UNIV f" "\<And>x. dist (f x) undefined \<le> y"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    24
  using assms bcontfunE
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    25
  by metis
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    26
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    27
lemma bcontfunI: "continuous_on UNIV f \<Longrightarrow> (\<And>x. dist (f x) u \<le> b) \<Longrightarrow> f \<in> bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    28
  unfolding bcontfun_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    29
  by (metis (lifting, no_types) bounded_def dist_commute mem_Collect_eq rangeE)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    30
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    31
lemma bcontfunI': "continuous_on UNIV f \<Longrightarrow> (\<And>x. dist (f x) undefined \<le> b) \<Longrightarrow> f \<in> bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    32
  using bcontfunI by metis
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    33
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    34
lemma continuous_on_Rep_bcontfun[intro, simp]: "continuous_on T (Rep_bcontfun x)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    35
  using Rep_bcontfun[of x]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    36
  by (auto simp: bcontfun_def intro: continuous_on_subset)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    37
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    38
instantiation bcontfun :: (topological_space, metric_space) metric_space
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    39
begin
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    40
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    41
definition dist_bcontfun :: "('a, 'b) bcontfun \<Rightarrow> ('a, 'b) bcontfun \<Rightarrow> real"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    42
  where "dist_bcontfun f g = (SUP x. dist (Rep_bcontfun f x) (Rep_bcontfun g x))"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    43
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    44
definition open_bcontfun :: "('a, 'b) bcontfun set \<Rightarrow> bool"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    45
  where "open_bcontfun S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    46
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    47
lemma dist_bounded:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    48
  fixes f :: "('a, 'b) bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    49
  shows "dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le> dist f g"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    50
proof -
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    51
  have "Rep_bcontfun f \<in> bcontfun" by (rule Rep_bcontfun)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    52
  from bcontfunE'[OF this] obtain y where y:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    53
    "continuous_on UNIV (Rep_bcontfun f)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    54
    "\<And>x. dist (Rep_bcontfun f x) undefined \<le> y"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    55
    by auto
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    56
  have "Rep_bcontfun g \<in> bcontfun" by (rule Rep_bcontfun)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    57
  from bcontfunE'[OF this] obtain z where z:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    58
    "continuous_on UNIV (Rep_bcontfun g)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    59
    "\<And>x. dist (Rep_bcontfun g x) undefined \<le> z"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    60
    by auto
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    61
  show ?thesis
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    62
    unfolding dist_bcontfun_def
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    63
  proof (intro cSUP_upper bdd_aboveI2)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    64
    fix x
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    65
    have "dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le>
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    66
      dist (Rep_bcontfun f x) undefined + dist (Rep_bcontfun g x) undefined"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    67
      by (rule dist_triangle2)
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    68
    also have "\<dots> \<le> y + z"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    69
      using y(2)[of x] z(2)[of x] by (rule add_mono)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    70
    finally show "dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le> y + z" .
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    71
  qed simp
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    72
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    73
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    74
lemma dist_bound:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    75
  fixes f :: "('a, 'b) bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    76
  assumes "\<And>x. dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le> b"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    77
  shows "dist f g \<le> b"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    78
  using assms by (auto simp: dist_bcontfun_def intro: cSUP_least)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    79
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    80
lemma dist_bounded_Abs:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    81
  fixes f g :: "'a \<Rightarrow> 'b"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    82
  assumes "f \<in> bcontfun" "g \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    83
  shows "dist (f x) (g x) \<le> dist (Abs_bcontfun f) (Abs_bcontfun g)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    84
  by (metis Abs_bcontfun_inverse assms dist_bounded)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    85
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    86
lemma const_bcontfun: "(\<lambda>x::'a. b::'b) \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    87
  by (auto intro: bcontfunI continuous_on_const)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    88
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    89
lemma dist_fun_lt_imp_dist_val_lt:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    90
  assumes "dist f g < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    91
  shows "dist (Rep_bcontfun f x) (Rep_bcontfun g x) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    92
  using dist_bounded assms by (rule le_less_trans)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    93
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    94
lemma dist_val_lt_imp_dist_fun_le:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    95
  assumes "\<forall>x. dist (Rep_bcontfun f x) (Rep_bcontfun g x) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    96
  shows "dist f g \<le> e"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
    97
  unfolding dist_bcontfun_def
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    98
proof (intro cSUP_least)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
    99
  fix x
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   100
  show "dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le> e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   101
    using assms[THEN spec[where x=x]] by (simp add: dist_norm)
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   102
qed simp
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   103
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   104
instance
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   105
proof
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   106
  fix f g h :: "('a, 'b) bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   107
  show "dist f g = 0 \<longleftrightarrow> f = g"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   108
  proof
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   109
    have "\<And>x. dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le> dist f g"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   110
      by (rule dist_bounded)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   111
    also assume "dist f g = 0"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   112
    finally show "f = g"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   113
      by (auto simp: Rep_bcontfun_inject[symmetric] Abs_bcontfun_inverse)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   114
  qed (auto simp: dist_bcontfun_def SUP_def simp del: Sup_image_eq intro!: cSup_eq)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   115
  show "dist f g \<le> dist f h + dist g h"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   116
  proof (subst dist_bcontfun_def, safe intro!: cSUP_least)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   117
    fix x
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   118
    have "dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le>
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   119
      dist (Rep_bcontfun f x) (Rep_bcontfun h x) + dist (Rep_bcontfun g x) (Rep_bcontfun h x)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   120
      by (rule dist_triangle2)
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   121
    also have "dist (Rep_bcontfun f x) (Rep_bcontfun h x) \<le> dist f h"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   122
      by (rule dist_bounded)
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   123
    also have "dist (Rep_bcontfun g x) (Rep_bcontfun h x) \<le> dist g h"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   124
      by (rule dist_bounded)
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   125
    finally show "dist (Rep_bcontfun f x) (Rep_bcontfun g x) \<le> dist f h + dist g h"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   126
      by simp
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   127
  qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   128
qed (simp add: open_bcontfun_def)
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   129
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   130
end
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   131
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   132
lemma closed_Pi_bcontfun:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   133
  fixes I :: "'a::metric_space set"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   134
    and X :: "'a \<Rightarrow> 'b::complete_space set"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   135
  assumes "\<And>i. i \<in> I \<Longrightarrow> closed (X i)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   136
  shows "closed (Abs_bcontfun ` (Pi I X \<inter> bcontfun))"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   137
  unfolding closed_sequential_limits
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   138
proof safe
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   139
  fix f l
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   140
  assume seq: "\<forall>n. f n \<in> Abs_bcontfun ` (Pi I X \<inter> bcontfun)" and lim: "f ----> l"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   141
  have lim_fun: "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x. dist (Rep_bcontfun (f n) x) (Rep_bcontfun l x) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   142
    using LIMSEQ_imp_Cauchy[OF lim, simplified Cauchy_def] metric_LIMSEQ_D[OF lim]
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   143
    by (intro uniformly_cauchy_imp_uniformly_convergent[where P="\<lambda>_. True", simplified])
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   144
      (metis dist_fun_lt_imp_dist_val_lt)+
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   145
  show "l \<in> Abs_bcontfun ` (Pi I X \<inter> bcontfun)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   146
  proof (rule, safe)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   147
    fix x assume "x \<in> I"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   148
    then have "closed (X x)"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   149
      using assms by simp
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   150
    moreover have "eventually (\<lambda>xa. Rep_bcontfun (f xa) x \<in> X x) sequentially"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   151
    proof (rule always_eventually, safe)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   152
      fix i
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60017
diff changeset
   153
      from seq[THEN spec, of i] \<open>x \<in> I\<close>
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   154
      show "Rep_bcontfun (f i) x \<in> X x"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   155
        by (auto simp: Abs_bcontfun_inverse)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   156
    qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   157
    moreover note sequentially_bot
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   158
    moreover have "(\<lambda>n. Rep_bcontfun (f n) x) ----> Rep_bcontfun l x"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   159
      using lim_fun by (blast intro!: metric_LIMSEQ_I)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   160
    ultimately show "Rep_bcontfun l x \<in> X x"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   161
      by (rule Lim_in_closed_set)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   162
  qed (auto simp: Rep_bcontfun Rep_bcontfun_inverse)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   163
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   164
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   165
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60017
diff changeset
   166
subsection \<open>Complete Space\<close>
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   167
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   168
instance bcontfun :: (metric_space, complete_space) complete_space
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   169
proof
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   170
  fix f :: "nat \<Rightarrow> ('a, 'b) bcontfun"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   171
  assume "Cauchy f"  -- \<open>Cauchy equals uniform convergence\<close>
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   172
  then obtain g where limit_function:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   173
    "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x. dist (Rep_bcontfun (f n) x) (g x) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   174
    using uniformly_convergent_eq_cauchy[of "\<lambda>_. True"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   175
      "\<lambda>n. Rep_bcontfun (f n)"]
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   176
    unfolding Cauchy_def
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   177
    by (metis dist_fun_lt_imp_dist_val_lt)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   178
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   179
  then obtain N where fg_dist:  -- \<open>for an upper bound on @{term g}\<close>
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   180
    "\<forall>n\<ge>N. \<forall>x. dist (g x) ( Rep_bcontfun (f n) x) < 1"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   181
    by (force simp add: dist_commute)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   182
  from bcontfunE'[OF Rep_bcontfun, of "f N"] obtain b where
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   183
    f_bound: "\<forall>x. dist (Rep_bcontfun (f N) x) undefined \<le> b"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   184
    by force
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   185
  have "g \<in> bcontfun"  -- \<open>The limit function is bounded and continuous\<close>
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   186
  proof (intro bcontfunI)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   187
    show "continuous_on UNIV g"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   188
      using bcontfunE[OF Rep_bcontfun] limit_function
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   189
      by (intro continuous_uniform_limit[where f="\<lambda>n. Rep_bcontfun (f n)" and F="sequentially"])
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   190
        (auto simp add: eventually_sequentially trivial_limit_def dist_norm)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   191
  next
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   192
    fix x
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   193
    from fg_dist have "dist (g x) (Rep_bcontfun (f N) x) < 1"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   194
      by (simp add: dist_norm norm_minus_commute)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   195
    with dist_triangle[of "g x" undefined "Rep_bcontfun (f N) x"]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   196
    show "dist (g x) undefined \<le> 1 + b" using f_bound[THEN spec, of x]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   197
      by simp
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   198
  qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   199
  show "convergent f"
60017
b785d6d06430 Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
paulson <lp15@cam.ac.uk>
parents: 59865
diff changeset
   200
  proof (rule convergentI, subst lim_sequentially, safe)
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   201
    -- \<open>The limit function converges according to its norm\<close>
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   202
    fix e :: real
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   203
    assume "e > 0"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   204
    then have "e/2 > 0" by simp
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   205
    with limit_function[THEN spec, of"e/2"]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   206
    have "\<exists>N. \<forall>n\<ge>N. \<forall>x. dist (Rep_bcontfun (f n) x) (g x) < e/2"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   207
      by simp
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   208
    then obtain N where N: "\<forall>n\<ge>N. \<forall>x. dist (Rep_bcontfun (f n) x) (g x) < e / 2" by auto
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   209
    show "\<exists>N. \<forall>n\<ge>N. dist (f n) (Abs_bcontfun g) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   210
    proof (rule, safe)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   211
      fix n
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   212
      assume "N \<le> n"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   213
      with N show "dist (f n) (Abs_bcontfun g) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   214
        using dist_val_lt_imp_dist_fun_le[of
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   215
          "f n" "Abs_bcontfun g" "e/2"]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60017
diff changeset
   216
          Abs_bcontfun_inverse[OF \<open>g \<in> bcontfun\<close>] \<open>e > 0\<close> by simp
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   217
    qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   218
  qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   219
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   220
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   221
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   222
subsection \<open>Supremum norm for a normed vector space\<close>
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   223
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   224
instantiation bcontfun :: (topological_space, real_normed_vector) real_vector
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   225
begin
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   226
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   227
definition "-f = Abs_bcontfun (\<lambda>x. -(Rep_bcontfun f x))"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   228
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   229
definition "f + g = Abs_bcontfun (\<lambda>x. Rep_bcontfun f x + Rep_bcontfun g x)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   230
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   231
definition "f - g = Abs_bcontfun (\<lambda>x. Rep_bcontfun f x - Rep_bcontfun g x)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   232
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   233
definition "0 = Abs_bcontfun (\<lambda>x. 0)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   234
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   235
definition "scaleR r f = Abs_bcontfun (\<lambda>x. r *\<^sub>R Rep_bcontfun f x)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   236
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   237
lemma plus_cont:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   238
  fixes f g :: "'a \<Rightarrow> 'b"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   239
  assumes f: "f \<in> bcontfun"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   240
    and g: "g \<in> bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   241
  shows "(\<lambda>x. f x + g x) \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   242
proof -
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   243
  from bcontfunE'[OF f] obtain y where "continuous_on UNIV f" "\<And>x. dist (f x) undefined \<le> y"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   244
    by auto
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   245
  moreover
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   246
  from bcontfunE'[OF g] obtain z where "continuous_on UNIV g" "\<And>x. dist (g x) undefined \<le> z"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   247
    by auto
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   248
  ultimately show ?thesis
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   249
  proof (intro bcontfunI)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   250
    fix x
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   251
    have "dist (f x + g x) 0 = dist (f x + g x) (0 + 0)"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   252
      by simp
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   253
    also have "\<dots> \<le> dist (f x) 0 + dist (g x) 0"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   254
      by (rule dist_triangle_add)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   255
    also have "\<dots> \<le> dist (Abs_bcontfun f) 0 + dist (Abs_bcontfun g) 0"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   256
      unfolding zero_bcontfun_def using assms
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   257
      by (auto intro!: add_mono dist_bounded_Abs const_bcontfun)
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   258
    finally show "dist (f x + g x) 0 \<le> dist (Abs_bcontfun f) 0 + dist (Abs_bcontfun g) 0" .
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   259
  qed (simp add: continuous_on_add)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   260
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   261
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   262
lemma Rep_bcontfun_plus[simp]: "Rep_bcontfun (f + g) x = Rep_bcontfun f x + Rep_bcontfun g x"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   263
  by (simp add: plus_bcontfun_def Abs_bcontfun_inverse plus_cont Rep_bcontfun)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   264
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   265
lemma uminus_cont:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   266
  fixes f :: "'a \<Rightarrow> 'b"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   267
  assumes "f \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   268
  shows "(\<lambda>x. - f x) \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   269
proof -
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   270
  from bcontfunE[OF assms, of 0] obtain y
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   271
    where "continuous_on UNIV f" "\<And>x. dist (f x) 0 \<le> y"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   272
    by auto
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   273
  then show ?thesis
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   274
  proof (intro bcontfunI)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   275
    fix x
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   276
    assume "\<And>x. dist (f x) 0 \<le> y"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   277
    then show "dist (- f x) 0 \<le> y"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   278
      by (subst dist_minus[symmetric]) simp
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   279
  qed (simp add: continuous_on_minus)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   280
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   281
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   282
lemma Rep_bcontfun_uminus[simp]: "Rep_bcontfun (- f) x = - Rep_bcontfun f x"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   283
  by (simp add: uminus_bcontfun_def Abs_bcontfun_inverse uminus_cont Rep_bcontfun)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   284
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   285
lemma minus_cont:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   286
  fixes f g :: "'a \<Rightarrow> 'b"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   287
  assumes f: "f \<in> bcontfun"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   288
    and g: "g \<in> bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   289
  shows "(\<lambda>x. f x - g x) \<in> bcontfun"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   290
  using plus_cont [of f "- g"] assms
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   291
  by (simp add: uminus_cont fun_Compl_def)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   292
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   293
lemma Rep_bcontfun_minus[simp]: "Rep_bcontfun (f - g) x = Rep_bcontfun f x - Rep_bcontfun g x"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   294
  by (simp add: minus_bcontfun_def Abs_bcontfun_inverse minus_cont Rep_bcontfun)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   295
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   296
lemma scaleR_cont:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   297
  fixes a :: real
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   298
    and f :: "'a \<Rightarrow> 'b"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   299
  assumes "f \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   300
  shows " (\<lambda>x. a *\<^sub>R f x) \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   301
proof -
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   302
  from bcontfunE[OF assms, of 0] obtain y
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   303
    where "continuous_on UNIV f" "\<And>x. dist (f x) 0 \<le> y"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   304
    by auto
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   305
  then show ?thesis
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   306
  proof (intro bcontfunI)
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   307
    fix x
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   308
    assume "\<And>x. dist (f x) 0 \<le> y"
59554
4044f53326c9 inlined rules to free user-space from technical names
haftmann
parents: 59453
diff changeset
   309
    then show "dist (a *\<^sub>R f x) 0 \<le> abs a * y"
4044f53326c9 inlined rules to free user-space from technical names
haftmann
parents: 59453
diff changeset
   310
      by (metis norm_cmul_rule_thm norm_conv_dist)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   311
  qed (simp add: continuous_intros)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   312
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   313
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   314
lemma Rep_bcontfun_scaleR[simp]: "Rep_bcontfun (a *\<^sub>R g) x = a *\<^sub>R Rep_bcontfun g x"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   315
  by (simp add: scaleR_bcontfun_def Abs_bcontfun_inverse scaleR_cont Rep_bcontfun)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   316
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   317
instance
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 60421
diff changeset
   318
  by standard
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   319
    (simp_all add: plus_bcontfun_def zero_bcontfun_def minus_bcontfun_def scaleR_bcontfun_def
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   320
      Abs_bcontfun_inverse Rep_bcontfun_inverse Rep_bcontfun algebra_simps
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   321
      plus_cont const_bcontfun minus_cont scaleR_cont)
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   322
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   323
end
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   324
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   325
instantiation bcontfun :: (topological_space, real_normed_vector) real_normed_vector
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   326
begin
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   327
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   328
definition norm_bcontfun :: "('a, 'b) bcontfun \<Rightarrow> real"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   329
  where "norm_bcontfun f = dist f 0"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   330
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   331
definition "sgn (f::('a,'b) bcontfun) = f /\<^sub>R norm f"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   332
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   333
instance
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   334
proof
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   335
  fix a :: real
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   336
  fix f g :: "('a, 'b) bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   337
  show "dist f g = norm (f - g)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   338
    by (simp add: norm_bcontfun_def dist_bcontfun_def zero_bcontfun_def
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   339
      Abs_bcontfun_inverse const_bcontfun norm_conv_dist[symmetric] dist_norm)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   340
  show "norm (f + g) \<le> norm f + norm g"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   341
    unfolding norm_bcontfun_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   342
  proof (subst dist_bcontfun_def, safe intro!: cSUP_least)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   343
    fix x
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   344
    have "dist (Rep_bcontfun (f + g) x) (Rep_bcontfun 0 x) \<le>
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   345
      dist (Rep_bcontfun f x) 0 + dist (Rep_bcontfun g x) 0"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   346
      by (metis (hide_lams, no_types) Rep_bcontfun_minus Rep_bcontfun_plus diff_0_right dist_norm
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   347
        le_less_linear less_irrefl norm_triangle_lt)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   348
    also have "dist (Rep_bcontfun f x) 0 \<le> dist f 0"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   349
      using dist_bounded[of f x 0]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   350
      by (simp add: Abs_bcontfun_inverse const_bcontfun zero_bcontfun_def)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   351
    also have "dist (Rep_bcontfun g x) 0 \<le> dist g 0" using dist_bounded[of g x 0]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   352
      by (simp add: Abs_bcontfun_inverse const_bcontfun zero_bcontfun_def)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   353
    finally show "dist (Rep_bcontfun (f + g) x) (Rep_bcontfun 0 x) \<le> dist f 0 + dist g 0" by simp
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   354
  qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   355
  show "norm (a *\<^sub>R f) = \<bar>a\<bar> * norm f"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   356
  proof -
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   357
    have "\<bar>a\<bar> * Sup (range (\<lambda>x. dist (Rep_bcontfun f x) 0)) =
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   358
      (SUP i:range (\<lambda>x. dist (Rep_bcontfun f x) 0). \<bar>a\<bar> * i)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   359
    proof (intro continuous_at_Sup_mono bdd_aboveI2)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   360
      fix x
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   361
      show "dist (Rep_bcontfun f x) 0 \<le> norm f" using dist_bounded[of f x 0]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   362
        by (simp add: norm_bcontfun_def norm_conv_dist Abs_bcontfun_inverse zero_bcontfun_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   363
          const_bcontfun)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   364
    qed (auto intro!: monoI mult_left_mono continuous_intros)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   365
    moreover
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   366
    have "range (\<lambda>x. dist (Rep_bcontfun (a *\<^sub>R f) x) 0) =
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   367
      (\<lambda>x. \<bar>a\<bar> * x) ` (range (\<lambda>x. dist (Rep_bcontfun f x) 0))"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   368
      by (auto simp: norm_conv_dist[symmetric])
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   369
    ultimately
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   370
    show "norm (a *\<^sub>R f) = \<bar>a\<bar> * norm f"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   371
      by (simp add: norm_bcontfun_def dist_bcontfun_def norm_conv_dist Abs_bcontfun_inverse
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   372
                    zero_bcontfun_def const_bcontfun SUP_def del: Sup_image_eq)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   373
  qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   374
qed (auto simp: norm_bcontfun_def sgn_bcontfun_def)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   375
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   376
end
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   377
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   378
lemma bcontfun_normI: "continuous_on UNIV f \<Longrightarrow> (\<And>x. norm (f x) \<le> b) \<Longrightarrow> f \<in> bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   379
  unfolding norm_conv_dist
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   380
  by (auto intro: bcontfunI)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   381
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   382
lemma norm_bounded:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   383
  fixes f :: "('a::topological_space, 'b::real_normed_vector) bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   384
  shows "norm (Rep_bcontfun f x) \<le> norm f"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   385
  using dist_bounded[of f x 0]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   386
  by (simp add: norm_bcontfun_def norm_conv_dist Abs_bcontfun_inverse zero_bcontfun_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   387
    const_bcontfun)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   388
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   389
lemma norm_bound:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   390
  fixes f :: "('a::topological_space, 'b::real_normed_vector) bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   391
  assumes "\<And>x. norm (Rep_bcontfun f x) \<le> b"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   392
  shows "norm f \<le> b"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   393
  using dist_bound[of f 0 b] assms
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   394
  by (simp add: norm_bcontfun_def norm_conv_dist Abs_bcontfun_inverse zero_bcontfun_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   395
    const_bcontfun)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   396
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   397
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   398
subsection \<open>Continuously Extended Functions\<close>
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   399
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   400
definition clamp :: "'a::euclidean_space \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a" where
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   401
  "clamp a b x = (\<Sum>i\<in>Basis. (if x\<bullet>i < a\<bullet>i then a\<bullet>i else if x\<bullet>i \<le> b\<bullet>i then x\<bullet>i else b\<bullet>i) *\<^sub>R i)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   402
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   403
definition ext_cont :: "('a::euclidean_space \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> ('a, 'b) bcontfun"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   404
  where "ext_cont f a b = Abs_bcontfun ((\<lambda>x. f (clamp a b x)))"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   405
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   406
lemma ext_cont_def':
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   407
  "ext_cont f a b = Abs_bcontfun (\<lambda>x.
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   408
    f (\<Sum>i\<in>Basis. (if x\<bullet>i < a\<bullet>i then a\<bullet>i else if x\<bullet>i \<le> b\<bullet>i then x\<bullet>i else b\<bullet>i) *\<^sub>R i))"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   409
  unfolding ext_cont_def clamp_def ..
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   410
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   411
lemma clamp_in_interval:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   412
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   413
  shows "clamp a b x \<in> cbox a b"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   414
  unfolding clamp_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   415
  using box_ne_empty(1)[of a b] assms by (auto simp: cbox_def)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   416
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   417
lemma dist_clamps_le_dist_args:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   418
  fixes x :: "'a::euclidean_space"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   419
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   420
  shows "dist (clamp a b y) (clamp a b x) \<le> dist y x"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   421
proof -
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   422
  from box_ne_empty(1)[of a b] assms have "(\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i)"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   423
    by (simp add: cbox_def)
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   424
  then have "(\<Sum>i\<in>Basis. (dist (clamp a b y \<bullet> i) (clamp a b x \<bullet> i))\<^sup>2) \<le>
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   425
    (\<Sum>i\<in>Basis. (dist (y \<bullet> i) (x \<bullet> i))\<^sup>2)"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   426
    by (auto intro!: setsum_mono simp: clamp_def dist_real_def abs_le_square_iff[symmetric])
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   427
  then show ?thesis
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   428
    by (auto intro: real_sqrt_le_mono
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   429
      simp: euclidean_dist_l2[where y=x] euclidean_dist_l2[where y="clamp a b x"] setL2_def)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   430
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   431
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   432
lemma clamp_continuous_at:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   433
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::metric_space"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   434
    and x :: 'a
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   435
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   436
    and f_cont: "continuous_on (cbox a b) f"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   437
  shows "continuous (at x) (\<lambda>x. f (clamp a b x))"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   438
  unfolding continuous_at_eps_delta
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   439
proof safe
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   440
  fix x :: 'a
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   441
  fix e :: real
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   442
  assume "e > 0"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   443
  moreover have "clamp a b x \<in> cbox a b"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   444
    by (simp add: clamp_in_interval assms)
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   445
  moreover note f_cont[simplified continuous_on_iff]
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   446
  ultimately
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   447
  obtain d where d: "0 < d"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   448
    "\<And>x'. x' \<in> cbox a b \<Longrightarrow> dist x' (clamp a b x) < d \<Longrightarrow> dist (f x') (f (clamp a b x)) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   449
    by force
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   450
  show "\<exists>d>0. \<forall>x'. dist x' x < d \<longrightarrow>
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   451
    dist (f (clamp a b x')) (f (clamp a b x)) < e"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   452
    by (auto intro!: d clamp_in_interval assms dist_clamps_le_dist_args[THEN le_less_trans])
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   453
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   454
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   455
lemma clamp_continuous_on:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   456
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::metric_space"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   457
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   458
    and f_cont: "continuous_on (cbox a b) f"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   459
  shows "continuous_on UNIV (\<lambda>x. f (clamp a b x))"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   460
  using assms
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   461
  by (auto intro: continuous_at_imp_continuous_on clamp_continuous_at)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   462
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   463
lemma clamp_bcontfun:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   464
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   465
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   466
    and continuous: "continuous_on (cbox a b) f"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   467
  shows "(\<lambda>x. f (clamp a b x)) \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   468
proof -
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   469
  have "bounded (f ` (cbox a b))"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   470
    by (rule compact_continuous_image[OF continuous compact_cbox[of a b], THEN compact_imp_bounded])
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   471
  then obtain c where f_bound: "\<forall>x\<in>f ` cbox a b. norm x \<le> c"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   472
    by (auto simp add: bounded_pos)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   473
  show "(\<lambda>x. f (clamp a b x)) \<in> bcontfun"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   474
  proof (intro bcontfun_normI)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   475
    fix x
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   476
    show "norm (f (clamp a b x)) \<le> c"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   477
      using clamp_in_interval[OF assms(1), of x] f_bound
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   478
      by (simp add: ext_cont_def)
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   479
  qed (simp add: clamp_continuous_on assms)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   480
qed
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   481
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   482
lemma integral_clamp:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   483
  "integral {t0::real..clamp t0 t1 x} f =
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   484
    (if x < t0 then 0 else if x \<le> t1 then integral {t0..x} f else integral {t0..t1} f)"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   485
  by (auto simp: clamp_def)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   486
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   487
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   488
declare [[coercion Rep_bcontfun]]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   489
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   490
lemma ext_cont_cancel[simp]:
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   491
  fixes x a b :: "'a::euclidean_space"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   492
  assumes x: "x \<in> cbox a b"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   493
    and "continuous_on (cbox a b) f"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   494
  shows "ext_cont f a b x = f x"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   495
  using assms
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   496
  unfolding ext_cont_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   497
proof (subst Abs_bcontfun_inverse[OF clamp_bcontfun])
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   498
  show "f (clamp a b x) = f x"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   499
    using x unfolding clamp_def mem_box
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   500
    by (intro arg_cong[where f=f] euclidean_eqI[where 'a='a]) (simp add: not_less)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   501
qed (auto simp: cbox_def)
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   502
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   503
lemma ext_cont_cong:
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   504
  assumes "t0 = s0"
60421
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   505
    and "t1 = s1"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   506
    and "\<And>t. t \<in> (cbox t0 t1) \<Longrightarrow> f t = g t"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   507
    and "continuous_on (cbox t0 t1) f"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   508
    and "continuous_on (cbox s0 s1) g"
92d9557fb78c misc tuning;
wenzelm
parents: 60420
diff changeset
   509
    and ord: "\<And>i. i \<in> Basis \<Longrightarrow> t0 \<bullet> i \<le> t1 \<bullet> i"
59453
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   510
  shows "ext_cont f t0 t1 = ext_cont g s0 s1"
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   511
  unfolding assms ext_cont_def
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   512
  using assms clamp_in_interval[OF ord]
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   513
  by (subst Rep_bcontfun_inject[symmetric]) simp
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   514
4736ff5a41d8 moved bcontfun from AFP/Ordinary_Differential_Equations
hoelzl
parents:
diff changeset
   515
end