Solution (source code)

= Solution

Let $L_A$ expand $L$ by a constant $c_a$ for each $a\in A$, and let $\mathcal A_A$ be the canonical expansion interpreting $c_a$ as $a$. Its <diagram of a structure> is the <set> of all atomic and negated atomic $L_A$-sentences true in $\mathcal A_A$. Its <elementary diagram> is the <set> of all $L_A$-sentences true there:
$$
\operatorname{Diag}(\mathcal A)=\{\theta:\theta\text{ atomic or negated atomic},\ \mathcal A_A\models\theta\},
$$
$$
\operatorname{CDiag}(\mathcal A)=\operatorname{Th}(\mathcal A_A).
$$
A <substructure> inclusion $\mathcal A\subseteq\mathcal B$ means that $A\subseteq B$, constants have the same interpretations, the operations of $\mathcal B$ restrict to those of $\mathcal A$, and each relation restricts to the corresponding relation on $A$.

An <elementary substructure> additionally preserves the truth of every <logical formula> with parameters from $A$:
$$
\boxed{\mathcal A\preccurlyeq\mathcal B\quad\Longleftrightarrow\quad
\mathcal A\models\phi(\vec a)\iff\mathcal B\models\phi(\vec a)
\text{ for every }\phi,\vec a\in A.}
$$
Here the right-hand condition includes the <substructure> requirements by applying it to atomic <logical formulas> and their <negations>.