A possible "finite set avoiding" version of Grothendieck's Zariski Main Theorem?

Recall that in EGA $$IV_3$$ (Théorème (8.12.6)), Grothendieck calls the following theorem Zariski's Main Theorem":

Let $$Y$$ be a quasi-compact separated scheme, and $$f : X \to Y$$ is a separated quasi-finite finitely presented morphism. Then it factors into $$X \to Z \to Y$$, where the first is an open immersion and the second is finite.

The way I always remembered this was as a quasi-finite version of a compactification theorem (e.g. Negata), so let's call $$Z \to Y$$, a compactification of $$X \to Y$$.

Regarding it, here is my question:

Under the situation of the above ZMT, in addition suppose both $$X$$, $$Y$$ are smooth integral affine $$k$$-schemes of finite type over a field $$k$$, with a sufficiently high dimension $$>0$$. Suppose we have a given finite set $$S \subset Y$$ of points. Then can we find a compactification $$Z \to Y$$ such that the image of the bad set" $$B:= Z \setminus X$$ in $$Y$$ under the finite morphism does not intersect the given finite set $$S$$?

Maybe I am making some redundant assumptions here. Note that since $$Z \to Y$$ is finite, the image of the bad set is a proper closed subset of $$Y$$. So, if the above holds, then I can actually find an affine open neighborhood $$U$$ of $$S$$, over which $$X_U \to U$$ itself is finite from the beginning.

I hope someone may know an answer, or may have an idea that may become useful in its resolution.

• There are trivial counterexamples to your question. For example, let $Y = \mathbb P^n$, let $X = \mathbb A^n$, and let $S = \{p\}$ be any point at infinity, i.e. $p \not \in X$. Whatever compactification of the inclusion $\mathbb A^n \to \mathbb P^n$ you choose, the boundary locus should always include a point above $p$. Nov 3 '18 at 17:22
• More generally, if the stalk $X \times_Y \operatorname{Spec} \mathcal O_{Y, p}$ is not finite over $\mathcal O_{Y, p}$ for some $p \in S$, then $Z \setminus X$ needs to contain a point above $p$. This is your comment after the question as well; it should be an assumption in the statement. Nov 3 '18 at 17:24
• @R.vanDobbendeBruyn Thank you. Let me add the assumption that $X \to Y$ is surjective, and over all points of S, it is already known to be finite. That would remove trivial counterexamples. (That was the case in the problem I was working on... from which this question came out.) Nov 3 '18 at 17:25
• @LSpice Oh, sure. Thank you. It was fixed. Dec 31 '21 at 0:14

Definition. Let $$f \colon X \to Y$$ be a quasi-finite morphism of varieties over a field $$k$$. Then let $$Z$$ be the normalisation of $$Y$$ in $$X$$, i.e. $$Z = \operatorname{\underline{Spec}}_Y \mathscr A$$ with $$\mathscr A$$ the normalisation of $$\mathcal O_Y$$ in $$f_* \mathcal O_X$$.
Note that $$g \colon Z \to Y$$ is finite [Tag 0BXS], and the map $$\iota \colon X \to Z$$ is an open immersion [Tag 02LR].
Lemma. Let $$U \subseteq Y$$ be an open above which $$f$$ is finite. Then $$\iota$$ is an isomorphism above $$U$$.
Proof. This is immediate from [Tags 035K and 03GP]. $$\square$$
If $$f$$ is finite above $$\operatorname{Spec} \mathcal O_{Y,y}$$ for some $$y \in Y$$, then it is finite in a neighbourhood of $$y$$. Thus, there exists a (nonempty) maximal open $$U \subseteq Y$$ above which $$f$$ is finite, and above this set the open immersion $$\iota \colon X \to Z$$ is an isomorphism. We conclude that $$g(Z \setminus X) = Y \setminus U,$$ so $$g(Z \setminus X)$$ avoids a set $$S$$ if and only if $$S \subseteq U$$, i.e. if and only if $$f$$ is already finite above $$S$$.