Documentation

CslibFrontier.Computability.Kolmogorov.KraftChaitin

Kraft's inequality and the online Kraft–Chaitin theorem #

This file develops the quantitative side of binary prefix-free codes for Kolmogorov complexity:

Main definitions #

Main results #

References #

Prefix-disjointness and Kraft's inequality #

Two binary words are prefix-disjoint when neither is a prefix of the other.

If u is prefix-disjoint with y and x extends u, then x is prefix-disjoint with y.

Adding a prefix q incomparable with every member of S strictly reserves weight 2⁻¹ ^ |q|.

theorem Cslib.Kolmogorov.DescriptionMethod.finsetSum_add_two_inv_pow_le_tsum_of_notMem {S : Set (List Bool)} (hS : InformationTheory.IsPrefixFree S) {T : Finset (List Bool)} (hT : ↑T ⊆ S) {p : List Bool} (hp : p ∈ S) (hpT : p ∉ T) :
∑ w ∈ T, 2⁻¹ ^ w.length + 2⁻¹ ^ p.length ≤ ∑' (w : ↑S), 2⁻¹ ^ (↑w).length

Any finite prefix subset T ⊆ S plus any outside element p ∈ S \ T has total weight at most the full Kraft sum over S.

Kraft's inequality for a finite set of halting programs of a prefix-free method.

Summability of 2⁻¹ ^ |p| over the halting domain of a prefix-free description method.

Kraft's inequality for the halting domain of a prefix-free description method.

Executable online binary Kraft–Chaitin allocator #

Dyadic weight 2⁻¹ ^ |w| in ℚ.

Total dyadic weight of a list of words in ℚ.

@[simp]
theorem Cslib.Kolmogorov.listWeight_append (L₁ L₂ : List (List Bool)) :
listWeight (L₁ ++ L₂) = listWeight L₁ + listWeight L₂

Splits an available prefix u down by d bits, returning (codeword, leftoverBlocks) where codeword = u ++ 0^d has length |u| + d and leftoverBlocks contains one fresh block of each length |u| + 1, ..., |u| + d.

Finds the largest length at most ℓ among the available blocks, if any exists.

Splits the first block in avail of length b down to length ℓ.

One online step of the Kraft–Chaitin allocator.

One online step of the Kraft–Chaitin allocator is primitive recursive.

Executable finite Kraft–Chaitin allocator taking a list of target lengths.

Allocates prefix-free codewords of the specified lengths whenever the Kraft sum is at most 1.

theorem Cslib.Kolmogorov.kcAllocList_eq_some_of_sum_le_one {reqs : List ℕ} (hsum : (List.map (fun (ℓ : ℕ) => 2⁻¹ ^ ℓ) reqs).sum ≤ 1) :
∃ (codes : List (List Bool)), kcAllocList reqs = some codes ∧ List.map List.length codes = reqs ∧ List.Pairwise PrefixDisjoint codes

Finite executable Kraft–Chaitin correctness: any list of lengths reqs with dyadic Kraft sum at most 1 is realized by a pairwise prefix-disjoint list of codewords of exact lengths reqs.

Online Kraft–Chaitin trace on request stream reqs : ℕ → Option ℕ.

The codeword assigned at step n by the online Kraft–Chaitin trace.

theorem Cslib.Kolmogorov.exists_kcCode_eq_some_of_sum_le_one {reqs : ℕ → Option ℕ} (hbound : ∀ (n : ℕ), (∑ i ∈ Finset.range n, match reqs i with | none => 0 | some ℓ => 2⁻¹ ^ ℓ) ≤ 1) {i ℓ : ℕ} (hi : reqs i = some ℓ) :
∃ (w : List Bool), kcCode reqs i = some w ∧ w.length = ℓ

Every request reqs i = some ℓ in a stream with partial dyadic Kraft sums at most 1 is allocated a codeword kcCode reqs i = some w of exact length ℓ.

theorem Cslib.Kolmogorov.kcCode_prefixDisjoint_of_ne {reqs : ℕ → Option ℕ} (hbound : ∀ (n : ℕ), (∑ i ∈ Finset.range n, match reqs i with | none => 0 | some ℓ => 2⁻¹ ^ ℓ) ≤ 1) {i j : ℕ} (hne : i ≠ j) {p q : List Bool} (hi : kcCode reqs i = some p) (hj : kcCode reqs j = some q) :

Distinct steps of kcCode produce prefix-disjoint codewords whenever partial dyadic Kraft sums stay at most 1.

def Cslib.Kolmogorov.DescriptionMethod.kcStreamEval {α : Type u_1} (req : ℕ → Option (ℕ × α)) (p : List Bool) :
ℕ → Option α

Bounded-step evaluator searching the online Kraft–Chaitin code stream req for program p.

theorem Cslib.Kolmogorov.DescriptionMethod.kcStreamEval_mono {α : Type u_1} (req : ℕ → Option (ℕ × α)) (p : List Bool) {m n : ℕ} {x : α} :
m ≤ n → kcStreamEval req p m = some x → kcStreamEval req p n = some x
theorem Cslib.Kolmogorov.DescriptionMethod.mem_kcStreamEval_iff {α : Type u_1} (req : ℕ → Option (ℕ × α)) (hbound : ∀ (n : ℕ), (∑ i ∈ Finset.range n, match Option.map Prod.fst (req i) with | none => 0 | some ℓ => 2⁻¹ ^ ℓ) ≤ 1) (p : List Bool) {t : ℕ} {x : α} :
kcStreamEval req p t = some x ↔ ∃ i < t, kcCode (fun (j : ℕ) => Option.map Prod.fst (req j)) i = some p ∧ Option.map Prod.snd (req i) = some x
theorem Cslib.Kolmogorov.DescriptionMethod.computable_kcStreamEval {α : Type u_1} {β : Type u_2} [Primcodable α] [Primcodable β] {req : β → ℕ → Option (ℕ × α)} (hreq : Computable₂ req) :
Computable₂ fun (bp : β × List Bool) (t : ℕ) => kcStreamEval (req bp.1) bp.2 t

Joint computability of kcStreamEval across any uniformly computable family of request streams req : β → ℕ → Option (ℕ × α).

theorem Cslib.Kolmogorov.DescriptionMethod.isPrefixFree_rfindOpt_kcStreamEval {α : Type u_1} (req : ℕ → Option (ℕ × α)) (hbound : ∀ (n : ℕ), (∑ i ∈ Finset.range n, match Option.map Prod.fst (req i) with | none => 0 | some ℓ => 2⁻¹ ^ ℓ) ≤ 1) :

Prefix-freeness of the halting domain of Nat.rfindOpt (kcStreamEval req ·) whenever partial dyadic Kraft sums stay at most 1.

theorem Cslib.Kolmogorov.DescriptionMethod.kraftChaitin_of_sum_le_one {α : Type u_1} [Primcodable α] {req : ℕ → Option (ℕ × α)} (hreq : Computable req) (hbound : ∀ (n : ℕ), (∑ i ∈ Finset.range n, match req i with | none => 0 | some (ℓ, snd) => 2⁻¹ ^ ℓ) ≤ 1) :
∃ (M : DescriptionMethod α), M.IsPrefixFree ∧ (∃ (eval : List Bool →. α), Partrec eval ∧ ∀ (p : List Bool) (x : α), M.Produces p x ↔ x ∈ eval p) ∧ ∀ (i ℓ : ℕ) (y : α), req i = some (ℓ, y) → ∃ (p : List Bool), p.length = ℓ ∧ M.Produces p y

Kraft–Chaitin theorem (finite-partial-sum form) [LiVitanyi2019, ShenUspenskyVereshchagin2017]: every computable sequence of requests (ℓ_i, y_i) whose partial Kraft sums stay at most 1 is realized by a prefix-free partial recursive DescriptionMethod α.

theorem Cslib.Kolmogorov.DescriptionMethod.kraftChaitin {α : Type u_1} [Primcodable α] {req : ℕ → Option (ℕ × α)} (hreq : Computable req) (hsummable : Summable fun (i : ℕ) => match req i with | none => 0 | some (ℓ, snd) => 2⁻¹ ^ ℓ) (hbound : (∑' (i : ℕ), match req i with | none => 0 | some (ℓ, snd) => 2⁻¹ ^ ℓ) ≤ 1) :
∃ (M : DescriptionMethod α), M.IsPrefixFree ∧ (∃ (eval : List Bool →. α), Partrec eval ∧ ∀ (p : List Bool) (x : α), M.Produces p x ↔ x ∈ eval p) ∧ ∀ (i ℓ : ℕ) (y : α), req i = some (ℓ, y) → ∃ (p : List Bool), p.length = ℓ ∧ M.Produces p y

Kraft–Chaitin theorem (tsum form) [LiVitanyi2019, ShenUspenskyVereshchagin2017]: every computable sequence of requests (ℓ_i, y_i) whose Kraft sum ∑' i, 2⁻¹ ^ ℓ_i is summable and at most 1 is realized by a prefix-free partial recursive DescriptionMethod α.

theorem Cslib.Kolmogorov.DescriptionMethod.MinorizesPrefixPartrec.kraftChaitin_of_sum_le_one {α : Type u_1} [Primcodable α] {U : DescriptionMethod α} (hU : U.MinorizesPrefixPartrec) {req : ℕ → Option (ℕ × α)} (hreq : Computable req) (hbound : ∀ (n : ℕ), (∑ i ∈ Finset.range n, match req i with | none => 0 | some (ℓ, snd) => 2⁻¹ ^ ℓ) ≤ 1) :
∃ (c : ℕ), ∀ (i ℓ : ℕ) (y : α), req i = some (ℓ, y) → U.ecomplexity y ≤ ↑ℓ + ↑c

Prefix-free minorization form of the Kraft–Chaitin theorem (finite partial sums): any computable request stream (ℓ_i, y_i) with partial Kraft sums at most 1 gives K_U(y_i) ≤ ℓ_i + c for a uniform constant c.

theorem Cslib.Kolmogorov.DescriptionMethod.MinorizesPrefixPartrec.kraftChaitin {α : Type u_1} [Primcodable α] {U : DescriptionMethod α} (hU : U.MinorizesPrefixPartrec) {req : ℕ → Option (ℕ × α)} (hreq : Computable req) (hsummable : Summable fun (i : ℕ) => match req i with | none => 0 | some (ℓ, snd) => 2⁻¹ ^ ℓ) (hbound : (∑' (i : ℕ), match req i with | none => 0 | some (ℓ, snd) => 2⁻¹ ^ ℓ) ≤ 1) :
∃ (c : ℕ), ∀ (i ℓ : ℕ) (y : α), req i = some (ℓ, y) → U.ecomplexity y ≤ ↑ℓ + ↑c

Prefix-free minorization form of the Kraft–Chaitin theorem (tsum form).