TITLE: Construction of a Borel set with positive but not full measure in each interval
QUESTION [120 upvotes]: I was wondering how one can construct a Borel set that doesn't have full measure on any interval of the real line but does have positive measure everywhere. 
To be precise, if $\mu$ denotes Lebesgue measure, how would one construct a Borel set $A \subset \mathbb{R}$ such that
$$0 < \mu(A \cap I) < \mu(I)$$
for every interval $I$ in $\mathbb{R}$? 
Moreover, would such a set necessarily have to contain infinite measure?

REPLY [11 votes]: This question has a cute answer -- if you know about Markov chains.
Consider the nearest-neighbour Markov chain $(X_n)$ on $\mathbf{Z}$ with the following transition probabilities: from $0$ it goes to $\pm 1$ with probability $1/2$, from $n\neq 0$ it moves one step towards $0$ with probability $1/4$ and one step towards $\infty$ (if $n>0$) or $-\infty$ (if $n<0$) with probability $3/4$.
It is simple to check (e.g. via the strong law of large numbers) that $|X_n|$ goes to $+\infty$ almost surely, so by symmetry
$$ \mathbf{P}(\lim X_n = + \infty | X_0=0) = \mathbf{P}(\lim X_n = - \infty | X_0=0) = \frac{1}{2}. $$
Now define a Borel set $A \subset [0,1]$ as follows: use the digits in the binary expansion of $x \in [0,1]$ (which are i.i.d. Bernoulli variables which parameter $1/2$) to simulate the Markov chain $(X_n)$ starting from the origin, and let $A$ be set of $x$ for which $X_n \to + \infty$. Since the Markov chain is irreducible, $A$ has non-full non-zero measure in every subinterval of $[0,1]$.
For the OP last question: since
$$ \lim_{k \to - \infty} \mathbf{P} \left(\lim X_n = +\infty | X_0= k\right) =0 ,$$
one gets a variant of the example with $m(A)$ arbitrary small by starting the Markov chain from $k$. Using such constructions in every interval $[n,n+1]$ produces a set $B \subset \mathbf{R}$ with finite measure whose intersection with every interval has positive measure.