author | wenzelm |
Thu, 01 Sep 2016 16:05:22 +0200 | |
changeset 63750 | 9c8a366778e1 |
parent 63589 | 58aab4745e85 |
child 63886 | 685fb01256af |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: HOL/Library/Inner_Product.thy |
2 |
Author: Brian Huffman |
|
29993 | 3 |
*) |
4 |
||
60500 | 5 |
section \<open>Inner Product Spaces and the Gradient Derivative\<close> |
29993 | 6 |
|
7 |
theory Inner_Product |
|
51642
400ec5ae7f8f
move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents:
51002
diff
changeset
|
8 |
imports "~~/src/HOL/Complex_Main" |
29993 | 9 |
begin |
10 |
||
60500 | 11 |
subsection \<open>Real inner product spaces\<close> |
29993 | 12 |
|
60500 | 13 |
text \<open> |
62101 | 14 |
Temporarily relax type constraints for @{term "open"}, @{term "uniformity"}, |
31492
5400beeddb55
replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents:
31446
diff
changeset
|
15 |
@{term dist}, and @{term norm}. |
60500 | 16 |
\<close> |
31492
5400beeddb55
replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents:
31446
diff
changeset
|
17 |
|
60500 | 18 |
setup \<open>Sign.add_const_constraint |
19 |
(@{const_name "open"}, SOME @{typ "'a::open set \<Rightarrow> bool"})\<close> |
|
31446 | 20 |
|
60500 | 21 |
setup \<open>Sign.add_const_constraint |
22 |
(@{const_name dist}, SOME @{typ "'a::dist \<Rightarrow> 'a \<Rightarrow> real"})\<close> |
|
31446 | 23 |
|
60500 | 24 |
setup \<open>Sign.add_const_constraint |
62101 | 25 |
(@{const_name uniformity}, SOME @{typ "('a::uniformity \<times> 'a) filter"})\<close> |
26 |
||
27 |
setup \<open>Sign.add_const_constraint |
|
60500 | 28 |
(@{const_name norm}, SOME @{typ "'a::norm \<Rightarrow> real"})\<close> |
31446 | 29 |
|
62101 | 30 |
class real_inner = real_vector + sgn_div_norm + dist_norm + uniformity_dist + open_uniformity + |
29993 | 31 |
fixes inner :: "'a \<Rightarrow> 'a \<Rightarrow> real" |
32 |
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
|
33 |
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
|
34 |
and inner_scaleR_left [simp]: "inner (scaleR r x) y = r * (inner x y)" |
29993 | 35 |
and inner_ge_zero [simp]: "0 \<le> inner x x" |
36 |
and inner_eq_zero_iff [simp]: "inner x x = 0 \<longleftrightarrow> x = 0" |
|
37 |
and norm_eq_sqrt_inner: "norm x = sqrt (inner x x)" |
|
38 |
begin |
|
39 |
||
40 |
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
|
41 |
using inner_add_left [of 0 0 x] by simp |
29993 | 42 |
|
43 |
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
|
44 |
using inner_add_left [of x "- x" y] by simp |
29993 | 45 |
|
46 |
lemma inner_diff_left: "inner (x - y) z = inner x z - inner y z" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53938
diff
changeset
|
47 |
using inner_add_left [of x "- y" z] by simp |
29993 | 48 |
|
44282
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
49 |
lemma inner_setsum_left: "inner (\<Sum>x\<in>A. f x) y = (\<Sum>x\<in>A. inner (f x) y)" |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
50 |
by (cases "finite A", induct set: finite, simp_all add: inner_add_left) |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
51 |
|
60500 | 52 |
text \<open>Transfer distributivity rules to right argument.\<close> |
29993 | 53 |
|
31590
776d6a4c1327
declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents:
31492
diff
changeset
|
54 |
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
|
55 |
using inner_add_left [of y z x] by (simp only: inner_commute) |
29993 | 56 |
|
31590
776d6a4c1327
declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents:
31492
diff
changeset
|
57 |
lemma inner_scaleR_right [simp]: "inner x (scaleR r y) = r * (inner x y)" |
29993 | 58 |
using inner_scaleR_left [of r y x] by (simp only: inner_commute) |
59 |
||
60 |
lemma inner_zero_right [simp]: "inner x 0 = 0" |
|
61 |
using inner_zero_left [of x] by (simp only: inner_commute) |
|
62 |
||
63 |
lemma inner_minus_right [simp]: "inner x (- y) = - inner x y" |
|
64 |
using inner_minus_left [of y x] by (simp only: inner_commute) |
|
65 |
||
66 |
lemma inner_diff_right: "inner x (y - z) = inner x y - inner x z" |
|
67 |
using inner_diff_left [of y z x] by (simp only: inner_commute) |
|
68 |
||
44282
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
69 |
lemma inner_setsum_right: "inner x (\<Sum>y\<in>A. f y) = (\<Sum>y\<in>A. inner x (f y))" |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
70 |
using inner_setsum_left [of f A x] by (simp only: inner_commute) |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
71 |
|
31590
776d6a4c1327
declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents:
31492
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
|
60500 | 76 |
text \<open>Legacy theorem names\<close> |
31590
776d6a4c1327
declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents:
31492
diff
changeset
|
77 |
lemmas inner_left_distrib = inner_add_left |
776d6a4c1327
declare inner_add, inner_diff [algebra_simps]; declare inner_scaleR [simp]
huffman
parents:
31492
diff
changeset
|
78 |
lemmas inner_right_distrib = inner_add_right |
29993 | 79 |
lemmas inner_distrib = inner_left_distrib inner_right_distrib |
80 |
||
81 |
lemma inner_gt_zero_iff [simp]: "0 < inner x x \<longleftrightarrow> x \<noteq> 0" |
|
82 |
by (simp add: order_less_le) |
|
83 |
||
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
84 |
lemma power2_norm_eq_inner: "(norm x)\<^sup>2 = inner x x" |
29993 | 85 |
by (simp add: norm_eq_sqrt_inner) |
86 |
||
61518
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
87 |
text \<open>Identities involving real multiplication and division.\<close> |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
88 |
|
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
89 |
lemma inner_mult_left: "inner (of_real m * a) b = m * (inner a b)" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
90 |
by (metis real_inner_class.inner_scaleR_left scaleR_conv_of_real) |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
91 |
|
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
92 |
lemma inner_mult_right: "inner a (of_real m * b) = m * (inner a b)" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
93 |
by (metis real_inner_class.inner_scaleR_right scaleR_conv_of_real) |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
94 |
|
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
95 |
lemma inner_mult_left': "inner (a * of_real m) b = m * (inner a b)" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
96 |
by (simp add: of_real_def) |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
97 |
|
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
98 |
lemma inner_mult_right': "inner a (b * of_real m) = (inner a b) * m" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
99 |
by (simp add: of_real_def real_inner_class.inner_scaleR_right) |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
100 |
|
30046 | 101 |
lemma Cauchy_Schwarz_ineq: |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
102 |
"(inner x y)\<^sup>2 \<le> inner x x * inner y y" |
29993 | 103 |
proof (cases) |
104 |
assume "y = 0" |
|
105 |
thus ?thesis by simp |
|
106 |
next |
|
107 |
assume y: "y \<noteq> 0" |
|
108 |
let ?r = "inner x y / inner y y" |
|
109 |
have "0 \<le> inner (x - scaleR ?r y) (x - scaleR ?r y)" |
|
110 |
by (rule inner_ge_zero) |
|
111 |
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
|
112 |
by (simp add: inner_diff) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
113 |
also have "\<dots> = inner x x - (inner x y)\<^sup>2 / inner y y" |
29993 | 114 |
by (simp add: power2_eq_square inner_commute) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
115 |
finally have "0 \<le> inner x x - (inner x y)\<^sup>2 / inner y y" . |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
116 |
hence "(inner x y)\<^sup>2 / inner y y \<le> inner x x" |
29993 | 117 |
by (simp add: le_diff_eq) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
118 |
thus "(inner x y)\<^sup>2 \<le> inner x x * inner y y" |
29993 | 119 |
by (simp add: pos_divide_le_eq y) |
120 |
qed |
|
121 |
||
30046 | 122 |
lemma Cauchy_Schwarz_ineq2: |
29993 | 123 |
"\<bar>inner x y\<bar> \<le> norm x * norm y" |
124 |
proof (rule power2_le_imp_le) |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
125 |
have "(inner x y)\<^sup>2 \<le> inner x x * inner y y" |
30046 | 126 |
using Cauchy_Schwarz_ineq . |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
127 |
thus "\<bar>inner x y\<bar>\<^sup>2 \<le> (norm x * norm y)\<^sup>2" |
29993 | 128 |
by (simp add: power_mult_distrib power2_norm_eq_inner) |
129 |
show "0 \<le> norm x * norm y" |
|
130 |
unfolding norm_eq_sqrt_inner |
|
131 |
by (intro mult_nonneg_nonneg real_sqrt_ge_zero inner_ge_zero) |
|
132 |
qed |
|
133 |
||
53938 | 134 |
lemma norm_cauchy_schwarz: "inner x y \<le> norm x * norm y" |
135 |
using Cauchy_Schwarz_ineq2 [of x y] by auto |
|
136 |
||
29993 | 137 |
subclass real_normed_vector |
138 |
proof |
|
139 |
fix a :: real and x y :: 'a |
|
140 |
show "norm x = 0 \<longleftrightarrow> x = 0" |
|
141 |
unfolding norm_eq_sqrt_inner by simp |
|
142 |
show "norm (x + y) \<le> norm x + norm y" |
|
143 |
proof (rule power2_le_imp_le) |
|
144 |
have "inner x y \<le> norm x * norm y" |
|
53938 | 145 |
by (rule norm_cauchy_schwarz) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
146 |
thus "(norm (x + y))\<^sup>2 \<le> (norm x + norm y)\<^sup>2" |
29993 | 147 |
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
|
148 |
by (simp add: inner_add inner_commute) |
29993 | 149 |
show "0 \<le> norm x + norm y" |
44126 | 150 |
unfolding norm_eq_sqrt_inner by simp |
29993 | 151 |
qed |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
152 |
have "sqrt (a\<^sup>2 * inner x x) = \<bar>a\<bar> * sqrt (inner x x)" |
29993 | 153 |
by (simp add: real_sqrt_mult_distrib) |
154 |
then show "norm (a *\<^sub>R x) = \<bar>a\<bar> * norm x" |
|
155 |
unfolding norm_eq_sqrt_inner |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56381
diff
changeset
|
156 |
by (simp add: power2_eq_square mult.assoc) |
29993 | 157 |
qed |
158 |
||
159 |
end |
|
160 |
||
61518
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
161 |
lemma inner_divide_left: |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
162 |
fixes a :: "'a :: {real_inner,real_div_algebra}" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
163 |
shows "inner (a / of_real m) b = (inner a b) / m" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
164 |
by (metis (no_types) divide_inverse inner_commute inner_scaleR_right mult.left_neutral mult.right_neutral mult_scaleR_right of_real_inverse scaleR_conv_of_real times_divide_eq_left) |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
165 |
|
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
166 |
lemma inner_divide_right: |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
167 |
fixes a :: "'a :: {real_inner,real_div_algebra}" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
168 |
shows "inner a (b / of_real m) = (inner a b) / m" |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
169 |
by (metis inner_commute inner_divide_left) |
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
paulson
parents:
60679
diff
changeset
|
170 |
|
60500 | 171 |
text \<open> |
62101 | 172 |
Re-enable constraints for @{term "open"}, @{term "uniformity"}, |
31492
5400beeddb55
replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents:
31446
diff
changeset
|
173 |
@{term dist}, and @{term norm}. |
60500 | 174 |
\<close> |
31492
5400beeddb55
replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents:
31446
diff
changeset
|
175 |
|
60500 | 176 |
setup \<open>Sign.add_const_constraint |
177 |
(@{const_name "open"}, SOME @{typ "'a::topological_space set \<Rightarrow> bool"})\<close> |
|
31446 | 178 |
|
60500 | 179 |
setup \<open>Sign.add_const_constraint |
62101 | 180 |
(@{const_name uniformity}, SOME @{typ "('a::uniform_space \<times> 'a) filter"})\<close> |
181 |
||
182 |
setup \<open>Sign.add_const_constraint |
|
60500 | 183 |
(@{const_name dist}, SOME @{typ "'a::metric_space \<Rightarrow> 'a \<Rightarrow> real"})\<close> |
31446 | 184 |
|
60500 | 185 |
setup \<open>Sign.add_const_constraint |
186 |
(@{const_name norm}, SOME @{typ "'a::real_normed_vector \<Rightarrow> real"})\<close> |
|
31446 | 187 |
|
44282
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
188 |
lemma bounded_bilinear_inner: |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
189 |
"bounded_bilinear (inner::'a::real_inner \<Rightarrow> 'a \<Rightarrow> real)" |
29993 | 190 |
proof |
191 |
fix x y z :: 'a and r :: real |
|
192 |
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
|
193 |
by (rule inner_add_left) |
29993 | 194 |
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
|
195 |
by (rule inner_add_right) |
29993 | 196 |
show "inner (scaleR r x) y = scaleR r (inner x y)" |
197 |
unfolding real_scaleR_def by (rule inner_scaleR_left) |
|
198 |
show "inner x (scaleR r y) = scaleR r (inner x y)" |
|
199 |
unfolding real_scaleR_def by (rule inner_scaleR_right) |
|
200 |
show "\<exists>K. \<forall>x y::'a. norm (inner x y) \<le> norm x * norm y * K" |
|
201 |
proof |
|
202 |
show "\<forall>x y::'a. norm (inner x y) \<le> norm x * norm y * 1" |
|
30046 | 203 |
by (simp add: Cauchy_Schwarz_ineq2) |
29993 | 204 |
qed |
205 |
qed |
|
206 |
||
44282
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
207 |
lemmas tendsto_inner [tendsto_intros] = |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
208 |
bounded_bilinear.tendsto [OF bounded_bilinear_inner] |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
209 |
|
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
210 |
lemmas isCont_inner [simp] = |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
211 |
bounded_bilinear.isCont [OF bounded_bilinear_inner] |
29993 | 212 |
|
56381
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents:
56181
diff
changeset
|
213 |
lemmas has_derivative_inner [derivative_intros] = |
44282
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
214 |
bounded_bilinear.FDERIV [OF bounded_bilinear_inner] |
29993 | 215 |
|
44282
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
216 |
lemmas bounded_linear_inner_left = |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
217 |
bounded_bilinear.bounded_linear_left [OF bounded_bilinear_inner] |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
218 |
|
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
219 |
lemmas bounded_linear_inner_right = |
f0de18b62d63
remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents:
44233
diff
changeset
|
220 |
bounded_bilinear.bounded_linear_right [OF bounded_bilinear_inner] |
44233 | 221 |
|
61915
e9812a95d108
theory for type of bounded linear functions; differentiation under the integral sign
immler
parents:
61518
diff
changeset
|
222 |
lemmas bounded_linear_inner_left_comp = bounded_linear_inner_left[THEN bounded_linear_compose] |
e9812a95d108
theory for type of bounded linear functions; differentiation under the integral sign
immler
parents:
61518
diff
changeset
|
223 |
|
e9812a95d108
theory for type of bounded linear functions; differentiation under the integral sign
immler
parents:
61518
diff
changeset
|
224 |
lemmas bounded_linear_inner_right_comp = bounded_linear_inner_right[THEN bounded_linear_compose] |
e9812a95d108
theory for type of bounded linear functions; differentiation under the integral sign
immler
parents:
61518
diff
changeset
|
225 |
|
56381
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents:
56181
diff
changeset
|
226 |
lemmas has_derivative_inner_right [derivative_intros] = |
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
227 |
bounded_linear.has_derivative [OF bounded_linear_inner_right] |
51642
400ec5ae7f8f
move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents:
51002
diff
changeset
|
228 |
|
56381
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents:
56181
diff
changeset
|
229 |
lemmas has_derivative_inner_left [derivative_intros] = |
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
230 |
bounded_linear.has_derivative [OF bounded_linear_inner_left] |
51642
400ec5ae7f8f
move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents:
51002
diff
changeset
|
231 |
|
400ec5ae7f8f
move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents:
51002
diff
changeset
|
232 |
lemma differentiable_inner [simp]: |
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
233 |
"f differentiable (at x within s) \<Longrightarrow> g differentiable at x within s \<Longrightarrow> (\<lambda>x. inner (f x) (g x)) differentiable at x within s" |
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
234 |
unfolding differentiable_def by (blast intro: has_derivative_inner) |
29993 | 235 |
|
60679 | 236 |
|
60500 | 237 |
subsection \<open>Class instances\<close> |
29993 | 238 |
|
239 |
instantiation real :: real_inner |
|
240 |
begin |
|
241 |
||
242 |
definition inner_real_def [simp]: "inner = op *" |
|
243 |
||
60679 | 244 |
instance |
245 |
proof |
|
29993 | 246 |
fix x y z r :: real |
247 |
show "inner x y = inner y x" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56381
diff
changeset
|
248 |
unfolding inner_real_def by (rule mult.commute) |
29993 | 249 |
show "inner (x + y) z = inner x z + inner y z" |
49962
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents:
44902
diff
changeset
|
250 |
unfolding inner_real_def by (rule distrib_right) |
29993 | 251 |
show "inner (scaleR r x) y = r * inner x y" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56381
diff
changeset
|
252 |
unfolding inner_real_def real_scaleR_def by (rule mult.assoc) |
29993 | 253 |
show "0 \<le> inner x x" |
254 |
unfolding inner_real_def by simp |
|
255 |
show "inner x x = 0 \<longleftrightarrow> x = 0" |
|
256 |
unfolding inner_real_def by simp |
|
257 |
show "norm x = sqrt (inner x x)" |
|
258 |
unfolding inner_real_def by simp |
|
259 |
qed |
|
260 |
||
261 |
end |
|
262 |
||
263 |
instantiation complex :: real_inner |
|
264 |
begin |
|
265 |
||
266 |
definition inner_complex_def: |
|
267 |
"inner x y = Re x * Re y + Im x * Im y" |
|
268 |
||
60679 | 269 |
instance |
270 |
proof |
|
29993 | 271 |
fix x y z :: complex and r :: real |
272 |
show "inner x y = inner y x" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56381
diff
changeset
|
273 |
unfolding inner_complex_def by (simp add: mult.commute) |
29993 | 274 |
show "inner (x + y) z = inner x z + inner y z" |
49962
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents:
44902
diff
changeset
|
275 |
unfolding inner_complex_def by (simp add: distrib_right) |
29993 | 276 |
show "inner (scaleR r x) y = r * inner x y" |
49962
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents:
44902
diff
changeset
|
277 |
unfolding inner_complex_def by (simp add: distrib_left) |
29993 | 278 |
show "0 \<le> inner x x" |
44126 | 279 |
unfolding inner_complex_def by simp |
29993 | 280 |
show "inner x x = 0 \<longleftrightarrow> x = 0" |
281 |
unfolding inner_complex_def |
|
282 |
by (simp add: add_nonneg_eq_0_iff complex_Re_Im_cancel_iff) |
|
283 |
show "norm x = sqrt (inner x x)" |
|
284 |
unfolding inner_complex_def complex_norm_def |
|
285 |
by (simp add: power2_eq_square) |
|
286 |
qed |
|
287 |
||
288 |
end |
|
289 |
||
44902
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
290 |
lemma complex_inner_1 [simp]: "inner 1 x = Re x" |
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
291 |
unfolding inner_complex_def by simp |
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
292 |
|
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
293 |
lemma complex_inner_1_right [simp]: "inner x 1 = Re x" |
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
294 |
unfolding inner_complex_def by simp |
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
295 |
|
63589 | 296 |
lemma complex_inner_ii_left [simp]: "inner \<i> x = Im x" |
44902
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
297 |
unfolding inner_complex_def by simp |
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
298 |
|
63589 | 299 |
lemma complex_inner_ii_right [simp]: "inner x \<i> = Im x" |
44902
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
300 |
unfolding inner_complex_def by simp |
9ba11d41cd1f
move lemmas about complex number 'i' to Complex.thy and Library/Inner_Product.thy
huffman
parents:
44282
diff
changeset
|
301 |
|
29993 | 302 |
|
60500 | 303 |
subsection \<open>Gradient derivative\<close> |
29993 | 304 |
|
305 |
definition |
|
306 |
gderiv :: |
|
307 |
"['a::real_inner \<Rightarrow> real, 'a, 'a] \<Rightarrow> bool" |
|
308 |
("(GDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60) |
|
309 |
where |
|
310 |
"GDERIV f x :> D \<longleftrightarrow> FDERIV f x :> (\<lambda>h. inner h D)" |
|
311 |
||
312 |
lemma gderiv_deriv [simp]: "GDERIV f x :> D \<longleftrightarrow> DERIV f x :> D" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
313 |
by (simp only: gderiv_def has_field_derivative_def inner_real_def mult_commute_abs) |
29993 | 314 |
|
315 |
lemma GDERIV_DERIV_compose: |
|
316 |
"\<lbrakk>GDERIV f x :> df; DERIV g (f x) :> dg\<rbrakk> |
|
317 |
\<Longrightarrow> GDERIV (\<lambda>x. g (f x)) x :> scaleR dg df" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
318 |
unfolding gderiv_def has_field_derivative_def |
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
319 |
apply (drule (1) has_derivative_compose) |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
320 |
apply (simp add: ac_simps) |
29993 | 321 |
done |
322 |
||
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
323 |
lemma has_derivative_subst: "\<lbrakk>FDERIV f x :> df; df = d\<rbrakk> \<Longrightarrow> FDERIV f x :> d" |
29993 | 324 |
by simp |
325 |
||
326 |
lemma GDERIV_subst: "\<lbrakk>GDERIV f x :> df; df = d\<rbrakk> \<Longrightarrow> GDERIV f x :> d" |
|
327 |
by simp |
|
328 |
||
329 |
lemma GDERIV_const: "GDERIV (\<lambda>x. k) x :> 0" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
330 |
unfolding gderiv_def inner_zero_right by (rule has_derivative_const) |
29993 | 331 |
|
332 |
lemma GDERIV_add: |
|
333 |
"\<lbrakk>GDERIV f x :> df; GDERIV g x :> dg\<rbrakk> |
|
334 |
\<Longrightarrow> GDERIV (\<lambda>x. f x + g x) x :> df + dg" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
335 |
unfolding gderiv_def inner_add_right by (rule has_derivative_add) |
29993 | 336 |
|
337 |
lemma GDERIV_minus: |
|
338 |
"GDERIV f x :> df \<Longrightarrow> GDERIV (\<lambda>x. - f x) x :> - df" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
339 |
unfolding gderiv_def inner_minus_right by (rule has_derivative_minus) |
29993 | 340 |
|
341 |
lemma GDERIV_diff: |
|
342 |
"\<lbrakk>GDERIV f x :> df; GDERIV g x :> dg\<rbrakk> |
|
343 |
\<Longrightarrow> GDERIV (\<lambda>x. f x - g x) x :> df - dg" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
344 |
unfolding gderiv_def inner_diff_right by (rule has_derivative_diff) |
29993 | 345 |
|
346 |
lemma GDERIV_scaleR: |
|
347 |
"\<lbrakk>DERIV f x :> df; GDERIV g x :> dg\<rbrakk> |
|
348 |
\<Longrightarrow> GDERIV (\<lambda>x. scaleR (f x) (g x)) x |
|
349 |
:> (scaleR (f x) dg + scaleR df (g x))" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
350 |
unfolding gderiv_def has_field_derivative_def inner_add_right inner_scaleR_right |
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
351 |
apply (rule has_derivative_subst) |
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
352 |
apply (erule (1) has_derivative_scaleR) |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
353 |
apply (simp add: ac_simps) |
29993 | 354 |
done |
355 |
||
356 |
lemma GDERIV_mult: |
|
357 |
"\<lbrakk>GDERIV f x :> df; GDERIV g x :> dg\<rbrakk> |
|
358 |
\<Longrightarrow> GDERIV (\<lambda>x. f x * g x) x :> scaleR (f x) dg + scaleR (g x) df" |
|
359 |
unfolding gderiv_def |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
360 |
apply (rule has_derivative_subst) |
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
361 |
apply (erule (1) has_derivative_mult) |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
362 |
apply (simp add: inner_add ac_simps) |
29993 | 363 |
done |
364 |
||
365 |
lemma GDERIV_inverse: |
|
366 |
"\<lbrakk>GDERIV f x :> df; f x \<noteq> 0\<rbrakk> |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
51642
diff
changeset
|
367 |
\<Longrightarrow> GDERIV (\<lambda>x. inverse (f x)) x :> - (inverse (f x))\<^sup>2 *\<^sub>R df" |
29993 | 368 |
apply (erule GDERIV_DERIV_compose) |
369 |
apply (erule DERIV_inverse [folded numeral_2_eq_2]) |
|
370 |
done |
|
371 |
||
372 |
lemma GDERIV_norm: |
|
373 |
assumes "x \<noteq> 0" shows "GDERIV (\<lambda>x. norm x) x :> sgn x" |
|
374 |
proof - |
|
375 |
have 1: "FDERIV (\<lambda>x. inner x x) x :> (\<lambda>h. inner x h + inner h x)" |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
376 |
by (intro has_derivative_inner has_derivative_ident) |
29993 | 377 |
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
|
378 |
by (simp add: fun_eq_iff inner_commute) |
60500 | 379 |
have "0 < inner x x" using \<open>x \<noteq> 0\<close> by simp |
29993 | 380 |
then have 3: "DERIV sqrt (inner x x) :> (inverse (sqrt (inner x x)) / 2)" |
381 |
by (rule DERIV_real_sqrt) |
|
382 |
have 4: "(inverse (sqrt (inner x x)) / 2) *\<^sub>R 2 *\<^sub>R x = sgn x" |
|
383 |
by (simp add: sgn_div_norm norm_eq_sqrt_inner) |
|
384 |
show ?thesis |
|
385 |
unfolding norm_eq_sqrt_inner |
|
386 |
apply (rule GDERIV_subst [OF _ 4]) |
|
387 |
apply (rule GDERIV_DERIV_compose [where g=sqrt and df="scaleR 2 x"]) |
|
388 |
apply (subst gderiv_def) |
|
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
389 |
apply (rule has_derivative_subst [OF _ 2]) |
29993 | 390 |
apply (rule 1) |
391 |
apply (rule 3) |
|
392 |
done |
|
393 |
qed |
|
394 |
||
56181
2aa0b19e74f3
unify syntax for has_derivative and differentiable
hoelzl
parents:
54230
diff
changeset
|
395 |
lemmas has_derivative_norm = GDERIV_norm [unfolded gderiv_def] |
29993 | 396 |
|
397 |
end |