Cite

This course has no released version yet: the text at this address may change. Cite a released version when one exists.

/courses/kolmogorov-complexity/prefix-free-complexity
@misc{kolmogorov-complexity-prefix-free-complexity,
  title = {{Prefix-free complexity}},
  howpublished = {Lesson 3 of \emph{Kolmogorov complexity}, Computability Theory course notes},
  url = {/courses/kolmogorov-complexity/prefix-free-complexity},
  note = {Unreleased working version}
}

To cite a single statement, use the # link that appears next to its heading.

Lesson 3 of 4

Prefix-free complexity

Machines whose domain is prefix-free; the optimal prefix-free machine and the complexity K; subadditivity, the Kraft inequality, and the comparison between K and C.

40 min3 questions
Kolmogorov complexity · lesson 3 of 4
  1. Plain Kolmogorov complexity
  2. Complexity of initial segments
  3. Prefix-free complexity
  4. The KC theorem and the coding theorem

The defects of plain complexity, the logarithmic cost of pairs and the oscillation of initial segments, have a common cause: a description of length ℓ\ell conveys, besides its bits, the number ℓ\ell. Levin and Chaitin proposed to restrict descriptions to self-delimiting ones: a machine reads its input bit by bit and decides by itself when to stop reading, so that no description is a proper prefix of another. The resulting complexity KK exceeds CC by at most a logarithmic term, but it behaves well with respect to concatenation, and it gives a definition of random sequences.

3.1 Prefix-free machines

Definition 3.1.#

A set of strings WW is prefix-free if no element of WW is a proper prefix of another element of WW. A machine MM is prefix-free if its domain is prefix-free. For a prefix-free machine MM, we write KM(σ)=CM(σ)K_M(\sigma) = C_M(\sigma).

The sets {0n1:n∈N}\{ 0^n 1 : n \in \nat \} and {ρˉ 01:ρ∈2<N}\{ \bar\rho\, 01 : \rho \in \bstr \}, with ρˉ\bar\rho the string ρ\rho with each bit doubled, are prefix-free. A prefix-free set WW corresponds to pairwise disjoint cylinders [τ]={X∈2N:τ≺X}[\tau] = \{ X \in \cs : \tau \prec X \}, τ∈W\tau \in W. The weight of WW is ∑τ∈W2−∣τ∣\sum_{\tau \in W} 2^{-|\tau|}.

Proposition 3.2 (Kraft inequality).#

The weight of a prefix-free set of strings is at most 11.

Proof of Proposition 3.2.

It suffices to treat finite prefix-free sets WW. Let ℓ\ell be larger than the length of every element of WW. The sets {ρ∈{0,1}ℓ:τ⪯ρ}\{ \rho \in \{0,1\}^\ell : \tau \preceq \rho \}, for τ∈W\tau \in W, are pairwise disjoint, since a string ρ\rho extending two elements of WW would make them comparable; and the one indexed by τ\tau has 2ℓ−∣τ∣2^{\ell - |\tau|} elements. So ∑τ∈W2ℓ−∣τ∣≤2ℓ\sum_{\tau \in W} 2^{\ell - |\tau|} \leq 2^\ell.

Theorem 3.3.#

There is a prefix-free machine UU that is optimal among prefix-free machines: for every prefix-free machine MM, KU≤+KMK_U \leq^+ K_M.

Proof of Theorem 3.3.

We first transform every machine into a prefix-free one, without changing prefix-free machines. Given an index ee, let M^e\hat M_e be the machine that, on input σ\sigma, enumerates the domain of MeM_e in order of convergence, using a fixed dovetailing of the computations Me(τ)[s]M_e(\tau)[s], and keeps a list LL of the strings enumerated so far that have been accepted. A newly enumerated string is accepted if it is incomparable with every string already accepted. M^e(σ)\hat M_e(\sigma) converges, with value Me(σ)M_e(\sigma), if and only if σ\sigma is enumerated and accepted.

The set of accepted strings is prefix-free, by construction, and it is the domain of M^e\hat M_e; the acceptance of a string does not depend on the input σ\sigma, since the enumeration is the same for all inputs. If the domain of MeM_e is prefix-free, every enumerated string is accepted, and M^e=Me\hat M_e = M_e. An index of M^e\hat M_e is computable from ee.

Let U(0e1τ)=M^e(τ)U(0^e 1 \tau) = \hat M_e(\tau). The domain of UU is the union of the sets 0e1 dom(M^e)0^e 1\, \mathrm{dom}(\hat M_e), which are prefix-free and pairwise incomparable for different ee; so UU is prefix-free. If M=MeM = M_e is prefix-free, KU(σ)≤KM(σ)+e+1K_U(\sigma) \leq K_M(\sigma) + e + 1.

We fix such a machine UU and write K(σ)=KU(σ)K(\sigma) = K_U(\sigma), the prefix-free complexity of σ\sigma. As for CC, statements of the form f≤+gf \leq^+ g about KK do not depend on the choice of UU, and K(n)K(n) denotes the complexity of the string associated with nn. The proofs of Proposition 1.4 (2) and of Theorem 1.9 carry over: K(f(σ))≤+K(σ)K(f(\sigma)) \leq^+ K(\sigma) for partial computable ff, since the domain of the machine τ↦f(U(τ))\tau \mapsto f(U(\tau)) is contained in that of UU, hence prefix-free; KK is not computable; and KK is approximable from above, with the computable bound K(σ)≤2∣σ∣+dK(\sigma) \leq 2|\sigma| + d, given by the prefix-free machine ρˉ 01↦ρ\bar\rho\, 01 \mapsto \rho, in place of C(σ)≤∣σ∣+dC(\sigma) \leq |\sigma| + d.

3.2 Properties of K

Proposition 3.4.#
  1. K(⟨σ,τ⟩)≤+K(σ)+K(τ)K(\langle \sigma, \tau \rangle) \leq^+ K(\sigma) + K(\tau).
  2. K(σ)≤+∣σ∣+K(∣σ∣)K(\sigma) \leq^+ |\sigma| + K(|\sigma|), and K(σ)≤+∣σ∣+2log⁡∣σ∣K(\sigma) \leq^+ |\sigma| + 2 \log |\sigma| for ∣σ∣≥2|\sigma| \geq 2.
  3. C(σ)≤+K(σ)C(\sigma) \leq^+ K(\sigma), and K(σ)≤+C(σ)+K(C(σ))≤+C(σ)+2log⁡C(σ)K(\sigma) \leq^+ C(\sigma) + K(C(\sigma)) \leq^+ C(\sigma) + 2 \log C(\sigma), where log⁡0\log 0 is read as 00.
  4. ∑σ2−K(σ)≤1\sum_\sigma 2^{-K(\sigma)} \leq 1.
Proof of Proposition 3.4.
  1. Let MM be the machine that, on input α\alpha, searches for a decomposition α=α0α1\alpha = \alpha_0 \alpha_1 with α0,α1\alpha_0, \alpha_1 in the domain of UU, and outputs ⟨U(α0),U(α1)⟩\langle U(\alpha_0), U(\alpha_1) \rangle. The decomposition is unique when it exists, since the domain of UU is prefix-free; it is found by enumerating the domain of UU and testing the prefixes of α\alpha. The domain of MM is prefix-free: if α0α1\alpha_0\alpha_1 and α0′α1′\alpha_0'\alpha_1' are both in it and comparable, then α0\alpha_0 and α0′\alpha_0' are comparable elements of the domain of UU, hence equal, and then α1\alpha_1 and α1′\alpha_1' are comparable, hence equal. Concatenating shortest descriptions of σ\sigma and τ\tau gives KM(⟨σ,τ⟩)≤K(σ)+K(τ)K_M(\langle \sigma, \tau \rangle) \leq K(\sigma) + K(\tau).
  2. The machine that, on input α0α1\alpha_0 \alpha_1 with α0\alpha_0 in the domain of UU and ∣α1∣=U(α0)|\alpha_1| = U(\alpha_0), read as a number, outputs α1\alpha_1, is prefix-free, by the same argument as in 1. It gives the first inequality. For the second, K(n)≤+2log⁡nK(n) \leq^+ 2 \log n for n≥2n \geq 2: the prefix-free machine ρˉ 01↦ρ\bar\rho\, 01 \mapsto \rho describes the string ρ\rho associated with nn with 2∣ρ∣+22|\rho| + 2 bits.
  3. UU is a machine, so C≤+KU=KC \leq^+ K_U = K. For the second inequality, let MM be the machine that, on input α0α1\alpha_0 \alpha_1 with α0\alpha_0 in the domain of UU and ∣α1∣=U(α0)|\alpha_1| = U(\alpha_0), outputs V(α1)V(\alpha_1), where VV is the optimal plain machine defining CC. It is prefix-free, and a shortest UU-description of the number C(σ)C(\sigma) followed by a shortest VV-description of σ\sigma is an MM-description of σ\sigma. The last inequality follows from the bound K(n)≤+2log⁡nK(n) \leq^+ 2 \log n of 2, the finitely many strings with C(σ)≤1C(\sigma) \leq 1 being absorbed in the constant.
  4. The shortest UU-descriptions of distinct strings are distinct elements of the domain of UU, so the sum is at most the weight of the domain of UU, which is at most 11 by Proposition 3.2.

Property 4 is the essential difference with plain complexity: ∑σ2−C(σ)\sum_\sigma 2^{-C(\sigma)} diverges, since there are 2n2^n strings of length nn with C(σ)≤+nC(\sigma) \leq^+ n, so that the sum over each length is bounded from below by a positive constant. It implies that KK exceeds the length infinitely often.

Corollary 3.5.#

For every cc there is a string σ\sigma with K(σ)>∣σ∣+cK(\sigma) > |\sigma| + c. More precisely, for every nn there is a string of length nn with K(σ)≥n+K(n)−dK(\sigma) \geq n + K(n) - d, for a constant dd independent of nn.

Proof of Corollary 3.5.

For the first statement: if K(σ)≤∣σ∣+cK(\sigma) \leq |\sigma| + c for every σ\sigma, then ∑∣σ∣=n2−K(σ)≥2−c\sum_{|\sigma| = n} 2^{-K(\sigma)} \geq 2^{-c} for every nn, and the sum over all lengths diverges, contradicting Proposition 3.4 (4). The second statement is proved in the next lesson (Theorem 4.5).

By Proposition 3.4 (2) and the corollary, the maximal complexity of a string of length nn is n+K(n)+O(1)n + K(n) + O(1), and it exceeds nn by an unbounded amount, since K(n)K(n) is unbounded. The term K(n)K(n) is the cost of self-delimitation: a prefix-free description of σ\sigma must also determine where it ends, which requires information about ∣σ∣|\sigma|.

3.3 Prefix-free complexity of initial segments

The proof of Theorem 2.3 does not carry over to KK: the machine in its proof, α↦βα\alpha \mapsto \beta\alpha, is not prefix-free, since it accepts every string. In the next course, a sequence XX is called random when K(X ⁣↾n)≥n−cK(X \uh n) \geq n - c for some constant cc and every nn. That course proves that such sequences exist, and in fact that almost every sequence, in the sense of the uniform measure, is random; the next lesson gives an example, Chaitin’s number Ω\Omega. Computable sequences are far from random, since K(X ⁣↾n)≤+K(n)≤+2log⁡nK(X \uh n) \leq^+ K(n) \leq^+ 2 \log n.

Proposition 3.6.#

If XX is computable, then K(X ⁣↾n)=+K(n)K(X \uh n) =^+ K(n).

Proof of Proposition 3.6.

As for Proposition 2.1: n↦X ⁣↾nn \mapsto X \uh n and σ↦∣σ∣\sigma \mapsto |\sigma| are computable, and partial computable functions do not increase KK by more than a constant.

Unlike the case of CC, the converse fails: there are non-computable sequences with K(X ⁣↾n)≤+K(n)K(X \uh n) \leq^+ K(n), the K-trivial sequences, a central topic of the theory of algorithmic randomness.

3.4 Exercises

Exercise 3.7 ★.

Show that K(στ)≤+K(σ)+K(τ)K(\sigma\tau) \leq^+ K(\sigma) + K(\tau). Show that KK is not monotone up to a constant on numbers: there are pairs nj≤mjn_j \leq m_j with K(mj)−K(nj)K(m_j) - K(n_j) tending to −∞-\infty.

Solution

The first inequality follows from Proposition 3.4 (1), since ⟨σ,τ⟩↦στ\langle \sigma, \tau \rangle \mapsto \sigma\tau is computable. For the second, let njn_j be a number whose associated string σ\sigma has length jj and satisfies C(σ)≥jC(\sigma) \geq j, by Proposition 1.6; then K(σ)≥j−dK(\sigma) \geq j - d for a constant dd, by Proposition 3.4 (3). Such numbers lie between 2j−12^j - 1 and 2j+1−22^{j+1} - 2. Let mj=2j+1m_j = 2^{j+1}, computable from jj, so that K(mj)≤+K(j)≤+2log⁡jK(m_j) \leq^+ K(j) \leq^+ 2 \log j for j≥2j \geq 2. Then K(mj)−K(nj)≤2log⁡j−j+O(1)K(m_j) - K(n_j) \leq 2 \log j - j + O(1) tends to −∞-\infty.

Exercise 3.8 ★★.

Show that K(σ)≤+∣σ∣+log⁡∣σ∣+2log⁡log⁡∣σ∣K(\sigma) \leq^+ |\sigma| + \log |\sigma| + 2 \log \log |\sigma| for ∣σ∣≥4|\sigma| \geq 4, and more generally that every iteration of the bound K(n)≤+log⁡n+K(⌊log⁡n⌋)K(n) \leq^+ \log n + K(\lfloor \log n \rfloor) improves the upper bound on K(σ)K(\sigma).

Solution

By Proposition 3.4 (2) applied to the string associated with nn, of length ℓ=⌊log⁡(n+1)⌋\ell = \lfloor \log(n+1) \rfloor, K(n)≤+ℓ+K(ℓ)≤+log⁡n+K(ℓ)K(n) \leq^+ \ell + K(\ell) \leq^+ \log n + K(\ell). Applying (2) again to K(ℓ)K(\ell) with the bound 2log⁡2 \log gives K(n)≤+log⁡n+2log⁡log⁡nK(n) \leq^+ \log n + 2 \log \log n for n≥4n \geq 4. Then K(σ)≤+∣σ∣+K(∣σ∣)≤+∣σ∣+log⁡∣σ∣+2log⁡log⁡∣σ∣K(\sigma) \leq^+ |\sigma| + K(|\sigma|) \leq^+ |\sigma| + \log |\sigma| + 2 \log \log |\sigma|. Iterating, K(σ)≤+∣σ∣+log⁡∣σ∣+log⁡log⁡∣σ∣+⋯K(\sigma) \leq^+ |\sigma| + \log |\sigma| + \log \log |\sigma| + \cdots, each stage replacing a term 2log⁡(k)2 \log^{(k)} by log⁡(k)+2log⁡(k+1)\log^{(k)} + 2 \log^{(k+1)}.

3.5 Notes and references

Prefix-free complexity was introduced by Levin (1974) and Chaitin (1975), with a related notion due to Gács. The Kraft inequality is a classical result of information theory (1949). The definition of randomness through KK and its equivalence with Martin-Löf randomness are due to Levin, Schnorr and Chaitin, and are treated in the next course. K-trivial sequences were introduced by Chaitin and studied by Solovay, and later by Downey, Hirschfeldt, Nies and Stephan.

  • L. A. Levin, Laws of information conservation (nongrowth) and aspects of the foundation of probability theory, Problems of Information Transmission 10 (1974), 206–210.
  • G. J. Chaitin, A theory of program size formally identical to information theory, Journal of the ACM 22 (1975), 329–340.
  • L. G. Kraft, A device for quantizing, grouping, and coding amplitude modulated pulses, Master’s thesis, MIT, 1949.
  • R. G. Downey and D. R. Hirschfeldt, Algorithmic Randomness and Complexity, Springer, 2010.