Cantor set

The Cantor ternary set is a remarkable subset of the real numbers named after German mathematician Georg Cantor who described the set in 1883. It has the same cardinality as R, yet it has zero Lebesgue measure.

The set can be constructed recursively by first considering the unit interval C0=[0,1]. In the next step, we divide the set into three equal parts and discard the open middle set. This leads to the new set C1=[0,13][23,1]. This procedure is repeated on the two remaining subintervals [0,13] and [23,1], and iteratively on all remaining subsets such that Cn=13Cn1(23+13Cn1). The Cantor set is defined by the limit as n, i.e., C=n=0Cn.

The recursion can be illustrated in python in the following way

  import numpy as np

  def transform_interval(x, scale=1.0, translation=0.0):
      return tuple(map(lambda z: z * scale + translation, x))

  def Cantor(n):
      if n==0: return {(0,1)}
      Cleft = set(map(lambda x: transform_interval(x, scale=1/3), Cantor(n-1)))
      Cright = set(map(lambda x: transform_interval(x, translation=2/3), Cleft))
      return Cleft.union(Cright)
  print(Cantor(1))
{(0.6666666666666666, 1.0), (0.0, 0.3333333333333333)}

The following code displays the first 5 iterations of the algorithm and clearly illustrates the self-similarity property in the sets Cn.

  def intervalprint(x, n=240):
     sym = n*[' ']
     val = np.linspace(0, 1, num=n)
     for interval in x:
	idx = np.where((val >= interval[0]) & (val <= interval[1]))[0]
	for i in idx:
           sym[i] = u'\u2500'
     st = ''.join(sym)
     print(st)

  x = list(map(Cantor, [0,1,2,3,4,5]))
  for i in range(0, len(x)): intervalprint(x[i])
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────                                                                                ────────────────────────────────────────────────────────────────────────────────
───────────────────────────                           ──────────────────────────                                                                                ──────────────────────────                           ───────────────────────────
─────────         ─────────                           ────────         ─────────                                                                                ─────────         ────────                           ─────────         ─────────
───   ───         ───   ───                           ───   ──         ───   ───                                                                                ───   ───         ──   ───                           ───   ───         ───   ───
─ ─   ─ ─         ─ ─   ─ ─                           ─ ─    ─         ─ ─   ─ ─                                                                                ─ ─   ─ ─         ─    ─ ─                           ─ ─   ─ ─         ─ ─   ─ ─

It is clear that C is bounded (being a subset of the unit interval) and closed since it constructed by removing countably many open intervals from a closed interval. It also has zero measure, meaning that it does not contain any intervals.

To see this, note that in the first step the open middle set (13,23) is removed which has measure 1/3. From the remaining two closed sets, [0,13] and [23,1], the open middle sets are removed in the next iteration: (132,232) and (23+132,23+232), each of measure 132. In the nth iteration 2n1 open intervals are removed each of length 13n. Hence, the Lebesgue measure of the Cantor set is m(C)=m([0,1])k=02n3n+1=113k=1(23)n=113(123)1=0.

In this sense, we can think of the Cantor set just containing “dust”.

It can also be shown that the Cantor set can be represented as C={i=1xn3nxn0,2}, from which it again follows that the set is uncountable. This can also be seen by considering an arbitrary countable subset N={n1,n2,}C. In the construction of C, we must have that n1 belongs to one of the two closed intervals in C1. Hence, there is one interval I1 of length 13 such that n1I1. Similarly, C2I1 is the union of two new closed intervals of length 132, and n2 can at most be in one of these two sets. Let I2I1 be this interval s.t. n2I2. Continuing in this fashion we construct a series of intervals CI1I2Ik, where Ik is one of the closed intervals of Cn of length 13n such that nkIk. The limit I=k=1Ik is non-empty (see below), and by construction NI=. Hence given any arbitrary countable subset of C we can still find elements in C that does not belong to this subset, and thus there cannot exist a bijection between N and C and we conclude that C is uncountable infinite.

Here we used Cantor’s Intersection Theorem: Let (X,d) be a complete metric space. Let (Ik)kN be a sequence of decreasing non-empty, closed subsets of X then kNIk.

Proof: For each kN choose xkIk. The diameter of Ik is defined as diam(Ik)=sup{𝑑(𝑥,𝑦):𝑥,𝑦Ik}. We only need to consider the case where diam(Ik)0. In this case, let ϵ>0 then there exists N>0 such that d(x,x)<ϵ for all x,xIN. Let m,n>N then xn,xmIN since ININ+1Im,In, and thus d(xn,xm)<ϵ. We conclude that (xk)kN is a Cauchy sequence. Since X is complete xnx as n for some xX. Note that (xn)n=NIN and since IN is closed, the limit point also lies in the set xIN. As this holds for any N, we conclude that xkNIk. This concludes the proof. Note, that in this case the limit point x is in fact the only element. Since if we let x be another element then x,xIn for all nN but d(x,x)diam(Fn)0 as n. Hence d(x,x)=0, and therefore kNIk={x}.