Define the function $d:X^w \times X^w \longrightarrow \mathbb{R}$ by \begin{equation*} d(x,y) = \begin{cases} 0 \text{ if } x = y \\ \frac{1}{n} \text{ if } x\not =y \text{ and } n \text{ is the first index where } x_n\not = y_n \end{cases} \end{equation*} Prove that $d$ is a metric on $X^w$.
I am having a bit of trouble proving the triangle inequality for this metric. Here is what I have done, but I am not certain whether my argument is solid. Here is what I have:
Let $x,y,z \in X^w$. If $x=z$, then $d(x,z) = 0 \leq d(x,y)+d(y,z)$. Suppose that $x \ne z$, where $d(x,z) = \frac{1}{k}$. Consider $d(x,y)$. There are two cases to consider, $m \leq k$ or $m > k$. If $d(x,y) = \frac{1}{m}$ where $m \leq k$. Then $\frac{1}{k} \leq \frac{1}{m}$ and we have $$d(x,z) \leq d(x,y) + d(y,z).$$ If $d(x,y) = \frac{1}{m}$ where $m > k$. In this case, we must have $d(y,z) = \frac{1}{k}$, so that $$d(x,z) \leq d(x,y)+d(y,z).$$
Is my argument correct?