Construction of a Borel set with positive but not full measure in each interval 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?   
 A: If you got this from Rudin (it is Exercise 8, Ch. 2 in his Real & Complex Analysis), here is his personal answer (excerpted from Amer. Math Monthly, Vol. 90, No.1 (Jan 1983) pp. 41-42). He works with the unit interval $[0,1]$, but of course this can be extended to $\mathbb R$ by doing the same thing in each interval (and by scaling these replications appropriately you can get the final set with finite measure). Anyways, here's how it goes:
"Let $I=[0,1]$, and let CTDP mean compact totally disconnected subset of $I$, having positive measure. Let $\langle I_n\rangle$ be an enumeration of all segments in $I$ whose endpoints are rational.
Construct sequences $\langle A_n\rangle,\langle B_n\rangle$ of CTDP's as follows: Start with disjoint CTDP's $A_1$ and $B_1$ in $I_1$. Once $A_1,B_1,\dots,A_{n-1},B_{n-1}$ are chosen, their union $C_n$ is CTD, hence $I_n\setminus C_n$ contains a nonempty segment $J$ and $J$ contains a pair $A_n,B_n$ of disjoint CTDP's. Continue in this way, and put
$$
A=\bigcup_{n=1}^{\infty}A_n.
$$
If $V\subset I$ is open and nonempty, then $I_n\subset V$ for some $n$, hence $A_n\subset V$ and $B_n\subset V$. Thus
$$
0<m(A_n)\leq m(A\cap V)<m(A\cap V)+m(B_n)\leq m(V);
$$
the last inequality holds because $A$ and $B_n$ are disjoint. Done.
The purpose of publishing this is to show that the highly computational construction of such a set in [another article] is much more complicated than necessary."  

Edit: In his excellent comment below, @ccc managed to isolate the necessary components of my solution, and after incorporating his observation it has been greatly simplified. (Actually, after trimming the fat, I've realized that it is actually not entirely dissimilar from Rudin's.) Here it is:
Let $\{r_n\}$ be an enumeration of the rationals, let $V_1$ be a segment of finite length centered at $r_1$, and let $V_n$ be a segment of length $m(V_{n-1})/3$ centered at $r_n$. Set
$$
W_n=V_n-\bigcup_{k=1}^{\infty}V_{n+k},
$$
and observe that
\begin{equation}
m(W_n)\geq m(V_n)-\sum_{k=1}^{\infty}m(V_{n+k})=m(V_n)-m(V_n)\sum_{k=1}^{\infty}3^{-k}=\frac{m(V_n)}{2}.
\end{equation}
In particular, $m(W_n)>0$.
For each $n$, choose a Borel set $A_n\subset W_n$ with $0<m(A_n)<m(W_n)$. Finally, put $A=\bigcup_{n=1}^{\infty}A_n$. Because $A_n\subset W_n$ and the $W_n$ are disjoint,  $m(A\cap W_n)=m(A_n)$. That is to say,
$$
0<m(A\cap W_n)<m(W_n)
$$
for every $n$. But every interval contains a $W_n$, so $A$ meets the criteria, and has finite measure (specifically, $m(A)\leq\sum_n m(V_n)=2 m(V_1)<\infty$).

As a curiosity, here's my own "unnecessarily computational" way (though it's not quite as lengthy as that in the article Rudin was referring to), which I can't resist including because I slaved over it when I first came across this problem, before finding Rudin's solution: 
Let $\{r_n\}$ be an enumeration of the rationals, and put
$$
V_n=\left(r_n-3^{-n-1},r_n+3^{-n-1}\right),\qquad W_n=V_n-\bigcup_{k=1}^{\infty}V_{n+k}.
$$
Observe that
\begin{equation}
m(W_n)>m(V_n)-\sum_{k=1}^{\infty}m(V_{n+k})=m(V_n)-m(V_n)\sum_{k=1}^{\infty}3^{-k}=\frac{m(V_n)}{2}.\qquad\qquad(1)\label{8.1}
\end{equation}
(We have strict inequality because there exist rationals $r_i$, with $i>n$, in the complement of $V_n$.) 
For each $n$, let $K_n$ be a Borel set in $V_n$ with measure $m(K_n)=m(V_n)/2$.  Finally, put
$$A_n=W_n\cap K_n,\qquad A=\bigcup_{n=1}^{\infty}A_n.$$
To prove that $A$ has the desired property, it is enough to verify that the inequalities
$$0<m(A\cap V_n)<m(V_n)\qquad\qquad(3)\label{8.3}$$
hold for every $n$. (This is because every interval contains a $V_n$.) For the left inequality, it is enough to prove that $m(A_n\cap V_n)=m(A_n)=m(W_n\cap K_n)>0$. This follows from the relations
$$m(W_n\cup K_n)\leq m(V_n)<m(W_n)+m(K_n)=m(W_n\cup K_n)+m(W_n\cap K_n),$$
the second inequality being a consequence of (1) and the fact that $m(K_n)=m(V_n)/2$.
For the right inequality of (3), observe that $V_n\subset W_i^c$ for $i<n$, and that therefore
$$
m(A\cap V_n)=m\left(\bigcup_{k=0}^{\infty}A_{n+k}\cap V_n\right)\leq\sum_{k=0}^{\infty}m(K_{n+k}\cap V_n)
$$
$$
<\sum_{k=0}^{\infty}m(K_{n+k})=\sum_{k=0}^{\infty}\frac{m(V_{n+k})}{2}=\sum_{k=0}^{\infty}\frac{m(V_n)}{2^{k+1}}=m(V_n).
$$
The strict inequality above follows from three observations: (i) $m(K_i)>0$ for every $i$; (ii) $K_i\subset V_i$; and (iii) there exist neighborhoods $V_i$, with $i>n$, that are contained entirely in the complement of $V_n$.
So $A$ meets the criteria (and also has finite measure).
A: 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.
A: Let $I = [0,1]$. We construct a partition of $I$ into $A_0$ and $A_1$ using binary digits of numbers in $x$. Recall that with respect to Lebesgue measure, the binary digits are like infinite coin toss experiment. Also recall that while a number can have more than one binary representations, such numbers form a measure zero set, so we can safely forget existence of such numbers.
Let $ c_1 = 1, c_2 = 2 < c_3 < c_4 < c_5 <  \cdots $ be an increasing sequence of integers, such that $c_{n+1} - c_n$ grows fast enough. (How fast? To be determined later.) Let $J_n = \{k \in \mathbb N: c_n \le k < c_{n+1} \}$.
We say $x\in I$ is $n$-happy if k'th (binary) digit of x for each k in $J_n$ is 0. We say $x$ is $n$-angry if k'th digit of x for each k in $J_n$ is 1 . We say $x$ is $n$-emotional if it is $n$-happy or $n$-angry. If you imagine $x$ as an outcome of tossing a coin infinite times, then you can think of "1-emotional", "2-emotional", "3-emotional", .... as a sequence of events with rapidly decreasing probability.
Given an $x\in I$, the set $N(x)$ of all $n$ for which $x$ is $n$-emotional is a non-empty set because $1 \in N(x)$. If $c_{n+1} - c_n$ grows fast enough (linear growth is enough), then $N(x)$ is a finite set for almost all $x$, due to Borel-Cantelli lemma. Let $n(x) = \sup N(x)$. Now the function $x \mapsto n(x) $ is finite a.e. This allows us to partition $I$ into $A_0$ consisting of all $x$ that are $n(x)$-happy and $A_1$ consisting of all $x$ that are $n(x)$-angry.
To show that $A_0$ intersects every subinterval of $I$ in positive density, let $I'$ be an arbitrary subinterval of $I$. Then there exist $n$ and digits $x_1, \cdots x_{c_n-1}$ such that $I'$ contains the interval $I''$ consisting of all numbers in $I$ whose first $c_n -1$ digits are precisely $x_1, \cdots x_{c_n-1}$. The $n$-lucky numbers in $I''$ form yet another interval, say $I'''$. Given a random choice of $x \in I'''$, it's more likely for $x$ to be in $A_0$ than to be in $A_1$ because of $n$-luckiness of $x$. Therefore $A_0$ intersects $I'''$ in more than half density, and thus intersects $I'$ in positive density.
Remark 1. There is no measurable subset of $I$ which intersects every subinterval in exactly half density. Terence Tao uses this to construct a non-measurable set in here.
Remark 2. Lebesgue density theorem
A: Well, suppose you enumerated the rational intervals $I_n$, and for each $I_n$, let $J_n = I_n \setminus \cup_{i=1}^{n-1}I_i$.  If $J_n$ has measure 0, let $A_n = \varnothing$.  Otherwise, let $A_n$ be a subset of $I_n$ such that $\mu(A_n) < \max\{\mu(I_n)/2, \epsilon\cdot 2^{-n}\}$.  Then let $A$ be the union of the sets $A_n$.  Doesn't that do it?
