Cite

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

/courses/martin-lof-randomness/martin-lof-tests
@misc{martin-lof-randomness-martin-lof-tests,
  title = {{Martin-Löf tests}},
  howpublished = {Lesson 2 of \emph{Martin-Löf randomness}, Computability Theory course notes},
  url = {/courses/martin-lof-randomness/martin-lof-tests},
  note = {Unreleased working version}
}

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

Lesson 2 of 4

Martin-Löf tests

Martin-Löf tests and Martin-Löf random sequences; a universal test; random sequences form a conull Σ⁰₂ class, with low and computably dominated members; random sequences satisfy the law of large numbers; Solovay tests define the same notion.

40 min4 questions
Before this lesson:Measure on Cantor space · Basis theorems (Π⁰₁ classes)
Martin-Löf randomness · lesson 2 of 4
  1. Measure on Cantor space
  2. Martin-Löf tests
  3. The Levin–Schnorr theorem
  4. Randomness and Turing degrees

A sequence is random if it has no property that can be detected effectively and that only a null class of sequences shares. Martin-Löf (1966) made this precise by requiring the null class to be covered by open classes of measure at most 2−n2^{-n}, enumerated uniformly in nn. The rate 2−n2^{-n} allows all such tests to be combined into a single one, which is the main technical feature of the definition. This lesson introduces the tests, proves the existence of a universal test, shows that random sequences satisfy the law of large numbers, and gives an equivalent definition due to Solovay.

2.1 Tests

A sequence of classes (Un)n∈N(\mathcal U_n)_{n \in \nat} is uniformly Σ10\Sigma^0_1 if there is a c.e. set W⊆N×2<NW \subseteq \nat \times \bstr such that Un=[W[n]]≺\mathcal U_n = [W^{[n]}]^{\prec} for every nn, where W[n]={σ:(n,σ)∈W}W^{[n]} = \{ \sigma : (n, \sigma) \in W \}. An index of WW is an index of the sequence.

Definition 2.1 (Martin-Löf).#

A Martin-Löf test is a uniformly Σ10\Sigma^0_1 sequence (Un)(\mathcal U_n) with λ(Un)≤2−n\lambda(\mathcal U_n) \leq 2^{-n} for every nn. A sequence XX is captured by the test if X∈⋂nUnX \in \bigcap_n \mathcal U_n, and passes it otherwise. A sequence is Martin-Löf random if it passes every Martin-Löf test.

The class ⋂nUn\bigcap_n \mathcal U_n captured by a test is a null Π20\Pi^0_2 class, since its measure is at most 2−n2^{-n} for every nn. One may assume the test decreasing: the classes U0∩⋯∩Un\mathcal U_0 \cap \cdots \cap \mathcal U_n are uniformly Σ10\Sigma^0_1, decrease, satisfy the same bound, and have the same intersection. We write MLR for the class of Martin-Löf random sequences.

Example 2.2.#
  1. A computable sequence XX is not random: Un=[X ⁣↾n]\mathcal U_n = [X \uh n] is a Martin-Löf test capturing XX.
  2. The covers of Example 1.5 are Martin-Löf tests. So a random sequence XX has X(2i)≠X(2i+1)X(2i) \neq X(2i+1) for some ii, and for every computable infinite set AA, X(a)=1X(a) = 1 for some a∈Aa \in A, hence for infinitely many, applying this to the tails of AA.

The bound 2−n2^{-n} can be replaced by any computable bound tending to 00.

Lemma 2.3.#

Let (Vm)(\mathcal V_m) be uniformly Σ10\Sigma^0_1, and let (qm)(q_m) be a computable sequence of rationals with λ(Vm)≤qm\lambda(\mathcal V_m) \leq q_m and lim⁡mqm=0\lim_m q_m = 0. Then no Martin-Löf random sequence belongs to ⋂mVm\bigcap_m \mathcal V_m.

Proof of Lemma 2.3.

For each nn, let mnm_n be the least mm with qm≤2−nq_m \leq 2^{-n}; it exists since qmq_m tends to 00, and is computable from nn. The sequence Un=Vmn\mathcal U_n = \mathcal V_{m_n} is uniformly Σ10\Sigma^0_1, with λ(Un)≤2−n\lambda(\mathcal U_n) \leq 2^{-n}, and ⋂mVm⊆⋂nUn\bigcap_m \mathcal V_m \subseteq \bigcap_n \mathcal U_n.

2.2 A universal test

Theorem 2.4 (Martin-Löf).#

There is a Martin-Löf test (Un)(\mathcal U_n) such that ⋂nUn\bigcap_n \mathcal U_n contains every class captured by a Martin-Löf test. So a sequence is Martin-Löf random if and only if it passes (Un)(\mathcal U_n).

Proof of Theorem 2.4.

Let (We)(W_e) be the standard enumeration of the c.e. subsets of N×2<N\nat \times \bstr. Every Martin-Löf test is of the form ([We[n]]≺)n([W_e^{[n]}]^{\prec})_n for some ee, but most indices ee do not define tests. We transform each WeW_e into a test, without changing those that already are.

Fix ee and nn, and let σ0,σ1,…\sigma_0, \sigma_1, \dots be the elements of We[n]W_e^{[n]} in the order of their enumeration (the list may be finite). Define finite sets F0=∅F_0 = \emptyset, and Fi+1=Fi∪{σi}F_{i+1} = F_i \cup \{ \sigma_i \} if λ([Fi∪{σi}]≺)≤2−n\lambda([F_i \cup \{ \sigma_i \}]^{\prec}) \leq 2^{-n}, and Fi+1=FiF_{i+1} = F_i otherwise. The measure of the open class generated by a finite set of strings is a rational computable from the set, so the sets FiF_i are computable from ee, nn and ii. Let Vne=⋃i[Fi]≺\mathcal V^e_n = \bigcup_i [F_i]^{\prec}. Then:

  • (Vne)n(\mathcal V^e_n)_n is uniformly Σ10\Sigma^0_1, uniformly in ee;
  • λ(Vne)≤2−n\lambda(\mathcal V^e_n) \leq 2^{-n}, as the supremum of the measures of the increasing classes [Fi]≺[F_i]^{\prec}, each at most 2−n2^{-n};
  • if λ([We[n]]≺)≤2−n\lambda([W_e^{[n]}]^{\prec}) \leq 2^{-n}, then every σi\sigma_i is accepted, since [Fi∪{σi}]≺⊆[We[n]]≺[F_i \cup \{ \sigma_i \}]^{\prec} \subseteq [W_e^{[n]}]^{\prec}; so Vne=[We[n]]≺\mathcal V^e_n = [W_e^{[n]}]^{\prec}.

So (Vne)n(\mathcal V^e_n)_n is a Martin-Löf test for every ee, and every Martin-Löf test is one of them. Let

Un=⋃eVn+e+1e.\mathcal U_n = \bigcup_e \mathcal V^e_{n + e + 1}.

It is uniformly Σ10\Sigma^0_1, and λ(Un)≤∑e2−n−e−1=2−n\lambda(\mathcal U_n) \leq \sum_e 2^{-n-e-1} = 2^{-n}. If XX is captured by the test (Vme)m(\mathcal V^e_m)_m, then X∈Vn+e+1e⊆UnX \in \mathcal V^e_{n+e+1} \subseteq \mathcal U_n for every nn.

2.3 Consequences

Corollary 2.5.#

Let (Un)(\mathcal U_n) be a universal Martin-Löf test.

  1. The class MLR is conull.
  2. For every nn, the complement Pn=2N∖Un\mathcal P_n = \cs \setminus \mathcal U_n is a Π10\Pi^0_1 class of measure at least 1−2−n1 - 2^{-n} consisting of random sequences. So MLR =⋃nPn= \bigcup_n \mathcal P_n is a Σ20\Sigma^0_2 class.
  3. There is a low Martin-Löf random sequence, and a computably dominated one.
Proof of Corollary 2.5.
  1. The complement of MLR is ⋂nUn\bigcap_n \mathcal U_n, which is null.
  2. The complement of a Σ10\Sigma^0_1 class is a Π10\Pi^0_1 class (Proposition 1.7 of “Trees and Π⁰₁ classes”). A sequence outside Un\mathcal U_n is outside ⋂mUm\bigcap_m \mathcal U_m, hence random by universality. A sequence is random if and only if it is outside ⋂nUn\bigcap_n \mathcal U_n, that is, in some Pn\mathcal P_n.
  3. P1\mathcal P_1 is a non-empty Π10\Pi^0_1 class, since its measure is at least 1/21/2. Apply the low basis theorem (Low basis theorem) and the computably dominated basis theorem (Computably dominated basis theorem).

The two random sequences of (3) are very different. A computably dominated sequence that is not computable is not Δ20\Delta^0_2 (Definition 3.3 of “Basis theorems”), whereas a low sequence is Δ20\Delta^0_2. The next lesson shows that Chaitin’s Ω\Omega is random, giving a random sequence of the degree of ∅′\emptyset'.

2.4 The law of large numbers

A random sequence should contain asymptotically as many zeros as ones. This is the law of large numbers, and it follows from a bound on the number of strings with a deviating frequency of ones.

Fact 2.6 (Hoeffding’s inequality).#

For every ε>0\varepsilon > 0 and m≥1m \geq 1, the number of strings σ\sigma of length mm with

∣∣{i<m:σ(i)=1}∣m−12∣>ε\left| \frac{|\{ i < m : \sigma(i) = 1 \}|}{m} - \frac{1}{2} \right| > \varepsilon

is at most 2m+1e−2mε22^{m+1} e^{-2 m \varepsilon^2}.

This is a classical estimate of probability theory, admitted here: it is the case of fair coin tosses of the inequality of Hoeffding (1963), and also follows from the Chernoff bound. A weaker bound, sufficient for the argument below, can be obtained from Markov’s inequality applied to the fourth moment of the number of ones.

Proposition 2.7.#

If XX is Martin-Löf random, then lim⁡m1m∣{i<m:X(i)=1}∣=12\lim_{m} \frac{1}{m} |\{ i < m : X(i) = 1 \}| = \frac{1}{2}.

Proof of Proposition 2.7.

Fix a rational ε>0\varepsilon > 0, let CmC_m be the computable set of strings of length mm described in Fact 2.6, and let Vn=⋃m>n[Cm]≺\mathcal V_n = \bigcup_{m > n} [C_m]^{\prec}, a uniformly Σ10\Sigma^0_1 sequence. Let a=e−2ε2<1a = e^{-2\varepsilon^2} < 1. By subadditivity,

λ(Vn)≤∑m>n2−m⋅2m+1am=2an+11−a.\lambda(\mathcal V_n) \leq \sum_{m > n} 2^{-m} \cdot 2^{m+1} a^m = \frac{2 a^{n+1}}{1 - a}.

One computes rationals qnq_n with 2an+1/(1−a)≤qn≤2an+1/(1−a)+2−n2a^{n+1} / (1 - a) \leq q_n \leq 2a^{n+1} / (1-a) + 2^{-n}; they tend to 00. If the frequency of ones in X ⁣↾mX \uh m differs from 12\frac12 by more than ε\varepsilon for infinitely many mm, then X∈VnX \in \mathcal V_n for every nn, and XX is not random by Lemma 2.3. A random XX therefore has frequencies eventually within ε\varepsilon of 12\frac12, for every rational ε>0\varepsilon > 0.

The same argument, with Hoeffding’s inequality for the independent events “the ii-th block is τ\tau”, each of probability 2−k2^{-k}, applies to blocks: for a random XX and a string τ\tau of length kk, the frequency of the occurrences of τ\tau among the blocks X(ik)⋯X(ik+k−1)X(ik) \cdots X(ik + k - 1) tends to 2−k2^{-k}. Since the tails of a random sequence are random (second exercise below), the same holds for the blocks starting at the positions ik+rik + r, for each r<kr < k; so τ\tau occurs at a position i<mi < m with frequency tending to 2−k2^{-k}. Random sequences are therefore normal in base 22 in the sense of Borel.

2.5 Solovay tests

The rate 2−n2^{-n} in the definition of tests is convenient for building a universal test, but proving that a given sequence is not random is often easier with a summability condition.

Definition 2.8 (Solovay).#

A Solovay test is a uniformly Σ10\Sigma^0_1 sequence (Sn)(\mathcal S_n) with ∑nλ(Sn)<∞\sum_n \lambda(\mathcal S_n) < \infty. A sequence XX is captured by the test if X∈SnX \in \mathcal S_n for infinitely many nn.

By the Borel–Cantelli lemma, the class captured by a Solovay test is null. A Martin-Löf test is a Solovay test, with ∑n2−n=2\sum_n 2^{-n} = 2, and a sequence in all its components is in infinitely many. The converse requires an argument.

Theorem 2.9 (Solovay).#

A sequence is Martin-Löf random if and only if it is not captured by any Solovay test.

Proof of Theorem 2.9.

(⇐\Leftarrow) A Martin-Löf test is a Solovay test, and a sequence captured by it as a Martin-Löf test is captured by it as a Solovay test.

(⇒\Rightarrow) Let (Sn)(\mathcal S_n) be a Solovay test, and let dd be such that ∑nλ(Sn)≤2d\sum_n \lambda(\mathcal S_n) \leq 2^d. Let Vk\mathcal V_k be the class of sequences that belong to Sn\mathcal S_n for at least 2k2^k values of nn. A sequence captured by the Solovay test belongs to every Vk\mathcal V_k. We show that (Vk+d)k(\mathcal V_{k + d})_k is a Martin-Löf test.

Fix an enumeration of the c.e. set defining (Sn)(\mathcal S_n). For a stage ss, let Sn,s\mathcal S_{n,s} be the clopen class generated by the strings enumerated into the nn-th component by stage ss, for n≤sn \leq s, and Sn,s=∅\mathcal S_{n,s} = \emptyset for n>sn > s. Delaying the enumeration of each string σ\sigma to a stage at least ∣σ∣|\sigma| does not change the classes Sn\mathcal S_n; so we may assume that the strings enumerated by stage ss have length at most ss. Each Sn,s\mathcal S_{n,s} is then a union of cylinders [τ][\tau] with ∣τ∣=s|\tau| = s. Let DsD_s be the set of strings τ\tau of length ss such that [τ]⊆Sn,s[\tau] \subseteq \mathcal S_{n,s} for at least 2k2^k values of nn; it is computable from ss and kk. Counting pairs (τ,n)(\tau, n) with ∣τ∣=s|\tau| = s and [τ]⊆Sn,s[\tau] \subseteq \mathcal S_{n,s} in two ways gives

2k ∣Ds∣≤∑∣τ∣=s∣{n:[τ]⊆Sn,s}∣=∑n≤s2sλ(Sn,s)≤2s⋅2d,2^k\, |D_s| \leq \sum_{|\tau| = s} |\{ n : [\tau] \subseteq \mathcal S_{n,s} \}| = \sum_{n \leq s} 2^s \lambda(\mathcal S_{n,s}) \leq 2^s \cdot 2^d,

so λ([Ds]≺)≤2d−k\lambda([D_s]^{\prec}) \leq 2^{d - k}. The classes [Ds]≺[D_s]^{\prec} increase with ss, since the classes Sn,s\mathcal S_{n,s} do. If XX belongs to 2k2^k classes Sn\mathcal S_n, all these memberships are witnessed at some stage ss, and then X ⁣↾s∈DsX \uh s \in D_s. So Vk=⋃s[Ds]≺\mathcal V_k = \bigcup_s [D_s]^{\prec}: it is uniformly Σ10\Sigma^0_1, and λ(Vk)≤2d−k\lambda(\mathcal V_k) \leq 2^{d-k} by continuity. Hence (Vk+d)k(\mathcal V_{k+d})_k is a Martin-Löf test, and it captures every sequence captured by (Sn)(\mathcal S_n).

The counting step is Markov’s inequality: the average number of classes Sn\mathcal S_n containing a sequence is ∑nλ(Sn)\sum_n \lambda(\mathcal S_n), so the sequences belonging to 2k2^k of them have measure at most 2−k2^{-k} times this sum.

2.6 Exercises

Exercise 2.10 ★.

Let XX be Martin-Löf random. Show that for every kk, some block X(ik)⋯X(ik+k−1)X(ik) \cdots X(ik + k - 1) consists of zeros only. Deduce that XX contains arbitrarily long runs of zeros.

Solution

Fix kk, and let VN\mathcal V_N be the clopen class of sequences none of whose first NN blocks of length kk is 0k0^k. The blocks are independent: λ(VN)=(1−2−k)N\lambda(\mathcal V_N) = (1 - 2^{-k})^N, which tends to 00 and is a computable rational. The sequence (VN)N(\mathcal V_N)_N is uniformly Σ10\Sigma^0_1, so by Lemma 2.3 a random sequence is outside some VN\mathcal V_N: one of its first NN blocks is 0k0^k.

Exercise 2.11 ★.

Let XX be Martin-Löf random. Show that σX\sigma X is random for every string σ\sigma, and that the tail Y=X(1)X(2)⋯Y = X(1) X(2) \cdots is random.

Solution

For an open class U=[W]≺\mathcal U = [W]^{\prec} and a string σ\sigma, write Uσ={Z:σZ∈U}\mathcal U_\sigma = \{ Z : \sigma Z \in \mathcal U \}. Then Uσ=[{τ:some prefix of στ is in W}]≺\mathcal U_\sigma = [\{ \tau : \text{some prefix of } \sigma\tau \text{ is in } W \}]^{\prec}; this generating set is c.e., uniformly in an index of WW and in σ\sigma, when WW is c.e. (if some prefix of σ\sigma is in WW, it contains the empty string and Uσ=2N\mathcal U_\sigma = \cs). So Uσ\mathcal U_\sigma is Σ10\Sigma^0_1 uniformly in σ\sigma and in an index of U\mathcal U, and λ(Uσ)=2∣σ∣λ(U∩[σ])\lambda(\mathcal U_\sigma) = 2^{|\sigma|} \lambda(\mathcal U \cap [\sigma]), since [τ]↦[στ][\tau] \mapsto [\sigma\tau] divides measures by 2∣σ∣2^{|\sigma|}.

If σX\sigma X is captured by (Un)(\mathcal U_n), then XX belongs to every (Un)σ(\mathcal U_n)_\sigma, and λ((Un)σ)≤2∣σ∣−n\lambda((\mathcal U_n)_\sigma) \leq 2^{|\sigma| - n}; by Lemma 2.3, XX is not random. For the tail, X=iYX = iY with i=X(0)i = X(0). If YY is captured by (Un)(\mathcal U_n), let Vn={jZ:j∈{0,1}, Z∈Un}\mathcal V_n = \{ jZ : j \in \{0, 1\},\ Z \in \mathcal U_n \}, a uniformly Σ10\Sigma^0_1 sequence with λ(Vn)=λ(Un)\lambda(\mathcal V_n) = \lambda(\mathcal U_n); it captures XX.

Exercise 2.12 ★★.

A sequence GG is weakly 1-generic if it meets every dense c.e. set of strings WW: some prefix of GG belongs to WW. A sequence is Kurtz random if it belongs to no null Π10\Pi^0_1 class. Show that every Martin-Löf random sequence is Kurtz random, that every weakly 1-generic sequence is Kurtz random, and that no weakly 1-generic sequence is Martin-Löf random.

Solution

A null Π10\Pi^0_1 class P\mathcal P is covered by clopen classes [Fn]≺[F_n]^{\prec} of measure at most 2−n2^{-n}, computable from nn (second exercise of Measure on Cantor space); this is a Martin-Löf test, so random sequences avoid P\mathcal P.

Let P=[T]\mathcal P = [T] be null, with TT computable. The set WW of strings not in TT is computable. It is dense: if some σ\sigma had all its extensions in TT, then [σ]⊆P[\sigma] \subseteq \mathcal P and λ(P)≥2−∣σ∣\lambda(\mathcal P) \geq 2^{-|\sigma|}. A weakly 1-generic GG has a prefix outside TT, so G∉PG \notin \mathcal P.

For each nn, the set DnD_n of strings τ\tau of length at least nn with at least 23∣τ∣\frac{2}{3}|\tau| ones is computable and dense: a string σ\sigma is extended by σ1k\sigma 1^k with k=max⁡(2∣σ∣,n)k = \max(2|\sigma|, n), which has at least k≥23(∣σ∣+k)k \geq \frac{2}{3}(|\sigma| + k) ones. A weakly 1-generic GG meets every DnD_n, so the frequency of ones in G ⁣↾mG \uh m is at least 23\frac{2}{3} for infinitely many mm. By Proposition 2.7, GG is not random.

2.7 Notes and references

Martin-Löf (1966) introduced the tests and the universal test; the definition was meant to capture all effective statistical tests, the law of large numbers being the first example. Solovay’s equivalent formulation appears in unpublished notes (1975). Kurtz (1981) introduced the randomness notion of the last exercise. Normal numbers were introduced by Borel (1909), who proved that almost every real is normal.

  • P. Martin-Löf, The definition of random sequences, Information and Control 9 (1966), 602–619.
  • W. Hoeffding, Probability inequalities for sums of bounded random variables, Journal of the American Statistical Association 58 (1963), 13–30.
  • S. A. Kurtz, Randomness and genericity in the degrees of unsolvability, PhD thesis, University of Illinois, 1981.
  • R. G. Downey and D. R. Hirschfeldt, Algorithmic Randomness and Complexity, Springer, 2010.