Pratik Patil

HelstromSpectral.lean

1module23public import SubentropyCertificates.BinaryBasisGuessing45/-! The positive spectral projector of a finite Hermitian matrix maximizes6the trace pairing over all effects. A second-moment estimate will be sharp7for the difference of two prior-weighted pure states. -/8@[expose] public section9noncomputable section10set_option autoImplicit false11set_option backward.isDefEq.respectTransparency false12open Matrix13open scoped BigOperators MatrixOrder ComplexOrder14namespace SubentropyCertificates.Helstrom15variable {D : Type*} [Fintype D] [DecidableEq D]1617private def spectralMatrix (U : Matrix.unitaryGroup D ℂ) (f : D → ℝ) : Matrix D D ℂ :=18  Unitary.conjStarAlgAut ℂ _ U (diagonal (fun i => (f i : ℂ)))1920private theorem spectral_mul (U : Matrix.unitaryGroup D ℂ) (f g : D → ℝ) :21    spectralMatrix U f * spectralMatrix U g = spectralMatrix U (fun i => f i*g i) := by22  simp only [spectralMatrix, ← map_mul, Matrix.diagonal_mul_diagonal, Complex.ofReal_mul]2324private theorem spectral_sub (U : Matrix.unitaryGroup D ℂ) (f g : D → ℝ) :25    spectralMatrix U f - spectralMatrix U g = spectralMatrix U (fun i => f i-g i) := by26  simp only [spectralMatrix, ← map_sub, ← Matrix.diagonal_sub, Complex.ofReal_sub]2728private theorem spectral_one (U : Matrix.unitaryGroup D ℂ) :29    spectralMatrix U (fun _ => 1) = 1 := by30  change Unitary.conjStarAlgAut ℂ _ U (diagonal (fun _ => ((1:ℝ):ℂ))) = 131  simp3233private theorem spectral_pos (U : Matrix.unitaryGroup D ℂ) (f : D → ℝ) (hf : ∀ i, 0 ≤ f i) :34    (spectralMatrix U f).PosSemidef := by35  have hd : (diagonal (fun i => (f i : ℂ))).PosSemidef :=36    Matrix.PosSemidef.diagonal (fun i => by simpa [Complex.le_def] using hf i)37  exact hd.mul_mul_conjTranspose_same (U : Matrix D D ℂ)3839private theorem spectral_trace (U : Matrix.unitaryGroup D ℂ) (f : D → ℝ) :40    (spectralMatrix U f).trace.re = ∑ i, f i := by41  change (((U : Matrix D D ℂ) * diagonal (fun i => (f i : ℂ))) *42    (U : Matrix D D ℂ).conjTranspose).trace.re = _43  have hu : (U : Matrix D D ℂ).conjTranspose * U = 1 := Unitary.coe_star_mul_self U44  rw [Matrix.trace_mul_comm, ← Matrix.mul_assoc, hu, Matrix.one_mul,45    Matrix.trace_diagonal, ← Complex.ofReal_sum, Complex.ofReal_re]4647omit [DecidableEq D] in48private theorem abs_sum_sq (f : D → ℝ) :49    2*(∑ i, f i^2) ≤ (∑ i, |f i|)^2 + (∑ i, f i)^2 := by50  have term (i j : D) : 0 ≤ |f i| * |f j| + f i*f j := by51    rw [← abs_mul]; linarith [neg_abs_le (f i*f j)]52  have row (i : D) : 2*f i^2 ≤ ∑ j, (|f i| * |f j| + f i*f j) := by53    have h := Finset.single_le_sum (s := Finset.univ) (fun j _ => term i j) (Finset.mem_univ i)54    simpa only [← sq,sq_abs,two_mul] using h55  have h := Finset.sum_le_sum (s := Finset.univ) (fun i _ => row i)56  simpa only [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.sum_mul, ← sq] using h5758/-- A projective binary test attaining the positive spectral part, together59with the variational upper bound for every competing effect. Zero eigenvalues60may be assigned to either outcome; this construction assigns them to E. -/61theorem spectral_test {H : Matrix D D ℂ} (hH : H.IsHermitian) :62    ∃ E : Matrix D D ℂ, E.PosSemidef ∧ (1-E).PosSemidef ∧ E*E=E ∧63      2*(E*H).trace.re-H.trace.re = ∑ i, |hH.eigenvalues i| ∧64      ∀ F : Matrix D D ℂ, F.PosSemidef → (1-F).PosSemidef →65        (F*H).trace.re ≤ (E*H).trace.re := by66  let U := hH.eigenvectorUnitary67  let w := hH.eigenvalues68  let k (i : D) : ℝ := if 0 ≤ w i then 1 else 069  let a i := k i*w i70  let b i := a i-w i71  let E := spectralMatrix U k72  let A := spectralMatrix U a73  let B := spectralMatrix U b74  have hd : H = spectralMatrix U w := hH.spectral_theorem75  have ha : A.PosSemidef := spectral_pos U a (fun i => by dsimp [a,k]; split_ifs <;> simp_all)76  have hb : B.PosSemidef := spectral_pos U b (fun i => by77    dsimp [b,a,k]; split_ifs <;> simp_all78    linarith)79  have hab : H = A-B := by80    rw [show A-B = _ from spectral_sub U a b]81    convert hd using 282    funext i83    dsimp [b]84    ring85  have heh : E*H = A := by rw [hd]; exact spectral_mul U k w86  refine ⟨E, spectral_pos U k (fun i => by dsimp [k]; split_ifs <;> norm_num), ?_, ?_, ?_, ?_⟩87  · rw [← spectral_one U, show spectralMatrix U (fun _ => 1) - E = _ from spectral_sub U _ k]88    exact spectral_pos U _ (fun i => by dsimp [k]; split_ifs <;> norm_num)89  · change spectralMatrix U k * spectralMatrix U k = spectralMatrix U k90    rw [spectral_mul]91    apply congrArg (spectralMatrix U)92    funext i93    simp [k]94  · rw [heh, show A.trace.re = _ from spectral_trace U a, show H.trace.re = ∑ i, w i from95      (congrArg (fun M : Matrix D D ℂ => M.trace.re) hd).trans (spectral_trace U w),96      Finset.mul_sum, ← Finset.sum_sub_distrib]97    apply Finset.sum_congr rfl98    intro i _99    change 2*(k i*w i)-w i=|w i|100    by_cases hi : 0 ≤ w i101    · rw [abs_of_nonneg hi]; simp [k,hi]; ring102    · rw [abs_of_neg (lt_of_not_ge hi)]; simp [k,hi]103  · intro F hF hC104    have h₁ : 0 ≤ (F*B).trace.re := RHLinalg.trace_mul_nonneg_of_posSemidef hF hb105    have h₂ : 0 ≤ ((1-F)*A).trace.re := RHLinalg.trace_mul_nonneg_of_posSemidef hC ha106    rw [Matrix.sub_mul,Matrix.one_mul,Matrix.trace_sub,Complex.sub_re] at h₂107    rw [heh,hab,Matrix.mul_sub,Matrix.trace_sub,Complex.sub_re]108    linarith109110/-- A lower bound on the square of the Hermitian trace norm. -/111theorem spectral_second_moment {H : Matrix D D ℂ} (hH : H.IsHermitian) :112    2*(H*H).trace.re ≤ (∑ i, |hH.eigenvalues i|)^2 + H.trace.re^2 := by113  let U := hH.eigenvectorUnitary114  let w := hH.eigenvalues115  have hd : H = spectralMatrix U w := hH.spectral_theorem116  have ht : H.trace.re = ∑ i, w i :=117    (congrArg (fun M : Matrix D D ℂ => M.trace.re) hd).trans (spectral_trace U w)118  have hsq : (H*H).trace.re = ∑ i, w i ^ 2 := by119    rw [hd,spectral_mul,spectral_trace]120    simp only [sq]121  rw [ht,hsq]122  exact abs_sum_sq w123124end SubentropyCertificates.Helstrom

Axioms used

Choose a statement to see which axioms its proof uses.