src/HOL/Library/Inner_Product.thy
author huffman
Tue, 16 Aug 2011 09:31:23 -0700
changeset 44233 aa74ce315bae
parent 44126 ce44e70d0c47
child 44282 f0de18b62d63
permissions -rw-r--r--
add simp rules for isCont
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41959
b460124855b8 tuned headers;
wenzelm
parents: 39302
diff changeset
     1
(*  Title:      HOL/Library/Inner_Product.thy
b460124855b8 tuned headers;
wenzelm
parents: 39302
diff changeset
     2
    Author:     Brian Huffman
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
     3
*)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
     4
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
     5
header {* Inner Product Spaces and the Gradient Derivative *}
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
     6
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
     7
theory Inner_Product
30663
0b6aff7451b2 Main is (Complex_Main) base entry point in library theories
haftmann
parents: 30067
diff changeset
     8
imports Complex_Main FrechetDeriv
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
     9
begin
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    10
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    11
subsection {* Real inner product spaces *}
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    12
31492
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    13
text {*
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    14
  Temporarily relax type constraints for @{term "open"},
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    15
  @{term dist}, and @{term norm}.
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    16
*}
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    17
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    18
setup {* Sign.add_const_constraint
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    19
  (@{const_name "open"}, SOME @{typ "'a::open set \<Rightarrow> bool"}) *}
31446
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
    20
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
    21
setup {* Sign.add_const_constraint
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
    22
  (@{const_name dist}, SOME @{typ "'a::dist \<Rightarrow> 'a \<Rightarrow> real"}) *}
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
    23
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
    24
setup {* Sign.add_const_constraint
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
    25
  (@{const_name norm}, SOME @{typ "'a::norm \<Rightarrow> real"}) *}
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
    26
31492
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
    27
class real_inner = real_vector + sgn_div_norm + dist_norm + open_dist +
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    28
  fixes inner :: "'a \<Rightarrow> 'a \<Rightarrow> real"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    29
  assumes inner_commute: "inner x y = inner y x"
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    30
  and inner_add_left: "inner (x + y) z = inner x z + inner y z"
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    31
  and inner_scaleR_left [simp]: "inner (scaleR r x) y = r * (inner x y)"
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    32
  and inner_ge_zero [simp]: "0 \<le> inner x x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    33
  and inner_eq_zero_iff [simp]: "inner x x = 0 \<longleftrightarrow> x = 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    34
  and norm_eq_sqrt_inner: "norm x = sqrt (inner x x)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    35
begin
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    36
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    37
lemma inner_zero_left [simp]: "inner 0 x = 0"
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    38
  using inner_add_left [of 0 0 x] by simp
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    39
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    40
lemma inner_minus_left [simp]: "inner (- x) y = - inner x y"
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    41
  using inner_add_left [of x "- x" y] by simp
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    42
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    43
lemma inner_diff_left: "inner (x - y) z = inner x z - inner y z"
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    44
  by (simp add: diff_minus inner_add_left)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    45
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    46
text {* Transfer distributivity rules to right argument. *}
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    47
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    48
lemma inner_add_right: "inner x (y + z) = inner x y + inner x z"
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    49
  using inner_add_left [of y z x] by (simp only: inner_commute)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    50
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    51
lemma inner_scaleR_right [simp]: "inner x (scaleR r y) = r * (inner x y)"
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    52
  using inner_scaleR_left [of r y x] by (simp only: inner_commute)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    53
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    54
lemma inner_zero_right [simp]: "inner x 0 = 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    55
  using inner_zero_left [of x] by (simp only: inner_commute)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    56
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    57
lemma inner_minus_right [simp]: "inner x (- y) = - inner x y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    58
  using inner_minus_left [of y x] by (simp only: inner_commute)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    59
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    60
lemma inner_diff_right: "inner x (y - z) = inner x y - inner x z"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    61
  using inner_diff_left [of y z x] by (simp only: inner_commute)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    62
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    63
lemmas inner_add [algebra_simps] = inner_add_left inner_add_right
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    64
lemmas inner_diff [algebra_simps]  = inner_diff_left inner_diff_right
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    65
lemmas inner_scaleR = inner_scaleR_left inner_scaleR_right
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    66
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    67
text {* Legacy theorem names *}
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    68
lemmas inner_left_distrib = inner_add_left
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    69
lemmas inner_right_distrib = inner_add_right
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    70
lemmas inner_distrib = inner_left_distrib inner_right_distrib
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    71
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    72
lemma inner_gt_zero_iff [simp]: "0 < inner x x \<longleftrightarrow> x \<noteq> 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    73
  by (simp add: order_less_le)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    74
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    75
lemma power2_norm_eq_inner: "(norm x)\<twosuperior> = inner x x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    76
  by (simp add: norm_eq_sqrt_inner)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    77
30046
49f603f92c47 fix spelling
huffman
parents: 29993
diff changeset
    78
lemma Cauchy_Schwarz_ineq:
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    79
  "(inner x y)\<twosuperior> \<le> inner x x * inner y y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    80
proof (cases)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    81
  assume "y = 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    82
  thus ?thesis by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    83
next
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    84
  assume y: "y \<noteq> 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    85
  let ?r = "inner x y / inner y y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    86
  have "0 \<le> inner (x - scaleR ?r y) (x - scaleR ?r y)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    87
    by (rule inner_ge_zero)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    88
  also have "\<dots> = inner x x - inner y x * ?r"
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
    89
    by (simp add: inner_diff)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    90
  also have "\<dots> = inner x x - (inner x y)\<twosuperior> / inner y y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    91
    by (simp add: power2_eq_square inner_commute)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    92
  finally have "0 \<le> inner x x - (inner x y)\<twosuperior> / inner y y" .
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    93
  hence "(inner x y)\<twosuperior> / inner y y \<le> inner x x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    94
    by (simp add: le_diff_eq)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    95
  thus "(inner x y)\<twosuperior> \<le> inner x x * inner y y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    96
    by (simp add: pos_divide_le_eq y)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    97
qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
    98
30046
49f603f92c47 fix spelling
huffman
parents: 29993
diff changeset
    99
lemma Cauchy_Schwarz_ineq2:
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   100
  "\<bar>inner x y\<bar> \<le> norm x * norm y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   101
proof (rule power2_le_imp_le)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   102
  have "(inner x y)\<twosuperior> \<le> inner x x * inner y y"
30046
49f603f92c47 fix spelling
huffman
parents: 29993
diff changeset
   103
    using Cauchy_Schwarz_ineq .
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   104
  thus "\<bar>inner x y\<bar>\<twosuperior> \<le> (norm x * norm y)\<twosuperior>"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   105
    by (simp add: power_mult_distrib power2_norm_eq_inner)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   106
  show "0 \<le> norm x * norm y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   107
    unfolding norm_eq_sqrt_inner
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   108
    by (intro mult_nonneg_nonneg real_sqrt_ge_zero inner_ge_zero)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   109
qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   110
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   111
subclass real_normed_vector
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   112
proof
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   113
  fix a :: real and x y :: 'a
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   114
  show "0 \<le> norm x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   115
    unfolding norm_eq_sqrt_inner by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   116
  show "norm x = 0 \<longleftrightarrow> x = 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   117
    unfolding norm_eq_sqrt_inner by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   118
  show "norm (x + y) \<le> norm x + norm y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   119
    proof (rule power2_le_imp_le)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   120
      have "inner x y \<le> norm x * norm y"
30046
49f603f92c47 fix spelling
huffman
parents: 29993
diff changeset
   121
        by (rule order_trans [OF abs_ge_self Cauchy_Schwarz_ineq2])
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   122
      thus "(norm (x + y))\<twosuperior> \<le> (norm x + norm y)\<twosuperior>"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   123
        unfolding power2_sum power2_norm_eq_inner
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
   124
        by (simp add: inner_add inner_commute)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   125
      show "0 \<le> norm x + norm y"
44126
ce44e70d0c47 avoid duplicate rewrite warnings
huffman
parents: 41959
diff changeset
   126
        unfolding norm_eq_sqrt_inner by simp
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   127
    qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   128
  have "sqrt (a\<twosuperior> * inner x x) = \<bar>a\<bar> * sqrt (inner x x)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   129
    by (simp add: real_sqrt_mult_distrib)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   130
  then show "norm (a *\<^sub>R x) = \<bar>a\<bar> * norm x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   131
    unfolding norm_eq_sqrt_inner
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
   132
    by (simp add: power2_eq_square mult_assoc)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   133
qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   134
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   135
end
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   136
31492
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
   137
text {*
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
   138
  Re-enable constraints for @{term "open"},
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
   139
  @{term dist}, and @{term norm}.
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
   140
*}
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
   141
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
   142
setup {* Sign.add_const_constraint
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31446
diff changeset
   143
  (@{const_name "open"}, SOME @{typ "'a::topological_space set \<Rightarrow> bool"}) *}
31446
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
   144
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
   145
setup {* Sign.add_const_constraint
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
   146
  (@{const_name dist}, SOME @{typ "'a::metric_space \<Rightarrow> 'a \<Rightarrow> real"}) *}
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
   147
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
   148
setup {* Sign.add_const_constraint
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
   149
  (@{const_name norm}, SOME @{typ "'a::real_normed_vector \<Rightarrow> real"}) *}
2d91b2416de8 add extra type constraints for dist, norm
huffman
parents: 31417
diff changeset
   150
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 30663
diff changeset
   151
interpretation inner:
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   152
  bounded_bilinear "inner::'a::real_inner \<Rightarrow> 'a \<Rightarrow> real"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   153
proof
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   154
  fix x y z :: 'a and r :: real
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   155
  show "inner (x + y) z = inner x z + inner y z"
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
   156
    by (rule inner_add_left)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   157
  show "inner x (y + z) = inner x y + inner x z"
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
   158
    by (rule inner_add_right)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   159
  show "inner (scaleR r x) y = scaleR r (inner x y)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   160
    unfolding real_scaleR_def by (rule inner_scaleR_left)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   161
  show "inner x (scaleR r y) = scaleR r (inner x y)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   162
    unfolding real_scaleR_def by (rule inner_scaleR_right)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   163
  show "\<exists>K. \<forall>x y::'a. norm (inner x y) \<le> norm x * norm y * K"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   164
  proof
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   165
    show "\<forall>x y::'a. norm (inner x y) \<le> norm x * norm y * 1"
30046
49f603f92c47 fix spelling
huffman
parents: 29993
diff changeset
   166
      by (simp add: Cauchy_Schwarz_ineq2)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   167
  qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   168
qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   169
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 30663
diff changeset
   170
interpretation inner_left:
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   171
  bounded_linear "\<lambda>x::'a::real_inner. inner x y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   172
  by (rule inner.bounded_linear_left)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   173
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 30663
diff changeset
   174
interpretation inner_right:
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   175
  bounded_linear "\<lambda>y::'a::real_inner. inner x y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   176
  by (rule inner.bounded_linear_right)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   177
44233
aa74ce315bae add simp rules for isCont
huffman
parents: 44126
diff changeset
   178
declare inner.isCont [simp]
aa74ce315bae add simp rules for isCont
huffman
parents: 44126
diff changeset
   179
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   180
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   181
subsection {* Class instances *}
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   182
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   183
instantiation real :: real_inner
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   184
begin
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   185
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   186
definition inner_real_def [simp]: "inner = op *"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   187
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   188
instance proof
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   189
  fix x y z r :: real
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   190
  show "inner x y = inner y x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   191
    unfolding inner_real_def by (rule mult_commute)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   192
  show "inner (x + y) z = inner x z + inner y z"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   193
    unfolding inner_real_def by (rule left_distrib)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   194
  show "inner (scaleR r x) y = r * inner x y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   195
    unfolding inner_real_def real_scaleR_def by (rule mult_assoc)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   196
  show "0 \<le> inner x x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   197
    unfolding inner_real_def by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   198
  show "inner x x = 0 \<longleftrightarrow> x = 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   199
    unfolding inner_real_def by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   200
  show "norm x = sqrt (inner x x)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   201
    unfolding inner_real_def by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   202
qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   203
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   204
end
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   205
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   206
instantiation complex :: real_inner
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   207
begin
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   208
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   209
definition inner_complex_def:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   210
  "inner x y = Re x * Re y + Im x * Im y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   211
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   212
instance proof
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   213
  fix x y z :: complex and r :: real
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   214
  show "inner x y = inner y x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   215
    unfolding inner_complex_def by (simp add: mult_commute)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   216
  show "inner (x + y) z = inner x z + inner y z"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   217
    unfolding inner_complex_def by (simp add: left_distrib)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   218
  show "inner (scaleR r x) y = r * inner x y"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   219
    unfolding inner_complex_def by (simp add: right_distrib)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   220
  show "0 \<le> inner x x"
44126
ce44e70d0c47 avoid duplicate rewrite warnings
huffman
parents: 41959
diff changeset
   221
    unfolding inner_complex_def by simp
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   222
  show "inner x x = 0 \<longleftrightarrow> x = 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   223
    unfolding inner_complex_def
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   224
    by (simp add: add_nonneg_eq_0_iff complex_Re_Im_cancel_iff)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   225
  show "norm x = sqrt (inner x x)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   226
    unfolding inner_complex_def complex_norm_def
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   227
    by (simp add: power2_eq_square)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   228
qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   229
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   230
end
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   231
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   232
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   233
subsection {* Gradient derivative *}
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   234
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   235
definition
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   236
  gderiv ::
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   237
    "['a::real_inner \<Rightarrow> real, 'a, 'a] \<Rightarrow> bool"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   238
          ("(GDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   239
where
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   240
  "GDERIV f x :> D \<longleftrightarrow> FDERIV f x :> (\<lambda>h. inner h D)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   241
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   242
lemma deriv_fderiv: "DERIV f x :> D \<longleftrightarrow> FDERIV f x :> (\<lambda>h. h * D)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   243
  by (simp only: deriv_def field_fderiv_def)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   244
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   245
lemma gderiv_deriv [simp]: "GDERIV f x :> D \<longleftrightarrow> DERIV f x :> D"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   246
  by (simp only: gderiv_def deriv_fderiv inner_real_def)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   247
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   248
lemma GDERIV_DERIV_compose:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   249
    "\<lbrakk>GDERIV f x :> df; DERIV g (f x) :> dg\<rbrakk>
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   250
     \<Longrightarrow> GDERIV (\<lambda>x. g (f x)) x :> scaleR dg df"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   251
  unfolding gderiv_def deriv_fderiv
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   252
  apply (drule (1) FDERIV_compose)
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
   253
  apply (simp add: mult_ac)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   254
  done
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   255
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   256
lemma FDERIV_subst: "\<lbrakk>FDERIV f x :> df; df = d\<rbrakk> \<Longrightarrow> FDERIV f x :> d"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   257
  by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   258
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   259
lemma GDERIV_subst: "\<lbrakk>GDERIV f x :> df; df = d\<rbrakk> \<Longrightarrow> GDERIV f x :> d"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   260
  by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   261
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   262
lemma GDERIV_const: "GDERIV (\<lambda>x. k) x :> 0"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   263
  unfolding gderiv_def inner_right.zero by (rule FDERIV_const)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   264
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   265
lemma GDERIV_add:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   266
    "\<lbrakk>GDERIV f x :> df; GDERIV g x :> dg\<rbrakk>
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   267
     \<Longrightarrow> GDERIV (\<lambda>x. f x + g x) x :> df + dg"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   268
  unfolding gderiv_def inner_right.add by (rule FDERIV_add)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   269
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   270
lemma GDERIV_minus:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   271
    "GDERIV f x :> df \<Longrightarrow> GDERIV (\<lambda>x. - f x) x :> - df"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   272
  unfolding gderiv_def inner_right.minus by (rule FDERIV_minus)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   273
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   274
lemma GDERIV_diff:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   275
    "\<lbrakk>GDERIV f x :> df; GDERIV g x :> dg\<rbrakk>
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   276
     \<Longrightarrow> GDERIV (\<lambda>x. f x - g x) x :> df - dg"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   277
  unfolding gderiv_def inner_right.diff by (rule FDERIV_diff)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   278
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   279
lemma GDERIV_scaleR:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   280
    "\<lbrakk>DERIV f x :> df; GDERIV g x :> dg\<rbrakk>
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   281
     \<Longrightarrow> GDERIV (\<lambda>x. scaleR (f x) (g x)) x
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   282
      :> (scaleR (f x) dg + scaleR df (g x))"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   283
  unfolding gderiv_def deriv_fderiv inner_right.add inner_right.scaleR
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   284
  apply (rule FDERIV_subst)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   285
  apply (erule (1) scaleR.FDERIV)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   286
  apply (simp add: mult_ac)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   287
  done
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   288
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   289
lemma GDERIV_mult:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   290
    "\<lbrakk>GDERIV f x :> df; GDERIV g x :> dg\<rbrakk>
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   291
     \<Longrightarrow> GDERIV (\<lambda>x. f x * g x) x :> scaleR (f x) dg + scaleR (g x) df"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   292
  unfolding gderiv_def
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   293
  apply (rule FDERIV_subst)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   294
  apply (erule (1) FDERIV_mult)
31590
776d6a4c1327 declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents: 31492
diff changeset
   295
  apply (simp add: inner_add mult_ac)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   296
  done
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   297
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   298
lemma GDERIV_inverse:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   299
    "\<lbrakk>GDERIV f x :> df; f x \<noteq> 0\<rbrakk>
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   300
     \<Longrightarrow> GDERIV (\<lambda>x. inverse (f x)) x :> - (inverse (f x))\<twosuperior> *\<^sub>R df"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   301
  apply (erule GDERIV_DERIV_compose)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   302
  apply (erule DERIV_inverse [folded numeral_2_eq_2])
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   303
  done
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   304
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   305
lemma GDERIV_norm:
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   306
  assumes "x \<noteq> 0" shows "GDERIV (\<lambda>x. norm x) x :> sgn x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   307
proof -
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   308
  have 1: "FDERIV (\<lambda>x. inner x x) x :> (\<lambda>h. inner x h + inner h x)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   309
    by (intro inner.FDERIV FDERIV_ident)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   310
  have 2: "(\<lambda>h. inner x h + inner h x) = (\<lambda>h. inner h (scaleR 2 x))"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   311
    by (simp add: fun_eq_iff inner_commute)
29993
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   312
  have "0 < inner x x" using `x \<noteq> 0` by simp
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   313
  then have 3: "DERIV sqrt (inner x x) :> (inverse (sqrt (inner x x)) / 2)"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   314
    by (rule DERIV_real_sqrt)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   315
  have 4: "(inverse (sqrt (inner x x)) / 2) *\<^sub>R 2 *\<^sub>R x = sgn x"
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   316
    by (simp add: sgn_div_norm norm_eq_sqrt_inner)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   317
  show ?thesis
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   318
    unfolding norm_eq_sqrt_inner
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   319
    apply (rule GDERIV_subst [OF _ 4])
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   320
    apply (rule GDERIV_DERIV_compose [where g=sqrt and df="scaleR 2 x"])
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   321
    apply (subst gderiv_def)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   322
    apply (rule FDERIV_subst [OF _ 2])
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   323
    apply (rule 1)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   324
    apply (rule 3)
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   325
    done
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   326
qed
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   327
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   328
lemmas FDERIV_norm = GDERIV_norm [unfolded gderiv_def]
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   329
84b2c432b94a new theory of real inner product spaces
huffman
parents:
diff changeset
   330
end