Tutorials › Real Analysis › The Discrete Metric

Metric Spaces · Tutorial 654 of 1000

The Discrete Metric

Learn how the discrete metric treats distinct points equally and what that implies for balls, convergence, and completeness.

Advanced 10 min read

What You'll Learn

  • Define the discrete metric on any nonempty set and verify its metric axioms
  • Determine the metric balls for radii at most one and greater than one
  • Characterize convergence and Cauchy sequences as eventual constancy
  • Show that every set with the discrete metric is complete
  • Compare discrete-metric convergence with convergence under the usual metric

A Metric That Ignores the Set’s Geometry

The examples in “Examples of Metrics” showed that a set can carry different metrics, depending on how we choose to measure separation. The discrete metric is an especially simple choice: every pair of distinct points is assigned the same positive distance, no matter what the points are or what other structure the set may have. It therefore provides a useful way to study which features of convergence come from the metric itself rather than from familiar geometry.

The construction applies to any nonempty set \(X\). Its points need not be numbers, vectors, or functions. We only need to be able to tell whether two points are equal. Once the metric is defined, its small balls and its convergent sequences have particularly direct descriptions.

Definition: Let \(X\) be a nonempty set. The discrete metric on \(X\) is the function \(\delta:X\times X\to\mathbb{R}\) defined by $$ \delta(x,y)= \begin{cases} 0,&x=y,\\ 1,&x\ne y. \end{cases} $$ The pair \((X,\delta)\) is called a discrete metric space.

Verifying the Metric Axioms

Although the formula has only two possible values, each metric axiom still needs to be checked. The zero-distance condition follows directly from the two cases in the definition. Symmetry holds because \(x=y\) if and only if \(y=x\). The triangle inequality is also simple, but it is useful to separate the cases in its proof.

Theorem (The Discrete Metric Is a Metric): For every nonempty set \(X\), the function \(\delta\) defined above is a metric on \(X\).

Proof. By definition, \(\delta(x,y)\) is either \(0\) or \(1\), so it is nonnegative. Also, \(\delta(x,y)=0\) exactly when \(x=y\). Since equality is symmetric, $$ \delta(x,y)=\delta(y,x) $$ for all \(x,y\in X\).

To prove the triangle inequality, take any \(x,y,z\in X\). If \(x=z\), then $$ \delta(x,z)=0\leq \delta(x,y)+\delta(y,z), $$ because both terms on the right are nonnegative. If \(x\ne z\), then \(\delta(x,z)=1\). In this case, \(x\) and \(z\) cannot both equal \(y\): if they did, then \(x=z\). Thus at least one of \(x\ne y\) or \(y\ne z\) holds. At least one of \(\delta(x,y)\) and \(\delta(y,z)\) is therefore \(1\), so $$ \delta(x,y)+\delta(y,z)\geq1=\delta(x,z). $$ This proves the triangle inequality in both cases. Hence \(\delta\) satisfies all the metric axioms. \(\square\)

Worked Example: Distances in a Four-Point Set

Let \(X=\{a,b,c,d\}\), where the four elements are distinct, and give \(X\) the discrete metric. Then $$ \delta(a,a)=0,\qquad \delta(a,c)=1,\qquad \delta(b,d)=1. $$ The actual identities of the points do not affect the distance: every distance between distinct elements is \(1\). For example, the triangle inequality along the route from \(a\) to \(c\) through \(b\) reads $$ \delta(a,c)=1\leq \delta(a,b)+\delta(b,c)=1+1=2. $$ If instead the middle point is \(a\), then $$ \delta(a,c)=1\leq \delta(a,a)+\delta(a,c)=0+1=1. $$ Both calculations illustrate why the triangle inequality holds whether or not the intermediate point coincides with an endpoint.

Metric Balls and the Shape of the Space

For \(x\in X\) and \(r>0\), the open ball of radius \(r\) centered at \(x\) is $$ B_r(x)=\{y\in X:\delta(x,y)<r\}. $$ Because the only possible distances are \(0\) and \(1\), the radius determines the ball completely. If \(0<r\leq1\), a point belongs to \(B_r(x)\) only if its distance from \(x\) is \(0\). If \(r>1\), both possible distances are smaller than \(r\).

Proposition (Balls in the Discrete Metric): In a discrete metric space, $$ B_r(x)=\{x\}\quad\text{if }0<r\leq1, \qquad B_r(x)=X\quad\text{if }r>1. $$

Proof. Suppose first that \(0<r\leq1\). The inequality \(\delta(x,y)<r\) excludes the value \(1\), since \(1\not<r\). Thus it holds exactly when \(\delta(x,y)=0\), which is exactly when \(y=x\). Hence \(B_r(x)=\{x\}\). Now suppose \(r>1\). For every \(y\in X\), \(\delta(x,y)\) is either \(0\) or \(1\), and both values are less than \(r\). Therefore every \(y\in X\) belongs to \(B_r(x)\), so \(B_r(x)=X\). \(\square\)

This ball description also determines the open sets. Recall that a subset \(U\) of a metric space is open if, for each \(x\in U\), there is some radius \(r>0\) such that \(B_r(x)\subseteq U\). In a discrete metric space, every subset \(A\subseteq X\) is open: for each \(x\in A\), the ball \(B_{1/2}(x)=\{x\}\) is contained in \(A\). The empty set is open as well, since it has no points for which the condition needs to be checked. Since the complement of any subset is also a subset, every subset is closed too, using the definition that a set is closed when its complement is open.

Worked Example: A Ball Can Be a Singleton

Take \(X=\mathbb{Z}\) with the discrete metric and center the ball at \(5\). For radius \(r=0.8\), the point \(5\) has distance \(0<0.8\), while every other integer has distance \(1\), which is not less than \(0.8\). Thus $$ B_{0.8}(5)=\{5\}. $$ For radius \(r=1.4\), both \(0\) and \(1\) are less than \(1.4\), so every integer belongs to the ball: $$ B_{1.4}(5)=\mathbb{Z}. $$ There are no intermediate ball shapes for this metric: a ball is either the center alone or the entire space.

Convergence Means Eventual Equality

In a metric space, a sequence \((x_n)\) converges to \(x\) if for every \(\varepsilon>0\), there is an index \(N\) such that \(d(x_n,x)<\varepsilon\) whenever \(n\geq N\). The discrete metric turns this condition into an exact requirement. Choosing an error tolerance smaller than \(1\) rules out every point except \(x\) itself.

Theorem (Convergence in a Discrete Metric): Let \((X,\delta)\) be a discrete metric space. A sequence \((x_n)\) converges to \(x\in X\) if and only if there is an index \(N\) such that \(x_n=x\) for every \(n\geq N\).

Proof. First suppose \(x_n\to x\). Apply the definition of convergence with \(\varepsilon=1/2\). There is an \(N\) such that for all \(n\geq N\), $$ \delta(x_n,x)<\frac12. $$ The only possible values of \(\delta(x_n,x)\) are \(0\) and \(1\). The value \(1\) does not satisfy this inequality, so \(\delta(x_n,x)=0\), and hence \(x_n=x\), for every \(n\geq N\).

Conversely, suppose there is an \(N\) such that \(x_n=x\) for every \(n\geq N\). Let \(\varepsilon>0\). For every \(n\geq N\), $$ \delta(x_n,x)=\delta(x,x)=0<\varepsilon. $$ This is precisely the definition of \(x_n\to x\). The two conditions are therefore equivalent. \(\square\)

Worked Example: A Sequence That Converges Discretely

In the discrete metric on \(\mathbb{Z}\), define a sequence by \(x_n=12\) for \(n\geq4\), and choose \(x_1=3\), \(x_2=-1\), and \(x_3=8\). The sequence converges to \(12\), because its terms equal \(12\) at every index from \(4\) onward. More explicitly, for any \(\varepsilon>0\), choose \(N=4\). If \(n\geq4\), then $$ \delta(x_n,12)=\delta(12,12)=0<\varepsilon. $$ The first three terms do not affect convergence, which depends only on the tail of the sequence.

Worked Example: Usual Convergence Need Not Be Discrete Convergence

Consider \(x_n=1/n\) as a sequence in \(\mathbb{R}\). Under the usual metric, \(1/n\to0\). Under the discrete metric on \(\mathbb{R}\), however, \(x_n\) does not converge to \(0\). Indeed, \(1/n\ne0\) for every positive integer \(n\), so $$ \delta(x_n,0)=1 $$ for every \(n\). In particular, these distances are never less than \(1/2\). The sequence is not eventually equal to \(0\), as the convergence theorem requires. The same set \(\mathbb{R}\) thus has different convergent sequences under its usual and discrete metrics.

Cauchy Sequences and Completeness

A sequence in a metric space is Cauchy if, for every \(\varepsilon>0\), there is an \(N\) such that \(d(x_m,x_n)<\varepsilon\) whenever \(m,n\geq N\). In the discrete metric, choosing \(\varepsilon=1/2\) forces any two terms sufficiently far along the sequence to be equal. Thus the Cauchy condition, like convergence, becomes eventual constancy.

Theorem (Cauchy Sequences in a Discrete Metric): A sequence in a discrete metric space is Cauchy if and only if it is eventually constant. Consequently, every discrete metric space is complete.

Proof. Suppose \((x_n)\) is Cauchy. Use the Cauchy condition with \(\varepsilon=1/2\). There is an \(N\) such that for all \(m,n\geq N\), $$ \delta(x_m,x_n)<\frac12. $$ Since the distance is either \(0\) or \(1\), this implies \(\delta(x_m,x_n)=0\), and therefore \(x_m=x_n\), for all \(m,n\geq N\). In particular, setting \(m=N\) shows \(x_n=x_N\) for every \(n\geq N\). The sequence is eventually constant.

Conversely, suppose the sequence is eventually constant: there are \(N\) and \(x\in X\) such that \(x_n=x\) for all \(n\geq N\). For any \(\varepsilon>0\), if \(m,n\geq N\), then $$ \delta(x_m,x_n)=\delta(x,x)=0<\varepsilon. $$ Thus the sequence is Cauchy. By the convergence theorem, every eventually constant sequence converges, so every Cauchy sequence in \(X\) converges in \(X\). A metric space in which every Cauchy sequence converges is called complete (this notion is developed in detail later), so \((X,\delta)\) is complete. \(\square\)

Worked Example: An Alternating Sequence Is Not Cauchy

In the discrete metric on \(\{0,1\}\), let \(x_n=0\) for even \(n\) and \(x_n=1\) for odd \(n\). Given any proposed index \(N\), choose an even \(m\geq N\) and an odd \(n\geq N\). Then \(x_m\ne x_n\), so $$ \delta(x_m,x_n)=1\not<\frac12. $$ No index \(N\) can satisfy the Cauchy condition for \(\varepsilon=1/2\). The sequence is not Cauchy and, in particular, does not converge.

What the Discrete Metric Helps Isolate

The discrete metric is useful as a test case because it separates metric consequences from geometric intuition. In familiar metrics, distinct points can be arbitrarily close. Here they cannot: every distinct pair is exactly distance \(1\) apart. As a result, convergence to \(x\) is not a gradual approach toward \(x\); it requires the sequence to reach \(x\) and stay there. The same threshold argument shows that Cauchy sequences must settle on one point as well.

A common pitfall is to assume that a sequence which is close to a point in some other sense must also converge in the discrete metric. The example \(1/n\) shows why this is false: its usual distance from \(0\) becomes small, but its discrete distance from \(0\) remains \(1\). Convergence is always relative to the metric specified, not merely to the underlying set or the labels of its elements.

The discrete metric also gives a simple source of complete metric spaces: no matter what the nonempty set \(X\) contains, every Cauchy sequence is eventually constant and hence convergent. This does not mean that every possible metric on \(X\) is complete. It means that completeness depends on the chosen metric, just as convergence does.

Takeaway: In the discrete metric, distinct points are all distance \(1\) apart. Balls of radius at most \(1\) are singletons, convergence and the Cauchy property are equivalent to eventual constancy, and every discrete metric space is complete.

Check Your Understanding

Use the definition of the discrete metric and the results proved above to answer the following questions.

  1. Why does the triangle inequality hold when the endpoints \(x\) and \(z\) are distinct?
  2. Describe \(B_{0.6}(x)\) and \(B_{2}(x)\) in a discrete metric space.
  3. What condition on the tail of a sequence is necessary and sufficient for it to converge to \(x\)?
  4. Why must a Cauchy sequence in a discrete metric space eventually be constant?
  5. Can the sequence \(1/n\) converge to \(0\) under the discrete metric on \(\mathbb{R}\)? Explain.