TITLE: metric property in a group
QUESTION [5 upvotes]: Can we define a metric function on a group $G$? Please give examples other than $\mathbb{R}$. Actually most groups have elements in discrete manner. It sounds vague but I can't be more precise.

REPLY [2 votes]: Let $G=(\Bbb Z/2\Bbb Z)^\omega$, the direct product of countably infinitely many copies of $\Bbb Z/2\Bbb Z$, the cyclic group of order $2$. Elements of $G$ can be viewed as infinite sequences of zeroes and ones. Give $\Bbb Z/2\Bbb Z$ the discrete topology and $G$ the usual product topology; then $G$ is a Cantor set, so it’s a compact space with no isolated points. For $x=\langle x_n:n\in\omega\rangle,y=\langle y_n:n\in\omega\rangle\in G$ with $x\ne y$ define $$\delta(x,y)=\min\{n\in\omega:x_n\ne y_n\}\;,$$ and define
$$d:G\times G\to\Bbb R:\langle x,y\rangle\mapsto\begin{cases}
0,&\text{if }x=y\\
2^{-\delta(x,y)},&\text{if }x\ne y\;.
\end{cases}$$
Then $d$ is a metric on $G$ compatible with the group operation. (It is in fact an ultrametric or non-Archimedean metric: it satisfies the strong triangle inequality $$d(x,y)\le\max\{d(x,z),d(z,y)\}$$ for all $x,y,z\in G$.)
$G$ is essentially the additive group of $2$-adic integers equipped with its usual metric. For any prime $p$ the $p$-adic integers furnish a good example; these lecture notes discuss the ring (hence group) $\Bbb Z_p$ of $p$-adic integers, defining an ultrametric $d_p$ on it; the relevant discussion concludes at the top of page $5$. Each of the metric spaces $\langle\Bbb Z_p,d_p\rangle$ is homeomorphic to the Cantor set. $\Bbb Z_p$ can be extended to the field of $p$-adic numbers, which can be naturally equipped with a metric extending $d_p$; the resulting space is homeomorphic to the Cantor set minus one point or, equivalently, to the discrete union of countably infinitely many copies of the Cantor set.
Of course one can also start with any metric group $\langle G,d\rangle$ and construct the metric group $\langle G^\omega,\bar d\rangle$ by defining
$$\bar d(x,y)=\sum_{n\ge 0}\frac{d(x_n,y_n)}{2^n\big(1+d(x_n,y_n)\big)}$$
for each $x=\langle x_n:n\in\omega\rangle,y=\langle y_n:n\in\omega\rangle\in G^\omega$.