Image of base change of immersion I'm revising for my exams now and struggling with the following exercise:
Let $f: X \to S$ be an open or closed immersion and $g: S' \to S$ another morphism where $X,S,S'$ are schemes. Then the base-change morphism $f' : X \times_S S' \to S'$ is such that $\text{Im}(f') = g^{-1}(\text{Im}(f))$.
If anyone could prove this for me I'd be really grateful!
 A: In this answer, $X$(resp. $X\otimes_S S'$), and $\mathrm{Im} f$(resp. $\mathrm{Im} f'$) are identified. (This is not problematic at all, especially about $X\otimes_S S'$, and $\mathrm{Im} f'$, thanks to the following fact. This is a standard result in algebraic geometry, and I think you have proved it in class. However, if you do not know it, please see Section 7.3, Proposition 13 of S. Bosch, Algebraic Geometry and Commutative Algebra, Springer, 2013 for a proof.)
Fact $f'$ is an open (resp. closed) immersion if $f$ is an open (resp. closed) immersion.
When $f$ is an open immersion, it is clear from the pull-back diagram
$$
\begin{array}{ccccccccc}
g^{-1}(X)& \xrightarrow{f'} & S' \\
\downarrow&  & \downarrow{g} \\ 
X& \xrightarrow{f} & S, 
\end{array} 
$$
which owes to the universal property of open immersion.
Prop (The Universal Property of Open Immersion)
If $f:X\to Y$ is a morphism between schemes, $V\subseteq Y$ an open subset(, or subscheme), and $f(X)\subseteq V$, then there exists a unique morphism $f':X\to V$ whose composition with the open immersion $V\to X$ is $f$.
Proof You can do it through looking at the structure sheaf of V, etc.
When $f$ is a closed immersion, first assume that $S$, and $S'$(, and so $X$) are affine schemes. Let $S = \mathrm{Spec} A, X = \mathrm{Spec} A/\mathfrak{a}$, and $S' = \mathrm{Spec} B$. Then, $X\times_S S'=\mathrm{Spec} A/\mathfrak{a}\otimes_A B=\mathrm{Spec} B/\mathfrak{a}B = V(\mathfrak{a}B) = g^{-1}(V(\mathfrak{a})) = g^{-1}(X)$. For the second last equality, if $\phi: A\to B$ is the corresponding homomorphism between rings to $g$, then $\mathfrak{q}\in g^{-1}(V(\mathfrak{a}))\Leftrightarrow \phi^{-1}(\mathfrak{p})\in V(\mathfrak{a})\Leftrightarrow \phi^{-1}(\mathfrak{p})\supseteq\mathfrak{a}\Leftrightarrow\mathfrak{p}\supseteq\phi(\mathfrak{a})(=\mathfrak{a}B)\Leftrightarrow \mathfrak{p}\in V(\mathfrak{a}B)$.
In the general case, take an affine open covering $S = \cup_{j\in J} V_j$, and for each $j\in J$, $g^{-1}(V_j) = \cup_{i\in I_j} U_{i,j}$. Let $g_{i,j}:U_{i,j}\to V_j$, and $g_{j}:g^{-1}(V_j)\to V_j$ be the restriction of f. Then, $X\times_S S' = \cup_{j\in J}\cup_{i\in I_j} f^{-1}(V_j)\times_{V_j} U_{i,j} = \cup\cup g_{i,j}^{-1} (V_j) = \cup g_{j}^{-1} (V_j) = g^{-1}(V)$.
