# Set of continuous function defined on some segment $[0,a]$: triangle inequality

Let $S$ be the set of continuous function $f$ defined on some segment $[0,a_f], a_f \ge 0$, and such that $f(0)=0$.
For $f$ and $g$ in $S$, let $$c_{fg}=\max\{z : f(x)=g(x) \text{ for all } x \in [0,z] \},$$ then, define the metric, $$d(f,g) = a_f - c_{fg} + a_g - c_{fg},$$ Show the triangle inequality holds for $d$.

The only proof I see is a case by case analysis of all the possibilities.
I don't see how to enumerate all the possibilities, there seems to be too much.
Also, for the case $$\begin{cases} f,g,h \text{ are different functions} \\ c_{fg} < c_{fh} < c_{hg} \\ a_{fg}<a_{fh}<a_{hg} \end{cases}$$ I don't see why the triangle inequality holds.

-
Perhaps it is easier to proceed by contradiction, that is, suppose that $d(f,h)>d(f,g)+d(g,h)$, and see what happens... – Matemáticos Chibchas Feb 1 '13 at 1:25

Suppose $a_f+a_h-2c_{fh}>a_f+a_g-2c_{fg}+a_g+a_h-2c_{gh}$, that is $c_{fg}+c_{gh}>c_{fh}+a_g$. By properties of the supremum we have
$$c_{fg}+c_{gh}=\sup\bigl\{w+z: f=g\ \style{font-family:inherit;}{\text{on}}\ [0,w], g=h\ \style{font-family:inherit;}{\text{on}}\ [0,z]\bigr\}\,,$$
and so (again by the definition of supremum) there exist $w,z$ as in the set above such that $w+z-a_g>c_{fh}$. Finally, recall that
$$c_{fh}=\sup\bigl\{t: f=h\ \style{font-family:inherit;}{\text{on}}\ [0,t]\bigr\}\,;$$
but $f=g$ on $[0,w]$ and $g=h$ on $[0,z]$, and so $f=h$ on $\bigl[0,\min\{w,z\}\bigr]$, which forces $w+z-a_g>\min\{w,z\}$, or equivalently $\max\{w,z\}>a_g$, which is impossible, since by (tacit) definition we have $w\leq\min\{a_f,a_g\}, z\leq\min\{a_g,a_h\}$, and in particular $w,z\leq a_g$. This concludes the proof.