Tutorials › Topology (Undergraduate) › Constructing The Middle-Thirds Cantor Set

Counterexamples in Topology · Tutorial 769 of 799

Constructing The Middle-Thirds Cantor Set

Follow the interval construction of the middle-thirds Cantor set and learn how ternary expansions detect its points without misclassifying endpoints.

Intermediate 9 min read

What You'll Learn

  • Build each stage by deleting the open middle third of every surviving interval.
  • Write the surviving stage intervals using finite strings of ternary digits.
  • Prove the connection between membership in the intersection and ternary expansions.
  • Recognize why a point can have two ternary expansions.
  • Handle endpoints whose alternative expansions include the digit one.
  • Distinguish an allowed expansion from a claim that every expansion is allowed.

Repeatedly Removing Middle Thirds

Start with the closed unit interval and remove its open middle third. Then remove the open middle third of each interval that remains, and repeat. The construction keeps the endpoints of every removed gap: deleting an open interval does not delete either endpoint. Keeping track of that distinction is essential when we describe the resulting set using ternary expansions.

Throughout, \(\mathbb{R}\) has its standard topology. Define \(C_0=[0,1]\). For each integer \(n\geq 0\), obtain \(C_{n+1}\) from \(C_n\) by removing the open middle third of every closed interval making up \(C_n\). The middle-thirds Cantor set is the intersection of all stages:

$$ C=\bigcap_{n=0}^{\infty}C_n. $$

Thus a point belongs to \(C\) precisely when it survives at every finite stage. To describe those stages precisely, let \(w=(w_1,\ldots,w_n)\) be a finite word whose entries are each either \(0\) or \(2\). Define \(L(w)=\sum_{i=1}^{n}w_i/3^i\), and associate to the word the closed interval \(I_w=[L(w),L(w)+3^{-n}]\). For \(n=0\), the empty word gives \(I_w=[0,1]\).

Theorem: For every \(n\geq0\), the stage \(C_n\) is the union of the intervals \(I_w\) over all length-\(n\) words \(w\) with entries in \(\{0,2\}\). In particular, \(C_n\) consists of \(2^n\) closed intervals, each of length \(3^{-n}\).

Proof. We use induction on \(n\). At \(n=0\), the only word is empty, and its interval is \([0,1]=C_0\). Suppose the description holds for \(n\), and consider one interval \(I_w=[L,L+3^{-n}]\). Its left third is \([L,L+3^{-(n+1)}]\); its right third is \([L+2\cdot3^{-(n+1)},L+3^{-n}]\), because \(2\cdot3^{-(n+1)}+3^{-(n+1)}=3^{-n}\). The construction removes the open interval between those two thirds and keeps both closed thirds. These are exactly \(I_{(w,0)}\) and \(I_{(w,2)}\), by the definition of \(L(w)\). Applying this to every interval gives the claimed description at stage \(n+1\). Each interval has length \(3^{-n}\); and replacing every interval by its two thirds doubles their number, giving \(2^n\) intervals. \(\square\)

The First Stages in Detail

Worked Example: Computing the First Two Stages

At stage zero, \(C_0=[0,1]\). Its open middle third is \((1/3,2/3)\), so the first stage is \(C_1=[0,1/3]\cup[2/3,1]\). The word formula gives the same result: the length-one words \(0\) and \(2\) give intervals \([0,1/3]\) and \([2/3,1]\).

At stage two, split each of those two intervals into its closed outer thirds. Splitting \([0,1/3]\) gives \([0,1/9]\) and \([2/9,1/3]\). Splitting \([2/3,1]\) gives \([2/3,7/9]\) and \([8/9,1]\). Thus \(C_2=[0,1/9]\cup[2/9,1/3]\cup[2/3,7/9]\cup[8/9,1]\). For example, the word \(20\) gives \(L=2/3+0/9=2/3\), and its interval is \([2/3,2/3+1/9]=[2/3,7/9]\). The word \(22\) gives \(L=2/3+2/9=8/9\), and its interval is \([8/9,8/9+1/9]=[8/9,1]\).

Check: the four intervals have length \(1/9=3^{-2}\), and their left endpoints are \(0,2/9,2/3,8/9\), as the word formula gives for \(00,02,20,22\). The gaps between successive intervals are open, so their endpoints remain in \(C_2\).

The finite words also suggest a ternary description: a digit \(0\) means take the left third, and a digit \(2\) means take the right third. An infinite digit sequence \((a_i)_{i\geq1}\), with each \(a_i\in\{0,2\}\), determines the real number \(\sum_{i=1}^{\infty}a_i/3^i\). The next theorem makes the relationship exact.

Theorem: A point \(x\in[0,1]\) belongs to \(C\) if and only if it has a ternary expansion \(x=\sum_{i=1}^{\infty}a_i/3^i\) in which every digit \(a_i\) is either \(0\) or \(2\). This says “has such an expansion,” not “every expansion has only those digits.”

Proof. Suppose first that \(x\in C\). At each stage \(n\), \(x\) belongs to one of the intervals \(I_w\) described above. The stage intervals are disjoint: distinct intervals at that stage are separated by a removed open gap. Also, each interval at stage \(n+1\) lies in its unique parent interval at stage \(n\). Therefore the words specifying the intervals containing \(x\) are compatible: each is the initial segment of the next. They define an infinite sequence \(a_1,a_2,\ldots\) with digits in \(\{0,2\}\). For every \(n\), membership in the interval specified by the first \(n\) digits gives \(0\leq x-\sum_{i=1}^{n}a_i/3^i\leq3^{-n}\). As \(n\) tends to infinity, \(3^{-n}\) tends to zero, so \(x=\sum_{i=1}^{\infty}a_i/3^i\).

Conversely, suppose \(x=\sum_{i=1}^{\infty}a_i/3^i\) with all \(a_i\in\{0,2\}\). Fix \(n\). The first \(n\) terms sum to \(L(w)\) for the word \(w=(a_1,\ldots,a_n)\). The remaining terms are nonnegative and at most \(\sum_{i=n+1}^{\infty}2/3^i=3^{-n}\), where the geometric series has first term \(2/3^{n+1}\) and ratio \(1/3\). Hence \(x\in[L(w),L(w)+3^{-n}]=I_w\subseteq C_n\). This holds for every \(n\), so \(x\in\bigcap_{n=0}^{\infty}C_n=C\). \(\square\)

Why Ternary Expansions Can Be Ambiguous

A point can have two ternary expansions at an endpoint shared by adjacent ternary intervals. To see the exact source of ambiguity, consider two different expansions \(x=\sum_{i\geq1}a_i/3^i=\sum_{i\geq1}b_i/3^i\), where each digit is in \(\{0,1,2\}\). Let \(m\) be the first index where they differ, and suppose \(a_m<b_m\). Equality of the sums requires the later digits in the first expansion to make up the difference at index \(m\). But their maximum possible contribution is \(\sum_{i=m+1}^{\infty}2/3^i=1/3^m\). Since \(b_m-a_m\geq1\), equality is possible only if \(b_m-a_m=1\), all later \(a_i=2\), and all later \(b_i=0\). Indeed, if any of those conditions failed, the later difference would be strictly less than \(1/3^m\). Thus the two forms are a tail of \(2\)s and the expansion obtained by increasing the last preceding differing digit by one and then using \(0\)s.

Takeaway: The endpoint ambiguity has the form “a digit followed by \(222\ldots\)” versus “the next digit followed by \(000\ldots\).” Consequently, a point of \(C\) can have one ternary expansion containing a \(1\) and another expansion using only \(0\)s and \(2\)s.

Worked Example: Two Expansions for the First Gap Endpoints

The endpoint \(1/3\) has the terminating expansion \(0.1000\ldots_3\), since \(1/3^1=1/3\) and all later terms are zero. It also has the expansion \(0.0222\ldots_3\), because \(\sum_{i=2}^{\infty}2/3^i=(2/9)/(1-1/3)=1/3\). The second expansion uses only \(0\)s and \(2\)s, so the theorem confirms \(1/3\in C\). In the interval construction, it is the right endpoint of the left interval in \(C_1\), and the open middle third does not remove it.

Likewise, \(2/3=0.2000\ldots_3\). The alternative expansion is \(0.1222\ldots_3\), whose value is \(1/3+\sum_{i=2}^{\infty}2/3^i=1/3+1/3=2/3\). Its first expansion uses only \(0\)s and \(2\)s, so \(2/3\in C\) as well. It is the left endpoint of the right interval in \(C_1\).

Check: both endpoints survive because the removed set at the first step is the open interval \((1/3,2/3)\), which contains neither \(1/3\) nor \(2/3\). The expansions agree with the interval construction, including its strict distinction between points inside the removed gap and its endpoints.

Worked Example: A Later Endpoint and a Point in a Removed Gap

Consider \(7/27\). One expansion is \(0.021000\ldots_3\), since \(2/3^2+1/3^3=2/9+1/27=7/27\). This expansion contains a \(1\), so it cannot by itself establish membership in \(C\). But the alternative expansion is \(0.020222\ldots_3\): its value is \(2/9+\sum_{i=4}^{\infty}2/3^i=2/9+1/27=7/27\). It uses only \(0\)s and \(2\)s, proving \(7/27\in C\).

The interval calculation gives the same result. At stage two, the interval \([2/9,1/3]\) survives. At stage three, its left third is \([2/9,7/27]\), so \(7/27\) remains as an endpoint. By contrast, \(1/2=0.111\ldots_3\), since \(\sum_{i=1}^{\infty}1/3^i=(1/3)/(1-1/3)=1/2\). Also \(1/3<1/2<2/3\), so \(1/2\) lies in the first open gap and is removed at stage one.

Check: \(7/27\) is the upper endpoint \(2/9+1/27\) of the left third of \([2/9,1/3]\); \(1/2\) is strictly between the two first-stage endpoints. The endpoint is retained, while the point strictly inside the open gap is not.

A Common Mistake

Common pitfall. A tempting shortcut is to say that a point belongs to \(C\) exactly when its ternary expansion contains no \(1\)s. That statement is incorrect if “its expansion” means every possible expansion. For example, \(1/3=0.1000\ldots_3\) contains a \(1\), yet \(1/3\in C\). The correction is to say that a point belongs to \(C\) exactly when it has at least one ternary expansion using only \(0\)s and \(2\)s. The alternative expansion \(1/3=0.0222\ldots_3\) verifies the condition. Conversely, \(1/2=0.111\ldots_3\) is strictly inside the first removed gap, so it is not in \(C\). The word “has” handles endpoint ambiguity; the construction itself explains why the endpoints survive.

The interval description is useful when a particular finite stage must be computed, while the expansion description provides a concise membership test. Together they retain the information most easily lost in this construction: every deletion is open, so an endpoint can remain even when one of its ternary expansions contains the digit \(1\).

Check Your Understanding

Use the stage intervals and the existence of an expansion with digits \(0\) and \(2\) to justify your answers.

  1. Write all intervals making up \(C_3\), using the length-three words.
  2. Show that \(8/27\) belongs to \(C\) by giving an expansion whose digits are all \(0\) or \(2\).
  3. Explain why the expansion \(0.12000\ldots_3\) does not alone decide whether its value belongs to \(C\).
  4. Find two ternary expansions for \(2/9\), and determine whether \(2/9\) belongs to \(C\).
  5. Explain why \(5/9\) is removed at the first stage, using strict inequalities.