Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Many ways to measure “how far”
A bird flies straight from home to school. A taxi has to follow the street grid. A chess king moves one square in any direction, so for the king, “distance” is the number of moves. All three are reasonable distances, and they give different numbers.
Distance doesn’t have to be about places. How far apart are the words “robot” and “rocket”? Count the letter edits needed to turn one into the other. Any rule like this that behaves sensibly is called a metric.
“Sensible” means three rules: you are 0 away from yourself (and only from yourself), the distance from A to B equals the distance from B to A, and a detour is never shorter than going direct.
A robot planner needs a distance between robot poses. A spell-checker needs one between words. A reinforcement-learning agent needs one between value tables. The right metric makes algorithms provably converge, and the wrong one can quietly break them.
- 1. Taxi distance from (0,0) to (3,4) on a grid?
- 2. The bird's straight-line distance for the same trip?
- 3. Can a detour through C be shorter than going direct from A to B?
Level 1: Beginner
★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.The axioms and the usual examples
A metric space is a set with a function such that, for all :
- , and exactly when ;
- ;
- (the triangle inequality).
| Metric | Formula | Unit ball in the plane |
|---|---|---|
| Euclidean | circle | |
| Manhattan | diamond | |
| Chebyshev | square | |
| discrete | 0 if equal, else 1 | a single point |
| Hamming (strings) | number of differing positions | |
| edit (Levenshtein) | fewest insert/delete/substitute operations |
Not metrics:
- squared Euclidean distance (the triangle inequality fails);
- cosine “distance” (parallel vectors get distance 0, and the triangle inequality can fail);
- the formula with (the triangle inequality fails, as the demo shows).
- 1. Chebyshev distance from (1,2) to (4,−2)?
- 2. Hamming distance between 10110 and 11100?
- 3. Is squared Euclidean distance a metric?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.Convergence, Cauchy sequences, completeness
A sequence converges to if . It is Cauchy if its terms get close to each other: for every there is an such that for all . The Cauchy test doesn’t need to know the limit in advance, which makes it the practical one.
Every convergent sequence is Cauchy. The converse can fail. Newton’s iterates for are all rational and Cauchy, but . A space where every Cauchy sequence converges is complete:
- complete: with any norm, closed subsets of complete spaces, and the continuous functions on with the sup metric (A3.5-2);
- not complete: , the interval , and polynomials under the sup metric.
Beware the trap of steps shrinking to zero. For , each step , yet . That’s not Cauchy, and the sequence diverges.
Open, closed, compact
- The open ball is . A set is open if each of its points has a ball inside the set. It is closed if it contains the limits of its convergent sequences.
- A set is compact if every sequence in it has a subsequence converging in the set. In , that’s exactly the closed and bounded sets (Heine–Borel).
- Why it matters: a continuous function on a compact set attains its maximum and minimum (the extreme value theorem). That’s how you know an optimal policy, a best fit, or a minimum-energy configuration exists before you try to compute it.
- 1. Every convergent sequence is Cauchy. The converse holds in…
- 2. Is (0, 1] complete with |x − y|?
- 3. Compact subsets of ℝⁿ are exactly the…
Level 3: Advanced
★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.Banach’s fixed-point theorem
Theorem. Let be complete and a contraction: with . Then has exactly one fixed point . The iterates converge to it from any start, with .
Proof.
- Steps shrink geometrically. .
- The iterates are Cauchy. For , the triangle inequality and a geometric series give .
- A limit exists. By completeness, .
- It’s a fixed point. is continuous (Lipschitz), so .
- It’s unique. If , then , which forces .
Letting in step 2 gives the error bound. ∎
Completeness is essential. On , the contraction (near ) has no fixed point.
Bolzano–Weierstrass
Every bounded sequence in has a convergent subsequence. Proof by bisection: one half of the interval contains infinitely many terms, so keep that half and repeat. The nested intervals shrink to a point, and choosing one term from each with increasing indices gives a Cauchy subsequence. By completeness of , it converges (Practice Code 4). Extending this coordinate by coordinate proves Heine–Borel in .
In infinite dimensions, closed and bounded is not enough
In , the unit vectors are bounded, but for all . No subsequence is Cauchy. The right characterization is compact ⇔ complete and totally bounded, where totally bounded means a finite -net exists for every . This is why function spaces need extra conditions, such as equicontinuity in Arzelà–Ascoli, to guarantee compactness.
Exercise 3.1: Prove that every convergent sequence is Cauchy
Suppose and . Pick with for . Then for , . ∎
- 1. Banach's theorem needs the space to be…
- 2. The a-priori error after k steps is at most…
- 3. The unit vectors in ℓ² have a convergent subsequence?
Level 4: Expert
★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.Contractions in reinforcement learning
The Bellman optimality operator is a -contraction in the sup norm: , because a max of averages can’t move further than the inputs. The space of bounded value functions is complete. So Banach’s theorem says the optimal value function exists and is unique, and value iteration converges to it at rate (Bellman, 1957; Puterman, 1994; Bertsekas, 2012). Policy evaluation, Q-learning’s convergence proofs and many TD analyses rest on the same fact.
Metrics everywhere in AI and robotics
- Metric learning. Siamese and triplet networks learn embeddings where Euclidean distance means semantic similarity (Schroff et al., 2015, FaceNet). Retrieval and place recognition for robot localization use this.
- Distances between distributions. The Wasserstein metric (optimal transport) metrizes weak convergence and gives Wasserstein GANs their stable gradients (Arjovsky et al., 2017). KL divergence is not a metric: it’s asymmetric and has no triangle inequality.
- Covering numbers and generalization. If a function class has an -net of size , uniform-convergence bounds scale like (B1, B2). How fast grows is the “metric entropy”, which reveals the intrinsic dimension (Practice Code 5).
- Robot configuration spaces. Distances on (rotation angle) and drive sampling planners like RRT and PRM (LaValle, 2006). Their probabilistic completeness proofs rely on compactness of the free space.
- Existence of optimal controls. Compactness of the admissible set plus lower semicontinuity of the cost (Weierstrass/Tonelli) guarantees an optimal trajectory exists, as in Filippov’s theorem.
References
- W. Rudin (1976). Principles of Mathematical Analysis, 3rd ed. McGraw-Hill.
- E. Kreyszig (1978). Introductory Functional Analysis with Applications. Wiley.
- S. Banach (1922). “Sur les opérations dans les ensembles abstraits et leur application aux équations intégrales.” Fundamenta Mathematicae, 3.
- M. Puterman (1994). Markov Decision Processes. Wiley.
- D. Bertsekas (2012). Dynamic Programming and Optimal Control, Vol. II, 4th ed. Athena Scientific.
- F. Schroff, D. Kalenichenko, J. Philbin (2015). “FaceNet: a unified embedding for face recognition and clustering.” CVPR.
- M. Arjovsky, S. Chintala, L. Bottou (2017). “Wasserstein generative adversarial networks.” ICML.
- S. LaValle (2006). Planning Algorithms. Cambridge.
- V. Levenshtein (1966). “Binary codes capable of correcting deletions, insertions, and reversals.” Soviet Physics Doklady, 10.