Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.HaarPathRuns

Download original .lean · View on GitHub · Jump to source

Catalog entries: Corrected marked-position and middle-run accounting

Direct imports

  • Nonadditivity.HaarPathProfiles
  • Mathlib.Data.Finset.Card dependency
  • Mathlib.Algebra.BigOperators.Group.Finset.Basic dependency
  • Mathlib.Algebra.BigOperators.Group.Finset.Pi dependency

Imported by project modules

4 direct reverse imports

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

37 project constants, including generated, internal and private declarations.

37 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.HaarPathProfiles7import Mathlib.Data.Finset.Card8import Mathlib.Algebra.BigOperators.Group.Finset.Basic9import Mathlib.Algebra.BigOperators.Group.Finset.Pi1011/-! # First/last markers and the corrected BC coefficient exponent1213The number of middle blocks need not be at most the number of distinct14edges. The valid bound is at most the number of marked positions minus one.15Only marked factors incur a moment-order factor, so this weaker block bound16still gives the required coefficient exponent.17-/18noncomputable section19namespace Nonadditivity.HaarPathRuns20open scoped BigOperators2122/-- Number of maximal false runs that end before the end of the list.23When the last flag is true, these are exactly all middle blocks. -/24def middleRuns : List Bool → ℕ25  | [] => 026  | [_] => 027  | a::b::l => (if a=false ∧ b=true then 1 else 0) + middleRuns (b::l)2829/-- Each middle block can be charged to its following marker; the initial30marker is never charged. This is the sharp general combinatorial bound. -/31theorem middleRuns_add_head_le (l : List Bool) :32    middleRuns l + (if l.head?=some true then 1 else 0) ≤ l.count true := by33  induction l with34  | nil => simp [middleRuns]35  | cons a l ih =>36      cases l with37      | nil => cases a <;> simp [middleRuns]38      | cons b l => cases a <;> cases b <;> simp [middleRuns] at * <;> omega3940theorem middleRuns_add_one_le {l : List Bool} (hhead : l.head?=some true) :41    middleRuns l + 1 ≤ l.count true := by42  simpa only [hhead,if_pos rfl] using middleRuns_add_head_le l4344/-- Marked first/last visits are singleton blocks; the unmarked intervals are45middle blocks. -/46def blockCount (l : List Bool) : ℕ := l.count true + middleRuns l4748/-- The combined exponent from compositions and marked coefficient factors.49This replaces the unnecessarily strong and false bound `r ≤ 3*e`. -/50theorem corrected_exponent_le {l : List Bool} {e : ℕ}51    (hhead : l.head?=some true) (hmarks : l.count true ≤ 2*e) :52    blockCount l - 1 + l.count true ≤ 6*e-2 := by53  have hr := middleRuns_add_one_le hhead54  dsimp [blockCount]55  omega5657variable {E : Type*} [DecidableEq E] {n : ℕ}5859/-- The first occurrence of each label. -/60def firstPositions (f : Fin n → E) : Finset (Fin n) :=61  Finset.univ.filter fun i => ∀ j : Fin n, j < i → f j ≠ f i6263/-- The last occurrence of each label. -/64def lastPositions (f : Fin n → E) : Finset (Fin n) :=65  Finset.univ.filter fun i => ∀ j : Fin n, i < j → f j ≠ f i6667def endpointPositions (f : Fin n → E) : Finset (Fin n) :=68  firstPositions f ∪ lastPositions f6970theorem card_firstPositions_le (f : Fin n → E) :71    (firstPositions f).card ≤ (Finset.univ.image f).card := by72  apply Finset.card_le_card_of_injOn f73  · intro i hi74    exact Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩75  · intro i hi j hj he76    by_contra hij77    rcases lt_or_gt_of_ne hij with hlt | hgt78    · exact (Finset.mem_filter.mp hj).2 i hlt he79    · exact (Finset.mem_filter.mp hi).2 j hgt he.symm8081theorem card_lastPositions_le (f : Fin n → E) :82    (lastPositions f).card ≤ (Finset.univ.image f).card := by83  apply Finset.card_le_card_of_injOn f84  · intro i hi85    exact Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩86  · intro i hi j hj he87    by_contra hij88    rcases lt_or_gt_of_ne hij with hlt | hgt89    · exact (Finset.mem_filter.mp hi).2 j hlt he.symm90    · exact (Finset.mem_filter.mp hj).2 i hgt he9192/-- At most two distinguished visits per distinct edge, with singleton93occurrences counted only once. -/94theorem card_endpointPositions_le (f : Fin n → E) :95    (endpointPositions f).card ≤ 2*(Finset.univ.image f).card := by96  have h := Finset.card_union_le (firstPositions f) (lastPositions f)97  have hf := card_firstPositions_le f98  have hl := card_lastPositions_le f99  dsimp [endpointPositions]100  omega101102theorem first_endpoint (f : Fin (n+1) → E) : (0 : Fin (n+1)) ∈ endpointPositions f := by103  apply Finset.mem_union_left104  apply Finset.mem_filter.mpr105  refine ⟨Finset.mem_univ _,?_⟩106  intro j hj107  exact (Fin.not_lt_zero _ hj).elim108109theorem last_endpoint (f : Fin (n+1) → E) : Fin.last n ∈ endpointPositions f := by110  apply Finset.mem_union_right111  apply Finset.mem_filter.mpr112  refine ⟨Finset.mem_univ _,?_⟩113  intro j hj114  exact (not_lt_of_ge (Fin.le_last j) hj).elim115116/-- The literal marker flags of a finite edge-occurrence sequence. -/117def endpointFlags (f : Fin n → E) : List Bool :=118  List.ofFn fun i => decide (i ∈ endpointPositions f)119120lemma count_true_eq_sum (l : List Bool) :121    l.count true = (l.map (fun b => if b then 1 else 0)).sum := by122  induction l with123  | nil => rfl124  | cons a l ih => cases a <;> simp [ih,Nat.add_comm]125126/-- The Boolean marker count is exactly the cardinality of first/last positions. -/127theorem count_endpointFlags (f : Fin n → E) :128    (endpointFlags f).count true = (endpointPositions f).card := by129  rw [count_true_eq_sum]130  simp [endpointFlags,List.map_ofFn,List.sum_ofFn,Function.comp_def]131132theorem head_endpointFlags (f : Fin (n+1) → E) :133    (endpointFlags f).head?=some true := by134  simp [endpointFlags,List.ofFn_succ,first_endpoint]135136/-- The repaired BC exponent for the actual first/last markers of any137nonempty occurrence sequence. -/138theorem occurrence_exponent_le (f : Fin (n+1) → E) :139    blockCount (endpointFlags f) - 1 + (endpointFlags f).count true ≤140      6*(Finset.univ.image f).card-2 := by141  apply corrected_exponent_le (head_endpointFlags f)142  rw [count_endpointFlags]143  exact card_endpointPositions_le f144145/-- The eight-position balanced-word example has four markers and three146middle blocks. Thus the generic bound `r ≤ 3*e` fails already for two edges. -/147theorem two_edge_run_counterexample :148    blockCount [true,false,false,true,false,true,false,true]=7 ∧149    3*2 < blockCount [true,false,false,true,false,true,false,true] := by150  decide151152end Nonadditivity.HaarPathRuns