Metric, Proximity, And Function Spaces
Many ML systems start with vectors, distances, and functions. Topology provides the rules for when those distances and functions behave consistently.
Status: active prototypes for metric covers, finite-probe weak convergence, and Euclidean point-cloud/time-delay embeddings. General metric objects and full function-space topology remain future work.
Metric Spaces
A metric \(d : X \times X \to \mathbb{R}_{\ge 0}\) must satisfy:
ML translation: distance is not just an implementation detail. It determines nearest neighbors, persistence radii, clustering behavior, approximate search, and routing cells.
Cauchy Behavior
A sequence \((x_n)\) is Cauchy when:
ML translation: a training run, streaming embedding, or online summary may look stable if its later states become mutually close. This is different from being close to a known target.
Uniform Spaces
Uniform spaces generalize metric spaces by describing nearness through entourages rather than one fixed distance function. An entourage is a subset:
If \((x,y) \in U\), then \(x\) and \(y\) are considered close under that tolerance.
ML translation: this is useful when a backend needs tolerance contracts across mixed precision, approximate kernels, quantized features, or hardware-specific distance paths.
Proximity Spaces
Proximity spaces describe when sets are near each other, not only when points are near each other. Write:
to mean set \(A\) is near set \(B\).
ML translation: this is a natural language for cluster-level drift, batch overlap, cache reuse, and feature-store consistency.
flowchart LR
A["Point distance"] --> B["Metric space"]
C["Tolerance relation"] --> D["Uniform space"]
E["Set nearness"] --> F["Proximity space"]
B --> G["Persistence and kNN"]
D --> H["Backend tolerance contracts"]
F --> I["Batch, cache, and drift decisions"]
Topological Vector Spaces
A topological vector space is a vector space with a topology where addition and scalar multiplication are continuous:
ML translation: this is the foundation for talking about convergence of model parameters, embeddings, kernels, gradients, and distributions beyond finite Euclidean arrays.
Seminorm Neighborhoods
A seminorm \(p\) behaves like a norm but may assign zero to nonzero vectors. Neighborhoods can be described by:
Multiple seminorms can define different notions of closeness.
ML translation: one model update can be small under a weak diagnostic and large under another. That matters for monitoring and distribution shift.
Weak Convergence
A sequence \(x_n\) converges weakly to \(x\) when every continuous linear functional \(\phi\) sees convergence:
ML translation: weak convergence is relevant when models or distributions converge under tests or projections even if they do not converge strongly in norm.
flowchart TB
A["Function or distribution sequence"] --> B["Strong norm check"]
A --> C["Projection / test function checks"]
B --> D["May be too strict or too expensive"]
C --> E["Weak convergence signal"]
E --> F["Distribution shift or optimizer stability diagnostic"]
Prototype: topoml.weak_convergence_residual evaluates the last element of a
finite sequence against a limit under finite linear probes:
It also reports the strong norm residual. This makes projection-level drift visible without claiming a proof of mathematical weak convergence.
API Direction
Future metric and function-space APIs should expand toward:
- explicit metric objects;
- tolerance contracts for backend equivalence;
- neighborhood samplers;
- drift diagnostics over sets;
- richer weak convergence tests over selected probes;
- benchmark artifacts comparing against norm-only drift checks.
No broad metric or function-space API should be called complete until it has unit tests, E2E examples, and a failure case where it adds information beyond ordinary Euclidean distance.