import Mathlib namespace OAI namespace BorsukNine open scoped RealInnerProductSpace ContDiff open scoped Manifold open MeasureTheory Set Metric open scoped ENNReal Pointwise Matrix section MatrixNorm open scoped MatrixOrder Matrix.Norms.L2Operator variable {ν : Type*} [Fintype ν] [DecidableEq ν] local notation "E" => EuclideanSpace ℝ ν lemma matrix_action_norm_sq (A : Matrix ν ν ℝ) (x : E) : ‖(Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ)) A x‖ ^ 2 = ⟪x, (Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ)) (star A * A) x⟫ := by rw [map_mul, map_star] change ‖(Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ)) A x‖ ^ 2 = ⟪x, (star ((Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ)) A)) ((Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ)) A x)⟫ rw [ContinuousLinearMap.star_eq_adjoint, ContinuousLinearMap.adjoint_inner_right, real_inner_self_eq_norm_sq] lemma sqrt_action_norm_sq (Q : Matrix ν ν ℝ) (hQ : 0 ≤ Q) (x : E) : ‖(Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ)) (CFC.sqrt Q) x‖ ^ 2 = ⟪x, (Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ)) Q x⟫ := by rw [matrix_action_norm_sq, (CFC.sqrt_nonneg Q).star_eq, CFC.sqrt_mul_sqrt_self Q hQ] lemma matrix_sqrt_smul {Q : Matrix ν ν ℝ} (hQ : 0 ≤ Q) {t : ℝ} (ht : 0 ≤ t) : CFC.sqrt (t • Q) = Real.sqrt t • CFC.sqrt Q := by apply (CFC.sqrt_eq_iff _ _ (smul_nonneg ht hQ) (smul_nonneg (Real.sqrt_nonneg _) (CFC.sqrt_nonneg _))).mpr rw [smul_mul_smul, CFC.sqrt_mul_sqrt_self Q hQ, Real.mul_self_sqrt ht] end MatrixNorm section MatrixRange open scoped MatrixOrder Matrix.Norms.L2Operator variable {ν : Type*} [Fintype ν] [DecidableEq ν] local notation "E" => EuclideanSpace ℝ ν local notation "op" => Matrix.toEuclideanCLM (n := ν) (𝕜 := ℝ) lemma matrix_sqrt_range (Q : Matrix ν ν ℝ) (hQ : 0 ≤ Q) : LinearMap.range (op (CFC.sqrt Q)).toLinearMap = LinearMap.range (op Q).toLinearMap := by have hs : star (op (CFC.sqrt Q)) = op (CFC.sqrt Q) := by rw [← map_star, (CFC.sqrt_nonneg Q).star_eq] have hh := LinearMap.range_adjoint_comp_self (op (CFC.sqrt Q)).toLinearMap have ha : (op (CFC.sqrt Q)).toLinearMap.adjoint = (op (CFC.sqrt Q)).toLinearMap := by change (ContinuousLinearMap.adjoint (op (CFC.sqrt Q))).toLinearMap = _ rw [← ContinuousLinearMap.star_eq_adjoint, hs] rw [ha] at hh have hm : (op (CFC.sqrt Q)).toLinearMap.comp (op (CFC.sqrt Q)).toLinearMap = (op Q).toLinearMap := by change (op (CFC.sqrt Q) * op (CFC.sqrt Q)).toLinearMap = _ rw [← map_mul, CFC.sqrt_mul_sqrt_self Q hQ] rw [hm] at hh exact hh.symm end MatrixRange end BorsukNine end OAI