# Resource-bounded measure

Lutz's resource-bounded measure is a generalisation of Lebesgue measure to complexity classes. It was originally developed by Jack Lutz. Just as Lebesgue measure gives a method to quantify the size of subsets of the Euclidean space $\mathbb {R} ^{n}$, resource bounded measure gives a method to classify the size of subsets of complexity classes.
For instance, computer scientists generally believe that the complexity class P (the set of all decision problems solvable in polynomial time) is not equal to the complexity class NP (the set of all decision problems checkable, but not necessarily solvable, in polynomial time). Since P is a subset of NP, this would mean that NP contains more problems than P. A stronger hypothesis than "P is not NP" is the statement "NP does not have p-measure 0". Here, p-measure is a generalization of Lebesgue measure to subsets of the complexity class E, in which P is contained. P is known to have p-measure 0, and so the hypothesis "NP does not have p-measure 0" would imply not only that NP and P are unequal, but that NP is, in a measure-theoretic sense, "much bigger than P".

## Definition

$\{0,1\}^{\infty }$ is the set of all infinite binary sequences. We can view a real number in the unit interval as an infinite binary sequence, by considering its binary expansion. We may also view a language (a set of binary strings) as an infinite binary sequence, by setting the nth bit of the sequence to 1 if and only if the nth binary string (in lexicographical order) is contained in the language. Thus, sets of real numbers in the unit interval and complexity classes (which are sets of languages) may both be viewed as sets of infinite binary sequences, and thus the techniques of measure theory used to measure the size of sets of real numbers may be applied to measure complexity classes. However, since each computable complexity class contains only a countable number of elements(because the number of computable languages is countable), each complexity class has Lebesgue measure 0. Thus, to do measure theory inside of complexity classes, we must define an alternative measure that works meaningfully on countable sets of infinite sequences. For this measure to be meaningful, it should reflect something about the underlying definition of each complexity class; namely, that they are defined by computational problems that can be solved within a given resource bound.
The foundation of resource-bounded measure is Ville's formulation of martingales. A martingale is a function $d:\{0,1\}^{*}\to [0,\infty )$ such that, for all finite strings w,
    $d(w)={\frac {d(w0)+d(w1)}{2}}$.
(This is Ville's original definition of a martingale, later extended by Joseph Leo Doob.) A martingale d is said to succeed on a sequence $S\in \{0,1\}^{\infty }$ if $\limsup _{n\to \infty }d(S\upharpoonright n)=\infty ,$ where $S\upharpoonright n$ is the first n bits of S. A martingale succeeds on a set of sequences $X\subseteq \{0,1\}^{\infty }$ if it succeeds on every sequence in X.
Intuitively, a martingale is a gambler that starts with some finite amount of money (say, one dollar). It reads a sequence of bits indefinitely. After reading the finite prefix $w\in \{0,1\}^{*}$, it bets some of its current money that the next bit will be a 0, and the remainder of its money that the next bit will be a 1. It doubles whatever money was placed on the bit that appears next, and it loses the money placed on the bit that did not appear. It must bet all of its money, but it may "bet nothing" by placing half of its money on each bit. For a martingale d, d(w) represents the amount of money d has after reading the string w. Although the definition of a martingale has the martingale calculating how much money it will have, rather than calculating what bets to place, because of the constrained nature of the game, knowledge the values d(w), d(w0), and d(w1) suffices to calculate the bets that d placed on 0 and 1 after seeing the string w. The fact that the martingale is a function that takes as input the string seen so far means that the bets placed are solely a function of the bits already read; no other information may affect the bets (other information being the so-called filtration in the generalized theory of martingales).
The key result relating measure to martingales is Ville's observation that a set $X\subseteq \{0,1\}^{\infty }$ has Lebesgue measure 0 if and only if there is a martingale that succeeds on X. Thus, we can define a measure 0 set to be one for which there exists a martingale that succeeds on all elements of the set.
To extend this type of measure to complexity classes, Lutz considered restricting the computational power of the martingale. For instance, if instead of allowing any martingale, we require the martingale to be polynomial-time computable, then we obtain a definition of p-measure: a set of sequences has p-measure 0 if there is a polynomial-time computable martingale that succeeds on the set. We define a set to have p-measure 1 if its complement has p-measure 0. For example, proving the above-mentioned conjecture, that NP does not have p-measure 0, amounts to proving that no polynomial-time martingale succeeds on all of NP.

## Almost complete

A problem is almost complete for a complexity class C if it is in C and "many" other problems in C reduce to it. More specifically, the subset of problems of C which reduce to the problem is a measure one set, in terms of the resource bounded measure. This is a weaker requirement than the problem being complete for the class.