1.
In class we claimed that the Hamming distance is a metric on the set of all n-tuples over an alphabet, \(\Sigma^n\text{.}\) Prove this claim by verifying that the Hamming distance satisfies the properties of a metric.
(a)
\(d(x,y)\geq 0\) (positive semidefinite)
(b)
(c)
\(d(x,y)=d(y,x)\) (symmetric)
(d)
\(d(x,z) \leq d(x,y) + d(y,z)\) (triangle inequality)
Solution.
This is the trickiest of the properties to verify, so letβs be careful. Fix vectors \(x,z \in \Sigma^n\text{.}\) To show that \(d(x,z)\leq d(x,y)+d(y,z)\) for any \(y \in \Sigma^n\text{,}\) we will show that each position where \(x\) and \(z\) differ is either a position where \(x\) and \(y\) differ or a position where \(y\) and \(z\) differ (or both). Since the right hand side counts all such positions, with repetition for positions where both pairs differ, this will establish the inequality.
So, let \(i\) be a position where \(x\) and \(z\) differ, hence \(x_i\neq z_i\text{.}\) If \(y_i \neq x_i\text{,}\) we are done, since then this position is counted by \(d(x,y)\text{.}\) Otherwise, we have \(y_i = x_i\text{,}\) and since \(x_i \neq z_i\text{,}\) it follows that \(y_i \neq z_i\text{,}\) so this position is counted by \(d(y,z)\text{.}\) In either case, the position \(i\) is counted by the right hand side, completing the proof.
