Standard Discrete Metric is Metric

Let $$M = \left\{{A, d}\right\}$$ where $$A \ne \varnothing$$.

Let $$d \left({x, y}\right) = \begin{cases} 1 & : x \ne y \\ 0 & : x = y \end{cases}$$.

Then $$M = \left\{{A, d}\right\}$$ is a metric space.

The metric $$d$$ is known as the standard discrete metric, and can be applied to any non-empty set.

Proof
M0, M1 and M2 clearly hold, so we just need to check M3:


 * $$x = z \Longrightarrow d \left({x, z}\right) = 0 \Longrightarrow d \left({x, y}\right) + d \left({y, z}\right) \ge d \left({x, z}\right)$$.
 * $$x \ne z$$: Either $$x \ne y$$ or $$y \ne z$$, so $$d \left({x, y}\right) + d \left({y, z}\right) \ge 1$$, but $$d \left({x, z}\right) = 1$$, so $$d \left({x, y}\right) + d \left({y, z}\right) \ge d \left({x, z}\right)$$.

Either way, $$d \left({x, y}\right) + d \left({y, z}\right) \ge d \left({x, z}\right)$$ and M3 holds.