A metric space is a set on which a distance between points is defined as a function \(d:X \times X \to [0,\infty)\). With this definition each metric space is a topological space which is paracompact and Hausdorff (\(T_2\)), hence normal (in fact even perfectly normal).
A metric on \(X\) is usually defined as a function \(d:X \times X \to [0,\infty)\) that satisfies the conditions \(d(x,x) = 0\), \(d(x, y) = 0 \Rightarrow x = y\) (identity of indiscernibles), \(d(x, y) = d(y, x)\) (symmetry) and \(d(x, y) \le d(x, z) + d(z, y)\) (triangle inequality) for all \(x,y \in X\). Here we are going to be a bit more general and define metric and pseudo-metric as a function valued in an ordered group.
First we define a pseudo-metric, which has the axioms of a metric, but without the second part of the identity of indiscernibles. In our definition IsApseudoMetric is a predicate on five sets: the function \(d\), the set \(X\) on which the metric is defined, the group carrier \(G\), the group operation \(A\) and the order \(r\) on \(G\).
Definition
\( \text{IsApseudoMetric}(d,X,G,A,r) \equiv d:X\times X \rightarrow \text{Nonnegative}(G,A,r) \) \( \wedge (\forall x\in X.\ d\langle x,x\rangle = \text{TheNeutralElement}(G,A))\) \( \wedge (\forall x\in X.\ \forall y\in X.\ d\langle x,y\rangle = d\langle y,x\rangle )\) \( \wedge (\forall x\in X.\ \forall y\in X.\ \forall z\in X.\ \langle d\langle x,z\rangle , A\langle d\langle x,y\rangle ,d\langle y,z\rangle \rangle \rangle \in r) \)
We add the full axiom of identity of indiscernibles to the definition of a pseudometric to get the definition of metric.
Definition
\( \text{IsAmetric}(d,X,G,A,r) \equiv \) \( \text{IsApseudoMetric}(d,X,G,A,r) \wedge (\forall x\in X.\ \forall y\in X.\ d\langle x,y\rangle = \text{TheNeutralElement}(G,A) \longrightarrow x=y) \)
A disk is defined as set of points located less than the radius from the center.
Definition
\( \text{Disk}(X,d,r,c,R) \equiv \{x\in X.\ \langle d\langle c,x\rangle ,R\rangle \in \text{StrictVersion}(r)\} \)
Next we define notation for metric spaces. We will use additive notation for the group operation but we do not assume that the group is abelian. Since for many theorems it is sufficient to assume the pseudometric axioms we will assume in this context that the sets \(d,X,G,A,r\) form a pseudometric raher than a metric.
Locale pmetric_space
assumes ordGroupAssum: \( \text{IsAnOrdGroup}(G,A,r) \)
assumes pmetricAssum: \( \text{IsApseudoMetric}(d,X,G,A,r) \)
defines \( 0 \equiv \text{TheNeutralElement}(G,A) \)
defines \( x + y \equiv A\langle x,y\rangle \)
defines \( ( - x) \equiv \text{GroupInv}(G,A)(x) \)
defines \( x \leq y \equiv \langle x,y\rangle \in r \)
defines \( x \lt y \equiv x\leq y \wedge x\neq y \)
defines \( G^+ \equiv \text{Nonnegative}(G,A,r) \)
defines \( G_+ \equiv \text{PositiveSet}(G,A,r) \)
defines \( -C \equiv \text{GroupInv}(G,A)(C) \)
defines \( abs(x) \equiv \text{AbsoluteValue}(G,A,r)(x) \)
defines \( f^\circ \equiv \text{OddExtension}(G,A,r,f) \)
defines \( disk(c,R) \equiv \text{Disk}(X,d,r,c,R) \)
The theorems proven the in the group3 locale are valid in the pmetric_space locale.
using ordGroupAssum unfolding group3_def
The theorems proven the in the group0 locale are valid in the pmetric_space locale.
using ordGroupAssum unfolding group0_def , IsAnOrdGroup_def
The next lemma shows the definition of the pseudometric in the notation used in the metric_space context.
lemma (in pmetric_space) pmetric_properties:
shows \( d: X\times X \rightarrow G^+ \), \( \forall x\in X.\ d\langle x,x\rangle = 0 \), \( \forall x\in X.\ \forall y\in X.\ d\langle x,y\rangle = d\langle y,x\rangle \), \( \forall x\in X.\ \forall y\in X.\ \forall z\in X.\ d\langle x,z\rangle \leq d\langle x,y\rangle + d\langle y,z\rangle \) using pmetricAssum unfolding IsApseudoMetric_defThe definition of the disk in the notation used in the pmetric_space context:
lemma (in pmetric_space) disk_definition:
shows \( disk(c,R) = \{x\in X.\ d\langle c,x\rangle \lt R\} \)proofIf the radius is positive then the center is in disk.
lemma (in pmetric_space) center_in_disk:
assumes \( c\in X \) and \( R\in G_+ \)
shows \( c \in disk(c,R) \) using pmetricAssum , assms , IsApseudoMetric_def , PositiveSet_def , disk_definitionA technical lemma that allows us to shorten some proofs:
lemma (in pmetric_space) radius_in_group:
assumes \( c\in X \) and \( x \in disk(c,R) \)
shows \( R\in G \), \( 0 \lt R \), \( R\in G_+ \), \( (( - d\langle c,x\rangle ) + R) \in G_+ \)proofIf a point \(x\) is inside a disk \(B\) and \(m\leq R-d(c,x)\) then the disk centered at the point \(x\) and with radius \(m\) is contained in the disk \(B\).
lemma (in pmetric_space) disk_in_disk:
assumes \( c\in X \) and \( x \in disk(c,R) \) and \( m \leq ( - d\langle c,x\rangle ) + R \)
shows \( disk(x,m) \subseteq disk(c,R) \)proofIf we assume that the order on the group makes the positive set a meet semi-lattice (i.e. every two-element subset of \(G_+\) has a greatest lower bound) then the collection of disks centered at points of the space and with radii in the positive set of the group satisfies the base condition. The meet semi-lattice assumption can be weakened to "each two-element subset of \(G_+\) has a lower bound in \(G_+\)", but we don't do that here.
lemma (in pmetric_space) disks_form_base:
assumes \( \text{IsMeetSemilattice}(G_+,r \cap G_+\times G_+) \)
defines \( B \equiv \bigcup c\in X.\ \{disk(c,R).\ R\in G_+\} \)
shows \( B \text{ satisfies the base condition } \)proofUnions of disks form a topology, hence (pseudo)metric spaces are topological spaces. We have to add the assumption that the positive set is not empty. This is necessary to show that we can cover the space with disks and it does not look like it follows from anything we have assumed so far.
theorem (in pmetric_space) pmetric_is_top:
assumes \( \text{IsMeetSemilattice}(G_+,r \cap G_+\times G_+) \), \( G_+\neq 0 \)
defines \( B \equiv \bigcup c\in X.\ \{disk(c,R).\ R\in G_+\} \)
defines \( T \equiv \{\bigcup A.\ A \in Pow(B)\} \)
shows \( T \text{ is a topology } \), \( B \text{ is a base for } T \), \( \bigcup T = X \)proofassumes \( a\leq b \) and \( b \lt c \)
shows \( a \lt c \)assumes \( a \lt b \)
shows \( a\in G \), \( b\in G \)assumes \( x\in G \)
shows \( x^{-1}\in G \)assumes \( a \lt b \) and \( c\in G \)
shows \( a\cdot c \lt b\cdot c \), \( c\cdot a \lt c\cdot b \)assumes \( x\in G \)
shows \( x\cdot x^{-1} = 1 \wedge x^{-1}\cdot x = 1 \)assumes \( c\in X \) and \( x \in disk(c,R) \)
shows \( R\in G \), \( 0 \lt R \), \( R\in G_+ \), \( (( - d\langle c,x\rangle ) + R) \in G_+ \)assumes \( a \lt b \) and \( b\leq c \)
shows \( a \lt c \)assumes \( a\in G \), \( b\in G \)
shows \( a\cdot b^{-1}\cdot b = a \), \( a\cdot b\cdot b^{-1} = a \), \( a^{-1}\cdot (a\cdot b) = b \), \( a\cdot (a^{-1}\cdot b) = b \)assumes \( c\in X \) and \( x \in disk(c,R) \)
shows \( R\in G \), \( 0 \lt R \), \( R\in G_+ \), \( (( - d\langle c,x\rangle ) + R) \in G_+ \)assumes \( \text{IsMeetSemilattice}(L,r) \), \( x\in L \), \( y\in L \)
defines \( m \equiv \text{Meet}(L,r)\langle x,y\rangle \)
shows \( m\in L \), \( m = \text{Infimum}(r,\{x,y\}) \), \( \langle m,x\rangle \in r \), \( \langle m,y\rangle \in r \)assumes \( \text{IsMeetSemilattice}(L,r) \), \( x\in L \), \( y\in L \)
defines \( m \equiv \text{Meet}(L,r)\langle x,y\rangle \)
shows \( m\in L \), \( m = \text{Infimum}(r,\{x,y\}) \), \( \langle m,x\rangle \in r \), \( \langle m,y\rangle \in r \)assumes \( \text{IsMeetSemilattice}(L,r) \), \( x\in L \), \( y\in L \)
defines \( m \equiv \text{Meet}(L,r)\langle x,y\rangle \)
shows \( m\in L \), \( m = \text{Infimum}(r,\{x,y\}) \), \( \langle m,x\rangle \in r \), \( \langle m,y\rangle \in r \)assumes \( c\in X \) and \( x \in disk(c,R) \) and \( m \leq ( - d\langle c,x\rangle ) + R \)
shows \( disk(x,m) \subseteq disk(c,R) \)assumes \( c\in X \) and \( R\in G_+ \)
shows \( c \in disk(c,R) \)assumes \( \text{IsMeetSemilattice}(G_+,r \cap G_+\times G_+) \)
defines \( B \equiv \bigcup c\in X.\ \{disk(c,R).\ R\in G_+\} \)
shows \( B \text{ satisfies the base condition } \)assumes \( B \text{ satisfies the base condition } \) and \( T = \{\bigcup A.\ A\in Pow(B)\} \)
shows \( T \text{ is a topology } \) and \( B \text{ is a base for } T \)assumes \( B \text{ is a base for } T \)
shows \( \bigcup T = \bigcup B \)