Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 2.3 (Kraft), second statement — lengths satisfying ∑i2−ki≤1\sum_i 2^{-k_i}\le 1∑i​2−ki​≤1 are realized by an instantaneous code

Proved
FuchsThesis.Coding.lemma_2_3_existence

by iris · Oct 30, 2026 · Mathlib 0df444a (Lean v4.33.1)

information-theoryp2o-gran-per-chapterp2o-plan-bookp2o-strengthenedp2o-v1source-coding

Let x1,…,xnx_1,\dots,x_nx1​,…,xn​ be messages and let k1,…,knk_1,\dots,k_nk1​,…,kn​ be integers satisfying the Kraft inequality

∑i=1n2−ki≤1.\sum_{i=1}^{n} 2^{-k_i} \le 1 .i=1∑n​2−ki​≤1.

Then there is a binary instantaneous (prefix-free) code for x1,…,xnx_1,\dots,x_nx1​,…,xn​ whose codeword for xix_ixi​ has length exactly kik_iki​, for every iii.

Together with the first statement of Lemma 2.3 (every instantaneous code satisfies the Kraft inequality), this characterizes the length profiles of instantaneous codes. It is what turns the lengths ⌈−log⁡p(xi)⌉\lceil -\log p(x_i)\rceil⌈−logp(xi​)⌉ of (2.141) into an actual code in the proof of the upper bound of Theorem 2.8.

Note that the inequality forces every ki≥0k_i \ge 0ki​≥0 (a single term with ki<0k_i < 0ki​<0 already exceeds 111), and ki=0k_i = 0ki​=0 is possible only for a single message, whose codeword is then empty.

Differences from the source:

  • generalization: integers listed in increasing order k1≤⋯≤knk_1 \le \dots \le k_nk1​≤⋯≤kn​ → any family of integers indexed by the messages, in no order; reason: the order is only a labelling, and every family can be relabelled increasingly, so the statement specializes to the source's.
  • encoding: messages {x1,…,xn}\{x_1,\dots,x_n\}{x1​,…,xn​} → an arbitrary finite type; reason: Lean convention, every finite type is a relabelling of {1,…,n}\{1,\dots,n\}{1,…,n}.
Preamble
import Mathlib
import Definitions.Def_FuchsThesis_Coding_IsInstantaneous
Formal statement
namespace FuchsThesis.Coding

/-- Fuchs, *Distinguishability and Accessible Information in Quantum Theory*,
arXiv:quant-ph/9601020v1, Lemma 2.3 (Kraft), second statement, p.37 (PDF p.46): "for any set of
integers `k₁ ≤ k₂ ≤ ⋯ ≤ kₙ` satisfying this inequality [`∑ 2^{−kᵢ} ≤ 1`, (2.134)], there exists a
instantaneous code with these as codeword lengths."

**Formalization Note.** The messages form an arbitrary finite type `ι` and the integers are a
family `k : ι → ℤ`; no ordering is imposed (the source's `k₁ ≤ ⋯ ≤ kₙ` is a labelling, and every
family can be relabelled in increasing order). The Kraft sum is taken in `ℝ` with integer powers
`2 ^ (−kᵢ)`. Negative integers are not excluded by hypothesis: a single term with `kᵢ < 0` already
exceeds `1`. A zero length is allowed (the empty codeword, possible only when `ι` has one
element). -/
theorem lemma_2_3_existence {ι : Type*} [Fintype ι] (k : ι → ℤ)
    (hK : ∑ i, (2 : ℝ) ^ (-(k i)) ≤ 1) :
    ∃ c : ι → List Bool, IsInstantaneous c ∧ ∀ i, ((c i).length : ℤ) = k i := by sorry

end FuchsThesis.Coding
Source
Fuchs, Distinguishability and Accessible Information in Quantum Theory, arXiv:quant-ph/9601020v1, Lemma 2.3 (Kraft), second statement, p.37 (PDF p.46); proof on p.39 (PDF p.48)
Human review
  • Endorsed by Shuze Chen · Oct 30, 2026

    Confirmed by the moderator at approval.

  • Endorsed by iris · Oct 30, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me