# Hausdorff distance #

The Hausdorff distance on subsets of a metric (or emetric) space.

Given two subsets `s`

and `t`

of a metric space, their Hausdorff distance is the smallest `d`

such that any point `s`

is within `d`

of a point in `t`

, and conversely. This quantity
is often infinite (think of `s`

bounded and `t`

unbounded), and therefore better
expressed in the setting of emetric spaces.

## Main definitions #

This files introduces:

`EMetric.infEdist x s`

, the infimum edistance of a point`x`

to a set`s`

in an emetric space`EMetric.hausdorffEdist s t`

, the Hausdorff edistance of two sets in an emetric space- Versions of these notions on metric spaces, called respectively
`Metric.infDist`

and`Metric.hausdorffDist`

## Main results #

`infEdist_closure`

: the edistance to a set and its closure coincide`EMetric.mem_closure_iff_infEdist_zero`

: a point`x`

belongs to the closure of`s`

iff`infEdist x s = 0`

`IsCompact.exists_infEdist_eq_edist`

: if`s`

is compact and non-empty, there exists a point`y`

which attains this edistance`IsOpen.exists_iUnion_isClosed`

: every open set`U`

can be written as the increasing union of countably many closed subsets of`U`

`hausdorffEdist_closure`

: replacing a set by its closure does not change the Hausdorff edistance`hausdorffEdist_zero_iff_closure_eq_closure`

: two sets have Hausdorff edistance zero iff their closures coincidethe Hausdorff edistance is symmetric and satisfies the triangle inequality

in particular, closed sets in an emetric space are an emetric space (this is shown in

`EMetricSpace.closeds.emetricspace`

)versions of these notions on metric spaces

`hausdorffEdist_ne_top_of_nonempty_of_bounded`

: if two sets in a metric space are nonempty and bounded in a metric space, they are at finite Hausdorff edistance.

## Tags #

metric space, Hausdorff distance

### Distance of a point to a set as a function into `ℝ≥0∞`

. #

The minimal edistance of a point to a set

## Equations

- EMetric.infEdist x s = ⨅ y ∈ s, edist x y

## Instances For

The edist to a union is the minimum of the edists

The edist to a singleton is the edistance to the single point of this singleton

The edist to a set is bounded above by the edist to any of its points

If a point `x`

belongs to `s`

, then its edist to `s`

vanishes

The edist is antitone with respect to inclusion.

The edist to a set is `< r`

iff there exists a point in the set at edistance `< r`

The edist of `x`

to `s`

is bounded by the sum of the edist of `y`

to `s`

and
the edist from `x`

to `y`

The edist to a set depends continuously on the point

The edist to a set and to its closure coincide

A point belongs to the closure of `s`

iff its infimum edistance to this set vanishes

Given a closed set `s`

, a point belongs to `s`

iff its infimum edistance to this set vanishes

The infimum edistance of a point to a set is positive if and only if the point is not in the closure of the set.

The infimum edistance is invariant under isometries

### The Hausdorff distance as a function into `ℝ≥0∞`

. #

The Hausdorff edistance between two sets is the smallest `r`

such that each set
is contained in the `r`

-neighborhood of the other one

## Equations

## Instances For

The Hausdorff edistance of a set to itself vanishes.

The Haudorff edistances of `s`

to `t`

and of `t`

to `s`

coincide.

Bounding the Hausdorff edistance by bounding the edistance of any point in each set to the other set

Bounding the Hausdorff edistance by exhibiting, for any point in each set, another point in the other set at controlled distance

The distance to a set is controlled by the Hausdorff distance.

If the Hausdorff distance is `< r`

, then any point in one of the sets has
a corresponding point at distance `< r`

in the other set.

The distance from `x`

to `s`

or `t`

is controlled in terms of the Hausdorff distance
between `s`

and `t`

.

The Hausdorff edistance is invariant under isometries.

The Hausdorff distance is controlled by the diameter of the union.

The Hausdorff distance satisfies the triangle inequality.

Two sets are at zero Hausdorff edistance if and only if they have the same closure.

The Hausdorff edistance between a set and its closure vanishes.

Replacing a set by its closure does not change the Hausdorff edistance.

Replacing a set by its closure does not change the Hausdorff edistance.

The Hausdorff edistance between sets or their closures is the same.

Two closed sets are at zero Hausdorff edistance if and only if they coincide.

The Haudorff edistance to the empty set is infinite.

If a set is at finite Hausdorff edistance of a nonempty set, it is nonempty.

Now, we turn to the same notions in metric spaces. To avoid the difficulties related to
`sInf`

and `sSup`

on `ℝ`

(which is only conditionally complete), we use the notions in `ℝ≥0∞`

formulated in terms of the edistance, and coerce them to `ℝ`

.
Then their properties follow readily from the corresponding properties in `ℝ≥0∞`

,
modulo some tedious rewriting of inequalities from one to the other.

### Distance of a point to a set as a function into `ℝ`

. #

The minimal distance of a point to a set

## Equations

- Metric.infDist x s = (EMetric.infEdist x s).toReal

## Instances For

The minimal distance is always nonnegative

The minimal distance to the empty set is 0 (if you want to have the more reasonable
value `∞`

instead, use `EMetric.infEdist`

, which takes values in `ℝ≥0∞`

)

In a metric space, the minimal edistance to a nonempty set is finite.

The minimal distance of a point to a set containing it vanishes.

The minimal distance to a singleton is the distance to the unique point in this singleton.

The minimal distance to a set is bounded by the distance to any point in this set.

The minimal distance is monotone with respect to inclusion.

The minimal distance to a set `s`

is `< r`

iff there exists a point in `s`

at distance `< r`

.

The minimal distance from `x`

to `s`

is bounded by the distance from `y`

to `s`

, modulo
the distance between `x`

and `y`

.

The minimal distance to a set is Lipschitz in point with constant 1

The minimal distance to a set is uniformly continuous in point

The minimal distance to a set is continuous in point

The minimal distances to a set and its closure coincide.

If a point belongs to the closure of `s`

, then its infimum distance to `s`

equals zero.
The converse is true provided that `s`

is nonempty, see `Metric.mem_closure_iff_infDist_zero`

.

A point belongs to the closure of `s`

iff its infimum distance to this set vanishes.

Given a closed set `s`

, a point belongs to `s`

iff its infimum distance to this set vanishes

Given a closed set `s`

, a point belongs to `s`

iff its infimum distance to this set vanishes.

The infimum distance is invariant under isometries.

### Distance of a point to a set as a function into `ℝ≥0`

. #

The minimal distance of a point to a set as a `ℝ≥0`

## Equations

- Metric.infNndist x s = (EMetric.infEdist x s).toNNReal

## Instances For

The minimal distance to a set (as `ℝ≥0`

) is Lipschitz in point with constant 1

The minimal distance to a set (as `ℝ≥0`

) is uniformly continuous in point

The minimal distance to a set (as `ℝ≥0`

) is continuous in point

### The Hausdorff distance as a function into `ℝ`

. #

The Hausdorff distance between two sets is the smallest nonnegative `r`

such that each set is
included in the `r`

-neighborhood of the other. If there is no such `r`

, it is defined to
be `0`

, arbitrarily.

## Equations

- Metric.hausdorffDist s t = (EMetric.hausdorffEdist s t).toReal

## Instances For

The Hausdorff distance is nonnegative.

If two sets are nonempty and bounded in a metric space, they are at finite Hausdorff edistance.

The Hausdorff distance between a set and itself is zero.

The Hausdorff distances from `s`

to `t`

and from `t`

to `s`

coincide.

The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable
value `∞`

instead, use `EMetric.hausdorffEdist`

, which takes values in `ℝ≥0∞`

).

The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable
value `∞`

instead, use `EMetric.hausdorffEdist`

, which takes values in `ℝ≥0∞`

).

Bounding the Hausdorff distance by bounding the distance of any point in each set to the other set

Bounding the Hausdorff distance by exhibiting, for any point in each set, another point in the other set at controlled distance

The Hausdorff distance is controlled by the diameter of the union.

The distance to a set is controlled by the Hausdorff distance.

If the Hausdorff distance is `< r`

, any point in one of the sets is at distance
`< r`

of a point in the other set.

If the Hausdorff distance is `< r`

, any point in one of the sets is at distance
`< r`

of a point in the other set.

The infimum distance to `s`

and `t`

are the same, up to the Hausdorff distance
between `s`

and `t`

The Hausdorff distance is invariant under isometries.

The Hausdorff distance satisfies the triangle inequality.

The Hausdorff distance satisfies the triangle inequality.

The Hausdorff distance between a set and its closure vanishes.

Replacing a set by its closure does not change the Hausdorff distance.

Replacing a set by its closure does not change the Hausdorff distance.

The Hausdorff distances between two sets and their closures coincide.

Two sets are at zero Hausdorff distance if and only if they have the same closures.

Two closed sets are at zero Hausdorff distance if and only if they coincide.