/- Copyright (c) 2026 Marcel Morgenstern. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Marcel Morgenstern -/ module public import OperatorEntropy.DataProcessing.GeneralInput public import OperatorEntropy.Petz.RecoveryMap public import OperatorEntropy.PartialTraceKraus public import Mathlib.LinearAlgebra.Lagrange /-! # The data-processing inequality for general CPTP maps This file proves monotonicity of the Umegaki relative entropy under every completely positive trace-preserving map `Λ : M_n → M_m` given in Kraus form (`KrausChannel n m`; the input and output dimensions may differ), for all pairs of states, with the `EReal`-valued relative entropy (`relEntropy`, equal to `⊤` off the support condition): `D(Λ ρ ‖ Λ σ) ≤ D(ρ ‖ σ)` (`KrausChannel.relEntropy_le`). ## Proof The route is the Stinespring dilation in its isometric form: 1. Isometric invariance (`relEntropy_isometryConj`). For an isometry `V` (`Vᴴ V = 1`) the functional calculus satisfies `f(V A Vᴴ) = V f(A) Vᴴ` whenever `f 0 = 0` (`cfc_isometry_conj`, proved by Lagrange interpolation of `f` on the joint spectrum and the identity `(V A Vᴴ)ᵏ⁺¹ = V Aᵏ⁺¹ Vᴴ`). With `f = log` this gives `D(V ρ Vᴴ ‖ V σ Vᴴ) = D(ρ ‖ σ)`, together with the invariance of the support condition. 2. Partial-trace monotonicity for arbitrary states (`relEntropy_partialTraceRight_le`). The faithful-second-argument case is `Lieb.relEntropyMonotone_partialTrace` (Lieb's joint convexity plus a Weyl-twirl average). A singular `σ` with `supp ρ ⊆ supp σ` is handled by the regularisation `σ_ε = (1-ε)σ + ε·𝟙/d`: both `Tr ρ log σ_ε` and its partial-trace analogue converge as `ε → 0` (`tendsto_trace_mul_cfc_log_regularize`); the terms with `qₘ = 0` have weight zero by the support condition. If the support condition fails the right-hand side is `⊤`. 3. Kraus form as isometry followed by partial trace: `Λ ρ = Tr_ι (V ρ Vᴴ)` for the Stinespring isometry `V (a, i) j = (Kᵢ) a j` (`KrausChannel.toMat_eq_partialTraceRight`). -/ @[expose] public section open Matrix Real Polynomial Filter Topology open scoped ComplexOrder Kronecker noncomputable section namespace OperatorEntropy /-! ## Functional calculus under an isometric embedding -/ section Isometry variable {n N : Type*} [Fintype n] [DecidableEq n] [Fintype N] [DecidableEq N] /-- `(V A Vᴴ)ᵏ⁺¹ = V Aᵏ⁺¹ Vᴴ` for an isometry `V`. -/ lemma isometry_conj_pow (V : Matrix N n ℂ) (hV : Vᴴ * V = 1) (A : Matrix n n ℂ) (k : ℕ) : (V * A * Vᴴ) ^ (k + 1) = V * A ^ (k + 1) * Vᴴ := by induction k with | zero => simp | succ k ih => rw [pow_succ, ih, pow_succ] calc V * A ^ (k + 1) * Vᴴ * (V * A * Vᴴ) = V * A ^ (k + 1) * (Vᴴ * V) * A * Vᴴ := by simp only [Matrix.mul_assoc] _ = V * (A ^ (k + 1) * A) * Vᴴ := by rw [hV, Matrix.mul_one, Matrix.mul_assoc V] /-- Polynomials under an isometric embedding: `p(V A Vᴴ) = V p(A) Vᴴ + p(0) (1 - V Vᴴ)`. -/ lemma aeval_isometry_conj (V : Matrix N n ℂ) (hV : Vᴴ * V = 1) (A : Matrix n n ℂ) (p : ℝ[X]) : aeval (V * A * Vᴴ) p = V * aeval A p * Vᴴ + (p.eval 0) • (1 - V * Vᴴ) := by induction p using Polynomial.induction_on' with | add p q hp hq => simp only [map_add, hp, hq, eval_add, add_smul, Matrix.mul_add, Matrix.add_mul] abel | monomial k c => rw [aeval_monomial, aeval_monomial, eval_monomial] rcases k with _ | k · simp only [pow_zero, mul_one, Algebra.algebraMap_eq_smul_one] rw [Matrix.mul_smul, Matrix.mul_one, Matrix.smul_mul, smul_sub] abel · rw [isometry_conj_pow V hV, zero_pow (Nat.succ_ne_zero k), mul_zero, zero_smul, add_zero] simp only [Algebra.algebraMap_eq_smul_one, Matrix.smul_mul, Matrix.mul_smul, Matrix.one_mul] /-- **Functional calculus under an isometry.** `f(V A Vᴴ) = V f(A) Vᴴ` for Hermitian `A`, an isometry `V` (`Vᴴ V = 1`) and any `f` with `f 0 = 0` (e.g. `f = log` with Mathlib's `log 0 = 0`). -/ lemma cfc_isometry_conj (V : Matrix N n ℂ) (hV : Vᴴ * V = 1) {A : Matrix n n ℂ} (hA : A.IsHermitian) (f : ℝ → ℝ) (hf : f 0 = 0) : cfc f (V * A * Vᴴ) = V * cfc f A * Vᴴ := by classical have hB : (V * A * Vᴴ).IsHermitian := isHermitian_mul_mul_conjTranspose V hA set S : Set ℝ := spectrum ℝ A ∪ spectrum ℝ (V * A * Vᴴ) ∪ {0} with hS have hSfin : S.Finite := ((Matrix.finite_real_spectrum (A := A)).union (Matrix.finite_real_spectrum (A := V * A * Vᴴ))).union (Set.finite_singleton 0) set s := hSfin.toFinset set p : ℝ[X] := Lagrange.interpolate s id f with hp have hpf : ∀ x ∈ S, p.eval x = f x := by intro x hx have := Lagrange.eval_interpolate_at_node (s := s) (v := id) (i := x) f (Set.injOn_id _) (hSfin.mem_toFinset.mpr hx) rw [hp]; exact this have hA' : cfc f A = aeval A p := by rw [← cfc_polynomial p A hA.isSelfAdjoint] exact cfc_congr fun x hx => (hpf x (Or.inl (Or.inl hx))).symm have hB' : cfc f (V * A * Vᴴ) = aeval (V * A * Vᴴ) p := by rw [← cfc_polynomial p _ hB.isSelfAdjoint] exact cfc_congr fun x hx => (hpf x (Or.inl (Or.inr hx))).symm rw [hA', hB', aeval_isometry_conj V hV, hpf 0 (Or.inr rfl), hf, zero_smul, add_zero] /-- The isometric embedding `ρ ↦ V ρ Vᴴ` of a state, for an isometry `V` (`Vᴴ V = 1`). -/ def DensityMatrix.isometryConj (V : Matrix N n ℂ) (hV : Vᴴ * V = 1) (ρ : DensityMatrix n) : DensityMatrix N where val := V * ρ.val * Vᴴ posSemidef := ρ.posSemidef.mul_mul_conjTranspose_same V trace_one := by rw [Matrix.trace_mul_comm, ← Matrix.mul_assoc, hV, Matrix.one_mul, ρ.trace_one] /-- The spectral relative-entropy formula in trace form with the generic `cfc`. -/ lemma relEntropyReal_eq_trace_cfc (ρ σ : DensityMatrix n) : relEntropyReal ρ σ = (ρ.val * cfc Real.log ρ.val).trace.re - (ρ.val * cfc Real.log σ.val).trace.re := by rw [relEntropyReal_eq_trace, ρ.posSemidef.1.cfc_eq, σ.posSemidef.1.cfc_eq] /-- `Tr (V ρ Vᴴ · log(V τ Vᴴ)) = Tr (ρ log τ)` for an isometry `V`. -/ lemma trace_isometryConj_mul_cfc_log (V : Matrix N n ℂ) (hV : Vᴴ * V = 1) (ρ τ : DensityMatrix n) : ((ρ.isometryConj V hV).val * cfc Real.log (τ.isometryConj V hV).val).trace = (ρ.val * cfc Real.log τ.val).trace := by change (V * ρ.val * Vᴴ * cfc Real.log (V * τ.val * Vᴴ)).trace = _ rw [cfc_isometry_conj V hV τ.posSemidef.1 Real.log Real.log_zero, show V * ρ.val * Vᴴ * (V * cfc Real.log τ.val * Vᴴ) = V * (ρ.val * cfc Real.log τ.val) * Vᴴ by simp only [Matrix.mul_assoc]; rw [← Matrix.mul_assoc Vᴴ V, hV, Matrix.one_mul], Matrix.trace_mul_comm, ← Matrix.mul_assoc, hV, Matrix.one_mul] /-- **Isometric invariance of the relative-entropy formula.** -/ theorem relEntropyReal_isometryConj (V : Matrix N n ℂ) (hV : Vᴴ * V = 1) (ρ σ : DensityMatrix n) : relEntropyReal (ρ.isometryConj V hV) (σ.isometryConj V hV) = relEntropyReal ρ σ := by rw [relEntropyReal_eq_trace_cfc, relEntropyReal_eq_trace_cfc, trace_isometryConj_mul_cfc_log, trace_isometryConj_mul_cfc_log] /-- **Isometric invariance of the relative entropy:** `D(VρVᴴ ‖ VσVᴴ) = D(ρ‖σ)` for every isometry `V` and all states (including the value `⊤`). -/ theorem relEntropy_isometryConj (V : Matrix N n ℂ) (hV : Vᴴ * V = 1) (ρ σ : DensityMatrix n) : relEntropy (ρ.isometryConj V hV) (σ.isometryConj V hV) = relEntropy ρ σ := by have hiff := DensityMatrix.supportLE_isometry_iff V hV (ρ' := ρ.isometryConj V hV) (σ' := σ.isometryConj V hV) rfl rfl by_cases h : ρ.SupportLE σ · rw [relEntropy_of_supportLE h, relEntropy_of_supportLE (hiff.mpr h), relEntropyReal_isometryConj] · rw [relEntropy_of_not_supportLE h, relEntropy_of_not_supportLE (fun h' => h (hiff.mp h'))] end Isometry /-! ## Regularisation of a singular second argument -/ section Regularize variable {n : Type*} [Fintype n] [DecidableEq n] /-- `log(a σ + c 𝟙)` is a function of `σ`. -/ lemma cfc_log_affine (σ : DensityMatrix n) (a c : ℝ) : cfc Real.log (a • σ.val + c • (1 : Matrix n n ℂ)) = σ.posSemidef.1.cfc (fun x => Real.log (a * x + c)) := by have hsa : IsSelfAdjoint σ.val := σ.posSemidef.1.isSelfAdjoint have haff : a • σ.val + c • (1 : Matrix n n ℂ) = cfc (fun x : ℝ => a * x + c) σ.val := by rw [cfc_add (a := σ.val) (fun x : ℝ => a * x) (fun _ => c), cfc_const_mul a (fun x : ℝ => x) σ.val, cfc_id' ℝ σ.val, cfc_const c σ.val, Algebra.algebraMap_eq_smul_one] rw [haff, ← cfc_comp' Real.log (fun x : ℝ => a * x + c) σ.val (((Matrix.finite_real_spectrum (A := σ.val)).image _).continuousOn _), σ.posSemidef.1.cfc_eq] /-- **Regularisation limit.** If `supp ρ ⊆ supp σ`, then for every constant `c`, `Tr ρ log((1-ε)σ + εc·𝟙) → Tr ρ log σ` as `ε → 0`. The eigenvalues `qₘ > 0` of `σ` contribute continuously; the eigenvalues `qₘ = 0` carry the weight `∑ₖ pₖ |⟨eₖ|fₘ⟩|² = 0` by the support condition. -/ lemma tendsto_trace_mul_cfc_log_regularize (ρ σ : DensityMatrix n) (h : ρ.SupportLE σ) (c : ℝ) : Tendsto (fun ε : ℝ => (ρ.val * cfc Real.log ((1 - ε) • σ.val + (ε * c) • (1 : Matrix n n ℂ))).trace.re) (𝓝 0) (𝓝 ((ρ.val * cfc Real.log σ.val).trace.re)) := by simp_rw [cfc_log_affine, σ.posSemidef.1.cfc_eq, trace_val_mul_cfc_re] refine tendsto_finsetSum _ fun k _ => tendsto_finsetSum _ fun m _ => ?_ by_cases hq : σ.eig m = 0 · have h0 := h.overlap_eq_zero hq k have h1 : ρ.eig k * Complex.normSq ((star ρ.eigVec * σ.eigVec) k m) = 0 := by rw [mul_comm]; exact h0 simp only [h1, zero_mul] exact tendsto_const_nhds · refine Tendsto.const_mul _ ?_ have hcont : ContinuousAt (fun ε : ℝ => Real.log ((1 - ε) * σ.eig m + ε * c)) 0 := by refine ContinuousAt.log (by fun_prop) ?_ simpa using hq simpa using hcont.tendsto end Regularize /-! ## Partial-trace monotonicity for arbitrary states -/ section PartialTrace variable {nA nE : Type*} [Fintype nA] [DecidableEq nA] [Fintype nE] [DecidableEq nE] omit [Fintype nA] in /-- The right partial trace of `a M + b 𝟙` is `a Tr_E M + b |E| 𝟙`. -/ lemma partialTraceRight_smul_add_smul_one (M : Matrix (nA × nE) (nA × nE) ℂ) (a b : ℝ) : partialTraceRight (a • M + b • (1 : Matrix (nA × nE) (nA × nE) ℂ)) = a • partialTraceRight M + (b * Fintype.card nE) • (1 : Matrix nA nA ℂ) := by ext i i' simp only [partialTraceRight_apply, Matrix.add_apply, Matrix.smul_apply, Matrix.one_apply, Prod.mk.injEq, and_true, Finset.sum_add_distrib, ← Finset.smul_sum] by_cases hii : i = i' · simp [hii, Complex.real_smul] · simp [hii] /-- **Data-processing inequality for the partial trace, for all states.** `D(Tr_E ρ ‖ Tr_E σ) ≤ D(ρ ‖ σ)` with the `EReal`-valued relative entropy, without faithfulness or support hypotheses (if `supp ρ ⊄ supp σ` the right-hand side is `⊤`). -/ theorem relEntropy_partialTraceRight_le (ρ σ : DensityMatrix (nA × nE)) : relEntropy ρ.partialTraceRight σ.partialTraceRight ≤ relEntropy ρ σ := by by_cases hsupp : ρ.SupportLE σ swap · rw [relEntropy_of_not_supportLE hsupp]; exact le_top have hsuppA : ρ.partialTraceRight.SupportLE σ.partialTraceRight := hsupp.kraus (fun j => krausInclusionRight j) (partialTraceRight_eq_kraus ρ.val) (partialTraceRight_eq_kraus σ.val) rw [relEntropy_of_supportLE hsupp, relEntropy_of_supportLE hsuppA, EReal.coe_le_coe_iff, relEntropyReal_eq_trace_cfc, relEntropyReal_eq_trace_cfc] have hne : Nonempty (nA × nE) := by by_contra hcon rw [not_nonempty_iff] at hcon have ht := σ.trace_one simp only [Matrix.trace, Matrix.diag_apply, Finset.univ_eq_empty, Finset.sum_empty] at ht exact one_ne_zero ht.symm set τ : DensityMatrix (nA × nE) := DensityMatrix.maximallyMixed with hτ set c : ℝ := (Fintype.card (nA × nE) : ℝ)⁻¹ with hc have hτval : τ.val = c • (1 : Matrix (nA × nE) (nA × nE) ℂ) := rfl have hτpd : τ.val.PosDef := DensityMatrix.maximallyMixed_posDef -- the regularised second argument have hmixval : ∀ (ε : ℝ) (h0 : 0 ≤ ε) (h1 : ε ≤ 1), (σ.mix τ ε h0 h1).val = (1 - ε) • σ.val + (ε * c) • (1 : Matrix (nA × nE) (nA × nE) ℂ) := by intro ε h0 h1 change (1 - ε) • σ.val + ε • τ.val = _ rw [hτval, smul_smul] have hmixA : ∀ (ε : ℝ) (h0 : 0 ≤ ε) (h1 : ε ≤ 1), (σ.mix τ ε h0 h1).partialTraceRight.val = (1 - ε) • σ.partialTraceRight.val + (ε * (c * Fintype.card nE)) • (1 : Matrix nA nA ℂ) := by intro ε h0 h1 change partialTraceRight (σ.mix τ ε h0 h1).val = _ rw [hmixval, partialTraceRight_smul_add_smul_one, mul_assoc] rfl -- the faithful DPI along the regularisation have hdpi : ∀ᶠ ε in 𝓝[>] (0 : ℝ), (ρ.partialTraceRight.val * cfc Real.log ρ.partialTraceRight.val).trace.re - (ρ.partialTraceRight.val * cfc Real.log ((1 - ε) • σ.partialTraceRight.val + (ε * (c * Fintype.card nE)) • (1 : Matrix nA nA ℂ))).trace.re ≤ (ρ.val * cfc Real.log ρ.val).trace.re - (ρ.val * cfc Real.log ((1 - ε) • σ.val + (ε * c) • (1 : Matrix (nA × nE) (nA × nE) ℂ))).trace.re := by have h0ev : ∀ᶠ ε in 𝓝[>] (0 : ℝ), (0 : ℝ) < ε := self_mem_nhdsWithin have h1ev : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ε < 1 := nhdsWithin_le_nhds (Iio_mem_nhds (by norm_num : (0 : ℝ) < 1)) filter_upwards [h0ev, h1ev] with ε ha hb have hf := Lieb.relEntropyMonotone_partialTrace ρ (σ.mix τ ε ha.le hb.le) (mix_posDef hτpd ha hb.le) rw [relEntropyReal_eq_trace_cfc, relEntropyReal_eq_trace_cfc, hmixA ε ha.le hb.le, hmixval ε ha.le hb.le] at hf exact hf have hL := (tendsto_trace_mul_cfc_log_regularize ρ.partialTraceRight σ.partialTraceRight hsuppA (c * Fintype.card nE)).mono_left (nhdsWithin_le_nhds (s := Set.Ioi 0)) have hR := (tendsto_trace_mul_cfc_log_regularize ρ σ hsupp c).mono_left (nhdsWithin_le_nhds (s := Set.Ioi 0)) exact le_of_tendsto_of_tendsto (tendsto_const_nhds.sub hL) (tendsto_const_nhds.sub hR) hdpi end PartialTrace /-! ## The data-processing inequality for Kraus channels -/ section Kraus variable {n m : Type*} [Fintype n] [DecidableEq n] [Fintype m] [DecidableEq m] /-- The Stinespring isometry of a Kraus channel: `V : ℂⁿ → ℂᵐ ⊗ ℂ^ι`, `V (a, i) j = (Kᵢ) a j`. -/ def KrausChannel.stinespring (Λ : KrausChannel n m) : Matrix (m × Λ.ι) n ℂ := fun p j => Λ.K p.2 p.1 j /-- The Stinespring map is an isometry: `Vᴴ V = ∑ᵢ Kᵢᴴ Kᵢ = 1`. -/ theorem KrausChannel.stinespring_isometry (Λ : KrausChannel n m) : Λ.stinespringᴴ * Λ.stinespring = 1 := by rw [← Λ.htp] ext j j' simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, KrausChannel.stinespring, Matrix.sum_apply, Fintype.sum_prod_type] rw [Finset.sum_comm] /-- **Kraus = isometry followed by a partial trace:** `Λ X = Tr_ι (V X Vᴴ)`. -/ theorem KrausChannel.toMat_eq_partialTraceRight (Λ : KrausChannel n m) (X : Matrix n n ℂ) : Λ.toMat X = partialTraceRight (Λ.stinespring * X * Λ.stinespringᴴ) := by ext a b simp only [KrausChannel.toMat, partialTraceRight_apply, Matrix.sum_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, KrausChannel.stinespring] /-- **The data-processing inequality for a general quantum channel.** For every completely positive trace-preserving map `Λ : M_n → M_m` in Kraus form and all states `ρ, σ`, `D(Λ ρ ‖ Λ σ) ≤ D(ρ ‖ σ)` (Lindblad–Uhlmann monotonicity), with the `EReal`-valued Umegaki relative entropy. -/ theorem KrausChannel.relEntropy_le (Λ : KrausChannel n m) (ρ σ : DensityMatrix n) : relEntropy (Λ.toDM ρ) (Λ.toDM σ) ≤ relEntropy ρ σ := by classical set V := Λ.stinespring have hV : Vᴴ * V = 1 := Λ.stinespring_isometry have hρ : Λ.toDM ρ = (ρ.isometryConj V hV).partialTraceRight := DensityMatrix.ext (Λ.toMat_eq_partialTraceRight ρ.val) have hσ : Λ.toDM σ = (σ.isometryConj V hV).partialTraceRight := DensityMatrix.ext (Λ.toMat_eq_partialTraceRight σ.val) rw [hρ, hσ, ← relEntropy_isometryConj V hV ρ σ] exact relEntropy_partialTraceRight_le _ _ /-- Every Kraus channel is relative-entropy monotone. -/ theorem KrausChannel.isRelEntropyMonotone (Λ : KrausChannel n m) : IsRelEntropyMonotone Λ.toDM := Λ.relEntropy_le /-- The data-processing inequality on the real-valued formula, under the support condition. -/ theorem KrausChannel.relEntropyReal_le (Λ : KrausChannel n m) {ρ σ : DensityMatrix n} (h : ρ.SupportLE σ) : relEntropyReal (Λ.toDM ρ) (Λ.toDM σ) ≤ relEntropyReal ρ σ := by have hΛ : (Λ.toDM ρ).SupportLE (Λ.toDM σ) := h.kraus Λ.K rfl rfl have := Λ.relEntropy_le ρ σ rwa [relEntropy_of_supportLE h, relEntropy_of_supportLE hΛ, EReal.coe_le_coe_iff] at this end Kraus end OperatorEntropy