Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 36 Β· Projects and Practice

Project: A Small Topology Toolkit

Build a Python toolkit for finite topological spaces: closure, interior, connectedness, Hausdorff, continuity, quotients, and a census of all topologies on three points.

In this project you turn the definitions of the whole course into working code. Finite topological spaces are small enough to compute with exactly, yet they still show connectedness, continuity, quotients and homeomorphism. You will build a tiny library and then use it to count all the topologies on a three-point set.

The plan has three steps: a FiniteSpace class, a set of checks on examples, and a census of all topologies on three points up to homeomorphism.

Step 1: the data structure

A finite space is a set of points plus a family of subsets declared open. The class below checks the axioms and then offers the operations you already know by hand:

  • interior of A: the union of all open sets contained in A;
  • closure of A: the complement of the interior of the complement, or equivalently the intersection of all closed sets containing A;
  • connected: only βˆ… and the whole space are clopen;
  • Hausdorff: distinct points have disjoint open neighborhoods;
  • continuous map f: X β†’ Y between two spaces: preimages of open sets are open;
  • quotient by a partition: open iff the preimage is open.

Compactness is automatic in a finite space (every cover has a finite subcover because there are only finitely many sets), so the class only reports it.

Python FiniteSpace: axioms, closure, interior, connectedness, Hausdorff, continuity

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The assertions in __init__ mean you cannot build an invalid topology by accident; the program stops with a message. The identity from the discrete space to the SierpiΕ„ski space is continuous (a bigger topology maps to a smaller one) while the reverse fails, matching the rule that the identity (X, τ₁) β†’ (X, Ο„β‚‚) is continuous iff Ο„β‚‚ βŠ† τ₁.

Step 2: the census

How many different topologies can you put on a set of three points {a, b, c}? Choose which of the six proper nonempty subsets are open, then keep only choices closed under unions and intersections. This gives 29 topologies. Many of them are the same up to renaming the points. Two topologies are homeomorphic if some bijection of the points carries one family of open sets onto the other.

Python Census of all topologies on three points up to homeomorphism

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You should see 29 topologies in 9 homeomorphism classes, and exactly one class (the discrete topology with 8 open sets) is Hausdorff. The class sizes add up to 29. Finite spaces are Hausdorff only when they are discrete, which is why finite spaces are a good source of examples that are not Hausdorff.

Step 3: extensions

Once the toolkit works, try these:

  1. Add is_homeomorphic(other) by brute-forcing all bijections, and use it to check that two chains of the same length are homeomorphic.
  2. Add components() using minimal open neighborhoods, as in the lesson on components.
  3. Add a product constructor and verify that a product of connected finite spaces is connected.
  4. Count the topologies on four points (there are 355, falling into 33 homeomorphism classes). The search over 2^14 subsets is feasible, but give it some time.
  5. Add a chi_of_word function from the surfaces chapter and build a combined command-line report.

When you extend the toolkit, add an assertion for every theorem you rely on. For instance: every continuous bijection from a compact space to a Hausdorff space must be a homeomorphism; test this on all pairs of 3-point topologies.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. How many topologies exist on a three-point set (counting labelled points, so renamings count separately)?

    Of the 64 choices of open proper subsets, exactly 29 are closed under union and intersection.
  2. 2. When is the identity map (X, τ₁) β†’ (X, Ο„β‚‚) continuous?

    Continuity needs every Ο„β‚‚-open set to be τ₁-open.
  3. 3. Which finite topological spaces are Hausdorff?

    In a finite Hausdorff space every point can be separated from all others, so singletons are open, and the topology is discrete.
  4. 4. What does is_connected count in the toolkit?

    A space is connected iff its only clopen sets are βˆ… and the whole space.

Summary

  • A finite topological space can be stored as a set of points plus a family of open sets, with the axioms checked by assertions.
  • Interior, closure, connectedness, Hausdorffness, continuity and quotients are all short computations.
  • There are 29 topologies on three labelled points and 9 up to homeomorphism.
  • A finite Hausdorff space is discrete.
  • Extending the toolkit is a good way to test every theorem of the course on small cases.

Back to the Topology track for the rest of the course.