Topology

Finite spaces

A topology on a finite set is a finite list of open sets, so every definition in a first topology course can be checked by hand, or by machine. Finite spaces are also a good source of examples that are connected but not Hausdorff.

Open sets and the axioms

A family of subsets of XX is a topology when it contains ∅\varnothing and XX and is closed under unions and intersections; for a finite family, pairs are enough. finiteSpace(points, opens) checks the axioms and names a failing pair when they do not hold. A basis generates a topology when it covers XX and every point of B1∩B2B_1 \cap B_2 lies in a basis set inside B1∩B2B_1 \cap B_2; fromBasis checks that and takes all unions.

import { finiteSpace, fromBasis } from "@ratmath/geo";

const X = finiteSpace(["a", "b", "c"], [[], ["a"], ["a", "b"], ["a", "b", "c"]]);
X.closure(["b"]);        // ["b", "c"]: the smallest closed set containing b
X.interior(["b", "c"]);  // []: no open set inside {b, c} but ∅
X.boundary(["a"]);       // ["b", "c"]
finiteSpace([1, 2, 3], [[], [1], [2], [1, 2, 3]]);   // refused: the union of {1} and {2} is not open
fromBasis([1, 2, 3], [[1, 2], [2, 3], [2]]).opens;   // [[], [2], [1, 2], [2, 3], [1, 2, 3]]

Minimal open sets and preorders

In a finite space each point xx has a smallest open set UxU_x, the intersection of all open sets containing it, and these form the smallest basis. Write x≤yx \le y when y∈Uxy \in U_x. This is a preorder (reflexive and transitive), and the open sets are exactly its up-sets. So topologies on XX are the same as preorders on XX. The space is T0T_0 when distinct points have distinct UxU_x, which makes the preorder a partial order. T1T_1 means every Ux={x}U_x = \{x\}: the discrete topology.

import { fromPreorder, countTopologies } from "@ratmath/geo";

fromPreorder([1, 2, 3], [[1, 2], [2, 3]]).opens;   // [[], [3], [2, 3], [1, 2, 3]]: a chain
countTopologies(3);                 // 29
countTopologies(3, { t0: true });   // 19
[1, 2, 3, 4, 5].map((n) => countTopologies(n));   // [1, 4, 29, 355, 6942]

The count runs through every reflexive relation and keeps the transitive ones. The tests check it against brute force, every family of subsets tested against the axioms, up to four points.

Continuity and connectedness

A map is continuous when the preimage of every open set is open; continuity returns an open set whose preimage fails when it is not. A finite space is connected when the points are linked through their minimal open sets, and then it is also path connected. The pseudocircle, four points with {a}\{a\}, {b}\{b\} open, is connected, not Hausdorff, and has the weak homotopy type of a circle.

import { finiteSpaces } from "@ratmath/geo";
const S = finiteSpaces.sierpinski();          // {0, 1} with ∅, {1}, {0, 1} open
S.continuity((x) => 1 - x, S);               // { continuous: false, witness: { open: [1], preimage: [0] } }
finiteSpaces.pseudocircle().isConnected;      // true
Try itEdit the code and run it with @ratmath/geo and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs