Hausdorff Distance

lean4-prooffractal-geometrymetricvisualization
dH(A,B)=max(supaAd(a,B), supbBd(b,A))d_H(A, B) = \max\left(\sup_{a \in A} d(a, B),\ \sup_{b \in B} d(b, A)\right)

Definition

Let (X,d)(X, d) be a metric space and A,BXA, B \subseteq X non-empty subsets. The Hausdorff distance between AA and BB is

dH(A,B)=max(supaAinfbBd(a,b), supbBinfaAd(a,b)).d_H(A, B) = \max\left(\sup_{a \in A} \inf_{b \in B} d(a, b),\ \sup_{b \in B} \inf_{a \in A} d(a, b)\right).

An equivalent characterisation uses ε\varepsilon-thickenings Aε={xX:infaAd(x,a)ε}A_\varepsilon = \{x \in X : \inf_{a \in A} d(x, a) \leq \varepsilon\}:

dH(A,B)=inf{ε0:ABε and BAε}.d_H(A, B) = \inf\{\varepsilon \geq 0 : A \subseteq B_\varepsilon \text{ and } B \subseteq A_\varepsilon\}.

Intuitively, dH(A,B)εd_H(A, B) \leq \varepsilon means every point of AA has a partner in BB within ε\varepsilon, and vice versa.

Examples

Two points. dH({p},{q})=d(p,q)d_H(\{p\}, \{q\}) = d(p, q) — the Hausdorff distance reduces to the underlying metric on singletons.

Concentric circles. Let CrC_r and CRC_R be circles of radii r<Rr < R centred at the origin in R2\mathbb{R}^2. Then dH(Cr,CR)=Rrd_H(C_r, C_R) = R - r.

A point and a set. dH({p},A)=supaAd(p,a)d_H(\{p\}, A) = \sup_{a \in A} d(p, a) — the diameter of AA as seen from pp.

Nested squares. A square S[0,1]2S \subset [0,1]^2 of side 1/21/2 centred in the unit square has dH(S,[0,1]2)=24d_H(S, [0,1]^2) = \tfrac{\sqrt{2}}{4} — the distance from the centre of SS to a corner of [0,1]2[0,1]^2 minus the distance to a corner of SS.

Cantor approximations. Let CnC_n be the nn-th iterate of the middle-thirds Cantor construction (so C0=[0,1]C_0 = [0,1], C1=[0,1/3][2/3,1]C_1 = [0, 1/3] \cup [2/3, 1], …). Then dH(Cn,C)0d_H(C_n, C) \to 0 as nn \to \infty, where CC is the Cantor set itself. This is the Hausdorff-metric statement that the IFSIterated Function SystemsA=i=1Nfi(A)A = \bigcup_{i=1}^{N} f_i(A)Constructing fractals via contractive affine transformationsRead more → iteration converges.

The Space of Compact Sets

Let K(X)\mathcal{K}^*(X) denote the set of non-empty compact subsets of XX. The fundamental result is:

Theorem (Hausdorff completeness). If (X,d)(X, d) is complete, then (K(X),dH)(\mathcal{K}^*(X), d_H) is a complete metric space. If XX is compact, so is K(X)\mathcal{K}^*(X).

This is the platform on which the Iterated Function SystemsIterated Function SystemsA=i=1Nfi(A)A = \bigcup_{i=1}^{N} f_i(A)Constructing fractals via contractive affine transformationsRead more → attractor theorem is built: the Hutchinson operator F(K)=ifi(K)F(K) = \bigcup_i f_i(K) acts on K(X)\mathcal{K}^*(X), and the contraction ratios of the fif_i transfer to a contraction ratio for FF in the Hausdorff metric.

Why Hausdorff Distance for Fractals

Pointwise convergence is too weak for fractal sets — the Cantor set has Lebesgue measure zero, so any "LpL^p" sense of convergence collapses. The Hausdorff metric instead measures shape convergence: KnKK_n \to K in dHd_H iff every point of KK is approximated by points of KnK_n and vice versa, uniformly. This is exactly the notion needed to make sense of "the attractor is the limit of Fn(K0)F^n(K_0) for any starting compact K0K_0".

Connections

The Hausdorff metric makes the Iterated Function SystemsIterated Function SystemsA=i=1Nfi(A)A = \bigcup_{i=1}^{N} f_i(A)Constructing fractals via contractive affine transformationsRead more → attractor a Banach fixed point. Beyond fractals, dHd_H is the standard tool for shape comparison in image processing, computational geometry (e.g. mesh similarity), and optimal transport relaxations.

Lean4 Proof

import Mathlib.Topology.MetricSpace.HausdorffDistance
import Mathlib.Topology.MetricSpace.Closeds

open Metric Set TopologicalSpace

/-- Hausdorff distance between two non-empty bounded sets in a metric space. -/
noncomputable def hausdorffDist {X : Type*} [PseudoMetricSpace X] (A B : Set X) :  :=
  Metric.hausdorffDist A B

/-- Singleton case: d_H({p}, {q}) = d(p, q). -/
example {X : Type*} [MetricSpace X] (p q : X) :
    Metric.hausdorffDist ({p} : Set X) {q} = dist p q := by
  simp [hausdorffDist_singleton]

/-- The space of non-empty compact subsets of a complete metric space is complete
    under the Hausdorff distance. (Mathlib: `NonemptyCompacts.completeSpace`.) -/
example {X : Type*} [MetricSpace X] [CompleteSpace X] :
    CompleteSpace (NonemptyCompacts X) := inferInstance