d-metric on the space of types. Reading this paper http://math.univ-lyon1.fr/~begnac/articles/mtfms.pdf by Itaï Ben Yaacov, Alexander Berenstein, C. Ward Henson, and Alexander Usvyatsov I have encountered the following problem. In section 8, subsection 'The d-metric on types', they define the distance between two types $p$, $q\in S_n(T_A)$ to be the infimum of the distance between their realisations. More precisely:
$$ d(p,q)=\inf\{ d(a,b) : \mathcal{M}_A\models p[a] ,  \mathcal{M}_A\models q[b]\}.$$
I have problems proving the triangular inequality, I have tried to use compactness theorem and also tried to think this metric as a pseudometric induced in the quotient space in the usual way. However, I am not able to end the proof.
 A: Claim: The infimum above is always attained at a pair of points $a,b\in M^n$ such that $\mathcal{M}_A\models p[a]$, $\mathcal{M}_A\models q[b]$.
Proof: Since the set of conditions $p(x)\cup q(y)\cup \{ d(x,y)\leq d(p,q)+\frac{1}{n}: n\geq 1 \}$ is finitely satisfiable, the saturation of $\mathcal{M}$ implies that there exists an element satisfying the whole set. Hence, if $d(p,q)=0$, they have a common realization, so $p=q$.
Lemma: The distance $d$ defined above, defines a metric in $S_n(T_A)$.
Proof: The only property of a metric that is nontrivial is the triangular inequality. To prove it, we first show that given $a'\in M^n$ such that $\mathcal{M}_A\models p[a']$, there exists $b'\in M^n$, $\mathcal{M}_A\models q[b']$, such that $d(a',b')=d(p,q).$ Suppose that $d(p,q)$ is attained in a pair of points $a,b\in M^n$. As $a$ and $a'$ both realize the same type $p$ over $A$, there exists an elementary map
\begin{equation*}
  h:A\cup\{a\}\to A\cup\{a'\}.
  \end{equation*}
Now, we use that $\kappa$-saturation implies $\kappa$-homogeneity to extend this elementary map to an elementary map
\begin{equation*}
  h':A\cup\{a,b\}\to A\cup\{a',b'\}\subseteq {M}.
  \end{equation*}
Hence $\mathcal{M}\models q[b']$ and $d(a,b)=d(a',b')=d(p,q)$.
Now, let $p,q,r\in S_n(T_A)$. Suppose that $d(p,r)=d(a,c_1)$ and $d(r,q)=d(c_2,b)$. As, $c_1$ and $c_2$ realize the same type $r$ over $A$, by the discussion above, there exist $b'$, $\mathcal{M}\models q[b']$, such that $d(c_1,b')=d(c_2,b)$. Hence, $$d(p,r)+d(r,q)=d(a,c_1)+d(c_1,b')\geq d(a,b')\geq d(p,q),$$
Where the middle inequality is just the tiangular inequality for the metric on $M^n$.
