Solution (source code)

= Solution

The <compactness theorem> says that a set $T$ of <first-order sentence>[first-order sentences] has a <model of a first-order theory>[model] if and only if every finite subset of $T$ has a model. One implication follows by taking the same model. Conversely, if $T$ had no model, then by the <Godel completeness theorem> it would prove a contradiction. A formal proof uses only finitely many assumptions, so some finite subset of $T$ would already have no model. This contradiction proves compactness.

The <Upward Lowenheim-Skolem theorem> says that if an $L$-theory $T$ has an infinite model, then it has models of arbitrarily large cardinality; more precisely, it has a model of cardinality at least $\kappa$ for every cardinal $\kappa$. Add new constants $c_\alpha$ for $\alpha<\kappa$ and the sentences
$$
c_\alpha\ne c_\beta\qquad(\alpha\ne\beta).
$$
Every finite subset of the enlarged theory can be interpreted in the given infinite model, since it mentions only finitely many constants. Compactness supplies a model of the whole enlarged theory, in which the $c_\alpha$ are pairwise distinct. Its reduct to $L$ is a model of $T$ having at least $\kappa$ elements. If $\kappa\geq|L|+\aleph_0$, the <Downward Lowenheim-Skolem theorem> gives a model of cardinality exactly $\kappa$.