Definition (metric space)
Let $X$ be any set. A metric is a function $d: X\times X\to\R$ such that
-
(positive semidefinite) $d(x,y)\geq 0$ for all $x,y\in X$, and $d(x,y)=0$ iff $x=y$;
-
(symmetry) $d(x,y) = d(y,x)$ for all $x,y\in X$;
-
(triangle inequality) $d(x,y) \leq d(x,z) + d(z,y)$ for all $x,y,z\in X$.
We say $(X,d)$ is a metric space.