Pratik Patil

QuadraticGram.lean

1module23public import SubentropyCertificates.QuantumMeasurement4import Mathlib.Analysis.Convex.Mul5import Mathlib.Analysis.Convex.Jensen67/-! Twice the off-block Hilbert--Schmidt energy of a Gram matrix. -/8@[expose] public section9noncomputable section10set_option backward.isDefEq.respectTransparency false11open Matrix Set12open scoped BigOperators ComplexOrder MatrixOrder13namespace SubentropyCertificates.Quadratic14open SubentropyCertificates.MeasurementPosterior15variable {X B Y : Type*} [Fintype X] [DecidableEq X] [Fintype B] [Fintype Y]1617def distinctPairs (X : Type*) [Fintype X] [DecidableEq X] :=18  (Finset.univ : Finset (X × X)).filter (fun z => z.1 ≠ z.2)19def blockSquare (H : Matrix (X × B) (X × B) ℂ) (xz : X × X) :=20  ∑ k : B × B, Complex.normSq (H (xz.1,k.1) (xz.2,k.2))21def offSquare (H : Matrix (X × B) (X × B) ℂ) :=22  ∑ xz ∈ distinctPairs X, blockSquare H xz2324theorem distinct_sum (f : X → X → ℝ) :25    (∑ z ∈ distinctPairs X, f z.1 z.2) = (∑ x, ∑ z, f x z) - ∑ x, f x x := by26  have h (x z) : f x z = (if x≠z then f x z else 0) + (if x=z then f x z else 0) := by27    by_cases hz : x=z <;> simp [hz]28  have hs := Finset.sum_congr (s₁ := Finset.univ) rfl (fun x _ =>29    Finset.sum_congr (s₁ := Finset.univ) rfl (fun z _ => h x z))30  simp only [Finset.sum_add_distrib,Finset.sum_ite_eq,Finset.mem_univ,ite_true] at hs31  simp only [distinctPairs,Finset.sum_filter,Fintype.sum_prod_type]32  linarith3334theorem offSquare_nonneg (H : Matrix (X × B) (X × B) ℂ) : 0 ≤ offSquare H :=35  Finset.sum_nonneg fun _ _ => Finset.sum_nonneg fun _ _ => Complex.normSq_nonneg _3637private theorem entry_bound {D : Type*} {H : Matrix D D ℂ} (hH : H.PosSemidef) (i j : D) :38    Complex.normSq (H i j) ≤ (H i i).re*(H j j).re := by39  let f : Fin 2 → D := ![i,j]40  have h := (RCLike.nonneg_iff.mp ((hH.submatrix f).det_nonneg)).141  have hd (a : D) : (H a a).im = 0 := (RCLike.nonneg_iff.mp (hH.diag_nonneg (i := a))).242  have hh : H j i = star (H i j) := (hH.isHermitian.apply j i).symm43  simpa [Matrix.det_fin_two,f,hh,Complex.mul_re,Complex.normSq_apply,hd] using h4445omit [Fintype X] [DecidableEq X] in46theorem blockSquare_le (H : Matrix (X × B) (X × B) ℂ) (hH : H.PosSemidef) (xz : X × X) :47    blockSquare H xz ≤ labelMass H xz.1 * labelMass H xz.2 := by48  unfold blockSquare labelMass49  simp only [Complex.re_sum,Fintype.sum_prod_type,Finset.sum_mul]50  simp only [Finset.mul_sum]51  exact Finset.sum_le_sum fun _ _ => Finset.sum_le_sum fun _ _ => entry_bound hH _ _5253private theorem normSq_mean (q : Y → ℝ) (hq : ∀ y, 0 ≤ q y) (hs : ∑ y, q y = 1)54    (z : Y → ℂ) : Complex.normSq (∑ y, q y • z y) ≤ ∑ y, q y * Complex.normSq (z y) := by55  have hsquare (a : Y → ℝ) : (∑ y, q y*a y)^2 ≤ ∑ y, q y*(a y)^2 := by56    have h := (even_two.convexOn_pow (𝕜 := ℝ)).map_sum_le57      (t := Finset.univ) (w := q) (p := a) (fun y _ => hq y) hs (fun _ _ => Set.mem_univ _)58    simpa only [smul_eq_mul] using h59  simp only [Complex.normSq_apply,Complex.re_sum,Complex.im_sum,Complex.smul_re,60    Complex.smul_im,smul_eq_mul,mul_add,Finset.sum_add_distrib,← sq]61  exact add_le_add (hsquare fun y => (z y).re) (hsquare fun y => (z y).im)6263theorem offSquare_mean (q : Y → ℝ) (hq : ∀ y, 0 ≤ q y) (hs : ∑ y, q y = 1)64    (H : Y → Matrix (X × B) (X × B) ℂ) :65    offSquare (∑ y, q y • H y) ≤ ∑ y, q y*offSquare (H y) := by66  unfold offSquare blockSquare67  simp only [Matrix.sum_apply,Matrix.smul_apply,Finset.mul_sum]68  calc69    _ ≤ ∑ xz ∈ distinctPairs X, ∑ k : B × B, ∑ y,70          q y * Complex.normSq (H y (xz.1,k.1) (xz.2,k.2)) :=71      Finset.sum_le_sum fun _ _ => Finset.sum_le_sum fun _ _ => normSq_mean q hq hs _72    _ = _ := by73      simp_rw [Finset.sum_comm (s := (Finset.univ : Finset (B × B))) (t := (Finset.univ : Finset Y))]74      rw [Finset.sum_comm]7576end SubentropyCertificates.Quadratic

Axioms used

Choose a statement to see which axioms its proof uses.