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 is a topology when it contains and 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 and every point of lies in a basis set inside ; 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 has a smallest open set , the intersection of all open sets containing it, and these form the smallest basis. Write when . This is a preorder (reflexive and transitive), and the open sets are exactly its up-sets. So topologies on are the same as preorders on . The space is when distinct points have distinct , which makes the preorder a partial order. means every : 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 , 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
@ratmath/geo and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.