| author | wenzelm | 
| Mon, 17 May 2021 16:15:25 +0200 | |
| changeset 73718 | ecb31c3bf980 | 
| parent 70136 | f03a01a18c6e | 
| child 77490 | 2c86ea8961b5 | 
| permissions | -rw-r--r-- | 
| 63627 | 1 | (* Title: HOL/Analysis/Euclidean_Space.thy | 
| 44133 
691c52e900ca
split Linear_Algebra.thy from Euclidean_Space.thy
 huffman parents: 
44129diff
changeset | 2 | Author: Johannes Hölzl, TU München | 
| 
691c52e900ca
split Linear_Algebra.thy from Euclidean_Space.thy
 huffman parents: 
44129diff
changeset | 3 | Author: Brian Huffman, Portland State University | 
| 33175 | 4 | *) | 
| 5 | ||
| 60420 | 6 | section \<open>Finite-Dimensional Inner Product Spaces\<close> | 
| 33175 | 7 | |
| 8 | theory Euclidean_Space | |
| 9 | imports | |
| 69511 | 10 | L2_Norm | 
| 11 | Inner_Product | |
| 12 | Product_Vector | |
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 13 | begin | 
| 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 14 | |
| 69516 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 15 | |
| 70136 | 16 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Interlude: Some properties of real sets\<close> | 
| 69516 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 17 | |
| 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 18 | lemma seq_mono_lemma: | 
| 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 19 | assumes "\<forall>(n::nat) \<ge> m. (d n :: real) < e n" | 
| 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 20 | and "\<forall>n \<ge> m. e n \<le> e m" | 
| 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 21 | shows "\<forall>n \<ge> m. d n < e m" | 
| 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 22 | using assms by force | 
| 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 23 | |
| 
09bb8f470959
most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
 immler parents: 
69511diff
changeset | 24 | |
| 60420 | 25 | subsection \<open>Type class of Euclidean spaces\<close> | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 26 | |
| 68617 | 27 | class euclidean_space = real_inner + | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 28 | fixes Basis :: "'a set" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 29 |   assumes nonempty_Basis [simp]: "Basis \<noteq> {}"
 | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 30 | assumes finite_Basis [simp]: "finite Basis" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 31 | assumes inner_Basis: | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 32 | "\<lbrakk>u \<in> Basis; v \<in> Basis\<rbrakk> \<Longrightarrow> inner u v = (if u = v then 1 else 0)" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 33 | assumes euclidean_all_zero_iff: | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 34 | "(\<forall>u\<in>Basis. inner x u = 0) \<longleftrightarrow> (x = 0)" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 35 | |
| 63141 
7e5084ad95aa
recovered printing of DIM('a) (cf. 899c9c4e4a4c);
 wenzelm parents: 
63114diff
changeset | 36 | syntax "_type_dimension" :: "type \<Rightarrow> nat"  ("(1DIM/(1'(_')))")
 | 
| 
7e5084ad95aa
recovered printing of DIM('a) (cf. 899c9c4e4a4c);
 wenzelm parents: 
63114diff
changeset | 37 | translations "DIM('a)" \<rightharpoonup> "CONST card (CONST Basis :: 'a set)"
 | 
| 
7e5084ad95aa
recovered printing of DIM('a) (cf. 899c9c4e4a4c);
 wenzelm parents: 
63114diff
changeset | 38 | typed_print_translation \<open> | 
| 69597 | 39 | [(\<^const_syntax>\<open>card\<close>, | 
| 40 | fn ctxt => fn _ => fn [Const (\<^const_syntax>\<open>Basis\<close>, Type (\<^type_name>\<open>set\<close>, [T]))] => | |
| 41 | Syntax.const \<^syntax_const>\<open>_type_dimension\<close> $ Syntax_Phases.term_of_typ ctxt T)] | |
| 63141 
7e5084ad95aa
recovered printing of DIM('a) (cf. 899c9c4e4a4c);
 wenzelm parents: 
63114diff
changeset | 42 | \<close> | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 43 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 44 | lemma (in euclidean_space) norm_Basis[simp]: "u \<in> Basis \<Longrightarrow> norm u = 1" | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 45 | unfolding norm_eq_sqrt_inner by (simp add: inner_Basis) | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 46 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 47 | lemma (in euclidean_space) inner_same_Basis[simp]: "u \<in> Basis \<Longrightarrow> inner u u = 1" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 48 | by (simp add: inner_Basis) | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 49 | |
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 50 | lemma (in euclidean_space) inner_not_same_Basis: "u \<in> Basis \<Longrightarrow> v \<in> Basis \<Longrightarrow> u \<noteq> v \<Longrightarrow> inner u v = 0" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 51 | by (simp add: inner_Basis) | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 52 | |
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 53 | lemma (in euclidean_space) sgn_Basis: "u \<in> Basis \<Longrightarrow> sgn u = u" | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 54 | unfolding sgn_div_norm by (simp add: scaleR_one) | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 55 | |
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 56 | lemma (in euclidean_space) Basis_zero [simp]: "0 \<notin> Basis" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 57 | proof | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 58 | assume "0 \<in> Basis" thus "False" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 59 | using inner_Basis [of 0 0] by simp | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 60 | qed | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 61 | |
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 62 | lemma (in euclidean_space) nonzero_Basis: "u \<in> Basis \<Longrightarrow> u \<noteq> 0" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 63 | by clarsimp | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 64 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 65 | lemma (in euclidean_space) SOME_Basis: "(SOME i. i \<in> Basis) \<in> Basis" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 66 | by (metis ex_in_conv nonempty_Basis someI_ex) | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 67 | |
| 64773 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64267diff
changeset | 68 | lemma norm_some_Basis [simp]: "norm (SOME i. i \<in> Basis) = 1" | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64267diff
changeset | 69 | by (simp add: SOME_Basis) | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64267diff
changeset | 70 | |
| 64267 | 71 | lemma (in euclidean_space) inner_sum_left_Basis[simp]: | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 72 | "b \<in> Basis \<Longrightarrow> inner (\<Sum>i\<in>Basis. f i *\<^sub>R i) b = f b" | 
| 64267 | 73 | by (simp add: inner_sum_left inner_Basis if_distrib comm_monoid_add_class.sum.If_cases) | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 74 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 75 | lemma (in euclidean_space) euclidean_eqI: | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 76 | assumes b: "\<And>b. b \<in> Basis \<Longrightarrow> inner x b = inner y b" shows "x = y" | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 77 | proof - | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 78 | from b have "\<forall>b\<in>Basis. inner (x - y) b = 0" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 79 | by (simp add: inner_diff_left) | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 80 | then show "x = y" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 81 | by (simp add: euclidean_all_zero_iff) | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 82 | qed | 
| 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 83 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 84 | lemma (in euclidean_space) euclidean_eq_iff: | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 85 | "x = y \<longleftrightarrow> (\<forall>b\<in>Basis. inner x b = inner y b)" | 
| 44129 | 86 | by (auto intro: euclidean_eqI) | 
| 87 | ||
| 64267 | 88 | lemma (in euclidean_space) euclidean_representation_sum: | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 89 | "(\<Sum>i\<in>Basis. f i *\<^sub>R i) = b \<longleftrightarrow> (\<forall>i\<in>Basis. f i = inner b i)" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 90 | by (subst euclidean_eq_iff) simp | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 91 | |
| 64267 | 92 | lemma (in euclidean_space) euclidean_representation_sum': | 
| 54776 
db890d9fc5c2
ordered_euclidean_space compatible with more standard pointwise ordering on products; conditionally complete lattice with product order
 immler parents: 
53939diff
changeset | 93 | "b = (\<Sum>i\<in>Basis. f i *\<^sub>R i) \<longleftrightarrow> (\<forall>i\<in>Basis. f i = inner b i)" | 
| 64267 | 94 | by (auto simp add: euclidean_representation_sum[symmetric]) | 
| 54776 
db890d9fc5c2
ordered_euclidean_space compatible with more standard pointwise ordering on products; conditionally complete lattice with product order
 immler parents: 
53939diff
changeset | 95 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 96 | lemma (in euclidean_space) euclidean_representation: "(\<Sum>b\<in>Basis. inner x b *\<^sub>R b) = x" | 
| 64267 | 97 | unfolding euclidean_representation_sum by simp | 
| 44129 | 98 | |
| 67685 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67399diff
changeset | 99 | lemma (in euclidean_space) euclidean_inner: "inner x y = (\<Sum>b\<in>Basis. (inner x b) * (inner y b))" | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67399diff
changeset | 100 | by (subst (1 2) euclidean_representation [symmetric]) | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67399diff
changeset | 101 | (simp add: inner_sum_right inner_Basis ac_simps) | 
| 
bdff8bf0a75b
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
 immler parents: 
67399diff
changeset | 102 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 103 | lemma (in euclidean_space) choice_Basis_iff: | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 104 | fixes P :: "'a \<Rightarrow> real \<Rightarrow> bool" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 105 | shows "(\<forall>i\<in>Basis. \<exists>x. P i x) \<longleftrightarrow> (\<exists>x. \<forall>i\<in>Basis. P i (inner x i))" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 106 | unfolding bchoice_iff | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 107 | proof safe | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 108 | fix f assume "\<forall>i\<in>Basis. P i (f i)" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 109 | then show "\<exists>x. \<forall>i\<in>Basis. P i (inner x i)" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 110 | by (auto intro!: exI[of _ "\<Sum>i\<in>Basis. f i *\<^sub>R i"]) | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 111 | qed auto | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 112 | |
| 63952 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63938diff
changeset | 113 | lemma (in euclidean_space) bchoice_Basis_iff: | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63938diff
changeset | 114 | fixes P :: "'a \<Rightarrow> real \<Rightarrow> bool" | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63938diff
changeset | 115 | shows "(\<forall>i\<in>Basis. \<exists>x\<in>A. P i x) \<longleftrightarrow> (\<exists>x. \<forall>i\<in>Basis. inner x i \<in> A \<and> P i (inner x i))" | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63938diff
changeset | 116 | by (simp add: choice_Basis_iff Bex_def) | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63938diff
changeset | 117 | |
| 64267 | 118 | lemma (in euclidean_space) euclidean_representation_sum_fun: | 
| 60974 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 119 | "(\<lambda>x. \<Sum>b\<in>Basis. inner (f x) b *\<^sub>R b) = f" | 
| 64267 | 120 | by (rule ext) (simp add: euclidean_representation_sum) | 
| 60974 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 121 | |
| 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 122 | lemma euclidean_isCont: | 
| 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 123 | assumes "\<And>b. b \<in> Basis \<Longrightarrow> isCont (\<lambda>x. (inner (f x) b) *\<^sub>R b) x" | 
| 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 124 | shows "isCont f x" | 
| 64267 | 125 | apply (subst euclidean_representation_sum_fun [symmetric]) | 
| 126 | apply (rule isCont_sum) | |
| 60974 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 127 | apply (blast intro: assms) | 
| 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 128 | done | 
| 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60420diff
changeset | 129 | |
| 63938 | 130 | lemma DIM_positive [simp]: "0 < DIM('a::euclidean_space)"
 | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 131 | by (simp add: card_gt_0_iff) | 
| 44628 
bd17b7543af1
move lemmas from Topology_Euclidean_Space to Euclidean_Space
 huffman parents: 
44571diff
changeset | 132 | |
| 63938 | 133 | lemma DIM_ge_Suc0 [simp]: "Suc 0 \<le> card Basis" | 
| 63007 
aa894a49f77d
new theorems about convex hulls, etc.; also, renamed some theorems
 paulson <lp15@cam.ac.uk> parents: 
62390diff
changeset | 134 | by (meson DIM_positive Suc_leI) | 
| 
aa894a49f77d
new theorems about convex hulls, etc.; also, renamed some theorems
 paulson <lp15@cam.ac.uk> parents: 
62390diff
changeset | 135 | |
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63040diff
changeset | 136 | |
| 64267 | 137 | lemma sum_inner_Basis_scaleR [simp]: | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63040diff
changeset | 138 | fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_vector" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63040diff
changeset | 139 | assumes "b \<in> Basis" shows "(\<Sum>i\<in>Basis. (inner i b) *\<^sub>R f i) = f b" | 
| 64267 | 140 | by (simp add: comm_monoid_add_class.sum.remove [OF finite_Basis assms] | 
| 141 | assms inner_not_same_Basis comm_monoid_add_class.sum.neutral) | |
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63040diff
changeset | 142 | |
| 64267 | 143 | lemma sum_inner_Basis_eq [simp]: | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63040diff
changeset | 144 | assumes "b \<in> Basis" shows "(\<Sum>i\<in>Basis. (inner i b) * f i) = f b" | 
| 64267 | 145 | by (simp add: comm_monoid_add_class.sum.remove [OF finite_Basis assms] | 
| 146 | assms inner_not_same_Basis comm_monoid_add_class.sum.neutral) | |
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63040diff
changeset | 147 | |
| 66154 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 148 | lemma sum_if_inner [simp]: | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 149 | assumes "i \<in> Basis" "j \<in> Basis" | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 150 | shows "inner (\<Sum>k\<in>Basis. if k = i then f i *\<^sub>R i else g k *\<^sub>R k) j = (if j=i then f j else g j)" | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 151 | proof (cases "i=j") | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 152 | case True | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 153 | with assms show ?thesis | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 154 | by (auto simp: inner_sum_left if_distrib [of "\<lambda>x. inner x j"] inner_Basis cong: if_cong) | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 155 | next | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 156 | case False | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 157 | have "(\<Sum>k\<in>Basis. inner (if k = i then f i *\<^sub>R i else g k *\<^sub>R k) j) = | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 158 | (\<Sum>k\<in>Basis. if k = j then g k else 0)" | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 159 | apply (rule sum.cong) | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 160 | using False assms by (auto simp: inner_Basis) | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 161 | also have "... = g j" | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 162 | using assms by auto | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 163 | finally show ?thesis | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 164 | using False by (auto simp: inner_sum_left) | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 165 | qed | 
| 
bc5e6461f759
Tidying up integration theory and some new theorems
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 166 | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 167 | lemma norm_le_componentwise: | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 168 | "(\<And>b. b \<in> Basis \<Longrightarrow> abs(inner x b) \<le> abs(inner y b)) \<Longrightarrow> norm x \<le> norm y" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 169 | by (auto simp: norm_le euclidean_inner [of x x] euclidean_inner [of y y] abs_le_square_iff power2_eq_square intro!: sum_mono) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 170 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 171 | lemma Basis_le_norm: "b \<in> Basis \<Longrightarrow> \<bar>inner x b\<bar> \<le> norm x" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 172 | by (rule order_trans [OF Cauchy_Schwarz_ineq2]) simp | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 173 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 174 | lemma norm_bound_Basis_le: "b \<in> Basis \<Longrightarrow> norm x \<le> e \<Longrightarrow> \<bar>inner x b\<bar> \<le> e" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 175 | by (metis Basis_le_norm order_trans) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 176 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 177 | lemma norm_bound_Basis_lt: "b \<in> Basis \<Longrightarrow> norm x < e \<Longrightarrow> \<bar>inner x b\<bar> < e" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 178 | by (metis Basis_le_norm le_less_trans) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 179 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 180 | lemma norm_le_l1: "norm x \<le> (\<Sum>b\<in>Basis. \<bar>inner x b\<bar>)" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 181 | apply (subst euclidean_representation[of x, symmetric]) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 182 | apply (rule order_trans[OF norm_sum]) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 183 | apply (auto intro!: sum_mono) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 184 | done | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 185 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 186 | lemma sum_norm_allsubsets_bound: | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 187 | fixes f :: "'a \<Rightarrow> 'n::euclidean_space" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 188 | assumes fP: "finite P" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 189 | and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (sum f Q) \<le> e" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 190 |   shows "(\<Sum>x\<in>P. norm (f x)) \<le> 2 * real DIM('n) * e"
 | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 191 | proof - | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 192 | have "(\<Sum>x\<in>P. norm (f x)) \<le> (\<Sum>x\<in>P. \<Sum>b\<in>Basis. \<bar>inner (f x) b\<bar>)" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 193 | by (rule sum_mono) (rule norm_le_l1) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 194 | also have "(\<Sum>x\<in>P. \<Sum>b\<in>Basis. \<bar>inner (f x) b\<bar>) = (\<Sum>b\<in>Basis. \<Sum>x\<in>P. \<bar>inner (f x) b\<bar>)" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 195 | by (rule sum.swap) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 196 | also have "\<dots> \<le> of_nat (card (Basis :: 'n set)) * (2 * e)" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 197 | proof (rule sum_bounded_above) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 198 | fix i :: 'n | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 199 | assume i: "i \<in> Basis" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 200 | have "norm (\<Sum>x\<in>P. \<bar>inner (f x) i\<bar>) \<le> | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 201 |       norm (inner (\<Sum>x\<in>P \<inter> - {x. inner (f x) i < 0}. f x) i) + norm (inner (\<Sum>x\<in>P \<inter> {x. inner (f x) i < 0}. f x) i)"
 | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 202 | by (simp add: abs_real_def sum.If_cases[OF fP] sum_negf norm_triangle_ineq4 inner_sum_left | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 203 | del: real_norm_def) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 204 | also have "\<dots> \<le> e + e" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 205 | unfolding real_norm_def | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 206 | by (intro add_mono norm_bound_Basis_le i fPs) auto | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 207 | finally show "(\<Sum>x\<in>P. \<bar>inner (f x) i\<bar>) \<le> 2*e" by simp | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 208 | qed | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 209 |   also have "\<dots> = 2 * real DIM('n) * e" by simp
 | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 210 | finally show ?thesis . | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 211 | qed | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 212 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 213 | |
| 70136 | 214 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Subclass relationships\<close> | 
| 44571 | 215 | |
| 216 | instance euclidean_space \<subseteq> perfect_space | |
| 217 | proof | |
| 218 |   fix x :: 'a show "\<not> open {x}"
 | |
| 219 | proof | |
| 220 |     assume "open {x}"
 | |
| 221 | then obtain e where "0 < e" and e: "\<forall>y. dist y x < e \<longrightarrow> y = x" | |
| 222 | unfolding open_dist by fast | |
| 63040 | 223 | define y where "y = x + scaleR (e/2) (SOME b. b \<in> Basis)" | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 224 | have [simp]: "(SOME b. b \<in> Basis) \<in> Basis" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 225 | by (rule someI_ex) (auto simp: ex_in_conv) | 
| 60420 | 226 | from \<open>0 < e\<close> have "y \<noteq> x" | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 227 | unfolding y_def by (auto intro!: nonzero_Basis) | 
| 60420 | 228 | from \<open>0 < e\<close> have "dist y x < e" | 
| 53939 | 229 | unfolding y_def by (simp add: dist_norm) | 
| 60420 | 230 | from \<open>y \<noteq> x\<close> and \<open>dist y x < e\<close> show "False" | 
| 44571 | 231 | using e by simp | 
| 232 | qed | |
| 233 | qed | |
| 234 | ||
| 60420 | 235 | subsection \<open>Class instances\<close> | 
| 33175 | 236 | |
| 70136 | 237 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Type \<^typ>\<open>real\<close>\<close> | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 238 | |
| 68617 | 239 | instantiation real :: euclidean_space | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 240 | begin | 
| 44129 | 241 | |
| 63627 | 242 | definition | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 243 |   [simp]: "Basis = {1::real}"
 | 
| 44129 | 244 | |
| 245 | instance | |
| 61169 | 246 | by standard auto | 
| 44129 | 247 | |
| 248 | end | |
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 249 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 250 | lemma DIM_real[simp]: "DIM(real) = 1" | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 251 | by simp | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 252 | |
| 70136 | 253 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Type \<^typ>\<open>complex\<close>\<close> | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 254 | |
| 68617 | 255 | instantiation complex :: euclidean_space | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 256 | begin | 
| 44129 | 257 | |
| 63589 | 258 | definition Basis_complex_def: "Basis = {1, \<i>}"
 | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 259 | |
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 260 | instance | 
| 62390 | 261 | by standard (auto simp add: Basis_complex_def intro: complex_eqI split: if_split_asm) | 
| 44129 | 262 | |
| 263 | end | |
| 264 | ||
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 265 | lemma DIM_complex[simp]: "DIM(complex) = 2" | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 266 | unfolding Basis_complex_def by simp | 
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 267 | |
| 68310 | 268 | lemma complex_Basis_1 [iff]: "(1::complex) \<in> Basis" | 
| 269 | by (simp add: Basis_complex_def) | |
| 270 | ||
| 271 | lemma complex_Basis_i [iff]: "\<i> \<in> Basis" | |
| 272 | by (simp add: Basis_complex_def) | |
| 273 | ||
| 70136 | 274 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Type \<^typ>\<open>'a \<times> 'b\<close>\<close> | 
| 38656 | 275 | |
| 69511 | 276 | instantiation prod :: (real_inner, real_inner) real_inner | 
| 277 | begin | |
| 278 | ||
| 279 | definition inner_prod_def: | |
| 280 | "inner x y = inner (fst x) (fst y) + inner (snd x) (snd y)" | |
| 281 | ||
| 282 | lemma inner_Pair [simp]: "inner (a, b) (c, d) = inner a c + inner b d" | |
| 283 | unfolding inner_prod_def by simp | |
| 284 | ||
| 285 | instance | |
| 286 | proof | |
| 287 | fix r :: real | |
| 288 | fix x y z :: "'a::real_inner \<times> 'b::real_inner" | |
| 289 | show "inner x y = inner y x" | |
| 290 | unfolding inner_prod_def | |
| 291 | by (simp add: inner_commute) | |
| 292 | show "inner (x + y) z = inner x z + inner y z" | |
| 293 | unfolding inner_prod_def | |
| 294 | by (simp add: inner_add_left) | |
| 295 | show "inner (scaleR r x) y = r * inner x y" | |
| 296 | unfolding inner_prod_def | |
| 297 | by (simp add: distrib_left) | |
| 298 | show "0 \<le> inner x x" | |
| 299 | unfolding inner_prod_def | |
| 300 | by (intro add_nonneg_nonneg inner_ge_zero) | |
| 301 | show "inner x x = 0 \<longleftrightarrow> x = 0" | |
| 302 | unfolding inner_prod_def prod_eq_iff | |
| 303 | by (simp add: add_nonneg_eq_0_iff) | |
| 304 | show "norm x = sqrt (inner x x)" | |
| 305 | unfolding norm_prod_def inner_prod_def | |
| 306 | by (simp add: power2_norm_eq_inner) | |
| 307 | qed | |
| 308 | ||
| 309 | end | |
| 310 | ||
| 311 | lemma inner_Pair_0: "inner x (0, b) = inner (snd x) b" "inner x (a, 0) = inner (fst x) a" | |
| 312 | by (cases x, simp)+ | |
| 313 | ||
| 68617 | 314 | instantiation prod :: (euclidean_space, euclidean_space) euclidean_space | 
| 38656 | 315 | begin | 
| 316 | ||
| 44129 | 317 | definition | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 318 | "Basis = (\<lambda>u. (u, 0)) ` Basis \<union> (\<lambda>v. (0, v)) ` Basis" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 319 | |
| 64267 | 320 | lemma sum_Basis_prod_eq: | 
| 54781 | 321 |   fixes f::"('a*'b)\<Rightarrow>('a*'b)"
 | 
| 64267 | 322 | shows "sum f Basis = sum (\<lambda>i. f (i, 0)) Basis + sum (\<lambda>i. f (0, i)) Basis" | 
| 54781 | 323 | proof - | 
| 324 | have "inj_on (\<lambda>u. (u::'a, 0::'b)) Basis" "inj_on (\<lambda>u. (0::'a, u::'b)) Basis" | |
| 325 | by (auto intro!: inj_onI Pair_inject) | |
| 326 | thus ?thesis | |
| 327 | unfolding Basis_prod_def | |
| 64267 | 328 | by (subst sum.union_disjoint) (auto simp: Basis_prod_def sum.reindex) | 
| 54781 | 329 | qed | 
| 330 | ||
| 44129 | 331 | instance proof | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 332 |   show "(Basis :: ('a \<times> 'b) set) \<noteq> {}"
 | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 333 | unfolding Basis_prod_def by simp | 
| 44129 | 334 | next | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 335 |   show "finite (Basis :: ('a \<times> 'b) set)"
 | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 336 | unfolding Basis_prod_def by simp | 
| 44129 | 337 | next | 
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 338 | fix u v :: "'a \<times> 'b" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 339 | assume "u \<in> Basis" and "v \<in> Basis" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 340 | thus "inner u v = (if u = v then 1 else 0)" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 341 | unfolding Basis_prod_def inner_prod_def | 
| 62390 | 342 | by (auto simp add: inner_Basis split: if_split_asm) | 
| 44129 | 343 | next | 
| 344 | fix x :: "'a \<times> 'b" | |
| 44166 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 345 | show "(\<forall>u\<in>Basis. inner x u = 0) \<longleftrightarrow> x = 0" | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 346 | unfolding Basis_prod_def ball_Un ball_simps | 
| 
d12d89a66742
modify euclidean_space class to include basis set
 huffman parents: 
44133diff
changeset | 347 | by (simp add: inner_prod_def prod_eq_iff euclidean_all_zero_iff) | 
| 38656 | 348 | qed | 
| 44129 | 349 | |
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 350 | lemma DIM_prod[simp]: "DIM('a \<times> 'b) = DIM('a) + DIM('b)"
 | 
| 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 351 | unfolding Basis_prod_def | 
| 67399 | 352 | by (subst card_Un_disjoint) (auto intro!: card_image arg_cong2[where f="(+)"] inj_onI) | 
| 50526 
899c9c4e4a4c
Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
 hoelzl parents: 
44902diff
changeset | 353 | |
| 37489 
44e42d392c6e
Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
 hoelzl parents: 
36778diff
changeset | 354 | end | 
| 38656 | 355 | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 356 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 357 | subsection \<open>Locale instances\<close> | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 358 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 359 | lemma finite_dimensional_vector_space_euclidean: | 
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 360 | "finite_dimensional_vector_space (*\<^sub>R) Basis" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 361 | proof unfold_locales | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 362 | show "finite (Basis::'a set)" by (metis finite_Basis) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 363 | show "real_vector.independent (Basis::'a set)" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 364 | unfolding dependent_def dependent_raw_def[symmetric] | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 365 | apply (subst span_finite) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 366 | apply simp | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 367 | apply clarify | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 368 | apply (drule_tac f="inner a" in arg_cong) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 369 | apply (simp add: inner_Basis inner_sum_right eq_commute) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 370 | done | 
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 371 | show "module.span (*\<^sub>R) Basis = UNIV" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 372 | unfolding span_finite [OF finite_Basis] span_raw_def[symmetric] | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 373 | by (auto intro!: euclidean_representation[symmetric]) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 374 | qed | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 375 | |
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 376 | interpretation eucl?: finite_dimensional_vector_space "scaleR :: real => 'a => 'a::euclidean_space" "Basis" | 
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 377 | rewrites "module.dependent (*\<^sub>R) = dependent" | 
| 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 378 | and "module.representation (*\<^sub>R) = representation" | 
| 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 379 | and "module.subspace (*\<^sub>R) = subspace" | 
| 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 380 | and "module.span (*\<^sub>R) = span" | 
| 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 381 | and "vector_space.extend_basis (*\<^sub>R) = extend_basis" | 
| 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 382 | and "vector_space.dim (*\<^sub>R) = dim" | 
| 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 383 | and "Vector_Spaces.linear (*\<^sub>R) (*\<^sub>R) = linear" | 
| 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 384 | and "Vector_Spaces.linear (*) (*\<^sub>R) = linear" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 385 |     and "finite_dimensional_vector_space.dimension Basis = DIM('a)"
 | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 386 |     and "dimension = DIM('a)"
 | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 387 | by (auto simp add: dependent_raw_def representation_raw_def | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 388 | subspace_raw_def span_raw_def extend_basis_raw_def dim_raw_def linear_def | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 389 | real_scaleR_def[abs_def] | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 390 | finite_dimensional_vector_space.dimension_def | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 391 | intro!: finite_dimensional_vector_space.dimension_def | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 392 | finite_dimensional_vector_space_euclidean) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 393 | |
| 68620 
707437105595
relaxed assumptions for dim_image_eq and dim_image_le
 immler parents: 
68617diff
changeset | 394 | interpretation eucl?: finite_dimensional_vector_space_pair_1 | 
| 
707437105595
relaxed assumptions for dim_image_eq and dim_image_le
 immler parents: 
68617diff
changeset | 395 | "scaleR::real\<Rightarrow>'a::euclidean_space\<Rightarrow>'a" Basis | 
| 
707437105595
relaxed assumptions for dim_image_eq and dim_image_le
 immler parents: 
68617diff
changeset | 396 | "scaleR::real\<Rightarrow>'b::real_vector \<Rightarrow> 'b" | 
| 
707437105595
relaxed assumptions for dim_image_eq and dim_image_le
 immler parents: 
68617diff
changeset | 397 | by unfold_locales | 
| 
707437105595
relaxed assumptions for dim_image_eq and dim_image_le
 immler parents: 
68617diff
changeset | 398 | |
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 399 | interpretation eucl?: finite_dimensional_vector_space_prod scaleR scaleR Basis Basis | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 400 | rewrites "Basis_pair = Basis" | 
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 401 |     and "module_prod.scale (*\<^sub>R) (*\<^sub>R) = (scaleR::_\<Rightarrow>_\<Rightarrow>('a \<times> 'b))"
 | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 402 | proof - | 
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 403 | show "finite_dimensional_vector_space_prod (*\<^sub>R) (*\<^sub>R) Basis Basis" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 404 | by unfold_locales | 
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 405 | interpret finite_dimensional_vector_space_prod "(*\<^sub>R)" "(*\<^sub>R)" "Basis::'a set" "Basis::'b set" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 406 | by fact | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 407 | show "Basis_pair = Basis" | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 408 | unfolding Basis_pair_def Basis_prod_def by auto | 
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
68620diff
changeset | 409 | show "module_prod.scale (*\<^sub>R) (*\<^sub>R) = scaleR" | 
| 68072 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 410 | by (fact module_prod_scale_eq_scaleR) | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 411 | qed | 
| 
493b818e8e10
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
 immler parents: 
67962diff
changeset | 412 | |
| 38656 | 413 | end |