Solution (source code)

= Solution

A <morphism of schemes> $f:X\to Y$ is a <flat morphism> when each <local ring> $\mathcal O_{X,x}$ is a <flat module> over $\mathcal O_{Y,f(x)}$: tensoring with it preserves <exact sequences>. An <open immersion> induces isomorphisms on the <local rings> at its points, so it is flat.

For a <closed immersion>, the printed equivalence is valid with the additional hypothesis of finite presentation, for example over a locally Noetherian target, and with nonempty source. Here is the proof with that hypothesis. On an <affine chart> the map is $A\to A/I$, with $I$ finitely generated. If $\mathfrak p\supseteq I$, the flat cyclic <module> $A_{\mathfrak p}/I_{\mathfrak p}$ is free over the <local ring> $A_{\mathfrak p}$, and its residue-field <dimension> is one. Therefore its quotient map from $A_{\mathfrak p}$ is an <isomorphism> and $I_{\mathfrak p}=0$. Finite generation gives a neighbourhood of $\mathfrak p$ on which $I$ vanishes. The closed image $V(I)$ is consequently open. A nonempty <clopen> image in a connected target is the whole target; then $I$ vanishes at every prime and is zero. The immersion is an <isomorphism>. The converse is immediate. This proves the <flat closed immersion of finite presentation> assertion.

Without finite presentation, connectedness alone does not suffice. Take $A=C([0,1],\mathbb R)$ and let $\mathfrak m=\{a:a(0)=0\}$. Let $I$ consist of functions vanishing on some neighbourhood of zero. The map $A\to A_{\mathfrak m}$ has kernel $I$: multiplying such a function by a continuous cutoff equal to one at zero kills it, whereas $ga=0$ with $g(0)\ne0$ forces $a$ to vanish near zero. This map is surjective, because the reciprocal of any denominator nonzero at zero can be extended continuously from a small neighbourhood of zero to the whole interval. Thus
$$
A/I\cong A_{\mathfrak m}.
$$
The map $\operatorname{Spec}(A/I)\to\operatorname{Spec}A$ is both a <closed immersion> and a flat <localization>. Its source is connected because its <ring> is local. Its target is connected because continuous <idempotent> functions on the connected interval can only be the constants zero and one. It is not an <isomorphism>: $I$ contains nonzero functions supported away from zero. This supplies a concrete counterexample to the unrestricted assertion. The kernel is a <pure ideal>; this is the general mechanism behind such examples, as explained in https://stacks.math.columbia.edu/tag/04PQ[the Stacks Project's treatment of pure ideals].

For the finite-flat fibre assertion, first note the local algebra fact that a finitely generated <flat module> $M$ over a <local ring> $(A,\mathfrak m)$ is free. Choose generators $m_1,\ldots,m_r$ whose residues form a <basis> of $M/\mathfrak mM$, using <Nakayama's lemma>. If a row $a=(a_1,\ldots,a_r)$ gives a relation $\sum a_im_i=0$, the <equational criterion for flatness> supplies elements $n_j$ and a <matrix> $B=(b_{ij})$ such that $m_i=\sum_jb_{ij}n_j$ and $aB=0$. Write each $n_j$ as a linear combination of the $m_i$, with coefficient <matrix> $C$. Then $m=BCm$. Independence modulo $\mathfrak m$ makes $BC$ congruent to the identity. This square <matrix> is invertible over the <local ring>, and $aBC=0$ implies $a=0$. Thus the chosen generators are a <basis>. This also justifies the cyclic-module step above; see https://stacks.math.columbia.edu/tag/00NV#lemma-finite-flat-local[the finite-flat local lemma].

Now let $\mathcal A=f_*\mathcal O_X$ for the finite <flat morphism>. On each <affine chart> this is the finite flat algebra defining its inverse image. Hence $\mathcal A_y$ is free over $\mathcal O_{Y,y}$, of some finite rank $r_y$. Let $\eta$ be the <generic point> of the irreducible target. Localizing that <free module> at $\eta$ gives
$$
\mathcal A_\eta\cong\mathcal O_{Y,\eta}^{\oplus r_y}.
$$
Every point specializes from the same $\eta$, so every $r_y$ equals the fixed rank at $\eta$. This remains valid if the irreducible target is nonreduced: one compares free ranks over its nonzero generic <local ring>, not necessarily over a <field>. The fibre is affine, and
$$
\Gamma(X_y,\mathcal O_{X_y})\cong\mathcal A_y\otimes_{\mathcal O_{Y,y}}\kappa(y).
$$
Consequently
$$
\boxed{\dim_{\kappa(y)}\Gamma(X_y,\mathcal O_{X_y})=r_\eta\quad\text{for every }y.}
$$
This is <finite flat rank over an irreducible scheme>. No unjustified replacement of finite flat by finite locally free on an arbitrary base is needed.

For an algebraic curve of finite type over a <field>, its <normalization of an integral scheme> is finite and birational. If flat, the preceding rank is one, since the generic fibre has the same <function field>. Locally its normalization algebra $B$ is therefore a free $A$-module of rank one. The element $1_B$ generates: its image cannot vanish in the one-dimensional fibre algebra, and <Nakayama's lemma> applies. Thus $A\to B$ is an <isomorphism>. Conversely the identity normalization is flat.

The parenthetical definition in the PDF does not explicitly impose finite type. One can prove the conclusion even in that broader setting without assuming a finite normalization. For any <affine chart>, let $A\subseteq B\subseteq\operatorname{Frac}(A)$ describe its <normalization of an integral scheme>. Integrality makes the map on spectra surjective; if $B$ is flat it is faithfully flat. Faithful flatness gives contraction of <ideals>, $vB\cap A=vA$. For $b=u/v\in B$, with $u,v\in A$ and $v\ne0$, one has $u=vb\in vB\cap A=vA$. Thus $u=va$ for some $a\in A$, so $b=a$. Therefore $B=A$ on every chart. We have proved the <flat normalization is an isomorphism> result and, in particular,
$$
\boxed{C'\to C\text{ is flat}\iff C'=C.}
$$