# “Amalgamation” of elementary equivalent structures

I've been asked this as an "easy exercise" on diagrams. Let $\mathfrak M_1, \mathfrak M_2$ be two structures over the same language $\mathcal L$. Prove that $\mathfrak M_1 \equiv \mathfrak M_2$ if, and only if, there exists $\mathfrak N_1, \mathfrak N_2$ and $\mathfrak A$ such that $\mathfrak M_i \simeq \mathfrak N_i$ and $\mathfrak N_i \preccurlyeq \mathfrak A$.

Here is my attempt for the forward direction. For $m\in \mathfrak M_1$, let $c_m$ be new constants and for $m\in \mathfrak M_2$ let $d_m$ be new constants, all these constants being pairwise different. Let us consider the theory $T = Th(\mathfrak M_1^*) \cup Th(\mathfrak M_2^*)$, with $\mathfrak M_i^*$ being the structure $\mathfrak M_i$ interpreting the appropriate constants with its elements. I'd like to say that $T$ is coherent, so that $\mathfrak A$ would be its model. We would have $\mathfrak A \models Th(\mathfrak M_i)^*$ and a lemma we proved in class allows to say that $\mathfrak M_i$ is then isomorphic to some elementary substructure of $\mathfrak A$, as required.

To say that $T$ is coherent, let us take $\varphi$ a $\mathcal L\cup \{c_m\} \cup \{d_m\}$-formula and suppose that $T \vdash \varphi$ and $T\vdash \neg \varphi$. By compactness, some finite subset $T_0$ of $T$ must entail $\varphi$ and $\neg \varphi$. Now, I don't know how to deal with the case where $T_0$ contains formulas from both the diagrams of $\mathfrak M_1$ and $\mathfrak M_2$. Could someone provide me a hint?

Hint: Let $\phi_1(\bar c), ..., \phi_n(\bar c) \in Th({\cal M}_1^*)$, $\psi_1(\bar d), ..., \psi_m(\bar d) \in Th({\cal M}_2^*)$ be such that $\{\phi_1, ..., \phi_n, \psi_1, ..., \psi_m\}$ is inconsistent (incoherent in your terminology). Here $\phi_1(\bar v), ..., \phi_n(\bar v), \psi_1(\bar w), ..., \psi_m(\bar w)$ are $\cal L$-formulas, $\bar c, \bar d$ are new constant symbols. Then $\phi_1(\bar c), ..., \phi_n(\bar c) \models \lnot \exists \bar w (\psi_1(\bar w) \land ... \land \psi_m(\bar w))$. Hence the later sentence is true in ${\cal M}_1$, but false in ${\cal M}_2$.