Metric spaces #
This file defines metric spaces. Many definitions and theorems expected on metric spaces are already introduced on uniform spaces and topological spaces. For example: open and closed sets, compactness, completeness, continuity and uniform continuity
Main definitions #
Dist α
: Endows a spaceα
with a functiondist a b
.PseudoMetricSpace α
: A space endowed with a distance function, which can be zero even if the two elements are non-equal.Metric.ball x ε
: The set of all pointsy
withdist y x < ε
.Metric.Bounded s
: Whether a subset of aPseudoMetricSpace
is bounded.MetricSpace α
: APseudoMetricSpace
with the guaranteedist x y = 0 → x = y
.
Additional useful definitions:
nndist a b
:dist
as a function to the non-negative reals.Metric.closedBall x ε
: The set of all pointsy
withdist y x ≤ ε
.Metric.sphere x ε
: The set of all pointsy
withdist y x = ε
.ProperSpace α
: APseudoMetricSpace
where all closed balls are compact.Metric.diam s
: TheiSup
of the distances of members ofs
. Defined in terms ofEMetric.diam
, for better handling of the case when it should be infinite.
TODO (anyone): Add "Main results" section.
Implementation notes #
Since a lot of elementary properties don't require eq_of_dist_eq_zero
we start setting up the
theory of PseudoMetricSpace
, where we don't require dist x y = 0 → x = y
and we specialize
to MetricSpace
at the end.
Tags #
metric, pseudo_metric, dist
Construct a uniform structure from a distance function and metric space axioms
Equations
- UniformSpace.ofDist dist dist_self dist_comm dist_triangle = UniformSpace.ofFun dist dist_self dist_comm dist_triangle UniformSpace.ofDist.proof_1
Instances For
Construct a bornology from a distance function and metric space axioms.
Equations
- One or more equations did not get rendered due to their size.
Instances For
- dist : α → α → ℝ
- edist : α → α → ENNReal
- edist_dist : ∀ (x y : α), PseudoMetricSpace.edist x y = ENNReal.ofReal (dist x y)
- toUniformSpace : UniformSpace α
- uniformity_dist : uniformity α = ⨅ (ε : ℝ) (_ : ε > 0), Filter.principal {p | dist p.fst p.snd < ε}
- toBornology : Bornology α
Pseudo metric and Metric spaces
A pseudo metric space is endowed with a distance for which the requirement d(x,y)=0 → x = y
might
not hold. A metric space is a pseudo metric space such that d(x,y)=0 → x = y
.
Each pseudo metric space induces a canonical UniformSpace
and hence a canonical
TopologicalSpace
This is enforced in the type class definition, by extending the UniformSpace
structure. When instantiating a PseudoMetricSpace
structure, the uniformity fields are not
necessary, they will be filled in by default. In the same way, each (pseudo) metric space induces a
(pseudo) emetric space structure. It is included in the structure, but filled in by default.
Instances
Two pseudo metric space structures with the same distance function coincide.
Equations
- PseudoMetricSpace.toEDist = { edist := PseudoMetricSpace.edist }
Construct a pseudo-metric space structure whose underlying topological space structure (definitionally) agrees which a pre-existing topology which is compatible with a given distance function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The triangle (polygon) inequality for sequences of points; Finset.Ico
version.
The triangle (polygon) inequality for sequences of points; Finset.range
version.
A version of dist_le_Ico_sum_dist
with each intermediate distance replaced
with an upper estimate.
A version of dist_le_range_sum_dist
with each intermediate distance replaced
with an upper estimate.
Extension for the positivity
tactic: distances are nonnegative.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Distance as a nonnegative real number.
In a pseudometric space, the extended distance is always finite
In a pseudometric space, the extended distance is always finite
nndist x x
vanishes
Triangle inequality for the nonnegative distance
If a point belongs to an open ball, then there is a strictly smaller radius whose ball also contains it.
See also exists_lt_subset_ball
.
closedBall x ε
is the set of all points y
with dist y x ≤ ε
Equations
- Metric.closedBall x ε = {y | dist y x ≤ ε}
Instances For
Closed balls and spheres coincide when the radius is non-positive
If a property holds for all points in closed balls of arbitrarily large radii, then it holds for all points.
If a property holds for all points in balls of arbitrarily large radii, then it holds for all points.
Given f : β → ℝ
, if f
sends {i | p i}
to a set of positive numbers
accumulating to zero, then f i
-neighborhoods of the diagonal form a basis of 𝓤 α
.
For specific bases see uniformity_basis_dist
, uniformity_basis_dist_inv_nat_succ
,
and uniformity_basis_dist_inv_nat_pos
.
Given f : β → ℝ
, if f
sends {i | p i}
to a set of positive numbers
accumulating to zero, then closed neighborhoods of the diagonal of sizes {f i | p i}
form a basis of 𝓤 α
.
Currently we have only one specific basis uniformity_basis_dist_le
based on this constructor.
More can be easily added if needed in the future.
Constant size closed neighborhoods of the diagonal form a basis of the uniformity filter.
A constant size neighborhood of the diagonal is an entourage.
If a map between pseudometric spaces is a uniform embedding then the distance between f x
and f y
is controlled in terms of the distance between x
and y
.
A pseudometric space is totally bounded if one can reconstruct up to any ε>0 any element of the space from finitely many data.
Expressing uniform convergence using dist
Expressing locally uniform convergence on a set using dist
.
Expressing uniform convergence on a set using dist
.
Expressing locally uniform convergence using dist
.
Expressing uniform convergence using dist
.
A version of Filter.eventually_prod_iff
where the first filter consists of neighborhoods
in a pseudo-metric space.
A version of Filter.eventually_prod_iff
where the second filter consists of neighborhoods
in a pseudo-metric space.
A variant of tendsto_atTop
that
uses ∃ N, ∀ n > N, ...
rather than ∃ N, ∀ n ≥ N, ...
Given a point x
in a discrete subset s
of a pseudometric space, there is an open ball
centered at x
and intersecting s
only at x
.
Given a point x
in a discrete subset s
of a pseudometric space, there is a closed ball
of positive radius centered at x
and intersecting s
only at x
.
A pseudometric space induces a pseudoemetric space
Equations
- One or more equations did not get rendered due to their size.
Expressing the uniformity in terms of edist
In a pseudometric space, an open ball of infinite radius is the whole space
Balls defined using the distance or the edistance coincide
Balls defined using the distance or the edistance coincide
Closed balls defined using the distance or the edistance coincide
Closed balls defined using the distance or the edistance coincide
Build a new pseudometric space from an old one where the bundled uniform structure is provably (but typically non-definitionaly) equal to some given uniform structure. See Note [forgetful inheritance].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Build a new pseudo metric space from an old one where the bundled topological structure is provably (but typically non-definitionaly) equal to some given topological structure. See Note [forgetful inheritance].
Equations
Instances For
One gets a pseudometric space from an emetric space if the edistance is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the uniformity are defeq in the pseudometric space and the pseudoemetric space. In this definition, the distance is given separately, to be able to prescribe some expression which is not defeq to the push-forward of the edistance to reals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One gets a pseudometric space from an emetric space if the edistance is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the uniformity are defeq in the pseudometric space and the emetric space.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Build a new pseudometric space from an old one where the bundled bornology structure is provably (but typically non-definitionaly) equal to some given bornology structure. See Note [forgetful inheritance].
Equations
- One or more equations did not get rendered due to their size.
Instances For
A very useful criterion to show that a space is complete is to show that all sequences
which satisfy a bound of the form dist (u n) (u m) < B N
for all n m ≥ N
are
converging. This is often applied for B N = 2^{-N}
, i.e., with a very fast convergence to
0
, which makes it possible to use arguments of converging series, while this is impossible
to do in general for arbitrary Cauchy sequences.
Instantiate the reals as a pseudometric space.
Equations
- One or more equations did not get rendered due to their size.
Special case of the sandwich theorem; see tendsto_of_tendsto_of_tendsto_of_le_of_le'
for the
general case.
Special case of the sandwich theorem; see tendsto_of_tendsto_of_tendsto_of_le_of_le
and tendsto_of_tendsto_of_tendsto_of_le_of_le'
for the general case.
Alias of Filter.Tendsto.congr_dist
.
If u
is a neighborhood of x
, then for small enough r
, the closed ball
Metric.closedBall x r
is contained in u
.
In a pseudometric space, Cauchy sequences are characterized by the fact that, eventually, the distance between its elements is arbitrarily small
A variation around the pseudometric characterization of Cauchy sequences
In a pseudometric space, uniform Cauchy sequences are characterized by the fact that, eventually, the distance between all its elements is uniformly, arbitrarily small
If the distance between s n
and s m
, n ≤ m
is bounded above by b n
and b
converges to zero, then s
is a Cauchy sequence.
If the distance between s n
and s m
, n, m ≥ N
is bounded above by b N
and b
converges to zero, then s
is a Cauchy sequence.
Yet another metric characterization of Cauchy sequences on integers. This one is often the most efficient.
Pseudometric space structure pulled back by a function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pull back a pseudometric space structure by an inducing map. This is a version of
PseudoMetricSpace.induced
useful in case if the domain already has a TopologicalSpace
structure.
Equations
- Inducing.comapPseudoMetricSpace hf = PseudoMetricSpace.replaceTopology (PseudoMetricSpace.induced f m) (_ : inst = TopologicalSpace.induced f UniformSpace.toTopologicalSpace)
Instances For
Pull back a pseudometric space structure by a uniform inducing map. This is a version of
PseudoMetricSpace.induced
useful in case if the domain already has a UniformSpace
structure.
Equations
- UniformInducing.comapPseudoMetricSpace f h = PseudoMetricSpace.replaceUniformity (PseudoMetricSpace.induced f m) (_ : uniformity α = Filter.comap (fun x => (f x.fst, f x.snd)) (uniformity β))
Instances For
Equations
- Subtype.pseudoMetricSpace = PseudoMetricSpace.induced Subtype.val inst
Equations
- AddOpposite.instPseudoMetricSpaceAddOpposite = PseudoMetricSpace.induced AddOpposite.unop inst
Equations
- MulOpposite.instPseudoMetricSpaceMulOpposite = PseudoMetricSpace.induced MulOpposite.unop inst
Equations
- instPseudoMetricSpaceNNReal = Subtype.pseudoMetricSpace
Equations
- instPseudoMetricSpaceULift = PseudoMetricSpace.induced ULift.down inst
Equations
- One or more equations did not get rendered due to their size.
The preimage of a separable set by an inducing map is separable.
If a map is continuous on a separable set s
, then the image of s
is also separable.
A finite product of pseudometric spaces is a pseudometric space, with the sup distance.
Equations
- One or more equations did not get rendered due to their size.
An open ball in a product space is a product of open balls. See also ball_pi'
for a version assuming Nonempty β
instead of 0 < r
.
An open ball in a product space is a product of open balls. See also ball_pi
for a version assuming 0 < r
instead of Nonempty β
.
A closed ball in a product space is a product of closed balls. See also closedBall_pi'
for a version assuming Nonempty β
instead of 0 ≤ r
.
A closed ball in a product space is a product of closed balls. See also closedBall_pi
for a version assuming 0 ≤ r
instead of Nonempty β
.
A sphere in a product space is a union of spheres on each component restricted to the closed ball.
Any compact set in a pseudometric space can be covered by finitely many balls of a given positive radius
Alias of finite_cover_balls_of_compact
.
Any compact set in a pseudometric space can be covered by finitely many balls of a given positive radius
- isCompact_closedBall : ∀ (x : α) (r : ℝ), IsCompact (Metric.closedBall x r)
A pseudometric space is proper if all closed balls are compact.
Instances
In a proper pseudometric space, all spheres are compact.
In a proper pseudometric space, any sphere is a CompactSpace
when considered as a subtype.
A proper pseudo metric space is sigma compact, and therefore second countable.
If all closed balls of large enough radius are compact, then the space is proper. Especially useful when the lower bound for the radius is 0.
A proper space is locally compact
A proper space is complete
A binary product of proper spaces is proper.
Equations
A finite product of proper spaces is proper.
Equations
If a nonempty ball in a proper space includes a closed set s
, then there exists a nonempty
ball with the same center and a strictly smaller radius that includes s
.
If a ball in a proper space includes a closed set s
, then there exists a ball with the same
center and a strictly smaller radius that includes s
.
A pseudometric space is second countable if, for every ε > 0
, there is a countable set which
is ε
-dense.
Closed balls are bounded
Open balls are bounded
Spheres are bounded
Given a point, a bounded subset is included in some ball around this point
A totally bounded set is bounded
A compact set is bounded
Characterization of the boundedness of the range of a function
In a compact space, all sets are bounded
If a function is continuous within a set s
at every point of a compact set k
, then it is
bounded on some open neighborhood of k
in s
.
If a function is continuous at every point of a compact set k
, then it is bounded on
some open neighborhood of k
.
If a function is continuous on a set s
containing a compact set k
, then it is bounded on
some open neighborhood of k
in s
.
If a function is continuous on a neighborhood of a compact set k
, then it is bounded on
some open neighborhood of k
.
The Heine–Borel theorem: In a proper space, a closed bounded set is compact.
The Heine–Borel theorem: In a proper space, the closure of a bounded set is compact.
The Heine–Borel theorem: In a proper Hausdorff space, a set is compact if and only if it is closed and bounded.
In a pseudo metric space with a conditionally complete linear order such that the order and the metric structure give the same topology, any order-bounded set is metric-bounded.
The diameter of a set in a metric space. To get controllable behavior even when the diameter should be infinite, we express it in terms of the emetric.diameter
Equations
Instances For
The diameter of a set is always nonnegative
The empty set has zero diameter
A singleton has zero diameter
If the distance between any two points in a set is bounded by some constant C
,
then ENNReal.ofReal C
bounds the emetric diameter of this set.
If the distance between any two points in a set is bounded by some non-negative constant, this constant bounds the diameter.
If the distance between any two points in a nonempty set is bounded by some constant, this constant bounds the diameter.
The distance between two points in a set is controlled by the diameter of the set.
Characterize the boundedness of a set in terms of the finiteness of its emetric.diameter.
Alias of the forward direction of Metric.isBounded_iff_ediam_ne_top
.
Characterize the boundedness of a set in terms of the finiteness of its emetric.diameter.
The distance between two points in a set is controlled by the diameter of the set.
An unbounded set has zero diameter. If you would prefer to get the value ∞, use EMetric.diam
.
This lemma makes it possible to avoid side conditions in some situations
If s ⊆ t
, then the diameter of s
is bounded by that of t
, provided t
is bounded.
The diameter of a union is controlled by the sum of the diameters, and the distance between
any two points in each of the sets. This lemma is true without any side condition, since it is
obviously true if s ∪ t
is unbounded.
If two sets intersect, the diameter of the union is bounded by the sum of the diameters.
The diameter of a closed ball of radius r
is at most 2 r
.
The diameter of a ball of radius r
is at most 2 r
.
If a family of complete sets with diameter tending to 0
is such that each finite intersection
is nonempty, then the total intersection is also nonempty.
In a complete space, if a family of closed sets with diameter tending to 0
is such that each
finite intersection is nonempty, then the total intersection is also nonempty.
Extension for the positivity
tactic: the diameter of a set is always nonnegative.
Equations
- One or more equations did not get rendered due to their size.
Instances For
- dist : α → α → ℝ
- edist : α → α → ENNReal
- edist_dist : ∀ (x y : α), PseudoMetricSpace.edist x y = ENNReal.ofReal (dist x y)
- toUniformSpace : UniformSpace α
- uniformity_dist : uniformity α = ⨅ (ε : ℝ) (_ : ε > 0), Filter.principal {p | dist p.fst p.snd < ε}
- toBornology : Bornology α
We now define MetricSpace
, extending PseudoMetricSpace
.
Instances
Two metric space structures with the same distance coincide.
Construct a metric space structure whose underlying topological space structure (definitionally) agrees which a pre-existing topology which is compatible with a given distance function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Deduce the equality of points with the vanishing of the nonnegative distance
Characterize the equality of points with the vanishing of the nonnegative distance
A map between metric spaces is a uniform embedding if and only if the distance between f x
and f y
is controlled in terms of the distance between x
and y
and conversely.
If a PseudoMetricSpace
is a T₀ space, then it is a MetricSpace
.
Equations
- MetricSpace.ofT0PseudoMetricSpace α = MetricSpace.mk (_ : ∀ {x y : α}, dist x y = 0 → x = y)
Instances For
A metric space induces an emetric space
Equations
- MetricSpace.toEMetricSpace = EMetricSpace.ofT0PseudoEMetricSpace γ
If f : β → α
sends any two distinct points to points at distance at least ε > 0
, then
f
is a uniform embedding with respect to the discrete uniformity on β
.
Build a new metric space from an old one where the bundled uniform structure is provably (but typically non-definitionaly) equal to some given uniform structure. See Note [forgetful inheritance].
Equations
- MetricSpace.replaceUniformity m H = MetricSpace.mk (_ : ∀ {x y : γ}, dist x y = 0 → x = y)
Instances For
Build a new metric space from an old one where the bundled topological structure is provably (but typically non-definitionaly) equal to some given topological structure. See Note [forgetful inheritance].
Equations
- MetricSpace.replaceTopology m H = MetricSpace.replaceUniformity m (_ : uniformity γ = uniformity γ)
Instances For
One gets a metric space from an emetric space if the edistance is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the uniformity are defeq in the metric space and the emetric space. In this definition, the distance is given separately, to be able to prescribe some expression which is not defeq to the push-forward of the edistance to reals.
Equations
- EMetricSpace.toMetricSpaceOfDist dist edist_ne_top h = MetricSpace.ofT0PseudoMetricSpace α
Instances For
One gets a metric space from an emetric space if the edistance is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the uniformity are defeq in the metric space and the emetric space.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Build a new metric space from an old one where the bundled bornology structure is provably (but typically non-definitionaly) equal to some given bornology structure. See Note [forgetful inheritance].
Equations
- MetricSpace.replaceBornology m H = let src := PseudoMetricSpace.replaceBornology MetricSpace.toPseudoMetricSpace H; MetricSpace.mk (_ : ∀ {x y : α}, dist x y = 0 → x = y)
Instances For
Metric space structure pulled back by an injective function. Injectivity is necessary to
ensure that dist x y = 0
only if x = y
.
Equations
- MetricSpace.induced f hf m = let src := PseudoMetricSpace.induced f MetricSpace.toPseudoMetricSpace; MetricSpace.mk (_ : ∀ {x y : γ}, dist x y = 0 → x = y)
Instances For
Pull back a metric space structure by a uniform embedding. This is a version of
MetricSpace.induced
useful in case if the domain already has a UniformSpace
structure.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pull back a metric space structure by an embedding. This is a version of
MetricSpace.induced
useful in case if the domain already has a TopologicalSpace
structure.
Equations
- Embedding.comapMetricSpace f h = MetricSpace.replaceTopology (MetricSpace.induced f (_ : Function.Injective f) m) (_ : inst = TopologicalSpace.induced f UniformSpace.toTopologicalSpace)
Instances For
Equations
- Subtype.metricSpace = MetricSpace.induced Subtype.val (_ : Function.Injective fun a => ↑a) inst
Equations
- instMetricSpaceAddOpposite = MetricSpace.induced AddOpposite.unop (_ : Function.Injective AddOpposite.unop) inst
Equations
- instMetricSpaceMulOpposite = MetricSpace.induced MulOpposite.unop (_ : Function.Injective MulOpposite.unop) inst
Equations
- instMetricSpaceEmpty = MetricSpace.mk (_ : ∀ {x y : Empty}, dist x y = 0 → x = y)
Equations
- instMetricSpacePUnit = MetricSpace.mk (_ : ∀ {x y : PUnit.{u + 1} }, dist x y = 0 → x = y)
Instantiate the reals as a metric space.
Equations
- instMetricSpaceNNReal = Subtype.metricSpace
Equations
- instMetricSpaceULift = MetricSpace.induced ULift.down (_ : Function.Injective ULift.down) inst
Equations
- Prod.metricSpaceMax = MetricSpace.ofT0PseudoMetricSpace (γ × β)
A finite product of metric spaces is a metric space, with the sup distance.
Equations
- metricSpacePi = MetricSpace.ofT0PseudoMetricSpace ((b : β) → π b)
A metric space is second countable if one can reconstruct up to any ε>0
any element of the
space from countably many data.
Equations
- One or more equations did not get rendered due to their size.
Additive
, Multiplicative
#
The distance on those type synonyms is inherited without change.
Equations
- instDistMultiplicative = inst
Equations
- instPseudoMetricSpaceAdditive = inst
Equations
- instPseudoMetricSpaceMultiplicative = inst
Equations
- instMetricSpaceAdditive = inst
Equations
- instMetricSpaceMultiplicative = inst
Equations
- (_ : ProperSpace (Additive X)) = inst
Equations
- (_ : ProperSpace (Multiplicative X)) = inst
Order dual #
The distance on this type synonym is inherited without change.
Equations
- instPseudoMetricSpaceOrderDual = inst
Equations
- instMetricSpaceOrderDual = inst
Equations
- (_ : ProperSpace Xᵒᵈ) = inst