module public import SubentropyCertificates.PermutationVariance public import SubentropyCertificates.OptimalDecisionRule /-! Proposition 12 for finite classical–quantum ensembles, with arbitrary finite measurement outcomes and any choice among posterior MAP ties. -/ @[expose] public section noncomputable section set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Matrix open scoped BigOperators ComplexOrder MatrixOrder namespace SubentropyCertificates.PosteriorStability open D5.S3.Quantum.Foundation.FiniteStateChannel open D5.S3.Quantum.Subentropy.ClassicalQuantumGram open D5.S3.Quantum.Subentropy.GuessingProbability open SubentropyCertificates.MeasurementPosterior open SubentropyCertificates.Discrimination open SubentropyCertificates.ClassicalCurve open SubentropyCertificates.StrongConcavity variable {X B Y : Type*} [Fintype X] [DecidableEq X] [Fintype B] [DecidableEq B] [Fintype Y] /-- The mean posterior error of the reported labels on positive-mass outcomes. -/ def measurementError (p : X → ℝ) (ρ : X → DensityState B) (F : Y → Matrix B B ℂ) (selected : Y → X) : ℝ := ∑ y ∈ Finset.univ.filter (fun y => 0 < outcomeProbability p ρ (F y)), outcomeProbability p ρ (F y)*(1-posterior p ρ (F y) (selected y)) /-- The mean squared Euclidean deviation from the vector v_j(e) in Proposition 12. -/ def posteriorDeviation (m : ℕ) (p : X → ℝ) (ρ : X → DensityState B) (F : Y → Matrix B B ℂ) (selected : Y → X) (e : ℝ) : ℝ := ∑ y ∈ Finset.univ.filter (fun y => 0 < outcomeProbability p ρ (F y)), outcomeProbability p ρ (F y)*energy (posterior p ρ (F y)-target m (selected y) e) /-- Proposition 12 for any finite POVM. This version works for any decision rule, in particular for every MAP tie-breaking rule. Here n=card X=m+2. -/ theorem measurement_posterior_stability (m : ℕ) (hn : Fintype.card X=m+2) (p : X → ℝ) (hp : ∀ x,0 ≤ p x) (hs : ∑ x,p x=1) (ρ : X → DensityState B) (F : Y → Matrix B B ℂ) (hF : ∀ y,(F y).PosSemidef) (hsF : ∑ y,F y=1) (selected : Y → X) : let e := measurementError p ρ F selected let gap := phi m e-conditionalSubentropy p hp hs ρ posteriorDeviation m p ρ F selected e ≤ (6-4/(Fintype.card X:ℝ))*gap ∧ (6-4/(Fintype.card X:ℝ))*gap ≤ 6*gap := by let q (y : Y) := outcomeProbability p ρ (F y) let b (y : Y) := posterior p ρ (F y) let S := Finset.univ.filter (fun y => 0 < q y) let e := measurementError p ρ F selected let gap := phi m e-conditionalSubentropy p hp hs ρ let V := posteriorDeviation m p ρ F selected e change V ≤ (6-4/(Fintype.card X:ℝ))*gap ∧ (6-4/(Fintype.card X:ℝ))*gap ≤ 6*gap have hq y : 0 ≤ q y := outcomeProbability_nonneg p hp ρ (F y) (hF y) have hsum : ∑ y : S,q y=1 := by rw [Finset.sum_coe_sort] dsimp only [S] rw [sum_over_positive q hq q (fun _ hz => hz)] exact sum_outcomeProbability p hp hs ρ F hsF have hpost (y : S) : b y ∈ probabilitySimplex X := posterior_probability p hp ρ (F y) (hF y) (Finset.mem_filter.mp y.property).2 have herr : ∑ y : S,q y*(1-b y (selected y))=e := S.sum_coe_sort (fun y => q y*(1-b y (selected y))) have h := classical_posterior_stability m hn (fun y : S => q y) (fun y => hq y) hsum (fun y : S => b y) hpost (fun y : S => selected y) e herr rw [S.sum_coe_sort (fun y => q y*energy (b y-target m (selected y) e)), S.sum_coe_sort (fun y => q y*classicalSubentropy (b y))] at h have hcomp : conditionalSubentropy p hp hs ρ ≤ ∑ y ∈ S,q y*classicalSubentropy (b y) := (measurement_posterior_comparison p hp hs ρ F hF hsF).2 have hgap : mu (Fintype.card X)/2*V ≤ gap := h.trans (sub_le_sub_left hcomp _) have hd : 2 ≤ Fintype.card X := by omega have hk : 0 < mu (Fintype.card X)/2 := by linarith [variance_coefficient_ge_sixth hd] have hV : 0 ≤ V := Finset.sum_nonneg fun y _ => mul_nonneg (hq y) (Finset.sum_nonneg fun x _ => sq_nonneg _) have hg : 0 ≤ gap := le_trans (mul_nonneg hk.le hV) hgap constructor · rw [← inverse_variance_coefficient hd,inv_mul_eq_div] apply (le_div_iff₀ hk).mpr simpa only [mul_comm] using hgap · apply mul_le_mul_of_nonneg_right _ hg exact sub_le_self _ (by positivity) /-- Every optimal finite guessing measurement, with any posterior MAP rule on positive-probability outcomes. Optimality means that some decision rule on this measurement attains the operational optimum. -/ theorem optimal_posterior_stability (m : ℕ) (hn : Fintype.card X=m+2) (p : X → ℝ) (hp : ∀ x,0 ≤ p x) (hs : ∑ x,p x=1) (ρ : X → DensityState B) (F : Y → Matrix B B ℂ) (hF : ∀ y,(F y).PosSemidef) (hsF : ∑ y,F y=1) (selected : Y → X) (hMAP : ∀ y,0 < outcomeProbability p ρ (F y) → ∀ x,posterior p ρ (F y) x ≤ posterior p ρ (F y) (selected y)) (hopt : ∃ rule : Y → X,decisionSuccess p ρ F rule=pGuess p ρ) : let e := 1-pGuess p ρ let gap := phi m e-conditionalSubentropy p hp hs ρ measurementError p ρ F selected=e ∧ posteriorDeviation m p ρ F selected e ≤ (6-4/(Fintype.card X:ℝ))*gap ∧ (6-4/(Fintype.card X:ℝ))*gap ≤ 6*gap := by have he : measurementError p ρ F selected = 1-pGuess p ρ := (posterior_average_error p hp hs ρ F hF hsF selected).trans (congrArg (fun s : ℝ => 1-s) (map_rule_optimal p hp hs ρ F hF hsF selected hMAP hopt)) exact ⟨he,he ▸ measurement_posterior_stability m hn p hp hs ρ F hF hsF selected⟩ /-- An optimal labelled POVM exists, and the two stability inequalities hold there with the true minimum error. -/ theorem exists_optimal_povm_stability (m : ℕ) (hn : Fintype.card X=m+2) (p : X → ℝ) (hp : ∀ x,0 ≤ p x) (hs : ∑ x,p x=1) (ρ : X → DensityState B) : let e := 1-pGuess p ρ let gap := phi m e-conditionalSubentropy p hp hs ρ ∃ M : X → Matrix B B ℂ, (∀ x,(M x).PosSemidef) ∧ ∑ x,M x=1 ∧ successProbability p ρ M=pGuess p ρ ∧ (∀ y,0 < outcomeProbability p ρ (M y) → ∀ x,posterior p ρ (M y) x ≤ posterior p ρ (M y) y) ∧ measurementError p ρ M id=e ∧ posteriorDeviation m p ρ M id e ≤ (6-4/(Fintype.card X:ℝ))*gap ∧ (6-4/(Fintype.card X:ℝ))*gap ≤ 6*gap := by obtain ⟨M,hM,hsM,hopt⟩ := exists_optimal_povm p hp hs ρ have he : measurementError p ρ M id = 1-pGuess p ρ := (posterior_average_error p hp hs ρ M hM hsM id).trans (congrArg (fun s : ℝ => 1-s) hopt) exact ⟨M,hM,hsM,hopt,optimal_rule_is_map p hp hs ρ M hM hsM id hopt,he, he ▸ measurement_posterior_stability m hn p hp hs ρ M hM hsM id⟩ end SubentropyCertificates.PosteriorStability