PermutationVariance.lean
1module23public import SubentropyCertificates.MatrixStrongConcavity4public import SubentropyCertificates.ClassicalFano56/-! Strong Jensen applied to a posterior selected at random and then7cyclically permuted on its unselected labels. -/8@[expose] public section9noncomputable section10set_option autoImplicit false11open scoped BigOperators12namespace SubentropyCertificates.PosteriorStability13open SubentropyCertificates.ClassicalCurve14open SubentropyCertificates.StrongConcavity1516/-- For n=m+2 labels, the distinguished label receives 1-e and17each remaining label receives e/(n-1). -/18def target {X : Type*} [DecidableEq X] (m : ℕ) (i : X) (e : ℝ) (x : X) : ℝ :=19 if x=i then 1-e else e/(m+1 : ℕ)2021private theorem extremal_mean {Y : Type*} [Fintype Y] (m : ℕ)22 (q err : Y → ℝ) (hs : ∑ y,q y=1) :23 ∑ y,q y • extremalVector m (err y) = extremalVector m (∑ y,q y*err y) := by24 funext i25 cases i with26 | none => simp [extremalVector, Finset.sum_apply, mul_sub, Finset.sum_sub_distrib, hs]27 | some i => simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,extremalVector,28 ← mul_div_assoc,← Finset.sum_div]2930/-- Weighted posterior variance on a finite alphabet. The choice of label31may depend on the outcome, and need not have a unique maximum. -/32theorem classical_posterior_stability {X Y : Type*} [Fintype X] [DecidableEq X] [Fintype Y]33 (m : ℕ) (hn : Fintype.card X=m+2) (q : Y → ℝ) (hq : ∀ y,0 ≤ q y)34 (hs : ∑ y,q y=1) (b : Y → X → ℝ) (hb : ∀ y,b y ∈ probabilitySimplex X)35 (selected : Y → X) (e : ℝ) (he : ∑ y,q y*(1-b y (selected y))=e) :36 mu (Fintype.card X)/2 * (∑ y,q y*energy (b y-target m (selected y) e)) ≤37 phi m e - ∑ y,q y*classicalSubentropy (b y) := by38 let D := Option (Fin (m+1))39 let a : D ≃ X := Fintype.equivOfCardEq (by simp [D,hn,Nat.add_assoc])40 let align (y : Y) := a.trans (Equiv.swap (a none) (selected y))41 have hi (y : Y) : align y none = selected y := by simp [align]42 let perm (y : Y) (j : Fin (m+1)) := (tailShift m j).trans (align y)43 let P (z : Y × Fin (m+1)) := b z.1 ∘ perm z.1 z.244 let c := ((m+1 : ℕ) : ℝ)⁻¹45 let w (z : Y × Fin (m+1)) := q z.1*c46 have hc : (∑ _j : Fin (m+1), c) = 1 := by47 simp only [c,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]48 exact mul_inv_cancel₀ (by positivity)49 have sumW (f : Y → ℝ) :50 ∑ z : Y × Fin (m+1), w z*f z.1 = ∑ y,q y*f y := by51 rw [Fintype.sum_prod_type]52 apply Finset.sum_congr rfl53 intro y _54 change (∑ j : Fin (m+1), q y*c*f y) = q y*f y55 rw [← Finset.sum_mul,← Finset.mul_sum,hc,mul_one]56 have hw : ∑ z,w z=1 := by simpa only [mul_one] using (sumW (fun _ => 1)).trans (by simpa using hs)57 have hp (z : Y × Fin (m+1)) : P z ∈ probabilitySimplex D :=58 simplex_reindex _ (hb z.1) (perm z.1 z.2)59 have havg (y : Y) : ∑ j : Fin (m+1), c • P (y,j) =60 extremalVector m (1-b y (selected y)) := by61 have h := average_tail_shifts m (b y ∘ align y) (simplex_reindex _ (hb y) (align y))62 change (∑ j : Fin (m+1), c • ((b y ∘ align y) ∘ tailShift m j)) = _63 simpa only [Function.comp_apply,hi,c] using h64 have hmean : ∑ z,w z • P z = extremalVector m e := by65 rw [Fintype.sum_prod_type]66 calc _ = ∑ y,q y • extremalVector m (1-b y (selected y)) := by67 apply Finset.sum_congr rfl68 intro y _69 rw [← havg,Finset.smul_sum]70 simp only [w,smul_smul]71 _ = _ := (extremal_mean m q _ hs).trans (congrArg (extremalVector m) he)72 have pull (y : Y) (j : Fin (m+1)) :73 target m (selected y) e ∘ perm y j = extremalVector m e := by74 have hnone : perm y j none = selected y := by simpa [perm,tailShift] using hi y75 funext i76 cases i with77 | none => simp [Function.comp_apply,target,hnone,extremalVector]78 | some i =>79 have hne : perm y j (some i) ≠ selected y := fun h =>80 Option.some_ne_none i ((perm y j).injective (h.trans hnone.symm))81 simp [Function.comp_apply,target,hne,extremalVector]82 have hvar (z : Y × Fin (m+1)) :83 energy (P z-extremalVector m e)=energy (b z.1-target m (selected z.1) e) := by84 rw [← pull z.1 z.2]85 exact Equiv.sum_comp (perm z.1 z.2) (fun x => (b z.1 x-target m (selected z.1) e x)^2)86 have hQ (z : Y × Fin (m+1)) : classicalSubentropy (P z)=classicalSubentropy (b z.1) :=87 classical_subentropy_reindex _ (perm z.1 z.2)88 have hd : Fintype.card D = Fintype.card X := Fintype.card_congr a89 have hd₂ : 2 ≤ Fintype.card D := by omega90 have h := posterior_strong_concavity hd₂ w (fun z => mul_nonneg (hq z.1) (by dsimp [c]; positivity))91 hw P hp92 dsimp only at h93 rw [hmean] at h94 simp_rw [hvar,hQ] at h95 rw [sumW (fun y => energy (b y-target m (selected y) e)),sumW (fun y => classicalSubentropy (b y)),hd] at h96 exact h9798end SubentropyCertificates.PosteriorStability
Axioms used
Choose a statement to see which axioms its proof uses.