Embedding of structures in mathematical logic I'm working on Srivastava's A course on mathematical logic and I've encountered a difficulty of understanding in the way.
I just proved the following exercise:

Let $\alpha:N\to M$ be a map such that for every atomic $\varphi[v_1,\ldots,v_n]$ and every $\overline a\in N^n$,
$$N\models \varphi[i_{\overline a}]\iff M\models \varphi[i_{\alpha(\overline a)}].$$
Show that $\alpha$ is an embedding.

Right after this there's the following proposition:

If $N\models Diag(M)$, then $M$ has an embedding into $N$

The proof goes as follows:

For $a\in M$, take $\alpha(a)=(i_a)_N$. By the previous exercise, $\alpha:M\to N$ is an embedding.

I don't see how the exercise can be applied here. I do see one direction:
$M\models\varphi[i_{\overline a}]\Rightarrow\varphi[i_{\overline a}]\in Diag(M)\Rightarrow N\models\varphi[i_{\overline a}]\Rightarrow N\models\varphi[i_{(i_{\overline a})_N}]$ (since $i_{\overline a}=i_{(i_{\overline a})_N})\Rightarrow N\models\varphi[i_{\alpha(\overline a)}]$.
But I fail to see why the other direction is true, since $N\models\varphi[i_{\overline a}]\nRightarrow\varphi[i_{\overline a}]\in Diag(M)$.
Any suggestions will be appreciated.
 A: The definition of "diagram" in your book is wrong. Srivastava writes: $$\mathrm{Diag}(M) = \{\varphi[i_{\overline{a}}] : \overline{a} \in M, M \models \varphi[i_{\overline{a}}], \varphi\text{ an atomic formula of }L\}.$$
This is sometimes called the "positive diagram" (since it doesn't include any negated formulas). If $N$ is a model of the positive diagram of $M$, then the map $\alpha(a) = (i_a)_N$ is a homomorphism $M\to N$, but not necessarily an embedding.
The correct definition of "diagram" is:
$$\mathrm{Diag}(M) = \{\varphi[i_{\overline{a}}] : \overline{a} \in M, M \models \varphi[i_{\overline{a}}], \varphi\text{ an atomic or negated atomic formula of L}\}.$$
With the corrected definition, your idea works. We would like to show that if $N\models \mathrm{Diag}(M)$, then taking $\alpha(a) = (i_a)_N$, we have $M\models \varphi[i_{\overline{a}}]$ if and only if $N\models \varphi[i_{\alpha(\overline{a})}]$, for every atomic formula $\varphi[v_1,\dots,v_n]$ and every $\overline{a}\in M^n$. Note that in $N$, $i_{\alpha(\overline{a})} = i_{(i_{\overline{a}})_N} = (i_{\overline{a}})_N$.
Now if $M\models \varphi[i_{\overline{a}}]$, then $\varphi[i_{\overline{a}}]\in \mathrm{Diag}(M)$, so $N\models \varphi[(i_{\overline{a}})_N]$. And conversely, if $M\not\models \varphi[i_{\overline{a}}]$, then $M\models \lnot \varphi[i_{\overline{a}}]$,  so $\lnot\varphi[i_{\overline{a}}]\in \mathrm{Diag}(M)$, so $N\models \lnot\varphi[(i_{\overline{a}})_N]$, and $N\not\models \varphi[(i_{\overline{a}})_N]$.
