Solution (source code)

= Solution

The <empty-set cases for Cartesian projections> matter here. For $p_i$, write $X_j$ for the other factor. If $X_j$ is nonempty, any $x_i\in X_i$ can be paired with an element of $X_j$, so $p_i$ is <surjective>. If $X_j$ is empty, the <Cartesian product> is empty and its image is empty. Consequently
$$
\boxed{p_i\text{ is surjective}\iff X_i=\varnothing
\ \text{or}\ X_j\ne\varnothing.}
$$
The possibility $X_i=\varnothing$ is included because the empty <function> onto the empty set is <surjective>.

If $X_i$ is empty, $p_i$ has empty domain and is <injective>. If $X_j$ has at most one element, an ordered pair is determined by its $i$th coordinate, so $p_i$ is also <injective>. Conversely, when $X_i$ is nonempty and $X_j$ contains two different elements, pairing those two elements with one fixed $x_i$ gives distinct ordered pairs with the same <projection map>. Therefore
$$
\boxed{p_i\text{ is injective}\iff X_i=\varnothing
\ \text{or}\ |X_j|\leq1.}
$$