Solution
= Solution
For $s,t\in[0,1]$, define
$$
m_g(s,t)=\inf_{r\in[s\wedge t,s\vee t]}g(r),
\qquad
d_g(s,t)=g(s)+g(t)-2m_g(s,t).
$$
The function $d_g$ is a <pseudometric>. Declare $s\sim t$ when $d_g(s,t)=0$, and give the <quotient set> $T_g=[0,1]/\!\sim$ the induced metric, again denoted $d_g$. This is the <real tree encoded by an excursion> $g$.