The areas / V14. Topological algebra and infinite sums
Mathlib.Topology.Instances.CantorSet
37 declarations. Mathlib docs · Source
Ternary Cantor Set
This file defines the Cantor ternary set and proves a few properties.
Main Definitions
preCantorSet n: The ordernpre-Cantor set, defined inductively as the union of the images under the functions(· / 3)and((2 + ·) / 3), withpreCantorSet 0 := Set.Icc 0 1, i.e.preCantorSet 0is the unit interval [0,1].cantorSet: The ternary Cantor set, defined as the intersection of all pre-Cantor sets.cantorToTernary: given a numberxin the Cantor set, returns its ternary representation(d₀, d₁, ...)consisting only of digits0and2, such thatx = 0.d₀d₁...(seeofDigits_cantorToTernary).ofDigits_zero_two_sequence_mem_cantorSet: any such sequence corresponds to a number in the Cantor set.ofDigits_zero_two_sequence_unique: such a representation is unique.
Simple Properties
The Cantor set as the set of 0–2 numbers in the ternary system.
The Cantor set is homeomorphic to ℕ → Bool
theorem preCantorSet.match_1.congr_eq_1 E1 #
∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive n.succ),
x = 0 →
(match x with
| 0 => h_1 ()
| n.succ => h_2 n) ≍
h_1 ()
theorem preCantorSet.match_1.congr_eq_2 E1 #
∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive n.succ) (n : ℕ),
x = n.succ →
(match x with
| 0 => h_1 ()
| n.succ => h_2 n) ≍
h_2 n
def preCantorSet E1 #
ℕ → Set ℝ
The order n pre-Cantor set, defined starting from [0, 1] and successively removing the
middle third of each interval. Formally, the order n + 1 pre-Cantor set is the
union of the images under the functions (· / 3) and ((2 + ·) / 3) of preCantorSet n.
theorem preCantorSet_zero E0 #
preCantorSet 0 = Set.Icc 0 1
theorem preCantorSet_succ E0 #
∀ (n : ℕ), preCantorSet (n + 1) = (fun x ↦ x / 3) '' preCantorSet n ∪ (fun x ↦ (2 + x) / 3) '' preCantorSet n
def cantorSet E3 #
Set ℝ
The Cantor set is the subset of the unit interval obtained as the intersection of all
pre-Cantor sets. This means that the Cantor set is obtained by iteratively removing the
open middle third of each subinterval, starting from the unit interval [0, 1].
theorem quarters_mem_preCantorSet E1 #
∀ (n : ℕ), 1 / 4 ∈ preCantorSet n ∧ 3 / 4 ∈ preCantorSet n
theorem quarter_mem_preCantorSet E1 #
∀ (n : ℕ), 1 / 4 ∈ preCantorSet n
theorem quarter_mem_cantorSet E1 #
1 / 4 ∈ cantorSet
theorem zero_mem_preCantorSet E1 #
∀ (n : ℕ), 0 ∈ preCantorSet n
theorem zero_mem_cantorSet E1 #
0 ∈ cantorSet
theorem preCantorSet_antitone E1 #
Antitone preCantorSet
theorem preCantorSet_subset_unitInterval E1 #
∀ {n : ℕ}, preCantorSet n ⊆ Set.Icc 0 1
theorem cantorSet_subset_unitInterval E1 #
cantorSet ⊆ Set.Icc 0 1
The ternary Cantor set is a subset of [0,1].
theorem cantorSet_eq_union_halves E1 #
cantorSet = (fun x ↦ x / 3) '' cantorSet ∪ (fun x ↦ (2 + x) / 3) '' cantorSet
The ternary Cantor set satisfies the equation C = C / 3 ∪ (2 / 3 + C / 3).
theorem isClosed_preCantorSet E1 #
∀ (n : ℕ), IsClosed (preCantorSet n)
The preCantor sets are closed.
theorem isClosed_cantorSet E1 #
IsClosed cantorSet
The ternary Cantor set is closed.
theorem isCompact_cantorSet E1 #
IsCompact cantorSet
The ternary Cantor set is compact.
theorem ofDigits_zero_two_sequence_mem_cantorSet E3 #
∀ {a : ℕ → Fin 3}, (∀ (n : ℕ), a n ≠ 1) → Real.ofDigits a ∈ cantorSet
If x = 0.d₀d₁... in base-3 (ternary), and none of the digits dᵢ is 1,
then x belongs to the Cantor set.
theorem ofDigits_zero_two_sequence_unique E3 #
∀ {a b : ℕ → Fin 3}, (∀ (n : ℕ), a n ≠ 1) → (∀ (n : ℕ), b n ≠ 1) → Real.ofDigits a = Real.ofDigits b → a = b
If two base-3 representations using only digits 0 and 2 define the same number,
then the sequences must be equal.
This uniqueness fails for general base-3 representations (e.g. 0.1000... = 0.0222...).
def cantorStep E1 #
ℝ → ℝ
Given x ∈ [0, 1/3] ∪ [2/3, 1] (i.e. a level of the Cantor set),
this function rescales the interval containing x back to [0, 1].
Used to iteratively extract the ternary representation of x.
theorem cantorStep_mem_cantorSet E1 #
∀ {x : ℝ}, x ∈ cantorSet → cantorStep x ∈ cantorSet
def cantorSequence E1 #
ℝ → Stream' ℝ
The infinite sequence obtained by repeatedly applying cantorStep to x.
theorem cantorSequence_mem_cantorSet E1 #
∀ {x : ℝ}, x ∈ cantorSet → ∀ (n : ℕ), (cantorSequence x).get n ∈ cantorSet
def cantorToBinary E1 #
ℝ → Stream' Bool
Points of the Cantor set correspond to infinite paths in the full binary tree.
at each level n, the set preCantorSet (n + 1) splits each interval in
preCantorSet n into two parts.
Given x ∈ cantorSet, the point x lies in one of the intervals of preCantorSet n.
This function tracks which of the two intervals in preCantorSet (n + 1)
contains x at each step, producing the corresponding path as a stream of booleans.
def cantorToTernary E3 #
ℝ → Stream' (Fin 3)
Given x in the Cantor set, return its ternary representation (d₀, d₁, …)
using only digits 0 and 2, such that x = 0.d₀d₁... in base-3.
theorem ofDigits_bool_to_fin_three_mem_cantorSet E1 #
∀ (f : ℕ → Bool), (Real.ofDigits fun i ↦ bif f i then 2 else 0) ∈ cantorSet
theorem cantorToTernary_ne_one E1 #
∀ {x : ℝ} {n : ℕ}, (cantorToTernary x).get n ≠ 1
theorem cantorSequence_get_succ E1 #
∀ (x : ℝ) (n : ℕ),
(cantorSequence x).get (n + 1) = 3 * ((cantorSequence x).get n - 3 ^ n * Real.ofDigitsTerm (cantorToTernary x).get n)
theorem cantorSequence_eq_self_sub_sum_cantorToTernary E1 #
∀ (x : ℝ) (n : ℕ),
(cantorSequence x).get n = (x - ∑ i ∈ Finset.range n, Real.ofDigitsTerm (cantorToTernary x).get i) * 3 ^ n
theorem ofDigits_cantorToTernary_sum_le E1 #
∀ {x : ℝ}, x ∈ cantorSet → ∀ {n : ℕ}, ∑ i ∈ Finset.range n, Real.ofDigitsTerm (cantorToTernary x) i ≤ x
theorem le_ofDigits_cantorToTernary_sum E1 #
∀ {x : ℝ}, x ∈ cantorSet → ∀ {n : ℕ}, x - 3⁻¹ ^ n ≤ ∑ i ∈ Finset.range n, Real.ofDigitsTerm (cantorToTernary x) i
theorem ofDigits_cantorToTernary E3 #
∀ {x : ℝ}, x ∈ cantorSet → Real.ofDigits (cantorToTernary x).get = x
theorem cantorSet_eq_zero_two_ofDigits E1 #
cantorSet = {x | ∃ a, (∀ (i : ℕ), a i ≠ 1) ∧ Real.ofDigits a = x}
def cantorSetEquivNatToBool E1 #
↑cantorSet ≃ (ℕ → Bool)
Canonical bijection between the Cantor set and infinite binary tree.
def cantorSetHomeomorphNatToBool E1 #
↑cantorSet ≃ₜ (ℕ → Bool)
Canonical homeomorphism between the Cantor set and ℕ → Bool.
def cantorSpaceHomeomorphNatToCantorSpace E1 #
(ℕ → Bool) ≃ₜ (ℕ → ℕ → Bool)
The Cantor space is homeomorphic to a countable product of copies of itself.