src/HOL/Multivariate_Analysis/Ordered_Euclidean_Space.thy
author hoelzl
Fri Feb 19 13:40:50 2016 +0100 (2016-02-19)
changeset 62378 85ed00c1fe7c
parent 62376 85f38d5f8807
child 62620 d21dab28b3f9
permissions -rw-r--r--
generalize more theorems to support enat and ennreal
immler@54780
     1
theory Ordered_Euclidean_Space
immler@54780
     2
imports
immler@56189
     3
  Cartesian_Euclidean_Space
immler@54780
     4
  "~~/src/HOL/Library/Product_Order"
immler@54780
     5
begin
immler@54780
     6
wenzelm@60420
     7
subsection \<open>An ordering on euclidean spaces that will allow us to talk about intervals\<close>
immler@54780
     8
immler@54780
     9
class ordered_euclidean_space = ord + inf + sup + abs + Inf + Sup + euclidean_space +
immler@54780
    10
  assumes eucl_le: "x \<le> y \<longleftrightarrow> (\<forall>i\<in>Basis. x \<bullet> i \<le> y \<bullet> i)"
immler@54780
    11
  assumes eucl_less_le_not_le: "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x"
immler@54780
    12
  assumes eucl_inf: "inf x y = (\<Sum>i\<in>Basis. inf (x \<bullet> i) (y \<bullet> i) *\<^sub>R i)"
immler@54780
    13
  assumes eucl_sup: "sup x y = (\<Sum>i\<in>Basis. sup (x \<bullet> i) (y \<bullet> i) *\<^sub>R i)"
immler@54780
    14
  assumes eucl_Inf: "Inf X = (\<Sum>i\<in>Basis. (INF x:X. x \<bullet> i) *\<^sub>R i)"
immler@54780
    15
  assumes eucl_Sup: "Sup X = (\<Sum>i\<in>Basis. (SUP x:X. x \<bullet> i) *\<^sub>R i)"
wenzelm@61945
    16
  assumes eucl_abs: "\<bar>x\<bar> = (\<Sum>i\<in>Basis. \<bar>x \<bullet> i\<bar> *\<^sub>R i)"
immler@54780
    17
begin
immler@54780
    18
immler@54780
    19
subclass order
wenzelm@61169
    20
  by standard
immler@54780
    21
    (auto simp: eucl_le eucl_less_le_not_le intro!: euclidean_eqI antisym intro: order.trans)
immler@54780
    22
immler@54780
    23
subclass ordered_ab_group_add_abs
wenzelm@61169
    24
  by standard (auto simp: eucl_le inner_add_left eucl_abs abs_leI)
immler@54780
    25
immler@54780
    26
subclass ordered_real_vector
wenzelm@61169
    27
  by standard (auto simp: eucl_le intro!: mult_left_mono mult_right_mono)
immler@54780
    28
immler@54780
    29
subclass lattice
wenzelm@61169
    30
  by standard (auto simp: eucl_inf eucl_sup eucl_le)
immler@54780
    31
immler@54780
    32
subclass distrib_lattice
wenzelm@61169
    33
  by standard (auto simp: eucl_inf eucl_sup sup_inf_distrib1 intro!: euclidean_eqI)
immler@54780
    34
immler@54780
    35
subclass conditionally_complete_lattice
immler@54780
    36
proof
immler@54780
    37
  fix z::'a and X::"'a set"
immler@54780
    38
  assume "X \<noteq> {}"
immler@54780
    39
  hence "\<And>i. (\<lambda>x. x \<bullet> i) ` X \<noteq> {}" by simp
immler@54780
    40
  thus "(\<And>x. x \<in> X \<Longrightarrow> z \<le> x) \<Longrightarrow> z \<le> Inf X" "(\<And>x. x \<in> X \<Longrightarrow> x \<le> z) \<Longrightarrow> Sup X \<le> z"
haftmann@62343
    41
    by (auto simp: eucl_Inf eucl_Sup eucl_le
immler@54780
    42
      intro!: cInf_greatest cSup_least)
immler@54780
    43
qed (force intro!: cInf_lower cSup_upper
immler@54780
    44
      simp: bdd_below_def bdd_above_def preorder_class.bdd_below_def preorder_class.bdd_above_def
haftmann@62343
    45
        eucl_Inf eucl_Sup eucl_le)+
immler@54780
    46
immler@54780
    47
lemma inner_Basis_inf_left: "i \<in> Basis \<Longrightarrow> inf x y \<bullet> i = inf (x \<bullet> i) (y \<bullet> i)"
immler@54780
    48
  and inner_Basis_sup_left: "i \<in> Basis \<Longrightarrow> sup x y \<bullet> i = sup (x \<bullet> i) (y \<bullet> i)"
haftmann@57418
    49
  by (simp_all add: eucl_inf eucl_sup inner_setsum_left inner_Basis if_distrib comm_monoid_add_class.setsum.delta
immler@54780
    50
      cong: if_cong)
immler@54780
    51
immler@54780
    52
lemma inner_Basis_INF_left: "i \<in> Basis \<Longrightarrow> (INF x:X. f x) \<bullet> i = (INF x:X. f x \<bullet> i)"
immler@54780
    53
  and inner_Basis_SUP_left: "i \<in> Basis \<Longrightarrow> (SUP x:X. f x) \<bullet> i = (SUP x:X. f x \<bullet> i)"
haftmann@56166
    54
  using eucl_Sup [of "f ` X"] eucl_Inf [of "f ` X"] by (simp_all add: comp_def)
immler@54780
    55
wenzelm@61945
    56
lemma abs_inner: "i \<in> Basis \<Longrightarrow> \<bar>x\<bar> \<bullet> i = \<bar>x \<bullet> i\<bar>"
immler@54780
    57
  by (auto simp: eucl_abs)
immler@54780
    58
immler@54780
    59
lemma
immler@54780
    60
  abs_scaleR: "\<bar>a *\<^sub>R b\<bar> = \<bar>a\<bar> *\<^sub>R \<bar>b\<bar>"
immler@54780
    61
  by (auto simp: eucl_abs abs_mult intro!: euclidean_eqI)
immler@54780
    62
immler@54780
    63
lemma interval_inner_leI:
immler@54780
    64
  assumes "x \<in> {a .. b}" "0 \<le> i"
immler@54780
    65
  shows "a\<bullet>i \<le> x\<bullet>i" "x\<bullet>i \<le> b\<bullet>i"
immler@54780
    66
  using assms
immler@54780
    67
  unfolding euclidean_inner[of a i] euclidean_inner[of x i] euclidean_inner[of b i]
hoelzl@62376
    68
  by (auto intro!: ordered_comm_monoid_add_class.setsum_mono mult_right_mono simp: eucl_le)
immler@54780
    69
immler@54780
    70
lemma inner_nonneg_nonneg:
immler@54780
    71
  shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a \<bullet> b"
immler@54780
    72
  using interval_inner_leI[of a 0 a b]
immler@54780
    73
  by auto
immler@54780
    74
immler@54780
    75
lemma inner_Basis_mono:
immler@54780
    76
  shows "a \<le> b \<Longrightarrow> c \<in> Basis  \<Longrightarrow> a \<bullet> c \<le> b \<bullet> c"
immler@54780
    77
  by (simp add: eucl_le)
immler@54780
    78
immler@54780
    79
lemma Basis_nonneg[intro, simp]: "i \<in> Basis \<Longrightarrow> 0 \<le> i"
immler@54780
    80
  by (auto simp: eucl_le inner_Basis)
immler@54780
    81
immler@54781
    82
lemma Sup_eq_maximum_componentwise:
immler@54781
    83
  fixes s::"'a set"
immler@54781
    84
  assumes i: "\<And>b. b \<in> Basis \<Longrightarrow> X \<bullet> b = i b \<bullet> b"
immler@54781
    85
  assumes sup: "\<And>b x. b \<in> Basis \<Longrightarrow> x \<in> s \<Longrightarrow> x \<bullet> b \<le> X \<bullet> b"
immler@54781
    86
  assumes i_s: "\<And>b. b \<in> Basis \<Longrightarrow> (i b \<bullet> b) \<in> (\<lambda>x. x \<bullet> b) ` s"
immler@54781
    87
  shows "Sup s = X"
immler@54781
    88
  using assms
immler@54781
    89
  unfolding eucl_Sup euclidean_representation_setsum
haftmann@62343
    90
  by (auto intro!: conditionally_complete_lattice_class.cSup_eq_maximum)
immler@54781
    91
immler@54781
    92
lemma Inf_eq_minimum_componentwise:
immler@54781
    93
  assumes i: "\<And>b. b \<in> Basis \<Longrightarrow> X \<bullet> b = i b \<bullet> b"
immler@54781
    94
  assumes sup: "\<And>b x. b \<in> Basis \<Longrightarrow> x \<in> s \<Longrightarrow> X \<bullet> b \<le> x \<bullet> b"
immler@54781
    95
  assumes i_s: "\<And>b. b \<in> Basis \<Longrightarrow> (i b \<bullet> b) \<in> (\<lambda>x. x \<bullet> b) ` s"
immler@54781
    96
  shows "Inf s = X"
immler@54781
    97
  using assms
immler@54781
    98
  unfolding eucl_Inf euclidean_representation_setsum
haftmann@62343
    99
  by (auto intro!: conditionally_complete_lattice_class.cInf_eq_minimum)
immler@54781
   100
immler@54780
   101
end
immler@54780
   102
immler@54781
   103
lemma
immler@54781
   104
  compact_attains_Inf_componentwise:
immler@54781
   105
  fixes b::"'a::ordered_euclidean_space"
immler@54781
   106
  assumes "b \<in> Basis" assumes "X \<noteq> {}" "compact X"
immler@54781
   107
  obtains x where "x \<in> X" "x \<bullet> b = Inf X \<bullet> b" "\<And>y. y \<in> X \<Longrightarrow> x \<bullet> b \<le> y \<bullet> b"
immler@54781
   108
proof atomize_elim
immler@54781
   109
  let ?proj = "(\<lambda>x. x \<bullet> b) ` X"
immler@54781
   110
  from assms have "compact ?proj" "?proj \<noteq> {}"
hoelzl@56371
   111
    by (auto intro!: compact_continuous_image continuous_intros)
immler@54781
   112
  from compact_attains_inf[OF this]
immler@54781
   113
  obtain s x
immler@54781
   114
    where s: "s\<in>(\<lambda>x. x \<bullet> b) ` X" "\<And>t. t\<in>(\<lambda>x. x \<bullet> b) ` X \<Longrightarrow> s \<le> t"
immler@54781
   115
      and x: "x \<in> X" "s = x \<bullet> b" "\<And>y. y \<in> X \<Longrightarrow> x \<bullet> b \<le> y \<bullet> b"
immler@54781
   116
    by auto
immler@54781
   117
  hence "Inf ?proj = x \<bullet> b"
haftmann@62343
   118
    by (auto intro!: conditionally_complete_lattice_class.cInf_eq_minimum)
immler@54781
   119
  hence "x \<bullet> b = Inf X \<bullet> b"
haftmann@62343
   120
    by (auto simp: eucl_Inf inner_setsum_left inner_Basis if_distrib \<open>b \<in> Basis\<close> setsum.delta
haftmann@56166
   121
      cong: if_cong)
immler@54781
   122
  with x show "\<exists>x. x \<in> X \<and> x \<bullet> b = Inf X \<bullet> b \<and> (\<forall>y. y \<in> X \<longrightarrow> x \<bullet> b \<le> y \<bullet> b)" by blast
immler@54781
   123
qed
immler@54781
   124
immler@54781
   125
lemma
immler@54781
   126
  compact_attains_Sup_componentwise:
immler@54781
   127
  fixes b::"'a::ordered_euclidean_space"
immler@54781
   128
  assumes "b \<in> Basis" assumes "X \<noteq> {}" "compact X"
immler@54781
   129
  obtains x where "x \<in> X" "x \<bullet> b = Sup X \<bullet> b" "\<And>y. y \<in> X \<Longrightarrow> y \<bullet> b \<le> x \<bullet> b"
immler@54781
   130
proof atomize_elim
immler@54781
   131
  let ?proj = "(\<lambda>x. x \<bullet> b) ` X"
immler@54781
   132
  from assms have "compact ?proj" "?proj \<noteq> {}"
hoelzl@56371
   133
    by (auto intro!: compact_continuous_image continuous_intros)
immler@54781
   134
  from compact_attains_sup[OF this]
immler@54781
   135
  obtain s x
immler@54781
   136
    where s: "s\<in>(\<lambda>x. x \<bullet> b) ` X" "\<And>t. t\<in>(\<lambda>x. x \<bullet> b) ` X \<Longrightarrow> t \<le> s"
immler@54781
   137
      and x: "x \<in> X" "s = x \<bullet> b" "\<And>y. y \<in> X \<Longrightarrow> y \<bullet> b \<le> x \<bullet> b"
immler@54781
   138
    by auto
immler@54781
   139
  hence "Sup ?proj = x \<bullet> b"
haftmann@62343
   140
    by (auto intro!: cSup_eq_maximum)
immler@54781
   141
  hence "x \<bullet> b = Sup X \<bullet> b"
haftmann@62343
   142
    by (auto simp: eucl_Sup[where 'a='a] inner_setsum_left inner_Basis if_distrib \<open>b \<in> Basis\<close> setsum.delta
haftmann@62343
   143
      cong: if_cong)
immler@54781
   144
  with x show "\<exists>x. x \<in> X \<and> x \<bullet> b = Sup X \<bullet> b \<and> (\<forall>y. y \<in> X \<longrightarrow> y \<bullet> b \<le> x \<bullet> b)" by blast
immler@54781
   145
qed
immler@54781
   146
immler@54780
   147
lemma (in order) atLeastatMost_empty'[simp]:
immler@54780
   148
  "(~ a <= b) \<Longrightarrow> {a..b} = {}"
immler@54780
   149
  by (auto)
immler@54780
   150
immler@54780
   151
instance real :: ordered_euclidean_space
haftmann@62343
   152
  by standard auto
immler@54780
   153
immler@54780
   154
lemma in_Basis_prod_iff:
immler@54780
   155
  fixes i::"'a::euclidean_space*'b::euclidean_space"
immler@54780
   156
  shows "i \<in> Basis \<longleftrightarrow> fst i = 0 \<and> snd i \<in> Basis \<or> snd i = 0 \<and> fst i \<in> Basis"
immler@54780
   157
  by (cases i) (auto simp: Basis_prod_def)
immler@54780
   158
wenzelm@61945
   159
instantiation prod :: (abs, abs) abs
immler@54780
   160
begin
immler@54780
   161
wenzelm@61945
   162
definition "\<bar>x\<bar> = (\<bar>fst x\<bar>, \<bar>snd x\<bar>)"
immler@54780
   163
wenzelm@61945
   164
instance ..
wenzelm@61945
   165
immler@54780
   166
end
immler@54780
   167
immler@54780
   168
instance prod :: (ordered_euclidean_space, ordered_euclidean_space) ordered_euclidean_space
wenzelm@61169
   169
  by standard
immler@54780
   170
    (auto intro!: add_mono simp add: euclidean_representation_setsum'  Ball_def inner_prod_def
immler@54780
   171
      in_Basis_prod_iff inner_Basis_inf_left inner_Basis_sup_left inner_Basis_INF_left Inf_prod_def
immler@54780
   172
      inner_Basis_SUP_left Sup_prod_def less_prod_def less_eq_prod_def eucl_le[where 'a='a]
immler@54780
   173
      eucl_le[where 'a='b] abs_prod_def abs_inner)
immler@54780
   174
wenzelm@61808
   175
text\<open>Instantiation for intervals on \<open>ordered_euclidean_space\<close>\<close>
immler@56188
   176
immler@56188
   177
lemma
wenzelm@61076
   178
  fixes a :: "'a::ordered_euclidean_space"
immler@56188
   179
  shows cbox_interval: "cbox a b = {a..b}"
immler@56188
   180
    and interval_cbox: "{a..b} = cbox a b"
immler@56188
   181
    and eucl_le_atMost: "{x. \<forall>i\<in>Basis. x \<bullet> i <= a \<bullet> i} = {..a}"
immler@56188
   182
    and eucl_le_atLeast: "{x. \<forall>i\<in>Basis. a \<bullet> i <= x \<bullet> i} = {a..}"
immler@56188
   183
    by (auto simp: eucl_le[where 'a='a] eucl_less_def box_def cbox_def)
immler@56188
   184
immler@56188
   185
lemma closed_eucl_atLeastAtMost[simp, intro]:
wenzelm@61076
   186
  fixes a :: "'a::ordered_euclidean_space"
immler@56188
   187
  shows "closed {a..b}"
immler@56188
   188
  by (simp add: cbox_interval[symmetric] closed_cbox)
immler@56188
   189
immler@56188
   190
lemma closed_eucl_atMost[simp, intro]:
wenzelm@61076
   191
  fixes a :: "'a::ordered_euclidean_space"
immler@56188
   192
  shows "closed {..a}"
immler@56188
   193
  by (simp add: eucl_le_atMost[symmetric])
immler@56188
   194
immler@56188
   195
lemma closed_eucl_atLeast[simp, intro]:
wenzelm@61076
   196
  fixes a :: "'a::ordered_euclidean_space"
immler@56188
   197
  shows "closed {a..}"
immler@56188
   198
  by (simp add: eucl_le_atLeast[symmetric])
immler@56188
   199
immler@56189
   200
lemma bounded_closed_interval:
immler@56189
   201
  fixes a :: "'a::ordered_euclidean_space"
immler@56189
   202
  shows "bounded {a .. b}"
immler@56189
   203
  using bounded_cbox[of a b]
immler@56189
   204
  by (metis interval_cbox)
immler@56189
   205
immler@56190
   206
lemma convex_closed_interval:
immler@56190
   207
  fixes a :: "'a::ordered_euclidean_space"
immler@56190
   208
  shows "convex {a .. b}"
immler@56190
   209
  using convex_box[of a b]
immler@56190
   210
  by (metis interval_cbox)
immler@56190
   211
immler@56188
   212
lemma image_smult_interval:"(\<lambda>x. m *\<^sub>R (x::_::ordered_euclidean_space)) ` {a .. b} =
immler@56188
   213
  (if {a .. b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a .. m *\<^sub>R b} else {m *\<^sub>R b .. m *\<^sub>R a})"
immler@56188
   214
  using image_smult_cbox[of m a b]
immler@56188
   215
  by (simp add: cbox_interval)
immler@54780
   216
immler@56189
   217
lemma is_interval_closed_interval:
immler@56189
   218
  "is_interval {a .. (b::'a::ordered_euclidean_space)}"
immler@56189
   219
  by (metis cbox_interval is_interval_cbox)
immler@56189
   220
immler@56190
   221
lemma compact_interval:
immler@56190
   222
  fixes a b::"'a::ordered_euclidean_space"
immler@56190
   223
  shows "compact {a .. b}"
immler@56190
   224
  by (metis compact_cbox interval_cbox)
immler@56190
   225
immler@54780
   226
no_notation
immler@54780
   227
  eucl_less (infix "<e" 50)
immler@54780
   228
immler@56189
   229
lemma One_nonneg: "0 \<le> (\<Sum>Basis::'a::ordered_euclidean_space)"
immler@56189
   230
  by (auto intro: setsum_nonneg)
immler@56189
   231
immler@56189
   232
lemma content_closed_interval:
immler@56189
   233
  fixes a :: "'a::ordered_euclidean_space"
immler@56189
   234
  assumes "a \<le> b"
immler@56189
   235
  shows "content {a .. b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
immler@56189
   236
  using content_cbox[of a b] assms
immler@56189
   237
  by (simp add: cbox_interval eucl_le[where 'a='a])
immler@56189
   238
immler@56189
   239
lemma integrable_const_ivl[intro]:
immler@56189
   240
  fixes a::"'a::ordered_euclidean_space"
immler@56189
   241
  shows "(\<lambda>x. c) integrable_on {a .. b}"
immler@56189
   242
  unfolding cbox_interval[symmetric]
immler@56189
   243
  by (rule integrable_const)
immler@56189
   244
immler@56189
   245
lemma integrable_on_subinterval:
immler@56189
   246
  fixes f :: "'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
immler@56189
   247
  assumes "f integrable_on s"
immler@56189
   248
    and "{a .. b} \<subseteq> s"
immler@56189
   249
  shows "f integrable_on {a .. b}"
immler@56189
   250
  using integrable_on_subcbox[of f s a b] assms
immler@56189
   251
  by (simp add: cbox_interval)
immler@56189
   252
immler@56190
   253
lemma
immler@56190
   254
  fixes a b::"'a::ordered_euclidean_space"
immler@56190
   255
  shows bdd_above_cbox[intro, simp]: "bdd_above (cbox a b)"
immler@56190
   256
    and bdd_below_cbox[intro, simp]: "bdd_below (cbox a b)"
immler@56190
   257
    and bdd_above_box[intro, simp]: "bdd_above (box a b)"
immler@56190
   258
    and bdd_below_box[intro, simp]: "bdd_below (box a b)"
immler@56190
   259
  unfolding atomize_conj
immler@56190
   260
  by (metis bdd_above_Icc bdd_above_mono bdd_below_Icc bdd_below_mono bounded_box
immler@56190
   261
    bounded_subset_cbox interval_cbox)
immler@56190
   262
immler@56189
   263
instantiation vec :: (ordered_euclidean_space, finite) ordered_euclidean_space
immler@56189
   264
begin
immler@56189
   265
immler@56189
   266
definition "inf x y = (\<chi> i. inf (x $ i) (y $ i))"
immler@56189
   267
definition "sup x y = (\<chi> i. sup (x $ i) (y $ i))"
immler@56189
   268
definition "Inf X = (\<chi> i. (INF x:X. x $ i))"
immler@56189
   269
definition "Sup X = (\<chi> i. (SUP x:X. x $ i))"
wenzelm@61945
   270
definition "\<bar>x\<bar> = (\<chi> i. \<bar>x $ i\<bar>)"
immler@56189
   271
immler@56189
   272
instance
wenzelm@61169
   273
  apply standard
immler@56189
   274
  unfolding euclidean_representation_setsum'
immler@56189
   275
  apply (auto simp: less_eq_vec_def inf_vec_def sup_vec_def Inf_vec_def Sup_vec_def inner_axis
immler@56189
   276
    Basis_vec_def inner_Basis_inf_left inner_Basis_sup_left inner_Basis_INF_left
immler@56189
   277
    inner_Basis_SUP_left eucl_le[where 'a='a] less_le_not_le abs_vec_def abs_inner)
immler@56189
   278
  done
immler@56189
   279
immler@54780
   280
end
immler@56189
   281
immler@56189
   282
end
immler@56189
   283