Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

[Merged by Bors] - feat(analysis/inner_product_space/gram_schmidt_ortho): Gram-Schmidt Orthogonalization and Orthonormalization #12857

Closed
wants to merge 69 commits into from
Closed
Changes from 8 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d02693b
doc(linear_algebra): Gram-Schmidt Orthogonalization and Orthornormali…
Biiiilly Mar 21, 2022
89b0132
change from review
Biiiilly Mar 21, 2022
3c498d5
change import
Biiiilly Mar 21, 2022
bd02f66
changes from review
Biiiilly Mar 21, 2022
8769f46
changes from reviews
Biiiilly Mar 21, 2022
6f87999
changes from review
Biiiilly Mar 21, 2022
49238f0
changes from reviews
Biiiilly Mar 22, 2022
6b8e358
changes from reviews
Biiiilly Mar 22, 2022
63c3e86
changes from reviews
Biiiilly Mar 22, 2022
31af760
changes from reviews
Biiiilly Mar 22, 2022
ee95b97
changes from reviews
Biiiilly Mar 23, 2022
6c8964b
change some doc-strings
Biiiilly Mar 23, 2022
15c0b54
add proof of span
Biiiilly Mar 26, 2022
6e55b6e
change doc
Biiiilly Mar 26, 2022
5f329da
changes from reviews
Biiiilly Mar 26, 2022
ba9d844
changes from reviews
Biiiilly Mar 26, 2022
4e9899f
changes from reviews
Biiiilly Mar 26, 2022
40772c0
add doc to def of gs process
Biiiilly Mar 26, 2022
ad7fc34
change doc of inner notation
Biiiilly Mar 27, 2022
8c9e27e
changes from reviews
Biiiilly Mar 27, 2022
4ca03b5
change some
Biiiilly Mar 28, 2022
d385acb
change some small mistakes
Biiiilly Mar 28, 2022
c1d567e
change small mistake
Biiiilly Mar 28, 2022
928e45a
change from reviews
Biiiilly Mar 31, 2022
fda0a2b
change path to inner product space
Biiiilly Mar 31, 2022
d1ab7e6
add TODO
Biiiilly Apr 5, 2022
3c1f2a9
change from reviews
Biiiilly Apr 5, 2022
607af4f
change from reviews
Biiiilly Apr 5, 2022
8ff5618
change from review
Biiiilly Apr 5, 2022
280dd61
change from review
Biiiilly Apr 5, 2022
67c9d61
change Iic to range
Biiiilly Apr 6, 2022
b206c41
add gram_schmidt_orhogonal
Biiiilly Apr 6, 2022
a553ce5
change from reviews
Biiiilly Apr 10, 2022
4e176ee
suffices
Biiiilly Apr 12, 2022
be24d1b
simplify span proof
Biiiilly Apr 13, 2022
baa718a
simp span
Biiiilly Apr 14, 2022
f454a3c
change line length
Biiiilly Apr 14, 2022
19e1c52
change from review about induction and indent
Biiiilly Apr 14, 2022
bd76fb8
change some mistake
Biiiilly Apr 14, 2022
bb71c43
simp nezero proof
Biiiilly Apr 14, 2022
9caf604
simp proof
Biiiilly Apr 14, 2022
5f727c0
change doc
Biiiilly Apr 15, 2022
8319da4
simp proof
Biiiilly Apr 15, 2022
9c18e8a
simp proof
Biiiilly Apr 15, 2022
c3d0cde
changes
Biiiilly Apr 15, 2022
47c0e56
changess
Biiiilly Apr 15, 2022
26945ed
simp proof
Biiiilly Apr 15, 2022
2482b0a
simp proof again
Biiiilly Apr 15, 2022
14a3537
simp simp proof
Biiiilly Apr 15, 2022
1abfff2
simp proof
Biiiilly Apr 16, 2022
962091a
simp
Biiiilly Apr 16, 2022
b3afd14
change from review
Biiiilly Apr 17, 2022
4e3996b
Iic_succ
Biiiilly Apr 17, 2022
0360e03
add Iic_succ
Biiiilly Apr 17, 2022
7865671
simp proof
Biiiilly Apr 17, 2022
e8506b4
simp proof aaaagin
Biiiilly Apr 18, 2022
06d7d6d
iicsucc
Biiiilly Apr 19, 2022
f04f835
Merge remote-tracking branch 'origin' into GS_doc
Biiiilly Apr 19, 2022
3c5f8c5
add Iic_succ
Biiiilly Apr 19, 2022
aeeb897
small mis
Biiiilly Apr 19, 2022
c2aede2
cleanup weird induction
eric-wieser Apr 19, 2022
74d8e45
change from review
Biiiilly Apr 19, 2022
2f66e94
change from review
Biiiilly Apr 19, 2022
f6c8abe
change from review
Biiiilly Apr 19, 2022
e96ead0
change doc
Biiiilly Apr 20, 2022
ee54f41
change doc
Biiiilly Apr 20, 2022
431b352
change doc
Biiiilly Apr 20, 2022
418d5ca
change doc
Biiiilly Apr 20, 2022
736430f
change doc
Biiiilly Apr 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions src/linear_algebra/gram_schmidt_ortho.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/-
Copyright (c) 2022 Jiale Miao. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jiale Miao, Kevin Buzzard
-/

import tactic.basic
import algebra.big_operators.basic
import analysis.inner_product_space.basic
import analysis.inner_product_space.projection
import analysis.normed_space.is_R_or_C
Biiiilly marked this conversation as resolved.
Show resolved Hide resolved

/-!
# Gram-Schmidt Orthogonalization and Orthonormalization

In this file we introduce Gram-Schmidt Orthogonalization and Orthonormalization

## Main results

- `gram_schmidt_process` : Gram-Schmidt Process
- `gram_schmidt_process_orthogonal` :
the proof that "gram_schmidt_process" produces an orthogonal system of vectors
- `gram_schmidt_process_normed` :
Normalized "Gram-Schmidt" (i.e each vector in this system has unit length)
- `gram_schmidt_process_orthornormal` :
the proof that "gram_schmidt_process_normed" produces an orthornormal system of vectors
-/

open_locale big_operators

variables (𝕜 : Type*) (E : Type*) [is_R_or_C 𝕜] [inner_product_space 𝕜 E]
Biiiilly marked this conversation as resolved.
Show resolved Hide resolved

/-- Definition of Gram-Schmidt Process -/
noncomputable def gram_schmidt_process (f : ℕ → E) : ℕ → E
| n := f n - ∑ i in finset.range n,
if h1 : i < n then (orthogonal_projection (𝕜 ∙ (gram_schmidt_process i)) (f n) : E) else f 37

/-- 'gram_schmidt_process_def' gets rid of 'ite' in the definition of gram_schmidt_process -/
lemma gram_schmidt_process_def (f : ℕ → E) (n : ℕ) :
gram_schmidt_process 𝕜 E f n = f n - ∑ i in finset.range n,
(orthogonal_projection (𝕜 ∙ (gram_schmidt_process 𝕜 E f i)) (f n) : E) :=
begin
rw [gram_schmidt_process, sub_right_inj],
apply finset.sum_congr rfl,
intros x hx,
rw finset.mem_range at hx,
rw if_pos hx,
end
Biiiilly marked this conversation as resolved.
Show resolved Hide resolved

/-- # Gram-Schmidt Orthogonalisation -/
theorem gram_schmidt_process_orthogonal (f : ℕ → E) (a b : ℕ) (h₀ : a < b) :
(inner (gram_schmidt_process 𝕜 E f a) (gram_schmidt_process 𝕜 E f b) : 𝕜) = 0 :=
begin
have hc : ∃ c, b ≤ c := by refine ⟨b+1, by linarith⟩,
Biiiilly marked this conversation as resolved.
Show resolved Hide resolved
cases hc with c h₁,
induction c with c hc generalizing a b,
{ simp at h₁,
simp [h₁] at h₀,
contradiction },
{ rw nat.le_add_one_iff at h₁,
cases h₁ with hb₁ hb₂,
{ exact hc _ _ h₀ hb₁ },
{ simp only [gram_schmidt_process_def 𝕜 E f (c + 1), hb₂, inner_sub_right, inner_sum],
have h₂ : ∀ x ∈ finset.range(c + 1), x ≠ a →
(inner (gram_schmidt_process 𝕜 E f a)
(orthogonal_projection (𝕜 ∙ (gram_schmidt_process 𝕜 E f x)) (f (c + 1)) : E) : 𝕜) = 0,
{ intros x hx₁ hx₂,
simp only [orthogonal_projection_singleton],
rw inner_smul_right,
cases hx₂.lt_or_lt with hxa₁ hxa₂,
{ have ha₂ : a ≤ c,
{ rw hb₂ at h₀,
exact nat.lt_succ_iff.mp h₀ },
specialize hc x a,
simp [hxa₁, ha₂] at hc,
simp only [mul_eq_zero, div_eq_zero_iff, inner_self_eq_zero],
right,
rwa inner_eq_zero_sym at hc },
{ rw [finset.mem_range, nat.lt_succ_iff] at hx₁,
specialize hc a x,
simp [hxa₂, hx₁] at hc,
simp only [mul_eq_zero, div_eq_zero_iff, inner_self_eq_zero],
right,
exact hc }},
rw hb₂ at h₀,
have ha₂ : a ∈ finset.range(c + 1) := finset.mem_range.mpr h₀,
rw finset.sum_eq_single_of_mem a ha₂ h₂,
simp only [orthogonal_projection_singleton],
rw inner_smul_right,
by_cases (inner (gram_schmidt_process 𝕜 E f a) (gram_schmidt_process 𝕜 E f a) : 𝕜) = 0,
{ simp only [inner_self_eq_zero] at h,
repeat {rw h},
simp only [inner_zero_left, mul_zero, sub_zero] },
{ rw ← inner_self_eq_norm_sq_to_K,
simp [h] }}}
end

/-- Generalised Gram-Schmidt Orthorgonalization -/
theorem gram_schmidt_process_orthogonal' (f : ℕ → E) (a b : ℕ) (h₀ : a ≠ b) :
(inner (gram_schmidt_process 𝕜 E f a) (gram_schmidt_process 𝕜 E f b) : 𝕜) = 0 :=
begin
cases h₀.lt_or_lt with ha hb,
{ exact gram_schmidt_process_orthogonal 𝕜 E f a b ha },
{ rw inner_eq_zero_sym,
exact gram_schmidt_process_orthogonal 𝕜 E f b a hb }
end

/-- Normalized Gram-Schmidt Process -/
noncomputable def gram_schmidt_process_normed (f : ℕ → E) (n : ℕ) : E :=
(∥ gram_schmidt_process 𝕜 E f n ∥ : 𝕜)⁻¹ • (gram_schmidt_process 𝕜 E f n)

lemma gram_schmidt_process_unit_length (f : ℕ → E) (n : ℕ) (h : gram_schmidt_process 𝕜 E f n ≠ 0) :
∥ gram_schmidt_process_normed 𝕜 E f n ∥ = 1 :=
by simp only [gram_schmidt_process_normed, norm_smul_inv_norm h]

/-- # Gram-Schmidt Orthonormalization -/
Biiiilly marked this conversation as resolved.
Show resolved Hide resolved
theorem gram_schmidt_process_orthonormal (f : ℕ → E) (h : ∀ n, gram_schmidt_process 𝕜 E f n ≠ 0) :
orthonormal 𝕜 (gram_schmidt_process_normed 𝕜 E f) :=
begin
simp only [orthonormal],
split,
{ simp [gram_schmidt_process_unit_length, h] },
{ intros i j hij,
simp [gram_schmidt_process_normed, inner_smul_left, inner_smul_right],
repeat {right},
exact gram_schmidt_process_orthogonal' 𝕜 E f i j hij }
end