Exact Lean source
Nonadditivity.Entropy
Download original .lean · View on GitHub · Jump to source
Direct imports
Mathlib.Analysis.Matrix.PosDefdependencyMathlib.LinearAlgebra.Matrix.KroneckerdependencyMathlib.Analysis.SpecialFunctions.Log.BasicdependencyMathlib.Tactic.FieldSimpdependencyMathlib.Tactic.LinarithdependencyMathlib.Tactic.NormNumdependencyMathlib.Tactic.Ringdependency
Imported by project modules
Relationships above come from literal import commands. The declarations below link to types and references extracted from Lean’s environment. Source text is complete and unchanged.
Declarations in this module
99 project constants, including generated, internal and private declarations.
99 declarations
Nonadditivity.Entropy.DensityMatrixNonadditivity.Entropy.DensityMatrix._sizeOf_1internal/detail/privateNonadditivity.Entropy.DensityMatrix._sizeOf_instinternal/detail/privateNonadditivity.Entropy.DensityMatrix.casesOnNonadditivity.Entropy.DensityMatrix.centeredNonadditivity.Entropy.DensityMatrix.centered.eq_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.centered_isHermitianNonadditivity.Entropy.DensityMatrix.centered_trace_pairingNonadditivity.Entropy.DensityMatrix.centered_trace_squareNonadditivity.Entropy.DensityMatrix.centered_trace_zeroNonadditivity.Entropy.DensityMatrix.conjugateNonadditivity.Entropy.DensityMatrix.conjugate._proof_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.conjugate._proof_2internal/detail/privateNonadditivity.Entropy.DensityMatrix.conjugate_entropyNonadditivity.Entropy.DensityMatrix.conjugate_weightsNonadditivity.Entropy.DensityMatrix.ctorIdxNonadditivity.Entropy.DensityMatrix.entropy_bound_of_purityNonadditivity.Entropy.DensityMatrix.matrixNonadditivity.Entropy.DensityMatrix.mkNonadditivity.Entropy.DensityMatrix.mk._flat_ctorinternal/detail/privateNonadditivity.Entropy.DensityMatrix.mk.injNonadditivity.Entropy.DensityMatrix.mk.injEqNonadditivity.Entropy.DensityMatrix.mk.noConfusionNonadditivity.Entropy.DensityMatrix.mk.sizeOf_specNonadditivity.Entropy.DensityMatrix.noConfusionNonadditivity.Entropy.DensityMatrix.noConfusionTypeNonadditivity.Entropy.DensityMatrix.normalizedNonadditivity.Entropy.DensityMatrix.positiveNonadditivity.Entropy.DensityMatrix.purityNonadditivity.Entropy.DensityMatrix.purity.eq_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.purity_and_entropy_of_centered_boundNonadditivity.Entropy.DensityMatrix.purity_eq_inv_dim_add_centeredNonadditivity.Entropy.DensityMatrix.purity_eq_inv_dim_add_centered._simp_1_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.purity_eq_inv_dim_add_centered._simp_1_2internal/detail/privateNonadditivity.Entropy.DensityMatrix.purity_eq_inv_dim_add_centered._simp_1_3internal/detail/privateNonadditivity.Entropy.DensityMatrix.purity_posNonadditivity.Entropy.DensityMatrix.recNonadditivity.Entropy.DensityMatrix.recOnNonadditivity.Entropy.DensityMatrix.trace_square_eq_purityNonadditivity.Entropy.DensityMatrix.unitaryConjugateNonadditivity.Entropy.DensityMatrix.unitaryConjugate._proof_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.unitaryConjugate._proof_2internal/detail/privateNonadditivity.Entropy.DensityMatrix.unitaryConjugate_entropyNonadditivity.Entropy.DensityMatrix.unitaryConjugate_weightsNonadditivity.Entropy.DensityMatrix.vonNeumannNonadditivity.Entropy.DensityMatrix.vonNeumann.eq_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.vonNeumann_ge_neg_log_purityNonadditivity.Entropy.DensityMatrix.vonNeumann_le_log_dimNonadditivity.Entropy.DensityMatrix.vonNeumann_nonnegNonadditivity.Entropy.DensityMatrix.weightsNonadditivity.Entropy.DensityMatrix.weights._proof_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.weights.eq_1internal/detail/privateNonadditivity.Entropy.DensityMatrix.weights_nonnegNonadditivity.Entropy.DensityMatrix.weights_sumNonadditivity.Entropy.bellVectorNonadditivity.Entropy.bellVector.eq_1internal/detail/privateNonadditivity.Entropy.bellWeightsNonadditivity.Entropy.bellWeights.eq_1internal/detail/privateNonadditivity.Entropy.bellWeights.eq_2internal/detail/privateNonadditivity.Entropy.bellWeights.match_1internal/detail/privateNonadditivity.Entropy.bellWeights_nonnegNonadditivity.Entropy.bellWeights_shannonNonadditivity.Entropy.bellWeights_shannon._proof_1_1internal/detail/privateNonadditivity.Entropy.bellWeights_shannon._simp_1_10internal/detail/privateNonadditivity.Entropy.bellWeights_shannon._simp_1_11internal/detail/privateNonadditivity.Entropy.bellWeights_shannon._simp_1_12internal/detail/privateNonadditivity.Entropy.bellWeights_shannon._simp_1_6internal/detail/privateNonadditivity.Entropy.bellWeights_shannon._simp_1_7internal/detail/privateNonadditivity.Entropy.bellWeights_shannon._simp_1_8internal/detail/privateNonadditivity.Entropy.bellWeights_shannon._simp_1_9internal/detail/privateNonadditivity.Entropy.bellWeights_sumNonadditivity.Entropy.bellWeights_sum._proof_1_1internal/detail/privateNonadditivity.Entropy.distributionPurityNonadditivity.Entropy.distributionPurity.eq_1internal/detail/privateNonadditivity.Entropy.distributionPurity_posNonadditivity.Entropy.norm_le_of_sq_le_mulNonadditivity.Entropy.shannonNonadditivity.Entropy.shannon.eq_1internal/detail/privateNonadditivity.Entropy.shannon_ge_neg_log_purityNonadditivity.Entropy.shannon_ge_neg_log_purity._simp_1_1internal/detail/privateNonadditivity.Entropy.shannon_ge_neg_log_purity._simp_1_2internal/detail/privateNonadditivity.Entropy.shannon_ge_neg_log_purity._simp_1_3internal/detail/privateNonadditivity.Entropy.shannon_ge_neg_log_purity._simp_1_4internal/detail/privateNonadditivity.Entropy.shannon_le_log_cardNonadditivity.Entropy.shannon_le_log_card._simp_1_1internal/detail/privateNonadditivity.Entropy.shannon_le_log_card._simp_1_2internal/detail/privateNonadditivity.Entropy.shannon_le_log_card._simp_1_3internal/detail/privateNonadditivity.Entropy.shannon_le_log_card._simp_1_4internal/detail/privateNonadditivity.Entropy.shannon_le_log_card._simp_1_5internal/detail/privateNonadditivity.Entropy.shannon_le_log_card._simp_1_6internal/detail/privateNonadditivity.Entropy.shannon_le_log_card._simp_1_7internal/detail/privateNonadditivity.Entropy.shannon_le_log_card._simp_1_8internal/detail/privateNonadditivity.Entropy.shannon_nonnegNonadditivity.Entropy.unitary_kronecker_conjugate_fixes_bellNonadditivity.Entropy.unitary_kronecker_conjugate_fixes_bell._simp_1_2internal/detail/privateNonadditivity.Entropy.unitary_kronecker_conjugate_fixes_scaled_bell_private.Nonadditivity.Entropy.0.Nonadditivity.Entropy.bellWeights.match_1.eq_1internal/detail/private_private.Nonadditivity.Entropy.0.Nonadditivity.Entropy.bellWeights.match_1.eq_2internal/detail/private_private.Nonadditivity.Entropy.0.Nonadditivity.Entropy.bellWeights.match_1.splitterinternal/detail/private
Full module
1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Mathlib.Analysis.Matrix.PosDef7import Mathlib.LinearAlgebra.Matrix.Kronecker8import Mathlib.Analysis.SpecialFunctions.Log.Basic9import Mathlib.Tactic.FieldSimp10import Mathlib.Tactic.Linarith11import Mathlib.Tactic.NormNum12import Mathlib.Tactic.Ring1314/-!15# Entropy and purity components of `nonadditivity.tex`1617The results in the first sections are unconditional statements about finite18probability distributions and complex positive semidefinite matrices. Entropies19use natural logarithms. Divide by `Real.log 2` to obtain the paper's convention.2021The Bell weight computation proves the Shannon entropy of the actual list of22weights. It does not claim to prove the quantum mixture entropy inequality,23the complementary-output entropy identity, or the Weyl extension theorem.24-/2526namespace Nonadditivity.Entropy2728open scoped BigOperators ComplexOrder ComplexConjugate Kronecker Matrix2930noncomputable section3132def shannon {ι : Type*} [Fintype ι] (p : ι → ℝ) : ℝ :=33-∑ i, p i * Real.log (p i)3435def distributionPurity {ι : Type*} [Fintype ι] (p : ι → ℝ) : ℝ :=36∑ i, p i ^ 23738theorem distributionPurity_pos {ι : Type*} [Fintype ι]39(p : ι → ℝ) (hsum : ∑ i, p i = 1) : 0 < distributionPurity p := by40classical41have hn : 0 ≤ distributionPurity p := Finset.sum_nonneg (fun i _ => sq_nonneg (p i))42by_contra hp43have hz : distributionPurity p = 0 := le_antisymm (le_of_not_gt hp) hn44have hzero : ∀ i, p i = 0 := by45intro i46have hi : p i ^ 2 ≤ distributionPurity p := Finset.single_le_sum47(fun j _ => sq_nonneg (p j)) (Finset.mem_univ i)48nlinarith49simp only [hzero, Finset.sum_const_zero] at hsum50norm_num at hsum5152/-- The order-two Rényi lower bound for a finite distribution, including zero weights. -/53theorem shannon_ge_neg_log_purity {ι : Type*} [Fintype ι]54(p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hsum : ∑ i, p i = 1) :55-Real.log (distributionPurity p) ≤ shannon p := by56classical57let r := distributionPurity p58have hr : 0 < r := distributionPurity_pos p hsum59have hterm (i : ι) :60p i * (Real.log (p i) - Real.log r) ≤ p i * (p i / r - 1) := by61by_cases hz : p i = 062· simp [hz]63· have hi : 0 < p i := lt_of_le_of_ne (hp i) (Ne.symm hz)64have hh := Real.log_le_sub_one_of_pos (div_pos hi hr)65rw [Real.log_div hz (ne_of_gt hr)] at hh66exact mul_le_mul_of_nonneg_left hh (hp i)67have hsumterm := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hterm i)68have hleft : (∑ i, p i * (Real.log (p i) - Real.log r)) =69(∑ i, p i * Real.log (p i)) - Real.log r := by70simp only [mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul, hsum, one_mul]71have hright : (∑ i, p i * (p i / r - 1)) = 0 := by72simp only [mul_sub, mul_one, ← mul_div_assoc, ← pow_two,73Finset.sum_sub_distrib, ← Finset.sum_div, hsum]74change r / r - 1 = 075simp [ne_of_gt hr]76rw [hleft, hright] at hsumterm77unfold shannon78change -Real.log r ≤ _79linarith8081theorem shannon_nonneg {ι : Type*} [Fintype ι]82(p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hsum : ∑ i, p i = 1) : 0 ≤ shannon p := by83classical84have hterm (i : ι) : p i * Real.log (p i) ≤ 0 := by85by_cases hz : p i = 086· simp [hz]87· have hi : 0 < p i := lt_of_le_of_ne (hp i) (Ne.symm hz)88have hle : p i ≤ 1 := by89rw [← hsum]90exact Finset.single_le_sum (fun j _ => hp j) (Finset.mem_univ i)91exact mul_nonpos_of_nonneg_of_nonpos (hp i) (Real.log_nonpos (le_of_lt hi) hle)92have hsumterm := Finset.sum_nonpos (fun i (_ : i ∈ Finset.univ) => hterm i)93unfold shannon94linarith9596/-- The usual finite-alphabet entropy maximum, proved directly from `log x ≤ x-1`. -/97theorem shannon_le_log_card {ι : Type*} [Fintype ι] [Nonempty ι]98(p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hsum : ∑ i, p i = 1) :99shannon p ≤ Real.log (Fintype.card ι) := by100classical101let d : ℝ := Fintype.card ι102have hd : 0 < d := by103change (0 : ℝ) < Fintype.card ι104exact_mod_cast (Fintype.card_pos : 0 < Fintype.card ι)105have hterm (i : ι) : p i - 1 / d - p i * Real.log d ≤ p i * Real.log (p i) := by106by_cases hz : p i = 0107· simp only [hz, zero_sub, zero_mul, sub_zero]108exact neg_nonpos.mpr (le_of_lt (div_pos zero_lt_one hd))109· have hi : 0 < p i := lt_of_le_of_ne (hp i) (Ne.symm hz)110have hlog := Real.one_sub_inv_le_log_of_pos (mul_pos hd hi)111rw [Real.log_mul (ne_of_gt hd) hz] at hlog112have hm := mul_le_mul_of_nonneg_left hlog (hp i)113have hfrac : p i * (1 - (d * p i)⁻¹) = p i - 1 / d := by114field_simp115rw [hfrac] at hm116nlinarith117have hsumterm := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hterm i)118have hleft : (∑ i, (p i - 1 / d - p i * Real.log d)) = -Real.log d := by119simp only [Finset.sum_sub_distrib, ← Finset.sum_mul, hsum, Finset.sum_const,120Finset.card_univ, nsmul_eq_mul, one_mul]121change 1 - d * (1 / d) - Real.log d = -Real.log d122field_simp123ring124rw [hleft] at hsumterm125unfold shannon126change _ ≤ Real.log d127linarith128129/-- The scalar cancellation used in the adjoint-bound-to-purity argument.130The hypothesis is explicit: this theorem does not supply the channel adjoint131duality or the operator-norm expectation estimate. -/132theorem norm_le_of_sq_le_mul {E : Type*} [SeminormedAddCommGroup E]133(X : E) (t : ℝ) (ht : 0 ≤ t) (h : ‖X‖ ^ 2 ≤ t * ‖X‖) : ‖X‖ ≤ t := by134by_cases hz : ‖X‖ = 0135· simpa [hz] using ht136· have hp : 0 < ‖X‖ := lt_of_le_of_ne (norm_nonneg X) (Ne.symm hz)137nlinarith138139/-! ## Actual finite quantum density matrices -/140141/-- A finite-dimensional quantum density matrix. -/142structure DensityMatrix (ι : Type*) [Fintype ι] [DecidableEq ι] where143matrix : Matrix ι ι ℂ144positive : matrix.PosSemidef145normalized : matrix.trace = 1146147def DensityMatrix.weights {ι : Type*} [Fintype ι] [DecidableEq ι]148(ρ : DensityMatrix ι) : ι → ℝ :=149ρ.positive.isHermitian.eigenvalues150151theorem DensityMatrix.weights_nonneg {ι : Type*} [Fintype ι] [DecidableEq ι]152(ρ : DensityMatrix ι) (i : ι) : 0 ≤ ρ.weights i :=153ρ.positive.eigenvalues_nonneg i154155theorem DensityMatrix.weights_sum {ι : Type*} [Fintype ι] [DecidableEq ι]156(ρ : DensityMatrix ι) : ∑ i, ρ.weights i = 1 := by157have h := ρ.positive.isHermitian.trace_eq_sum_eigenvalues158rw [ρ.normalized] at h159have hre := congrArg Complex.re h160simpa [DensityMatrix.weights] using hre.symm161162/-- Von Neumann entropy defined spectrally, with the convention `0 log 0 = 0`. -/163def DensityMatrix.vonNeumann {ι : Type*} [Fintype ι] [DecidableEq ι]164(ρ : DensityMatrix ι) : ℝ := shannon ρ.weights165166/-- Spectral purity. The following theorem identifies it with the matrix trace. -/167def DensityMatrix.purity {ι : Type*} [Fintype ι] [DecidableEq ι]168(ρ : DensityMatrix ι) : ℝ := distributionPurity ρ.weights169170theorem DensityMatrix.purity_pos {ι : Type*} [Fintype ι] [DecidableEq ι]171(ρ : DensityMatrix ι) : 0 < ρ.purity :=172distributionPurity_pos ρ.weights ρ.weights_sum173174theorem DensityMatrix.trace_square_eq_purity {ι : Type*} [Fintype ι] [DecidableEq ι]175(ρ : DensityMatrix ι) : (ρ.matrix * ρ.matrix).trace = (ρ.purity : ℂ) := by176let U := ρ.positive.isHermitian.eigenvectorUnitary177let D := Matrix.diagonal (fun i => (ρ.weights i : ℂ))178have hs : ρ.matrix = Unitary.conjStarAlgAut ℂ _ U D :=179ρ.positive.isHermitian.spectral_theorem180calc181(ρ.matrix * ρ.matrix).trace =182(Unitary.conjStarAlgAut ℂ _ U (D * D)).trace := by rw [map_mul, ← hs]183_ = (D * D).trace := by184rw [Unitary.conjStarAlgAut_apply, Matrix.trace_mul_cycle, ← Matrix.mul_assoc,185Unitary.coe_star_mul_self, Matrix.one_mul]186_ = (ρ.purity : ℂ) := by187simp [D, DensityMatrix.purity, distributionPurity, Matrix.diagonal_mul_diagonal,188Matrix.trace_diagonal, pow_two]189190/-- The actual von Neumann entropy versus order-two Rényi entropy inequality. -/191theorem DensityMatrix.vonNeumann_ge_neg_log_purity192{ι : Type*} [Fintype ι] [DecidableEq ι] (ρ : DensityMatrix ι) :193-Real.log ρ.purity ≤ ρ.vonNeumann :=194shannon_ge_neg_log_purity ρ.weights ρ.weights_nonneg ρ.weights_sum195196theorem DensityMatrix.vonNeumann_nonneg197{ι : Type*} [Fintype ι] [DecidableEq ι] (ρ : DensityMatrix ι) :1980 ≤ ρ.vonNeumann :=199shannon_nonneg ρ.weights ρ.weights_nonneg ρ.weights_sum200201theorem DensityMatrix.vonNeumann_le_log_dim202{ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] (ρ : DensityMatrix ι) :203ρ.vonNeumann ≤ Real.log (Fintype.card ι) :=204shannon_le_log_card ρ.weights ρ.weights_nonneg ρ.weights_sum205206/-- Deviation from the maximally mixed output. -/207def DensityMatrix.centered {ι : Type*} [Fintype ι] [DecidableEq ι]208(ρ : DensityMatrix ι) : Matrix ι ι ℂ :=209ρ.matrix - (1 / (Fintype.card ι : ℂ)) • 1210211theorem DensityMatrix.centered_isHermitian {ι : Type*} [Fintype ι]212[DecidableEq ι] (ρ : DensityMatrix ι) : ρ.centered.IsHermitian := by213simp [Matrix.IsHermitian, DensityMatrix.centered,214ρ.positive.isHermitian.eq]215216theorem DensityMatrix.centered_trace_zero {ι : Type*} [Fintype ι]217[DecidableEq ι] [Nonempty ι] (ρ : DensityMatrix ι) : ρ.centered.trace = 0 := by218have hd : (Fintype.card ι : ℂ) ≠ 0 := by219exact_mod_cast Fintype.card_ne_zero220simp [DensityMatrix.centered, Matrix.trace_sub, Matrix.trace_smul,221Matrix.trace_one, ρ.normalized, hd]222223/-- Trace pairing with the output equals the squared centered Hilbert--Schmidt length. -/224theorem DensityMatrix.centered_trace_pairing {ι : Type*} [Fintype ι]225[DecidableEq ι] [Nonempty ι] (ρ : DensityMatrix ι) :226(ρ.centered * ρ.centered).trace = (ρ.matrix * ρ.centered).trace := by227change ((ρ.matrix - (1 / (Fintype.card ι : ℂ)) • 1) * ρ.centered).trace = _228simp [Matrix.sub_mul, Matrix.trace_sub,229Matrix.trace_smul, ρ.centered_trace_zero]230231/-- The exact centered-purity decomposition used in Lemma `purity`. -/232theorem DensityMatrix.centered_trace_square {ι : Type*} [Fintype ι]233[DecidableEq ι] [Nonempty ι] (ρ : DensityMatrix ι) :234(ρ.centered * ρ.centered).trace =235(ρ.purity : ℂ) - 1 / (Fintype.card ι : ℂ) := by236have hd : (Fintype.card ι : ℂ) ≠ 0 := by237exact_mod_cast Fintype.card_ne_zero238simp only [DensityMatrix.centered, Matrix.sub_mul, Matrix.mul_sub,239Matrix.trace_sub, Matrix.smul_mul, Matrix.mul_smul,240Matrix.one_mul, Matrix.trace_smul, ρ.normalized,241Matrix.trace_one, ρ.trace_square_eq_purity, smul_eq_mul, mul_one]242field_simp243ring244245theorem DensityMatrix.purity_eq_inv_dim_add_centered {ι : Type*} [Fintype ι]246[DecidableEq ι] [Nonempty ι] (ρ : DensityMatrix ι) :247ρ.purity = 1 / (Fintype.card ι : ℝ) +248(ρ.centered * ρ.centered).trace.re := by249have h := congrArg Complex.re ρ.centered_trace_square250simp only [Complex.sub_re, Complex.ofReal_re, ← Complex.ofReal_natCast,251← Complex.ofReal_one, ← Complex.ofReal_div, Complex.ofReal_re] at h252linarith253254/-- A concrete entropy bound for a finite density matrix satisfying a purity certificate.255This is the final entropy step of Lemma `purity`, independent of how the256certificate is produced. -/257theorem DensityMatrix.entropy_bound_of_purity {ι : Type*} [Fintype ι]258[DecidableEq ι] [Nonempty ι] (ρ : DensityMatrix ι) (t : ℝ)259(hpurity : ρ.purity ≤ 1 / (Fintype.card ι : ℝ) + t ^ 2) :260Real.log (Fintype.card ι) - Real.log (1 + (Fintype.card ι : ℝ) * t ^ 2) ≤261ρ.vonNeumann := by262have hd : (0 : ℝ) < Fintype.card ι := by263exact_mod_cast Fintype.card_pos264have hb : 0 < 1 / (Fintype.card ι : ℝ) + t ^ 2 :=265add_pos_of_pos_of_nonneg (div_pos zero_lt_one hd) (sq_nonneg t)266have hlog := Real.log_le_log ρ.purity_pos hpurity267have hrearr : 1 / (Fintype.card ι : ℝ) + t ^ 2 =268(1 + (Fintype.card ι : ℝ) * t ^ 2) / (Fintype.card ι : ℝ) := by269field_simp270have htpos : 0 < 1 + (Fintype.card ι : ℝ) * t ^ 2 := by271nlinarith [mul_nonneg (le_of_lt hd) (sq_nonneg t)]272rw [hrearr, Real.log_div (ne_of_gt htpos) (ne_of_gt hd)] at hlog273have hrenyi := ρ.vonNeumann_ge_neg_log_purity274linarith275276/-- The centered Hilbert--Schmidt certificate implies both claims of Lemma `purity`. -/277theorem DensityMatrix.purity_and_entropy_of_centered_bound {ι : Type*} [Fintype ι]278[DecidableEq ι] [Nonempty ι] (ρ : DensityMatrix ι) (t : ℝ)279(hcenter : (ρ.centered * ρ.centered).trace.re ≤ t ^ 2) :280ρ.purity ≤ 1 / (Fintype.card ι : ℝ) + t ^ 2 ∧281Real.log (Fintype.card ι) - Real.log (1 + (Fintype.card ι : ℝ) * t ^ 2) ≤282ρ.vonNeumann := by283have hp : ρ.purity ≤ 1 / (Fintype.card ι : ℝ) + t ^ 2 := by284rw [ρ.purity_eq_inv_dim_add_centered]285linarith286exact ⟨hp, ρ.entropy_bound_of_purity t hp⟩287288/-- Conjugation of a genuine density matrix by a genuine unitary matrix. -/289def DensityMatrix.unitaryConjugate {ι : Type*} [Fintype ι] [DecidableEq ι]290(ρ : DensityMatrix ι) (U : unitary (Matrix ι ι ℂ)) : DensityMatrix ι where291matrix := (U : Matrix ι ι ℂ) * ρ.matrix * (star U : Matrix ι ι ℂ)292positive := ρ.positive.mul_mul_conjTranspose_same (U : Matrix ι ι ℂ)293normalized := by294rw [Matrix.trace_mul_cycle, Unitary.coe_star_mul_self, Matrix.one_mul]295exact ρ.normalized296297theorem DensityMatrix.unitaryConjugate_weights {ι : Type*} [Fintype ι] [DecidableEq ι]298(ρ : DensityMatrix ι) (U : unitary (Matrix ι ι ℂ)) :299(ρ.unitaryConjugate U).weights = ρ.weights := by300apply ((ρ.unitaryConjugate U).positive.isHermitian.eigenvalues_eq_eigenvalues_iff301ρ.positive.isHermitian).mpr302change (U * ρ.matrix * (star U : Matrix ι ι ℂ)).charpoly = ρ.matrix.charpoly303rw [Matrix.charpoly_mul_comm, ← Matrix.mul_assoc, Unitary.coe_star_mul_self,304Matrix.one_mul]305306/-- Unitary invariance of actual von Neumann entropy. -/307theorem DensityMatrix.unitaryConjugate_entropy {ι : Type*} [Fintype ι] [DecidableEq ι]308(ρ : DensityMatrix ι) (U : unitary (Matrix ι ι ℂ)) :309(ρ.unitaryConjugate U).vonNeumann = ρ.vonNeumann := by310simp only [DensityMatrix.vonNeumann, ρ.unitaryConjugate_weights U]311312/-- Entrywise conjugation of a Hermitian density matrix equals its transpose. -/313def DensityMatrix.conjugate {ι : Type*} [Fintype ι] [DecidableEq ι]314(ρ : DensityMatrix ι) : DensityMatrix ι where315matrix := ρ.matrix.transpose316positive := ρ.positive.transpose317normalized := by simpa using ρ.normalized318319theorem DensityMatrix.conjugate_weights {ι : Type*} [Fintype ι] [DecidableEq ι]320(ρ : DensityMatrix ι) : ρ.conjugate.weights = ρ.weights := by321apply (ρ.conjugate.positive.isHermitian.eigenvalues_eq_eigenvalues_iff322ρ.positive.isHermitian).mpr323exact Matrix.charpoly_transpose ρ.matrix324325/-- Entropy equality of conjugate quantum output states. -/326theorem DensityMatrix.conjugate_entropy {ι : Type*} [Fintype ι] [DecidableEq ι]327(ρ : DensityMatrix ι) : ρ.conjugate.vonNeumann = ρ.vonNeumann := by328simp only [DensityMatrix.vonNeumann, ρ.conjugate_weights]329330/-! ## Bell-mixture weights (the classical component of Lemma `bell`) -/331332def bellWeights (K : ℕ) : Option (Fin (K * (K - 1))) → ℝ333| none => 1 / (K : ℝ)334| some _ => 1 / (K : ℝ) ^ 2335336theorem bellWeights_nonneg (K : ℕ) (i : Option (Fin (K * (K - 1)))) :3370 ≤ bellWeights K i := by338cases i <;> simp [bellWeights]339340theorem bellWeights_sum (K : ℕ) (hK : 1 ≤ K) : ∑ i, bellWeights K i = 1 := by341have hk : (K : ℝ) ≠ 0 := by exact_mod_cast (by omega : K ≠ 0)342have hm : ((K - 1 : ℕ) : ℝ) = (K : ℝ) - 1 := by343rw [Nat.cast_sub hK]344simp345simp [Fintype.sum_option, bellWeights, hm]346field_simp347ring348349/-- Exact Shannon entropy of one weight `1/K` and `K(K-1)` weights `1/K²`. -/350theorem bellWeights_shannon (K : ℕ) (hK : 1 ≤ K) :351shannon (bellWeights K) = 2 * Real.log K - Real.log K / K := by352have hk : (K : ℝ) ≠ 0 := by exact_mod_cast (by omega : K ≠ 0)353have hm : ((K - 1 : ℕ) : ℝ) = (K : ℝ) - 1 := by354rw [Nat.cast_sub hK]355simp356simp [shannon, Fintype.sum_option, bellWeights, hm,357Real.log_pow]358field_simp359ring360361/-! ## The actual Bell-vector unitary identity -/362363/-- The unnormalized Bell vector in the product basis. -/364def bellVector {ι : Type*} [DecidableEq ι] : ι × ι → ℂ :=365fun ij => if ij.1 = ij.2 then 1 else 0366367/-- `U ⊗ conjugate(U)` fixes the Bell vector, for any finite-dimensional unitary. -/368theorem unitary_kronecker_conjugate_fixes_bell {ι : Type*} [Fintype ι] [DecidableEq ι]369(U : unitary (Matrix ι ι ℂ)) :370((U : Matrix ι ι ℂ) ⊗ₖ (U : Matrix ι ι ℂ).map (starRingEnd ℂ)) *ᵥ371(bellVector : ι × ι → ℂ) = bellVector := by372ext ⟨i, j⟩373simp only [Matrix.mulVec, dotProduct, Fintype.sum_prod_type, Matrix.kronecker_apply,374Matrix.map_apply, bellVector, mul_ite, mul_one, mul_zero]375simp only [Finset.sum_ite_eq, Finset.mem_univ, if_true]376have h := congrArg (fun M : Matrix ι ι ℂ => M i j) (Unitary.coe_mul_star_self U)377simpa [Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.one_apply] using h378379/-- The same identity for any scalar normalization, including `1 / sqrt(dim)`. -/380theorem unitary_kronecker_conjugate_fixes_scaled_bell381{ι : Type*} [Fintype ι] [DecidableEq ι]382(U : unitary (Matrix ι ι ℂ)) (c : ℂ) :383((U : Matrix ι ι ℂ) ⊗ₖ (U : Matrix ι ι ℂ).map (starRingEnd ℂ)) *ᵥ384(c • (bellVector : ι × ι → ℂ)) = c • bellVector := by385rw [Matrix.mulVec_smul, unitary_kronecker_conjugate_fixes_bell]386387end388389end Nonadditivity.Entropy