Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.NoncommutativeCSSingletons

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

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

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

33 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.NoncommutativeCSEndpointSkeleton78/-! # Singleton labels of closed endpoint skeletons910The endpoint compiler's singleton nodes are exactly the labels occurring11once in the literal visit word. The proof tracks the actual active layout;12it does not assume that the skeleton was built by a particular compiler.13-/14noncomputable section15namespace Nonadditivity.NoncommutativeCS.EndpointSkeleton16variable {I : Type*}1718def singletonLabels {m n : ℕ} {a : Fin m → I} {b : Fin n → I} :19    EndpointSkeleton I a b → List I20  | .done _ => []21  | .first _ P => P.singletonLabels22  | .last _ P => P.singletonLabels23  | .middle _ P => P.singletonLabels24  | .singleton i P => i :: P.singletonLabels2526theorem singletonLabels_sublist_profileLabels {m n : ℕ}27    {a : Fin m → I} {b : Fin n → I} (P : EndpointSkeleton I a b) :28    P.singletonLabels.Sublist P.profileLabels := by29  induction P with30  | done => simp [singletonLabels, profileLabels]31  | first i P ih => exact ih.cons _32  | last p P ih => exact ih33  | middle visits P ih => exact ih34  | singleton i P ih => exact ih.cons_cons _3536theorem singletonLabels_nodup {m n : ℕ}37    {a : Fin m → I} {b : Fin n → I} (P : EndpointSkeleton I a b)38    (hP : P.profileLabels.Nodup) : P.singletonLabels.Nodup :=39  hP.sublist P.singletonLabels_sublist_profileLabels4041/-- A visit uses an initially active label or a label introduced by the42skeleton itself. -/43theorem mem_word_range_or_profile {m n : ℕ}44    {a : Fin m → I} {b : Fin n → I} (P : EndpointSkeleton I a b) (i : I) :45    i ∈ P.word → i ∈ Set.range a ∨ i ∈ P.profileLabels := by46  induction P with47  | done => simp [word]48  | @first m n a b j P ih =>49      intro hi50      rcases List.mem_cons.mp hi with rfl | hi51      · exact Or.inr (List.mem_cons_self)52      · rcases ih hi with hi | hi53        · rcases (show i=j ∨ i ∈ Set.range a by simpa [Fin.range_cons] using hi) with rfl | hi54          · exact Or.inr (List.mem_cons_self)55          · exact Or.inl hi56        · exact Or.inr (List.mem_cons_of_mem _ hi)57  | @last m n a b p P ih =>58      intro hi59      rcases List.mem_cons.mp hi with hi | hi60      · exact Or.inl ⟨p,hi.symm⟩61      · rcases ih hi with ⟨q,hq⟩ | hi62        · exact Or.inl ⟨p.succAbove q,hq⟩63        · exact Or.inr hi64  | @middle m n a b visits P ih =>65      intro hi66      rcases List.mem_append.mp hi with hi | hi67      · obtain ⟨p,hp,rfl⟩ := List.mem_map.mp hi68        exact Or.inl ⟨p,rfl⟩69      · exact ih hi70  | singleton j P ih =>71      intro hi72      rcases List.mem_cons.mp hi with rfl | hi73      · exact Or.inr List.mem_cons_self74      · exact (ih hi).imp_right (List.mem_cons_of_mem _)7576/-- An initially active label is eventually visited or remains in the final77layout. This is the finite register conservation property. -/78theorem mem_initial_range_word_or_final {m n : ℕ}79    {a : Fin m → I} {b : Fin n → I} (P : EndpointSkeleton I a b) (i : I) :80    i ∈ Set.range a → i ∈ P.word ∨ i ∈ Set.range b := by81  induction P with82  | done => exact Or.inr83  | @first m n a b j P ih =>84      intro hi85      have hi' : i ∈ Set.range (Fin.cons j a) := by86        simpa [Fin.range_cons] using (Or.inr hi : i=j ∨ i ∈ Set.range a)87      exact (ih hi').imp_left (List.mem_cons_of_mem _)88  | @last m n a b p P ih =>89      rintro ⟨q,rfl⟩90      by_cases hq : q=p91      · subst q92        exact Or.inl List.mem_cons_self93      · obtain ⟨r,hr⟩ := Fin.exists_succAbove_eq hq94        have hi : a q ∈ Set.range (p.removeNth a) := ⟨r,congrArg a hr⟩95        exact (ih hi).imp_left (List.mem_cons_of_mem _)96  | middle visits P ih =>97      intro hi98      exact (ih hi).imp_left (List.mem_append_right _)99  | singleton j P ih =>100      intro hi101      exact (ih hi).imp_left (List.mem_cons_of_mem _)102103theorem mem_word_of_initial_closed {m n : ℕ}104    {a : Fin m → I} {b : Fin n → I} (P : EndpointSkeleton I a b)105    (hend : ∀ q : Fin n, False) (i : I) (hi : i ∈ Set.range a) :106    i ∈ P.word := by107  rcases P.mem_initial_range_word_or_final i hi with hi | ⟨q,hq⟩108  · exact hi109  · exact (hend q).elim110111/-- Generic induction invariant: a singleton node accounts exactly for a112single visit of a label which was not active at the start. -/113theorem mem_singletonLabels_iff_count_eq_one_not_initial [DecidableEq I]114    {m n : ℕ} {a : Fin m → I} {b : Fin n → I} (P : EndpointSkeleton I a b)115    (hend : ∀ q : Fin n, False) (ha : Function.Injective a)116    (hP : P.profileLabels.Nodup)117    (hdisj : ∀ i ∈ P.profileLabels, i ∉ Set.range a) (i : I) :118    i ∈ P.singletonLabels ↔ P.word.count i=1 ∧ i ∉ Set.range a := by119  induction P with120  | done => simp [singletonLabels, word]121  | @first m n a b j P ih =>122      obtain ⟨hj,hP⟩ := List.nodup_cons.mp hP123      have hja : j ∉ Set.range a := hdisj j List.mem_cons_self124      have hd : ∀ k ∈ P.profileLabels, k ∉ Set.range (Fin.cons j a) := by125        intro k hk126        simp only [Fin.range_cons, Set.mem_insert_iff, not_or]127        exact ⟨fun he => hj (he ▸ hk), hdisj k (List.mem_cons_of_mem _ hk)⟩128      have hh := ih hend (Fin.cons_injective_of_injective hja ha) hP hd129      by_cases hij : i=j130      · subst i131        have hnot : j ∉ P.singletonLabels := fun h => hj132          (P.singletonLabels_sublist_profileLabels.subset h)133        have hpos : 0 < P.word.count j := List.count_pos_iff.mpr134          (P.mem_word_of_initial_closed hend j ⟨0,by simp⟩)135        simp only [singletonLabels, word, hnot, List.count_cons_self, false_iff, not_and]136        omega137      · simpa [singletonLabels, word, List.count_cons, hij, Ne.symm hij,138          Fin.range_cons] using hh139  | @last m n a b p P ih =>140      have hd : ∀ k ∈ P.profileLabels, k ∉ Set.range (p.removeNth a) := by141        intro k hk ⟨q,hq⟩142        exact hdisj k hk ⟨p.succAbove q,hq⟩143      have hh := ih hend (ha.comp Fin.succAbove_right_injective) hP hd144      by_cases hi : i=a p145      · subst i146        have hnot : a p ∉ P.singletonLabels := fun h =>147          hdisj _ (P.singletonLabels_sublist_profileLabels.subset h) ⟨p,rfl⟩148        simp [singletonLabels, word, hnot, show a p ∈ Set.range a from ⟨p,rfl⟩]149      · simpa [singletonLabels, word, List.count_cons, hi, Ne.symm hi,150          mem_range_removeNth ha p, not_and_or] using hh151  | @middle m n a b visits P ih =>152      have hh := ih hend ha hP hdisj153      by_cases hi : i ∈ Set.range a154      · have hnot : i ∉ P.singletonLabels := fun h =>155          hdisj _ (P.singletonLabels_sublist_profileLabels.subset h) hi156        simp [singletonLabels, hnot, hi]157      · have hm : i ∉ visits.map a := by158          rintro hi'159          obtain ⟨p,hp,hp'⟩ := List.mem_map.mp hi'160          exact hi ⟨p,hp'⟩161        simpa [singletonLabels, word, List.count_append,162          List.count_eq_zero.mpr hm, hi] using hh163  | @singleton m n a b j P ih =>164      obtain ⟨hj,hP⟩ := List.nodup_cons.mp hP165      have hd : ∀ k ∈ P.profileLabels, k ∉ Set.range a :=166        fun k hk => hdisj k (List.mem_cons_of_mem _ hk)167      have hh := ih hend ha hP hd168      have hja : j ∉ Set.range a := hdisj j List.mem_cons_self169      by_cases hij : i=j170      · subst i171        have hw : j ∉ P.word := fun h =>172          (P.mem_word_range_or_profile j h).elim hja hj173        simp [singletonLabels, word, List.count_eq_zero.mpr hw, hja]174      · simpa [singletonLabels, word, List.count_cons, hij, Ne.symm hij] using hh175176theorem closed_mem_singletonLabels_iff_count_eq_one [DecidableEq I]177    (P : EndpointSkeleton I (Fin.elim0 : Fin 0 → I) (Fin.elim0 : Fin 0 → I))178    (hP : P.profileLabels.Nodup) (i : I) :179    i ∈ P.singletonLabels ↔ P.word.count i=1 := by180  simpa using P.mem_singletonLabels_iff_count_eq_one_not_initial Fin.elim0181    (Function.injective_of_subsingleton _) hP (by simp) i182183theorem closed_singletonLabels_toFinset [DecidableEq I]184    (P : EndpointSkeleton I (Fin.elim0 : Fin 0 → I) (Fin.elim0 : Fin 0 → I))185    (hP : P.profileLabels.Nodup) :186    P.singletonLabels.toFinset=P.word.toFinset.filter (fun i => P.word.count i=1) := by187  ext i188  simp only [List.mem_toFinset, Finset.mem_filter,189    P.closed_mem_singletonLabels_iff_count_eq_one hP]190  constructor191  · intro hi192    exact ⟨List.count_pos_iff.mp (by omega),hi⟩193  · exact And.right194195end Nonadditivity.NoncommutativeCS.EndpointSkeleton