Quelle Order.lean
Sprache: Lean
|
|
/-
Copyright (c) 2025 Monica Omar. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Monica Omar
-/
module
public import Mathlib.Algebra.Order.Module.PositiveLinearMap
public import Mathlib.Analysis.CStarAlgebra.Matrix
public import Mathlib.Analysis.Matrix.HermitianFunctionalCalculus
public import Mathlib.Analysis.Matrix.PosDef
public import Mathlib.Analysis.RCLike.Sqrt
public import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.Abs
/-!
# The partial order on matrices
This file constructs the partial order and star ordered instances on matrices on ``.
This allows us to use more general results from C⋆-algebras, like `CFC.sqrt`.
## Main results
* `Matrix.instPartialOrder`: the partial order on matrices given by `x ≤ y := (y - x).PosSemidef`.
* `Matrix.toMatrixInnerProductSpace`: the inner product on matrices induced by a
positive semi-definite matrix `M`: `⟪x, y⟫ = (y * M * xᴴ).trace`.
## Implementation notes
Note that the partial order instance is scoped to `MatrixOrder`.
Please `open scoped MatrixOrder` to use this.
-/
@[expose] public section
variable { m n : Type*} [RCLike ]
open scoped ComplexOrder
open Matrix
namespace Matrix
section PartialOrder
/-- The preorder on matrices given by `A ≤ B := (B - A).PosSemidef`. -/
abbrev instPreOrder : Preorder (Matrix n n ) where
le A B := (B - A).PosSemidef
le_refl A := sub_self A ▸ PosSemidef.zero
le_trans A B C h₁ h₂ := sub_add_sub_cancel C B A ▸ h₂.add h₁
scoped[MatrixOrder] attribute [instance] Matrix.instPreOrder
open MatrixOrder
lemma le_iff {A B : Matrix n n } : A ≤ B ↔ (B - A).PosSemidef := Iff.rfl
lemma nonneg_iff_posSemidef {A : Matrix n n } : 0 ≤ A ↔ A.PosSemidef := by rw [le_iff, sub_zero]
protected alias ⟨LE.le.posSemidef, PosSemidef.nonneg⟩ := nonneg_iff_posSemidef
attribute [aesop safe forward (rule_sets := [CStarAlgebra])] PosSemidef.nonneg
private lemma le_antisymm_aux {A : Matrix n n } (h₁ : A.PosSemidef) (h₂ : (-A).PosSemidef) :
A = 0 := by
classical
ext i j
have hdiag i : A i i = 0 :=
le_antisymm (by simpa using h₂.diag_nonneg) (by simpa using h₁.diag_nonneg)
have h1 := h₁.2 (.single i 1 + .single j (A j i))
have h2 := h₂.2 (.single i 1 + .single j (A j i))
simp [Finsupp.sum_add_index, mul_add, add_mul,
-neg_add_rev, hdiag, ← h₁.1.apply j i, -RCLike.star_def] at *
simpa using le_antisymm h2 h1
/-- The partial order on matrices given by `A ≤ B := (B - A).PosSemidef`. -/
abbrev instPartialOrder : PartialOrder (Matrix n n ) where
le_antisymm A B h₁ h₂ := by
simpa [sub_eq_zero, eq_comm] using le_antisymm_aux h₁
(by simpa only [← neg_sub B, le_iff] using h₂)
scoped[MatrixOrder] attribute [instance] Matrix.instPartialOrder
lemma instIsOrderedAddMonoid : IsOrderedAddMonoid (Matrix n n ) where
add_le_add_left _ _ _ _ := by rwa [le_iff, add_sub_add_right_eq_sub]
scoped[MatrixOrder] attribute [instance] Matrix.instIsOrderedAddMonoid
@[deprecated isClosed_setOfPred_posSemidef +typeChanged (since := "2026-10-28")]
lemma posSemidef_is_closed : IsClosed {A : Matrix n n | A.PosSemidef} :=
isClosed_setOfPred_posSemidef
lemma instOrderClosedTopology : OrderClosedTopology (Matrix n n ) where
isClosed_le' := isClosed_le_of_isClosed_nonneg <| by
simpa [nonneg_iff_posSemidef] using isClosed_setOfPred_posSemidef
scoped[MatrixOrder] attribute [instance] Matrix.instOrderClosedTopology
variable [Fintype n]
lemma instNonnegSpectrumClass : NonnegSpectrumClass ℝ (Matrix n n ) where
quasispectrum_nonneg_of_nonneg A hA := by
classical
simp only [quasispectrum_eq_spectrum_union_zero ℝ A, Set.union_singleton, Set.mem_insert_iff,
forall_eq_or_imp, le_refl, true_and]
intro x hx
obtain ⟨i, rfl⟩ := Set.ext_iff.mp
hA.posSemidef.1.spectrum_real_eq_range_eigenvalues x |>.mp hx
exact hA.posSemidef.eigenvalues_nonneg _
scoped[MatrixOrder] attribute [instance] instNonnegSpectrumClass
lemma instStarOrderedRing : StarOrderedRing (Matrix n n ) :=
.of_nonneg_iff' add_le_add_right fun A ↦
⟨fun hA ↦ by
classical
obtain ⟨X, hX, -, rfl⟩ :=
sub_zero A ▸ CFC.exists_sqrt_of_isSelfAdjoint_of_quasispectrumRestricts hA.isHermitian
(QuasispectrumRestricts.nnreal_of_nonneg hA.nonneg)
exact ⟨X, hX.star_eq.symm ▸ rfl⟩,
fun ⟨A, hA⟩ => hA ▸ (posSemidef_conjTranspose_mul_self A).nonneg⟩
scoped[MatrixOrder] attribute [instance] instStarOrderedRing
end PartialOrder
open scoped MatrixOrder
namespace PosSemidef
variable [Fintype n]
section sqrtDeprecated
variable [DecidableEq n] {A : Matrix n n } (hA : PosSemidef A)
include hA
lemma inv_sqrt : (CFC.sqrt A)⁻¹ = CFC.sqrt A⁻¹ := by
rw [eq_comm, CFC.sqrt_eq_iff _ _ hA.inv.nonneg (CFC.sqrt_nonneg A).posSemidef.inv.nonneg, ← sq,
inv_pow', CFC.sq_sqrt A]
end sqrtDeprecated
theorem det_sqrt [DecidableEq n] {A : Matrix n n } (hA : A.PosSemidef) :
(CFC.sqrt A).det = RCLike.sqrt A.det := by
rw [CFC.sqrt_eq_cfc, cfc_nnreal_eq_real _ A, hA.1.cfc_eq, RCLike.sqrt_of_nonneg hA.det_nonneg]
simp only [IsHermitian.cfc, Real.coe_sqrt, Real.coe_toNNReal', det_map, det_diagonal,
Function.comp_apply, hA.isHermitian.det_eq_prod_eigenvalues, ← RCLike.ofReal_prod,
RCLike.ofReal_re, Real.sqrt_prod _ fun _ _ ↦ hA.eigenvalues_nonneg _]
grind
end PosSemidef
section
variable [Fintype n]
theorem IsHermitian.det_abs [DecidableEq n] {A : Matrix n n } (hA : A.IsHermitian) :
det (CFC.abs A) = ‖det A‖ := by
rw [CFC.abs_eq_cfc_norm A, hA.cfc_eq]
simp [IsHermitian.cfc, -Unitary.conjStarAlgAut_apply, hA.det_eq_prod_eigenvalues]
theorem posSemidef_iff_isHermitian_and_spectrum_nonneg [DecidableEq n] {A : Matrix n n } :
A.PosSemidef ↔ A.IsHermitian ∧ spectrum A ⊆ {a : | 0 ≤ a} := by
refine ⟨fun h => ⟨h.isHermitian, fun a => ?_⟩, fun ⟨h1, h2⟩ => ?_⟩
· simp only [h.isHermitian.spectrum_eq_image_range, Set.mem_image, Set.mem_range,
exists_exists_eq_and, Set.mem_ofPred_eq, forall_exists_index]
rintro i rfl
exact mod_cast h.eigenvalues_nonneg _
· rw [h1.posSemidef_iff_eigenvalues_nonneg]
intro i
simpa [h1.spectrum_eq_image_range] using @h2 (h1.eigenvalues i)
theorem isStrictlyPositive_iff_posDef [DecidableEq n] {x : Matrix n n } :
IsStrictlyPositive x ↔ x.PosDef :=
⟨fun h => h.nonneg.posSemidef.posDef_iff_isUnit.mpr h.isUnit,
fun h => h.isUnit.isStrictlyPositive h.posSemidef.nonneg⟩
alias ⟨IsStrictlyPositive.posDef, PosDef.isStrictlyPositive⟩ := isStrictlyPositive_iff_posDef
attribute [aesop safe forward (rule_sets := [CStarAlgebra])] PosDef.isStrictlyPositive
end
section kronecker
open scoped Kronecker
/-- The kronecker product of two positive semi-definite matrices is positive semi-definite. -/
theorem PosSemidef.kronecker {x : Matrix n n } {y : Matrix m m }
(hx : x.PosSemidef) (hy : y.PosSemidef) : (x ⊗ₖ y).PosSemidef := by
classical
rw [posSemidef_iff_submatrix_of_forall_finset
(fun p : Finset n × Finset m ↦ Prod.map ((↑) : p.1 → n) ((↑) : p.2 → m))]
· rintro ⟨s, t⟩
obtain ⟨a, ha⟩ :=
CStarAlgebra.nonneg_iff_eq_star_mul_self.mp (hx.submatrix ((↑) : s → n)).nonneg
obtain ⟨b, hb⟩ :=
CStarAlgebra.nonneg_iff_eq_star_mul_self.mp (hy.submatrix ((↑) : t → m)).nonneg
simpa [← kroneckerMap_submatrix_submatrix, ha, hb, mul_kronecker_mul, ← conjTranspose_kronecker,
star_eq_conjTranspose] using posSemidef_conjTranspose_mul_self _
· intro s
exact ⟨(s.image Prod.fst, s.image Prod.snd), fun _ ↦ by simp [Set.range_prodMap]; grind⟩
open Matrix in
/-- The kronecker of two positive definite matrices is positive definite. -/
theorem PosDef.kronecker {x : Matrix n n } {y : Matrix m m }
(hx : x.PosDef) (hy : y.PosDef) : (x ⊗ₖ y).PosDef := by
classical
rw [posDef_iff_submatrix_of_forall_finset
(fun p : Finset n × Finset m ↦ Prod.map ((↑) : p.1 → n) ((↑) : p.2 → m))
(fun _ ↦ Subtype.coe_injective.prodMap Subtype.coe_injective)]
· rintro ⟨s, t⟩
have hx' := hx.submatrix (Subtype.coe_injective (p := (· ∈ s)))
have hy' := hy.submatrix (Subtype.coe_injective (p := (· ∈ t)))
exact (hx'.posSemidef.kronecker hy'.posSemidef).posDef_iff_isUnit.mpr
(hx'.isUnit.kronecker hy'.isUnit)
· intro s
exact ⟨(s.image Prod.fst, s.image Prod.snd), fun _ ↦ by simp [Set.range_prodMap]; grind⟩
end kronecker
section hadamard
variable {ι : Type*}
/-- [**Schur product theorem**][schur1911] (positive semidefinite version): the Hadamard (entrywise)
product of positive semidefinite matrices is positive semidefinite. -/
theorem PosSemidef.hadamard {A B : Matrix ι ι }
(hA : A.PosSemidef) (hB : B.PosSemidef) : (A ⊙ B).PosSemidef :=
(hA.kronecker hB).submatrix fun i ↦ (i, i)
/-- **Schur product theorem**: the Hadamard (entrywise) product of positive definite
matrices is positive definite. -/
theorem PosDef.hadamard {A B : Matrix ι ι }
(hA : A.PosDef) (hB : B.PosDef) : (A ⊙ B).PosDef :=
(hA.kronecker hB).submatrix (e := fun i ↦ (i, i)) fun _ _ h ↦ congrArg Prod.fst h
end hadamard
section tracePositiveLinearMap
variable (n α : Type*) [Fintype n] [Semiring α] [RCLike ] [Module α ]
/-- `Matrix.trace` as a positive linear map. -/
def tracePositiveLinearMap : Matrix n n →ₚ[α] :=
.mk₀ (traceLinearMap n α ) fun _ h ↦ h.posSemidef.trace_nonneg
@[simp] lemma toLinearMap_tracePositiveLinearMap :
(tracePositiveLinearMap n α ).toLinearMap = traceLinearMap n α := rfl
@[simp] lemma tracePositiveLinearMap_apply (x) : tracePositiveLinearMap n α x = trace x := rfl
end tracePositiveLinearMap
section
variable [Fintype m] [Fintype n]
variable (m)
set_option backward.privateInPublic true in
/-- The pre-inner product space structure implementation. Only an auxiliary for
`Matrix.toMatrixSeminormedAddCommGroup`, `Matrix.toMatrixNormedAddCommGroup`,
and `Matrix.toMatrixInnerProductSpace`. -/
private abbrev PosSemidef.matrixPreInnerProductSpace {M : Matrix n n } (hM : M.PosSemidef) :
PreInnerProductSpace.Core (Matrix m n ) where
inner x y := (y * M * xᴴ).trace
conj_inner_symm _ _ := by
simp only [Matrix.mul_assoc, starRingEnd_apply, ← trace_conjTranspose, conjTranspose_mul,
conjTranspose_conjTranspose, hM.isHermitian.eq]
re_inner_nonneg x := RCLike.nonneg_iff.mp (hM.mul_mul_conjTranspose_same x).trace_nonneg |>.1
add_left := by simp [Matrix.mul_add]
smul_left := by simp
set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
/-- A positive definite matrix `M` induces a norm on `Matrix m n `
`‖x‖ = sqrt (x * M * xᴴ).trace`. -/
@[instance_reducible]
noncomputable def toMatrixSeminormedAddCommGroup (M : Matrix n n ) (hM : M.PosSemidef) :
SeminormedAddCommGroup (Matrix m n ) :=
@InnerProductSpace.Core.toSeminormedAddCommGroup _ _ _ _ _ (hM.matrixPreInnerProductSpace m)
set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
/-- A positive definite matrix `M` induces a norm on `Matrix m n `:
`‖x‖ = sqrt (x * M * xᴴ).trace`. -/
@[instance_reducible]
noncomputable def toMatrixNormedAddCommGroup (M : Matrix n n ) (hM : M.PosDef) :
NormedAddCommGroup (Matrix m n ) :=
letI : InnerProductSpace.Core (Matrix m n ) :=
{ __ := hM.posSemidef.matrixPreInnerProductSpace m
definite x hx := by
classical
obtain ⟨y, hy, rfl⟩ := CStarAlgebra.isStrictlyPositive_iff_eq_star_mul_self.mp
hM.isStrictlyPositive
simp +instances only at hx
rw [← Matrix.mul_assoc, ← conjTranspose_conjTranspose x, star_eq_conjTranspose,
← conjTranspose_mul, conjTranspose_conjTranspose, Matrix.mul_assoc,
trace_conjTranspose_mul_self_eq_zero_iff] at hx
lift y to (Matrix n n )ˣ using hy
simpa [← mul_assoc] using congr(y⁻¹.val * $hx) }
this.toNormedAddCommGroup
/-- A positive semi-definite matrix `M` induces an inner product on `Matrix m n `:
`⟪x, y⟫ = (y * M * xᴴ).trace`. -/
@[instance_reducible]
def toMatrixInnerProductSpace (M : Matrix n n ) (hM : M.PosSemidef) :
letI : SeminormedAddCommGroup (Matrix m n ) := M.toMatrixSeminormedAddCommGroup m hM
InnerProductSpace (Matrix m n ) :=
InnerProductSpace.ofCore _
open scoped Norms.L2Operator in
/-- The isometric continuous functional calculus on `Matrix n n ` arising from the operator norm
given by the identification with (continuous) linear endomorphisms of `EuclideanSpace n`. -/
instance instIsometricContinuousFunctionalCalculus [DecidableEq n] :
IsometricContinuousFunctionalCalculus ℝ (Matrix n n ) IsSelfAdjoint where
isometric A hA := by
rw [← isHermitian_iff_isSelfAdjoint] at hA
rw [IsHermitian.cfcHom_eq_cfcAux hA, AddMonoidHomClass.isometry_iff_norm]
intro f
simp only [IsHermitian.cfcAux_apply, Unitary.conjStarAlgAut_apply, ← Unitary.coe_star,
CStarRing.norm_mul_coe_unitary, CStarRing.norm_coe_unitary_mul, l2_opNorm_diagonal]
rw [((algebraMap_isometry ℝ ).postcomp_pi).norm_map_of_map_zero (by ext; simp)]
let : Fintype (spectrum ℝ A) := .ofFinite _
rw [ContinuousMap.norm_eq_norm_coeFn]
refine Function.Surjective.pi_norm_comp ?_ _
rw [← Function.Surjective.of_comp_iff'
(Set.equivOfEq hA.spectrum_real_eq_range_eigenvalues).bijective]
exact Set.codRestrict_range_surjective hA.eigenvalues
scoped[Matrix.Norms.L2Operator] attribute [instance]
Matrix.instIsometricContinuousFunctionalCalculus
end
end Matrix
¤ Dauer der Verarbeitung: 0.12 Sekunden
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|