Offline · exact source
Exact Lean source

MatrixFidelityTraceBound

formalization/Cloning/MatrixFidelityTraceBound.lean

Source hash: 0af66f18ceac01fce1677732eadb689645993b3be125062b420f29c944fd1b16

Full source copied without mathematical changes from the snapshot whose input hash matches the passing audit. Select a line number for a stable source pointer.

The declarations belong to the compiled inventory covered by the project’s shared axiom audit. That audit records an aggregate union, without attributing axioms to individual declarations.

Declarations in this module
1import Cloning.MatrixFidelityBounds
2import Cloning.MatrixRegularization
3import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
4import Mathlib.Analysis.SpecificLimits.Basic
5 
6/-! # Dimension-independent trace bound for concrete root fidelity
7 
8The invertible case follows from a matrix factorization and Hilbert--Schmidt
9Cauchy--Schwarz. Singular positive matrices are treated by regularization.
10-/
11 
12noncomputable section
13open scoped BigOperators Matrix MatrixOrder ComplexOrder
14open Matrix Filter
15open scoped Topology
16 
17namespace Cloning.MatrixFidelity
18 
19set_option autoImplicit false
20set_option backward.isDefEq.respectTransparency false
21set_option maxHeartbeats 800000
22 
23variable {n : Type*} [Fintype n] [DecidableEq n]
24 
25/-- Dimension-independent trace bound when the second positive matrix is
26invertible. The first matrix may have a nontrivial kernel. -/
27theorem fidelity_sq_le_trace_mul_trace_of_isUnit
28    {A B : Matrix n n ℂ} (hA : A.PosSemidef) (hB : B.PosSemidef)
29    (hBu : IsUnit B) :
30    fidelity A B ^ 2 ≤ A.trace.re * B.trace.re := by
31  let C := CFC.sqrt B
32  let R := CFC.sqrt (C * A * C)
33  let D := C⁻¹ * R
34  have hCu : IsUnit C := (CFC.isUnit_sqrt_iff B hB.nonneg).mpr hBu
35  have hCd : IsUnit C.det := (Matrix.isUnit_iff_isUnit_det C).mp hCu
36  have hCV : C * C⁻¹ = 1 := Matrix.mul_nonsing_inv C hCd
37  have hVC : C⁻¹ * C = 1 := Matrix.nonsing_inv_mul C hCd
38  have hCstar : Cᴴ = C := sqrt_conjTranspose B
39  have hRstar : Rᴴ = R := sqrt_conjTranspose (C * A * C)
40  have hVstar : C⁻¹ᴴ = C⁻¹ := by
41    rw [Matrix.conjTranspose_nonsing_inv, hCstar]
42  have hCC : Cᴴ * C = B := by
43    rw [hCstar]
44    exact sqrt_mul_self hB
45  have hRR : R * R = C * A * C :=
46    sqrt_mul_self (sandwich_posSemidef hA B)
47  have hCD : Cᴴ * D = R := by
48    dsimp [D]
49    rw [hCstar, ← Matrix.mul_assoc, hCV, one_mul]
50  have hDD : (Dᴴ * D).trace = A.trace := by
51    dsimp [D]
52    rw [Matrix.conjTranspose_mul, hRstar, hVstar]
53    calc
54      ((R * C⁻¹) * (C⁻¹ * R)).trace = ((C⁻¹ * R) * (R * C⁻¹)).trace :=
55        Matrix.trace_mul_comm _ _
56      _ = (C⁻¹ * (R * R) * C⁻¹).trace := by
57        simp only [Matrix.mul_assoc]
58      _ = (C⁻¹ * (C * A * C) * C⁻¹).trace := by rw [hRR]
59      _ = ((C⁻¹ * C) * A * (C * C⁻¹)).trace := by
60        simp only [Matrix.mul_assoc]
61      _ = A.trace := by rw [hVC, hCV, one_mul, mul_one]
62  have h := re_trace_cauchy_schwarz_sq C D
63  rw [hCD, hCC, hDD] at h
64  simpa only [fidelity, C, R, mul_comm] using h
65 
66/-- Concrete fidelity is continuous along positive matrix approximations
67in its second argument. -/
68theorem tendsto_fidelity_right
69    {A B : Matrix n n ℂ} (hA : A.PosSemidef) (hB : B.PosSemidef)
70    {Bseq : ℕ → Matrix n n ℂ} (hseq : ∀ k, (Bseq k).PosSemidef)
71    (hlim : Tendsto Bseq atTop (𝓝 B)) :
72    Tendsto (fun k => fidelity A (Bseq k)) atTop (𝓝 (fidelity A B)) := by
73  have hin : Tendsto Bseq atTop (𝓝[{X | X.PosSemidef}] B) :=
74    tendsto_nhdsWithin_iff.mpr ⟨hlim, Filter.Eventually.of_forall hseq⟩
75  have hsqrt : Tendsto (CFC.sqrt : Matrix n n ℂ → Matrix n n ℂ)
76      (𝓝[{X | X.PosSemidef}] B) (𝓝 (CFC.sqrt B)) :=
77    continuousOn_matrix_sqrt B hB
78  have hS : Tendsto (fun k => CFC.sqrt (Bseq k)) atTop (𝓝 (CFC.sqrt B)) :=
79    hsqrt.comp hin
80  have hprod : Tendsto (fun k => CFC.sqrt (Bseq k) * A * CFC.sqrt (Bseq k))
81      atTop (𝓝 (CFC.sqrt B * A * CFC.sqrt B)) := (hS.mul_const A).mul hS
82  exact Cloning.MatrixRegularization.tendsto_trace_sqrt
83    (sandwich_posSemidef hA B) hprod
84    (Filter.Eventually.of_forall (fun k => sandwich_posSemidef hA (Bseq k)))
85 
86/-- The trace estimate survives singular limits of positive invertible
87matrices. -/
88theorem fidelity_sq_le_trace_mul_trace_of_approximants
89    {A B : Matrix n n ℂ} (hA : A.PosSemidef) (hB : B.PosSemidef)
90    (Bseq : ℕ → Matrix n n ℂ) (hseq : ∀ k, (Bseq k).PosSemidef)
91    (hseqUnit : ∀ k, IsUnit (Bseq k)) (hlim : Tendsto Bseq atTop (𝓝 B)) :
92    fidelity A B ^ 2 ≤ A.trace.re * B.trace.re := by
93  have hf := (tendsto_fidelity_right hA hB hseq hlim).pow 2
94  have htrace : Continuous (fun X : Matrix n n ℂ => X.trace.re) := by
95    unfold Matrix.trace
96    fun_prop
97  have ht := (tendsto_const_nhds (x := A.trace.re)).mul
98    (htrace.continuousAt.tendsto.comp hlim)
99  apply le_of_tendsto_of_tendsto hf ht
100  exact Filter.Eventually.of_forall (fun k =>
101    fidelity_sq_le_trace_mul_trace_of_isUnit hA (hseq k) (hseqUnit k))
102 
103/-- Dimension-independent Cauchy--Schwarz bound for arbitrary positive
104matrices, including singular and zero matrices. -/
105theorem fidelity_sq_le_trace_mul_trace
106    {A B : Matrix n n ℂ} (hA : A.PosSemidef) (hB : B.PosSemidef) :
107    fidelity A B ^ 2 ≤ A.trace.re * B.trace.re := by
108  let ε : ℕ → ℝ := fun k => 1 / ((k : ℝ) + 1)
109  have hε (k : ℕ) : 0 < ε k := by
110    dsimp [ε]
111    positivity
112  let Bseq := fun k => Cloning.MatrixRegularization.regularize B (ε k)
113  have hseqPD (k : ℕ) : (Bseq k).PosDef :=
114    Cloning.MatrixRegularization.regularize_posDef hB (hε k)
115  apply fidelity_sq_le_trace_mul_trace_of_approximants hA hB Bseq
116    (fun k => (hseqPD k).posSemidef) (fun k => (hseqPD k).isUnit)
117  exact (Cloning.MatrixRegularization.tendsto_regularize_zero B).comp
118    tendsto_one_div_add_atTop_nhds_zero_nat
119 
120/-- The usual root-fidelity trace bound, proved for concrete complex
121matrices without assumptions about fidelity laws. -/
122theorem fidelity_le_sqrt_trace_mul_trace
123    {A B : Matrix n n ℂ} (hA : A.PosSemidef) (hB : B.PosSemidef) :
124    fidelity A B ≤ Real.sqrt (A.trace.re * B.trace.re) := by
125  have hsq := fidelity_sq_le_trace_mul_trace hA hB
126  have ht : 0 ≤ A.trace.re * B.trace.re :=
127    mul_nonneg (trace_re_nonneg hA) (trace_re_nonneg hB)
128  have hs := Real.sq_sqrt ht
129  have hs0 := Real.sqrt_nonneg (A.trace.re * B.trace.re)
130  nlinarith
131 
132/-- Fidelity between concrete subnormalized positive matrices is at most one. -/
133theorem fidelity_le_one
134    {A B : Matrix n n ℂ} (hA : A.PosSemidef) (hB : B.PosSemidef)
135    (htrA : A.trace.re ≤ 1) (htrB : B.trace.re ≤ 1) : fidelity A B ≤ 1 := by
136  have h := fidelity_sq_le_trace_mul_trace hA hB
137  have htrA0 := trace_re_nonneg hA
138  have htrB0 := trace_re_nonneg hB
139  have hm : A.trace.re * B.trace.re ≤ 1 := by nlinarith
140  nlinarith
141 
142end Cloning.MatrixFidelity