Logic, Sets and Infinity

The Cantor Set, Tiny in Length yet Uncountably Large

Build the Cantor set by removing middle thirds, then see why it has total length zero while holding as many points as the whole interval.

Key takeaways

  • After n steps of the construction there are 2ⁿ closed intervals with total length (2/3)ⁿ, which tends to zero.
  • A number between 0 and 1 belongs to the Cantor set exactly when it can be written in base 3 using only the digits 0 and 2.
  • The set is uncountable, because its base-3 digit strings can be converted into binary expansions of every number from 0 to 1.
  • It contains no interval, has no isolated point and is made of two shrunken copies of itself.
  • Changing the sizes of the removed pieces produces a similar set with positive length that still contains no interval.

The Cantor set is what remains of the interval from 0 to 1 after you remove the open middle third, then the middle third of each remaining piece, and so on forever. The pieces you remove have total length 1, so the leftover has length zero. Yet the leftover contains as many points as the entire interval you started with.

Both statements are true because length and number of points measure different things. This one set pulls them apart so cleanly that it has become a standard test case throughout analysis and topology.

Building it step by step

Start with the closed interval [0, 1], which includes both endpoints. Remove the open interval (1/3, 2/3), meaning everything strictly between those two numbers. Two closed intervals remain: [0, 1/3] and [2/3, 1].

Now repeat on each of them. From [0, 1/3] remove (1/9, 2/9), and from [2/3, 1] remove (7/9, 8/9). Four intervals remain. Continue forever.

The Cantor set, usually written C, consists of the points that survive every step. It is the intersection of all the stages.

Step Number of intervals Length of each Total length left
0 1 1 1
1 2 1/3 2/3
2 4 1/9 4/9
3 8 1/27 8/27
n 2ⁿ 1/3ⁿ (2/3)ⁿ

Something certainly survives. An endpoint such as 1/3 or 7/9 is never removed, because every later step takes only from the interior of the intervals.

The first stages of the middle-thirds construction
Start One interval, [0, 1]. Total length 1. Step 1 [0, 1/3] and [2/3, 1]. Total length 2/3. Step 2 Four intervals of length 1/9. Total length 4/9. Step 3 Eight intervals of length 1/27. Total length 8/27. Limit The Cantor set: total length 0, uncountably many points. Start One interval, [0, 1]. Total length 1. Step 1 [0, 1/3] and [2/3, 1]. Total length 2/3. Step 2 Four intervals of length 1/9. Total length 4/9. Step 3 Eight intervals of length 1/27. Total length 8/27. Limit The Cantor set: total length 0, uncountably many points.

Why the length is zero

The set C lies inside every stage, and stage n has total length (2/3)ⁿ. That number drops below any positive tolerance once n is large enough. So C can be covered by intervals whose total length is as small as you please, which is what it means to have measure zero.

You can confirm it by adding up what was removed. Step 1 removes one interval of length 1/3. Step 2 removes two of length 1/9. Step 3 removes four of length 1/27.

Removed = 1/3 + 2/9 + 4/27 + ...      (each term is 2/3 of the one before)
        = (1/3) / (1 − 2/3)           (sum of a geometric series)
        = 1

The removed length equals the whole length of [0, 1]. The idea of measuring complicated sets by covering them with intervals is the starting point of measure theory.

The base-3 address of every point

The cleanest way to see which numbers survive is to write them in base 3, or ternary, where each digit after the point is 0, 1 or 2. The first digit tells you which third of the interval a number lies in.

Removing the middle third throws out numbers whose first digit must be 1. The second step throws out numbers whose second digit must be 1, and so on. So a number belongs to C exactly when it has at least one ternary expansion using only 0s and 2s.

The phrase "at least one" matters. The number 1/3 can be written 0.1 in base 3, but also 0.0222..., repeating forever. The second form has no 1, so 1/3 is in C.

Here is a surprise. Take 0.020202... in base 3.

x = 2/9 + 2/81 + 2/729 + ...      (digits 0,2 repeating)
  = (2/9) / (1 − 1/9)
  = (2/9) / (8/9)
  = 1/4

So 1/4 is in the Cantor set. It is not an endpoint of any interval in the construction, since all endpoints have a power of 3 as denominator. Most points of C are like this: they are never at the edge of a removed gap.

You can also read the digits as directions. A 0 means "go into the left piece" and a 2 means "go into the right piece". Each infinite sequence of left and right choices picks out one point.

Why there are uncountably many points

A set is countable if its elements can be listed as first, second, third and so on, with each element appearing somewhere. The fractions are countable. The real numbers are not.

Take any point of C, written with 0s and 2s. Replace every 2 by 1 and read the result in base 2. For example, 0.020202... in base 3 becomes 0.010101... in base 2, which is 1/3.

Every number in [0, 1] has a binary expansion, and doubling its 1s gives the ternary address of a point in C. So this conversion reaches every number in [0, 1]. A countable set cannot be mapped onto an uncountable one, so C is uncountable.

In fact C has exactly the same size as [0, 1], the size of the continuum. You can also run Cantor's diagonal argument directly on the 0 and 2 strings: given any list of them, build a new string that differs from the n-th one in the n-th place.

Notice what this says about the endpoints. There are only countably many endpoints, because each step adds finitely many. Almost all the points of C, in the sense of counting, are something else.

What the set looks like up close

The Cantor set has a combination of properties that sounds contradictory until you picture it.

  • It is closed: it contains the limit of every convergent sequence of its own points, because it is an intersection of closed sets.
  • It contains no interval. At step n each remaining interval has length 1/3ⁿ, so no stretch of positive length fits inside all stages.
  • It has no isolated point. Every point of C has other points of C arbitrarily close to it, obtained by changing a very late ternary digit.
  • It is totally disconnected: between any two of its points lies a gap that was removed.

So the set is like dust, in that no two points are joined, yet no grain stands alone. It is also self-similar. Shrink C by a factor of 3 and you get its left half; shrink and shift right by 2/3 and you get its right half.

That self-similarity gives it a fractional dimension. Two copies at one third the scale yields the dimension log 2 ÷ log 3, about 0.631, where both logarithms use the same base. This sits between the dimension 0 of a point and 1 of a line, an idea introduced in fractals and fractional dimension.

Adding the set to itself

Consider all sums x + y where x and y both belong to C. Since C has length zero, you might expect the sums to be sparse too. Instead they fill the entire interval [0, 2].

The ternary digits show why. Halve each element of C and you get numbers whose digits are only 0 and 1. Any digit 0, 1 or 2 can be written as a sum of two digits that are each 0 or 1: 0 + 0, 1 + 0, or 1 + 1. No carrying occurs. So every number z in [0, 1] is a + b with a and b in half of C, and doubling gives every number in [0, 2] as a sum from C.

The devil's staircase and fat cousins

The digit conversion used earlier extends to a function on all of [0, 1], called the Cantor function. On C it replaces 2s by 1s and reads in binary. On each removed gap it is constant: equal to 1/2 on the first middle third, 1/4 and 3/4 on the next two gaps, and so on.

The function is continuous, never decreases and climbs from 0 to 1. Yet it is flat on every removed gap, and those gaps have total length 1. All of its rising happens on a set of length zero. It is a standard warning that a derivative equal to zero almost everywhere does not force a function to be constant.

You can also change the recipe. Remove from the middle of [0, 1] an interval of length 1/4, then from each of the two remaining pieces an interval of length 1/16, then 1/64 from each of four, and so on. The total removed is 1/4 + 2/16 + 4/64 + ..., which equals 1/2.

What is left, a fat Cantor set, has length 1/2 and still contains no interval. Positive length therefore does not guarantee even a tiny solid stretch.

Testing whether a fraction belongs

You can test any fraction with long division in base 3. Multiply by 3, read off the whole-number part as the next digit, keep the fractional part and repeat. For a rational number the remainders eventually cycle, so the test ends.

Try 3/4.

3/4 × 3 = 9/4 = 2 + 1/4      digit 2, keep 1/4
1/4 × 3 = 3/4 = 0 + 3/4      digit 0, keep 3/4  (back to the start)
So 3/4 = 0.202020... in base 3

Only 0s and 2s appear, so 3/4 is in C. Now try 1/2. Multiplying by 3 gives 1 + 1/2 every time, so 1/2 = 0.111... in base 3. It has no other ternary expansion, and it is removed at the very first step, as you would expect for the midpoint.

One caution applies when a digit 1 shows up and the expansion then ends. Such a number has a second spelling ending in repeating 2s, and you should check that one before ruling the number out.

Where the idea came from

Georg Cantor described the middle-thirds set in the 1880s while studying sets of points on the line. The British mathematician Henry Smith had examined sets built by similar removals somewhat earlier. Cantor's wider struggle to compare infinite sizes is told in his story.

The set now appears whenever mathematicians need an example that is small in one sense and large in another. In topology, a deep theorem says that every nonempty compact metric space is a continuous image of the Cantor set. In dynamics, sets of this shape arise as the points that never escape under certain repeated maps.

When you meet a claim about "small" sets, ask which meaning of small is intended: few points, little length, or containing no interval. The Cantor set answers no, yes and yes.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 41 articles in Logic, Sets and Infinity →

Latest news on this topic