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/plain-complexity
@misc{kolmogorov-complexity-plain-complexity,
  title = {{Plain Kolmogorov complexity}},
  howpublished = {Lesson 1 of \emph{Kolmogorov complexity}, Computability Theory course notes},
  url = {/courses/kolmogorov-complexity/plain-complexity},
  note = {Unreleased working version}
}

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

Lesson 1 of 4

Plain Kolmogorov complexity

The complexity of a string is the length of its shortest description by an optimal machine; the invariance theorem; incompressible strings; the complexity function is not computable but is approximable from above.

40 min4 questions
Before this lesson:Computably enumerable sets (Fundamentals of computability)
Kolmogorov complexity · lesson 1 of 4
  1. Plain Kolmogorov complexity
  2. Complexity of initial segments
  3. Prefix-free complexity
  4. The KC theorem and the coding theorem

The string 0000⋯00000\cdots0 of length one million can be described in a few words, while a typical string obtained by tossing a coin one million times seems to admit no description shorter than itself. Kolmogorov complexity makes this distinction precise: the complexity of a string is the length of its shortest description, where descriptions are inputs of an algorithm that reconstructs the string. The definition depends on the algorithm, but only up to an additive constant, provided that the algorithm is optimal. This lesson sets up the definition, proves that most strings are incompressible, and shows that the complexity function is not computable.

1.1 Conventions

We work with binary strings 2<N\bstr. Natural numbers are identified with strings through the length-lexicographic enumeration ε,0,1,00,01,10,11,000,…\varepsilon, 0, 1, 00, 01, 10, 11, 000, \dots: the number nn is the nn-th string in this list, counting from 00. The string associated with nn has length ⌊log⁡(n+1)⌋\lfloor \log(n + 1) \rfloor, where log⁡\log denotes the logarithm in base 22. The number of strings of length less than nn is 2n−12^n - 1.

We fix a computable bijection ⟨⋅,⋅⟩:2<N×2<N→2<N\langle \cdot, \cdot \rangle : \bstr \times \bstr \to \bstr for coding pairs. All partial computable functions between countable sets of finite objects are understood through these codings.

1.2 Description machines

Definition 1.1.#

A machine is a partial computable function M:2<N→2<NM : \bstr \to \bstr. If M(τ)=σM(\tau) = \sigma, the string τ\tau is an MM-description of σ\sigma. The complexity of σ\sigma relative to MM is

CM(σ)=min⁡{∣τ∣:M(τ)=σ},C_M(\sigma) = \min \{ |\tau| : M(\tau) = \sigma \},

with CM(σ)=∞C_M(\sigma) = \infty if σ\sigma has no MM-description.

For instance, the identity machine gives CM(σ)=∣σ∣C_M(\sigma) = |\sigma|, and the machine τ↦0n\tau \mapsto 0^{n}, where nn is the number coded by τ\tau, describes 0n0^n with about log⁡n\log n bits. A machine that compresses some strings well may compress others badly; the following notion selects the machines that are optimal up to a constant.

We write f≤+gf \leq^+ g if there is a constant cc such that f(x)≤g(x)+cf(x) \leq g(x) + c for every xx, and f=+gf =^+ g if f≤+gf \leq^+ g and g≤+fg \leq^+ f.

Definition 1.2.#

A machine UU is optimal, or universal, if for every machine MM there is a constant cMc_M with CU(σ)≤CM(σ)+cMC_U(\sigma) \leq C_M(\sigma) + c_M for every string σ\sigma, that is, CU≤+CMC_U \leq^+ C_M.

Theorem 1.3 (Invariance theorem; Solomonoff, Kolmogorov).#

There is an optimal machine. If UU and VV are optimal, then CU=+CVC_U =^+ C_V.

Proof of Theorem 1.3.

Let (Me)(M_e) be an enumeration of the machines, with Me(τ)=Φe(τ)M_e(\tau) = \Phi_e(\tau) through the identification of strings with numbers. Define U(0e1τ)=Me(τ)U(0^e 1 \tau) = M_e(\tau), and let UU be undefined on the strings of the form 0e0^e. Every string other than 0e0^e decomposes uniquely as 0e1τ0^e 1 \tau, so UU is well defined, and it is partial computable by the universality of the enumeration. If τ\tau is an MeM_e-description of σ\sigma, then 0e1τ0^e 1 \tau is a UU-description of σ\sigma of length ∣τ∣+e+1|\tau| + e + 1. So CU≤CMe+e+1C_U \leq C_{M_e} + e + 1.

If UU and VV are optimal, then CU≤+CVC_U \leq^+ C_V by optimality of UU applied to the machine VV, and symmetrically.

We fix an optimal machine UU once and for all, and write C(σ)=CU(σ)C(\sigma) = C_U(\sigma), the (plain) Kolmogorov complexity of σ\sigma. By the invariance theorem, the statements of the form f≤+gf \leq^+ g involving CC do not depend on this choice. For a number nn, C(n)C(n) is the complexity of the string associated with nn.

Proposition 1.4.#
  1. C(σ)≤+∣σ∣C(\sigma) \leq^+ |\sigma|.
  2. For every partial computable function f:2<N→2<Nf : \bstr \to \bstr, C(f(σ))≤+C(σ)C(f(\sigma)) \leq^+ C(\sigma) for every σ\sigma in the domain of ff.
  3. C(n)≤+log⁡nC(n) \leq^+ \log n for n≥1n \geq 1, and C(∣σ∣)≤+C(σ)C(|\sigma|) \leq^+ C(\sigma).
Proof of Proposition 1.4.
  1. Apply the optimality of UU to the identity machine.
  2. The machine M(τ)=f(U(τ))M(\tau) = f(U(\tau)) satisfies CM(f(σ))≤C(σ)C_M(f(\sigma)) \leq C(\sigma): a shortest UU-description of σ\sigma is an MM-description of f(σ)f(\sigma). Conclude by optimality.
  3. The first inequality is 1, since the string associated with nn has length ⌊log⁡(n+1)⌋≤log⁡n+1\lfloor \log(n+1) \rfloor \leq \log n + 1. The second is 2 with f(σ)=∣σ∣f(\sigma) = |\sigma|.

The second item says that an algorithm cannot create information: the complexity of the output of a computation is bounded by the complexity of its input, up to a constant depending only on the algorithm.

1.3 Incompressible strings

Definition 1.5.#

A string σ\sigma is cc-incompressible if C(σ)≥∣σ∣−cC(\sigma) \geq |\sigma| - c.

Proposition 1.6.#

For every nn and cc, fewer than 2n−c2^{n-c} strings σ\sigma satisfy C(σ)<n−cC(\sigma) < n - c. In particular, for every nn there is a string of length nn with C(σ)≥nC(\sigma) \geq n, and at least 2n−2n−c2^n - 2^{n-c} strings of length nn are cc-incompressible.

Proof of Proposition 1.6.

A string σ\sigma with C(σ)<n−cC(\sigma) < n - c has a description of length less than n−cn - c, and distinct strings have distinct descriptions, since UU is a function. There are 2n−c−12^{n-c} - 1 strings of length less than n−cn - c.

So at least half of the strings of each length are 11-incompressible, and the proportion of strings of length nn that can be compressed by more than cc bits, that is, with C(σ)<n−cC(\sigma) < n - c, is less than 2−c2^{-c}. Incompressibility is the first formal approximation of randomness for finite strings: a string with a regularity that an algorithm can exploit is compressible.

Example 1.7.#
  1. C(0n)=+C(n)≤+log⁡nC(0^n) =^+ C(n) \leq^+ \log n for n≥1n \geq 1: item 2 of Proposition 1.4, applied to the computable function n↦0nn \mapsto 0^n, gives C(0n)≤+C(n)C(0^n) \leq^+ C(n), and item 3 gives C(n)=C(∣0n∣)≤+C(0n)C(n) = C(|0^n|) \leq^+ C(0^n).
  2. If σ\sigma has length 2n2n and the bits of σ\sigma at odd positions are all 00, then C(σ)≤+nC(\sigma) \leq^+ n: a description is the string of the bits at even positions.
  3. Let σ\sigma be a string of length nn containing exactly kk ones. It is determined by nn, kk and its rank among the (nk)\binom{n}{k} strings of length nn with kk ones. When k≤n/4k \leq n/4, the number log⁡(nk)\log \binom{n}{k} is at most nh(1/4)<0.82 nn h(1/4) < 0.82\, n, where h(p)=−plog⁡p−(1−p)log⁡(1−p)h(p) = -p \log p - (1 - p) \log (1 - p) is the binary entropy function, and σ\sigma is compressible by a linear number of bits for large nn. For the bound, let p=k/np = k/n with 0<k≤n/40 < k \leq n/4: the term of index kk in the binomial expansion of (p+(1−p))n=1(p + (1 - p))^n = 1 gives (nk)pk(1−p)n−k≤1\binom{n}{k} p^k (1 - p)^{n - k} \leq 1, that is, log⁡(nk)≤nh(p)\log \binom{n}{k} \leq n h(p), and h(p)≤h(1/4)h(p) \leq h(1/4) since hh is increasing on [0,1/2][0, 1/2]. The triple is coded with a logarithmic overhead by the technique of Proposition 1.8 below.

1.4 Pairs

The complexity of a pair is not bounded by the sum of the complexities. A description of σ\sigma followed by a description of τ\tau does not tell where the first one ends. The length of the first description has to be coded as well.

Proposition 1.8.#

C(⟨σ,τ⟩)≤+C(σ)+C(τ)+2log⁡C(σ)C(\langle \sigma, \tau \rangle) \leq^+ C(\sigma) + C(\tau) + 2 \log C(\sigma), where log⁡0\log 0 is read as 00.

Proof of Proposition 1.8.

For a string ρ=ρ0⋯ρk−1\rho = \rho_0 \cdots \rho_{k-1}, let ρˉ=ρ0ρ0ρ1ρ1⋯ρk−1ρk−1\bar\rho = \rho_0 \rho_0 \rho_1 \rho_1 \cdots \rho_{k-1} \rho_{k-1}. A string of the form ρˉ 01 α\bar\rho\, 01\, \alpha determines ρ\rho and α\alpha: read pairs of bits until the first pair 0101. Let MM be the machine that, on an input of the form ρˉ 01 α\bar\rho\, 01\, \alpha, interprets ρ\rho as a number ℓ\ell, splits α=α0α1\alpha = \alpha_0 \alpha_1 with ∣α0∣=ℓ|\alpha_0| = \ell, and outputs ⟨U(α0),U(α1)⟩\langle U(\alpha_0), U(\alpha_1) \rangle. If α0\alpha_0 and α1\alpha_1 are shortest descriptions of σ\sigma and τ\tau, and ρ\rho is the string of the number ∣α0∣=C(σ)|\alpha_0| = C(\sigma), the input has length 2∣ρ∣+2+C(σ)+C(τ)2|\rho| + 2 + C(\sigma) + C(\tau), and ∣ρ∣≤log⁡C(σ)+1|\rho| \leq \log C(\sigma) + 1. Conclude by optimality of UU.

The logarithmic term cannot be replaced by a constant. Fix n≥1n \geq 1. There are (n+1)2n(n + 1) 2^n pairs (σ,τ)(\sigma, \tau) with ∣σ∣+∣τ∣=n|\sigma| + |\tau| = n, and their codes ⟨σ,τ⟩\langle \sigma, \tau \rangle are distinct. By the argument of Proposition 1.6, fewer than 2n+⌊log⁡n⌋≤n2n2^{n + \lfloor \log n \rfloor} \leq n 2^n strings have complexity less than n+⌊log⁡n⌋n + \lfloor \log n \rfloor, so one of these pairs satisfies C(⟨σ,τ⟩)≥n+⌊log⁡n⌋C(\langle \sigma, \tau \rangle) \geq n + \lfloor \log n \rfloor. With dd such that C(ρ)≤∣ρ∣+dC(\rho) \leq |\rho| + d for every ρ\rho, this pair also satisfies C(σ)+C(τ)≤n+2dC(\sigma) + C(\tau) \leq n + 2d, so the difference is at least ⌊log⁡n⌋−2d\lfloor \log n \rfloor - 2d, which is unbounded. This defect motivates the prefix-free complexity of a later lesson.

1.5 Non-computability

Theorem 1.9.#
  1. The function CC is not computable. More precisely, if g:2<N→Ng : \bstr \to \nat is a partial computable function such that g(σ)≤C(σ)g(\sigma) \leq C(\sigma) for every σ\sigma in its domain, then gg is bounded.
  2. The function CC is approximable from above: there is a computable function (s,σ)↦Cs(σ)(s, \sigma) \mapsto C_s(\sigma), non-increasing in ss, with lim⁡sCs(σ)=C(σ)\lim_s C_s(\sigma) = C(\sigma).
Proof of Theorem 1.9.
  1. Suppose that gg is unbounded on its domain. Let f(n)f(n) be the first string σ\sigma found, in an enumeration of the domain of gg, with g(σ)>ng(\sigma) > n. Then ff is total computable, and C(f(n))≥g(f(n))>nC(f(n)) \geq g(f(n)) > n. By Proposition 1.4, C(f(n))≤+C(n)≤+log⁡nC(f(n)) \leq^+ C(n) \leq^+ \log n. So n<log⁡n+cn < \log n + c for some constant cc and every n≥1n \geq 1, which fails for large nn. If CC were computable, it would be such a function gg, and it is unbounded by Proposition 1.6.
  2. Let dd be a constant with C(σ)≤∣σ∣+dC(\sigma) \leq |\sigma| + d for every σ\sigma. Let Cs(σ)C_s(\sigma) be the least length of a string τ\tau with ∣τ∣≤∣σ∣+d|\tau| \leq |\sigma| + d and U(τ)[s] ⁣ ⁣↓=σU(\tau)[s]\converge = \sigma, or ∣σ∣+d|\sigma| + d if there is none. It is computable, non-increasing in ss, and equal to C(σ)C(\sigma) from the stage at which a shortest description converges.

The proof formalizes the Berry paradox, “the least number that cannot be defined in fewer than twenty words”: the first string of complexity larger than nn has a description of length about log⁡n\log n. Statement 1 says more than non-computability: no algorithm certifies that strings have large complexity, except for finitely many values. This is a form of Gödel’s incompleteness theorem, due to Chaitin. Let TT be a theory with a c.e. set of axioms that proves only true statements of the form "C(σ)>nC(\sigma) > n". Searching through the proofs of TT enumerates the set SS of pairs (σ,n)(\sigma, n) such that TT proves "C(σ)>nC(\sigma) > n". If SS contained pairs with arbitrarily large second coordinate, the function f(m)f(m), the first σ\sigma found such that (σ,n)∈S(\sigma, n) \in S for some n>mn > m, would be total computable with C(f(m))>mC(f(m)) > m, and the argument of 1 would give a contradiction. So there is a number n0n_0 such that TT proves no statement "C(σ)>nC(\sigma) > n" with n≥n0n \geq n_0, although all but finitely many strings satisfy C(σ)>n0C(\sigma) > n_0.

The approximation from above makes CC computable in ∅′\emptyset': C(σ)C(\sigma) is the value of Cs(σ)C_s(\sigma) at the first stage ss such that no description shorter than Cs(σ)C_s(\sigma) ever converges, and whether a given ss has this property is the negation of a c.e. condition, which ∅′\emptyset' decides. Conversely, CC computes ∅′\emptyset': this is the second exercise below, after a first exercise that proves the same for the domain of UU.

1.6 Exercises

Exercise 1.10 ★.

Let XX be the set of strings σ\sigma such that U(σ)U(\sigma) converges. Show that ∅′≤TX\emptyset' \leq_T X.

Solution

Let MM be the machine with M(0e)=0sM(0^e) = 0^s, where ss is the least stage with Φe(e)[s] ⁣ ⁣↓\Phi_e(e)[s]\converge, and MM undefined elsewhere. Let dd be such that C≤CM+dC \leq C_M + d. If Φe(e)\Phi_e(e) converges at stage ss, then C(0s)≤e+dC(0^s) \leq e + d. With oracle XX, list the strings τ\tau of length at most e+de + d such that U(τ)U(\tau) converges, compute their outputs, and let tt be the largest number such that 0t0^t is one of them (t=0t = 0 if there is none). Then Φe(e)\Phi_e(e) converges if and only if Φe(e)[t] ⁣ ⁣↓\Phi_e(e)[t]\converge.

Exercise 1.11 ★★.

Show that ∅′≤TC\emptyset' \leq_T C, where CC is used as an oracle through its graph.

Hint

Adapt the previous solution: when Φe(e)\Phi_e(e) converges at stage ss, describe with about ee bits a string of length 2e2e that has no short description converging by stage ss.

Solution

Let MM be the machine defined on the strings 0e0^e as follows: search for the least ss with Φe(e)[s] ⁣ ⁣↓\Phi_e(e)[s]\converge, and output the first string σ\sigma of length 2e2e, in the lexicographic order, such that U(τ)[s] ⁣ ⁣↓=σU(\tau)[s] \converge = \sigma for no τ\tau of length less than 2e2e. Such a string exists, since fewer than 22e2^{2e} strings are outputs of strings of length less than 2e2e. Let dd be such that C≤CM+dC \leq C_M + d, and let e>de > d.

With oracle CC, compute the finite set SS of strings σ\sigma of length 2e2e with C(σ)<2eC(\sigma) < 2e, and then a stage tt such that every σ∈S\sigma \in S satisfies U(τ)[t] ⁣ ⁣↓=σU(\tau)[t]\converge = \sigma for some τ\tau of length less than 2e2e; the search for tt terminates, since every element of SS has such a description. If Φe(e)\Phi_e(e) converges at stage ss, the string σ=M(0e)\sigma = M(0^e) satisfies C(σ)≤e+d<2eC(\sigma) \leq e + d < 2e, so σ∈S\sigma \in S, and no description of σ\sigma of length less than 2e2e converges by stage ss; hence s<ts < t. So Φe(e) ⁣ ⁣↓\Phi_e(e)\converge if and only if Φe(e)[t] ⁣ ⁣↓\Phi_e(e)[t]\converge. The finitely many e≤de \leq d are handled by a finite table.

Exercise 1.12 ★.

Fix cc. Show that the set Rc={σ:C(σ)≥∣σ∣−c}R_c = \{ \sigma : C(\sigma) \geq |\sigma| - c \} of cc-incompressible strings is immune: it is infinite and has no infinite c.e. subset.

Solution

RcR_c contains a string of each length by Proposition 1.6, so it is infinite. If W⊆RcW \subseteq R_c were an infinite c.e. set, the partial computable function g(σ)=max⁡(∣σ∣−c,0)g(\sigma) = \max(|\sigma| - c, 0) with domain WW would satisfy g≤Cg \leq C on its domain, and it would be unbounded, since WW contains strings of arbitrary length. This contradicts Theorem 1.9.

1.7 Notes and references

Solomonoff (1960–1964), Kolmogorov (1965) and Chaitin (1966) introduced the complexity of strings independently, with different motivations: inductive inference, the definition of information and randomness, and the length of programs. Chaitin’s form of the incompleteness theorem dates from 1974. Kummer (1996) proved that the set of compressible strings {σ:C(σ)<∣σ∣}\{ \sigma : C(\sigma) < |\sigma| \} is truth-table complete, a stronger form of the second exercise. Li and Vitányi’s book is the standard reference on Kolmogorov complexity.

  • A. N. Kolmogorov, Three approaches to the quantitative definition of information, Problems of Information Transmission 1 (1965), 1–7.
  • R. J. Solomonoff, A formal theory of inductive inference I, Information and Control 7 (1964), 1–22.
  • G. J. Chaitin, Information-theoretic limitations of formal systems, Journal of the ACM 21 (1974), 403–424.
  • M. Kummer, On the complexity of random strings, STACS 96, Lecture Notes in Computer Science 1046, Springer, 1996, 25–36.
  • M. Li and P. Vitányi, An Introduction to Kolmogorov Complexity and Its Applications, 4th edition, Springer, 2019.