src/HOL/Library/Product_Vector.thy
author wenzelm
Mon Apr 25 16:09:26 2016 +0200 (2016-04-25)
changeset 63040 eb4ddd18d635
parent 62367 d2bc8a7e5fec
permissions -rw-r--r--
eliminated old 'def';
tuned comments;
huffman@30019
     1
(*  Title:      HOL/Library/Product_Vector.thy
huffman@30019
     2
    Author:     Brian Huffman
huffman@30019
     3
*)
huffman@30019
     4
wenzelm@60500
     5
section \<open>Cartesian Products as Vector Spaces\<close>
huffman@30019
     6
huffman@30019
     7
theory Product_Vector
huffman@30019
     8
imports Inner_Product Product_plus
huffman@30019
     9
begin
huffman@30019
    10
wenzelm@60500
    11
subsection \<open>Product is a real vector space\<close>
huffman@30019
    12
haftmann@37678
    13
instantiation prod :: (real_vector, real_vector) real_vector
huffman@30019
    14
begin
huffman@30019
    15
huffman@30019
    16
definition scaleR_prod_def:
huffman@30019
    17
  "scaleR r A = (scaleR r (fst A), scaleR r (snd A))"
huffman@30019
    18
huffman@30019
    19
lemma fst_scaleR [simp]: "fst (scaleR r A) = scaleR r (fst A)"
huffman@30019
    20
  unfolding scaleR_prod_def by simp
huffman@30019
    21
huffman@30019
    22
lemma snd_scaleR [simp]: "snd (scaleR r A) = scaleR r (snd A)"
huffman@30019
    23
  unfolding scaleR_prod_def by simp
huffman@30019
    24
huffman@30019
    25
lemma scaleR_Pair [simp]: "scaleR r (a, b) = (scaleR r a, scaleR r b)"
huffman@30019
    26
  unfolding scaleR_prod_def by simp
huffman@30019
    27
wenzelm@60679
    28
instance
wenzelm@60679
    29
proof
huffman@30019
    30
  fix a b :: real and x y :: "'a \<times> 'b"
huffman@30019
    31
  show "scaleR a (x + y) = scaleR a x + scaleR a y"
huffman@44066
    32
    by (simp add: prod_eq_iff scaleR_right_distrib)
huffman@30019
    33
  show "scaleR (a + b) x = scaleR a x + scaleR b x"
huffman@44066
    34
    by (simp add: prod_eq_iff scaleR_left_distrib)
huffman@30019
    35
  show "scaleR a (scaleR b x) = scaleR (a * b) x"
huffman@44066
    36
    by (simp add: prod_eq_iff)
huffman@30019
    37
  show "scaleR 1 x = x"
huffman@44066
    38
    by (simp add: prod_eq_iff)
huffman@30019
    39
qed
huffman@30019
    40
huffman@30019
    41
end
huffman@30019
    42
wenzelm@60500
    43
subsection \<open>Product is a metric space\<close>
huffman@31339
    44
hoelzl@62101
    45
(* TODO: Product of uniform spaces and compatibility with metric_spaces! *)
hoelzl@62101
    46
hoelzl@62101
    47
instantiation prod :: (metric_space, metric_space) dist
huffman@31339
    48
begin
huffman@31339
    49
immler@54779
    50
definition dist_prod_def[code del]:
wenzelm@53015
    51
  "dist x y = sqrt ((dist (fst x) (fst y))\<^sup>2 + (dist (snd x) (snd y))\<^sup>2)"
huffman@31339
    52
hoelzl@62101
    53
instance ..
hoelzl@62101
    54
end
hoelzl@62101
    55
hoelzl@62101
    56
instantiation prod :: (metric_space, metric_space) uniformity_dist
hoelzl@62101
    57
begin
hoelzl@62101
    58
hoelzl@62101
    59
definition [code del]:
hoelzl@62102
    60
  "(uniformity :: (('a \<times> 'b) \<times> ('a \<times> 'b)) filter) =
hoelzl@62101
    61
    (INF e:{0 <..}. principal {(x, y). dist x y < e})"
hoelzl@62101
    62
hoelzl@62102
    63
instance
hoelzl@62101
    64
  by standard (rule uniformity_prod_def)
hoelzl@62101
    65
end
hoelzl@62101
    66
hoelzl@62102
    67
declare uniformity_Abort[where 'a="'a :: metric_space \<times> 'b :: metric_space", code]
hoelzl@62102
    68
hoelzl@62101
    69
instantiation prod :: (metric_space, metric_space) metric_space
hoelzl@62101
    70
begin
hoelzl@62101
    71
wenzelm@53015
    72
lemma dist_Pair_Pair: "dist (a, b) (c, d) = sqrt ((dist a c)\<^sup>2 + (dist b d)\<^sup>2)"
huffman@31339
    73
  unfolding dist_prod_def by simp
huffman@31339
    74
huffman@36332
    75
lemma dist_fst_le: "dist (fst x) (fst y) \<le> dist x y"
huffman@53930
    76
  unfolding dist_prod_def by (rule real_sqrt_sum_squares_ge1)
huffman@36332
    77
huffman@36332
    78
lemma dist_snd_le: "dist (snd x) (snd y) \<le> dist x y"
huffman@53930
    79
  unfolding dist_prod_def by (rule real_sqrt_sum_squares_ge2)
huffman@36332
    80
wenzelm@60679
    81
instance
wenzelm@60679
    82
proof
huffman@31339
    83
  fix x y :: "'a \<times> 'b"
huffman@31339
    84
  show "dist x y = 0 \<longleftrightarrow> x = y"
huffman@44066
    85
    unfolding dist_prod_def prod_eq_iff by simp
huffman@31339
    86
next
huffman@31339
    87
  fix x y z :: "'a \<times> 'b"
huffman@31339
    88
  show "dist x y \<le> dist x z + dist y z"
huffman@31339
    89
    unfolding dist_prod_def
huffman@31563
    90
    by (intro order_trans [OF _ real_sqrt_sum_squares_triangle_ineq]
huffman@31563
    91
        real_sqrt_le_mono add_mono power_mono dist_triangle2 zero_le_dist)
huffman@31415
    92
next
huffman@31492
    93
  fix S :: "('a \<times> 'b) set"
hoelzl@62101
    94
  have *: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
huffman@31563
    95
  proof
huffman@36332
    96
    assume "open S" show "\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S"
huffman@36332
    97
    proof
huffman@36332
    98
      fix x assume "x \<in> S"
huffman@36332
    99
      obtain A B where "open A" "open B" "x \<in> A \<times> B" "A \<times> B \<subseteq> S"
wenzelm@60500
   100
        using \<open>open S\<close> and \<open>x \<in> S\<close> by (rule open_prod_elim)
huffman@36332
   101
      obtain r where r: "0 < r" "\<forall>y. dist y (fst x) < r \<longrightarrow> y \<in> A"
wenzelm@60500
   102
        using \<open>open A\<close> and \<open>x \<in> A \<times> B\<close> unfolding open_dist by auto
huffman@36332
   103
      obtain s where s: "0 < s" "\<forall>y. dist y (snd x) < s \<longrightarrow> y \<in> B"
wenzelm@60500
   104
        using \<open>open B\<close> and \<open>x \<in> A \<times> B\<close> unfolding open_dist by auto
huffman@36332
   105
      let ?e = "min r s"
huffman@36332
   106
      have "0 < ?e \<and> (\<forall>y. dist y x < ?e \<longrightarrow> y \<in> S)"
huffman@36332
   107
      proof (intro allI impI conjI)
huffman@36332
   108
        show "0 < min r s" by (simp add: r(1) s(1))
huffman@36332
   109
      next
huffman@36332
   110
        fix y assume "dist y x < min r s"
huffman@36332
   111
        hence "dist y x < r" and "dist y x < s"
huffman@36332
   112
          by simp_all
huffman@36332
   113
        hence "dist (fst y) (fst x) < r" and "dist (snd y) (snd x) < s"
huffman@36332
   114
          by (auto intro: le_less_trans dist_fst_le dist_snd_le)
huffman@36332
   115
        hence "fst y \<in> A" and "snd y \<in> B"
huffman@36332
   116
          by (simp_all add: r(2) s(2))
huffman@36332
   117
        hence "y \<in> A \<times> B" by (induct y, simp)
wenzelm@60500
   118
        with \<open>A \<times> B \<subseteq> S\<close> show "y \<in> S" ..
huffman@36332
   119
      qed
huffman@36332
   120
      thus "\<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S" ..
huffman@36332
   121
    qed
huffman@31563
   122
  next
huffman@44575
   123
    assume *: "\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S" show "open S"
huffman@44575
   124
    proof (rule open_prod_intro)
huffman@44575
   125
      fix x assume "x \<in> S"
huffman@44575
   126
      then obtain e where "0 < e" and S: "\<forall>y. dist y x < e \<longrightarrow> y \<in> S"
huffman@44575
   127
        using * by fast
wenzelm@63040
   128
      define r where "r = e / sqrt 2"
wenzelm@63040
   129
      define s where "s = e / sqrt 2"
wenzelm@60500
   130
      from \<open>0 < e\<close> have "0 < r" and "0 < s"
nipkow@56541
   131
        unfolding r_def s_def by simp_all
wenzelm@60500
   132
      from \<open>0 < e\<close> have "e = sqrt (r\<^sup>2 + s\<^sup>2)"
huffman@44575
   133
        unfolding r_def s_def by (simp add: power_divide)
wenzelm@63040
   134
      define A where "A = {y. dist (fst x) y < r}"
wenzelm@63040
   135
      define B where "B = {y. dist (snd x) y < s}"
huffman@44575
   136
      have "open A" and "open B"
huffman@44575
   137
        unfolding A_def B_def by (simp_all add: open_ball)
huffman@44575
   138
      moreover have "x \<in> A \<times> B"
huffman@44575
   139
        unfolding A_def B_def mem_Times_iff
wenzelm@60500
   140
        using \<open>0 < r\<close> and \<open>0 < s\<close> by simp
huffman@44575
   141
      moreover have "A \<times> B \<subseteq> S"
huffman@44575
   142
      proof (clarify)
huffman@44575
   143
        fix a b assume "a \<in> A" and "b \<in> B"
huffman@44575
   144
        hence "dist a (fst x) < r" and "dist b (snd x) < s"
huffman@44575
   145
          unfolding A_def B_def by (simp_all add: dist_commute)
huffman@44575
   146
        hence "dist (a, b) x < e"
wenzelm@60500
   147
          unfolding dist_prod_def \<open>e = sqrt (r\<^sup>2 + s\<^sup>2)\<close>
huffman@44575
   148
          by (simp add: add_strict_mono power_strict_mono)
huffman@44575
   149
        thus "(a, b) \<in> S"
huffman@44575
   150
          by (simp add: S)
huffman@44575
   151
      qed
huffman@44575
   152
      ultimately show "\<exists>A B. open A \<and> open B \<and> x \<in> A \<times> B \<and> A \<times> B \<subseteq> S" by fast
huffman@44575
   153
    qed
huffman@31563
   154
  qed
hoelzl@62101
   155
  show "open S = (\<forall>x\<in>S. \<forall>\<^sub>F (x', y) in uniformity. x' = x \<longrightarrow> y \<in> S)"
hoelzl@62101
   156
    unfolding * eventually_uniformity_metric
hoelzl@62101
   157
    by (simp del: split_paired_All add: dist_prod_def dist_commute)
huffman@31339
   158
qed
huffman@31339
   159
huffman@31339
   160
end
huffman@31339
   161
haftmann@54890
   162
declare [[code abort: "dist::('a::metric_space*'b::metric_space)\<Rightarrow>('a*'b) \<Rightarrow> real"]]
immler@54779
   163
huffman@31405
   164
lemma Cauchy_fst: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. fst (X n))"
huffman@53930
   165
  unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_fst_le])
huffman@31405
   166
huffman@31405
   167
lemma Cauchy_snd: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. snd (X n))"
huffman@53930
   168
  unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_snd_le])
huffman@31405
   169
huffman@31405
   170
lemma Cauchy_Pair:
huffman@31405
   171
  assumes "Cauchy X" and "Cauchy Y"
huffman@31405
   172
  shows "Cauchy (\<lambda>n. (X n, Y n))"
huffman@31405
   173
proof (rule metric_CauchyI)
huffman@31405
   174
  fix r :: real assume "0 < r"
nipkow@56541
   175
  hence "0 < r / sqrt 2" (is "0 < ?s") by simp
huffman@31405
   176
  obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < ?s"
wenzelm@60500
   177
    using metric_CauchyD [OF \<open>Cauchy X\<close> \<open>0 < ?s\<close>] ..
huffman@31405
   178
  obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. dist (Y m) (Y n) < ?s"
wenzelm@60500
   179
    using metric_CauchyD [OF \<open>Cauchy Y\<close> \<open>0 < ?s\<close>] ..
huffman@31405
   180
  have "\<forall>m\<ge>max M N. \<forall>n\<ge>max M N. dist (X m, Y m) (X n, Y n) < r"
huffman@31405
   181
    using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair)
huffman@31405
   182
  then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" ..
huffman@31405
   183
qed
huffman@31405
   184
wenzelm@60500
   185
subsection \<open>Product is a complete metric space\<close>
huffman@31405
   186
haftmann@37678
   187
instance prod :: (complete_space, complete_space) complete_space
huffman@31405
   188
proof
huffman@31405
   189
  fix X :: "nat \<Rightarrow> 'a \<times> 'b" assume "Cauchy X"
wenzelm@61969
   190
  have 1: "(\<lambda>n. fst (X n)) \<longlonglongrightarrow> lim (\<lambda>n. fst (X n))"
wenzelm@60500
   191
    using Cauchy_fst [OF \<open>Cauchy X\<close>]
huffman@31405
   192
    by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff)
wenzelm@61969
   193
  have 2: "(\<lambda>n. snd (X n)) \<longlonglongrightarrow> lim (\<lambda>n. snd (X n))"
wenzelm@60500
   194
    using Cauchy_snd [OF \<open>Cauchy X\<close>]
huffman@31405
   195
    by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff)
wenzelm@61969
   196
  have "X \<longlonglongrightarrow> (lim (\<lambda>n. fst (X n)), lim (\<lambda>n. snd (X n)))"
huffman@36660
   197
    using tendsto_Pair [OF 1 2] by simp
huffman@31405
   198
  then show "convergent X"
huffman@31405
   199
    by (rule convergentI)
huffman@31405
   200
qed
huffman@31405
   201
wenzelm@60500
   202
subsection \<open>Product is a normed vector space\<close>
huffman@30019
   203
haftmann@37678
   204
instantiation prod :: (real_normed_vector, real_normed_vector) real_normed_vector
huffman@30019
   205
begin
huffman@30019
   206
immler@54779
   207
definition norm_prod_def[code del]:
wenzelm@53015
   208
  "norm x = sqrt ((norm (fst x))\<^sup>2 + (norm (snd x))\<^sup>2)"
huffman@30019
   209
huffman@30019
   210
definition sgn_prod_def:
huffman@30019
   211
  "sgn (x::'a \<times> 'b) = scaleR (inverse (norm x)) x"
huffman@30019
   212
wenzelm@53015
   213
lemma norm_Pair: "norm (a, b) = sqrt ((norm a)\<^sup>2 + (norm b)\<^sup>2)"
huffman@30019
   214
  unfolding norm_prod_def by simp
huffman@30019
   215
wenzelm@60679
   216
instance
wenzelm@60679
   217
proof
huffman@30019
   218
  fix r :: real and x y :: "'a \<times> 'b"
huffman@30019
   219
  show "norm x = 0 \<longleftrightarrow> x = 0"
huffman@30019
   220
    unfolding norm_prod_def
huffman@44066
   221
    by (simp add: prod_eq_iff)
huffman@30019
   222
  show "norm (x + y) \<le> norm x + norm y"
huffman@30019
   223
    unfolding norm_prod_def
huffman@30019
   224
    apply (rule order_trans [OF _ real_sqrt_sum_squares_triangle_ineq])
huffman@30019
   225
    apply (simp add: add_mono power_mono norm_triangle_ineq)
huffman@30019
   226
    done
huffman@30019
   227
  show "norm (scaleR r x) = \<bar>r\<bar> * norm x"
huffman@30019
   228
    unfolding norm_prod_def
huffman@31587
   229
    apply (simp add: power_mult_distrib)
webertj@49962
   230
    apply (simp add: distrib_left [symmetric])
huffman@30019
   231
    apply (simp add: real_sqrt_mult_distrib)
huffman@30019
   232
    done
huffman@30019
   233
  show "sgn x = scaleR (inverse (norm x)) x"
huffman@30019
   234
    by (rule sgn_prod_def)
huffman@31290
   235
  show "dist x y = norm (x - y)"
huffman@31339
   236
    unfolding dist_prod_def norm_prod_def
huffman@31339
   237
    by (simp add: dist_norm)
huffman@30019
   238
qed
huffman@30019
   239
huffman@30019
   240
end
huffman@30019
   241
haftmann@54890
   242
declare [[code abort: "norm::('a::real_normed_vector*'b::real_normed_vector) \<Rightarrow> real"]]
immler@54779
   243
haftmann@37678
   244
instance prod :: (banach, banach) banach ..
huffman@31405
   245
wenzelm@60500
   246
subsubsection \<open>Pair operations are linear\<close>
huffman@30019
   247
huffman@44282
   248
lemma bounded_linear_fst: "bounded_linear fst"
huffman@44127
   249
  using fst_add fst_scaleR
huffman@44127
   250
  by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def)
huffman@30019
   251
huffman@44282
   252
lemma bounded_linear_snd: "bounded_linear snd"
huffman@44127
   253
  using snd_add snd_scaleR
huffman@44127
   254
  by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def)
huffman@30019
   255
immler@61915
   256
lemmas bounded_linear_fst_comp = bounded_linear_fst[THEN bounded_linear_compose]
immler@61915
   257
immler@61915
   258
lemmas bounded_linear_snd_comp = bounded_linear_snd[THEN bounded_linear_compose]
immler@61915
   259
huffman@30019
   260
lemma bounded_linear_Pair:
huffman@30019
   261
  assumes f: "bounded_linear f"
huffman@30019
   262
  assumes g: "bounded_linear g"
huffman@30019
   263
  shows "bounded_linear (\<lambda>x. (f x, g x))"
huffman@30019
   264
proof
huffman@30019
   265
  interpret f: bounded_linear f by fact
huffman@30019
   266
  interpret g: bounded_linear g by fact
huffman@30019
   267
  fix x y and r :: real
huffman@30019
   268
  show "(f (x + y), g (x + y)) = (f x, g x) + (f y, g y)"
huffman@30019
   269
    by (simp add: f.add g.add)
huffman@30019
   270
  show "(f (r *\<^sub>R x), g (r *\<^sub>R x)) = r *\<^sub>R (f x, g x)"
huffman@30019
   271
    by (simp add: f.scaleR g.scaleR)
huffman@30019
   272
  obtain Kf where "0 < Kf" and norm_f: "\<And>x. norm (f x) \<le> norm x * Kf"
huffman@30019
   273
    using f.pos_bounded by fast
huffman@30019
   274
  obtain Kg where "0 < Kg" and norm_g: "\<And>x. norm (g x) \<le> norm x * Kg"
huffman@30019
   275
    using g.pos_bounded by fast
huffman@30019
   276
  have "\<forall>x. norm (f x, g x) \<le> norm x * (Kf + Kg)"
huffman@30019
   277
    apply (rule allI)
huffman@30019
   278
    apply (simp add: norm_Pair)
huffman@30019
   279
    apply (rule order_trans [OF sqrt_add_le_add_sqrt], simp, simp)
webertj@49962
   280
    apply (simp add: distrib_left)
huffman@30019
   281
    apply (rule add_mono [OF norm_f norm_g])
huffman@30019
   282
    done
huffman@30019
   283
  then show "\<exists>K. \<forall>x. norm (f x, g x) \<le> norm x * K" ..
huffman@30019
   284
qed
huffman@30019
   285
wenzelm@60500
   286
subsubsection \<open>Frechet derivatives involving pairs\<close>
huffman@30019
   287
hoelzl@56381
   288
lemma has_derivative_Pair [derivative_intros]:
hoelzl@56181
   289
  assumes f: "(f has_derivative f') (at x within s)" and g: "(g has_derivative g') (at x within s)"
hoelzl@56181
   290
  shows "((\<lambda>x. (f x, g x)) has_derivative (\<lambda>h. (f' h, g' h))) (at x within s)"
hoelzl@56181
   291
proof (rule has_derivativeI_sandwich[of 1])
huffman@44575
   292
  show "bounded_linear (\<lambda>h. (f' h, g' h))"
hoelzl@56181
   293
    using f g by (intro bounded_linear_Pair has_derivative_bounded_linear)
hoelzl@51642
   294
  let ?Rf = "\<lambda>y. f y - f x - f' (y - x)"
hoelzl@51642
   295
  let ?Rg = "\<lambda>y. g y - g x - g' (y - x)"
hoelzl@51642
   296
  let ?R = "\<lambda>y. ((f y, g y) - (f x, g x) - (f' (y - x), g' (y - x)))"
hoelzl@51642
   297
wenzelm@61973
   298
  show "((\<lambda>y. norm (?Rf y) / norm (y - x) + norm (?Rg y) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)"
hoelzl@56181
   299
    using f g by (intro tendsto_add_zero) (auto simp: has_derivative_iff_norm)
hoelzl@51642
   300
hoelzl@51642
   301
  fix y :: 'a assume "y \<noteq> x"
hoelzl@51642
   302
  show "norm (?R y) / norm (y - x) \<le> norm (?Rf y) / norm (y - x) + norm (?Rg y) / norm (y - x)"
hoelzl@51642
   303
    unfolding add_divide_distrib [symmetric]
hoelzl@51642
   304
    by (simp add: norm_Pair divide_right_mono order_trans [OF sqrt_add_le_add_sqrt])
hoelzl@51642
   305
qed simp
hoelzl@51642
   306
hoelzl@56381
   307
lemmas has_derivative_fst [derivative_intros] = bounded_linear.has_derivative [OF bounded_linear_fst]
hoelzl@56381
   308
lemmas has_derivative_snd [derivative_intros] = bounded_linear.has_derivative [OF bounded_linear_snd]
hoelzl@51642
   309
hoelzl@56381
   310
lemma has_derivative_split [derivative_intros]:
hoelzl@51642
   311
  "((\<lambda>p. f (fst p) (snd p)) has_derivative f') F \<Longrightarrow> ((\<lambda>(a, b). f a b) has_derivative f') F"
hoelzl@51642
   312
  unfolding split_beta' .
huffman@44575
   313
wenzelm@60500
   314
subsection \<open>Product is an inner product space\<close>
huffman@44575
   315
huffman@44575
   316
instantiation prod :: (real_inner, real_inner) real_inner
huffman@44575
   317
begin
huffman@44575
   318
huffman@44575
   319
definition inner_prod_def:
huffman@44575
   320
  "inner x y = inner (fst x) (fst y) + inner (snd x) (snd y)"
huffman@44575
   321
huffman@44575
   322
lemma inner_Pair [simp]: "inner (a, b) (c, d) = inner a c + inner b d"
huffman@44575
   323
  unfolding inner_prod_def by simp
huffman@44575
   324
wenzelm@60679
   325
instance
wenzelm@60679
   326
proof
huffman@44575
   327
  fix r :: real
huffman@44575
   328
  fix x y z :: "'a::real_inner \<times> 'b::real_inner"
huffman@44575
   329
  show "inner x y = inner y x"
huffman@44575
   330
    unfolding inner_prod_def
huffman@44575
   331
    by (simp add: inner_commute)
huffman@44575
   332
  show "inner (x + y) z = inner x z + inner y z"
huffman@44575
   333
    unfolding inner_prod_def
huffman@44575
   334
    by (simp add: inner_add_left)
huffman@44575
   335
  show "inner (scaleR r x) y = r * inner x y"
huffman@44575
   336
    unfolding inner_prod_def
webertj@49962
   337
    by (simp add: distrib_left)
huffman@44575
   338
  show "0 \<le> inner x x"
huffman@44575
   339
    unfolding inner_prod_def
huffman@44575
   340
    by (intro add_nonneg_nonneg inner_ge_zero)
huffman@44575
   341
  show "inner x x = 0 \<longleftrightarrow> x = 0"
huffman@44575
   342
    unfolding inner_prod_def prod_eq_iff
huffman@44575
   343
    by (simp add: add_nonneg_eq_0_iff)
huffman@44575
   344
  show "norm x = sqrt (inner x x)"
huffman@44575
   345
    unfolding norm_prod_def inner_prod_def
huffman@44575
   346
    by (simp add: power2_norm_eq_inner)
huffman@44575
   347
qed
huffman@30019
   348
huffman@30019
   349
end
huffman@44575
   350
hoelzl@59425
   351
lemma inner_Pair_0: "inner x (0, b) = inner (snd x) b" "inner x (a, 0) = inner (fst x) a"
hoelzl@59425
   352
    by (cases x, simp)+
hoelzl@59425
   353
hoelzl@62102
   354
lemma
lp15@60615
   355
  fixes x :: "'a::real_normed_vector"
hoelzl@62102
   356
  shows norm_Pair1 [simp]: "norm (0,x) = norm x"
lp15@60615
   357
    and norm_Pair2 [simp]: "norm (x,0) = norm x"
lp15@60615
   358
by (auto simp: norm_Pair)
lp15@60615
   359
paulson@62131
   360
lemma norm_commute: "norm (x,y) = norm (y,x)"
paulson@62131
   361
  by (simp add: norm_Pair)
paulson@62131
   362
paulson@62131
   363
lemma norm_fst_le: "norm x \<le> norm (x,y)"
paulson@62131
   364
  by (metis dist_fst_le fst_conv fst_zero norm_conv_dist)
paulson@62131
   365
paulson@62131
   366
lemma norm_snd_le: "norm y \<le> norm (x,y)"
paulson@62131
   367
  by (metis dist_snd_le snd_conv snd_zero norm_conv_dist)
hoelzl@59425
   368
huffman@44575
   369
end