Upper semicontinuity of fibre dimension on the target This is Vakil 18.1.C. Suppose $\pi : X \to Y$ is a projective morphism where $Y$ is locally Noetherian (or more generally $\mathcal{O}_Y$ is coherent over itself). Show that $\{y \in Y : \dim \pi^{-1}(y) > k\}$ is a Zariski-closed subset of $Y$. 
He says this exercise is important to know how projective morphisms work so I ideally I should work it out for myself. But I am reading the chapter without having read a lot of the preceding chapters so I am finding it rather difficult. I would like some copious hints and directions. His suggestion seemed to me to be to find a hypersurface upstairs that could somehow collect the fibres into a closed subset. Then perhaps to push down this closed subset while claiming $\pi$ is a closed map. But I don't see how to this. Thanks.
 A: I think the current answer doesn't solve the problem, since $a)$ I don't follow the argument for why it is sufficient to consider the case of closed points, and $b)$, it applies a previous theorem about projective space over a field to projective space over a general ring, where I'm not sure it holds. 
Here's a complete solution. The problem with the approach one would immediately think of (by applying Vakil's $11.3.C$, or similar results about intersecting closed subschemes of $\mathbb{P}_k^n$ with hyperplanes) is that the fibres are not naturally given to us as closed subsets of projective space over a field, they are given as (not necessarily closed) subsets of projective space over a ring. The fix is surprisingly simple, although a little confusing in the sense that it will give the fibre the structure of a closed subscheme of $\mathbb{P}_k^n$ for a suitable field $k$, in addition to it's already ambiguous status as a subset of $X$ and a scheme in it's own right.
Let $Y_r = \{p \in Y : \dim (\pi^{-1}(p)) \leq r$. We aim to show that $Y_r$ is open.
Take $q \in Y_r$, and let $q \in U \cong \operatorname{Spec}(A)$ be an affine open piece of $Y$, so by projectivity, $V = \pi^{-1}(U)$ is isomorphic to a closed subscheme of $\mathbb{P}_A^n$. Since $\pi: V \rightarrow U$ factors through $\mathbb{P}_A^n$, the map $\pi^{-1}(p)\rightarrow \operatorname{Spec(\kappa(p))}$ factors through $\mathbb{P}_{\kappa(p)}^n$, and since $V \rightarrow \mathbb{P}_A^n$ is a closed embedding, so is $\pi^{-1}(p)\rightarrow \mathbb{P}_{\kappa(p)}^n$. The below is a fibre diagram for the situation:
$$
\require{AMScd} \begin{CD}
    \pi^{-1}(p) @>>>\mathbb{P}_{\kappa(p)}^n@>>>\operatorname{Spec}(\kappa(p))
    \\ @VVV @VVV @VVV\\
    V @>>> \mathbb{P}_A^n @>>> \operatorname{Spec}(A)
    \end{CD}
$$
But now $\pi^{-1}(p)$ is a closed subscheme of $\mathbb{P}_{\kappa(p)}^n$, of dimension $\leq r$, and so we may find $r+1$ hyperplanes $H'_i$ in $\mathbb{P}_{\kappa(p)}^n$ such that $\pi^{-1}(p)\cap_i H'_i = \phi$. Now take hyperplanes $H_i \subset \mathbb{P}_A^n$ that have pre-image $H'_i$ in $\mathbb{P}_{\kappa(p)}^n$ (makes sure you know how to do this!). Then it must be the case that $\pi^{-1}(p)\cap_i H_i = \phi$ (since any element of this intersection would come from an element of $\pi^{-1}(p)\cap H'_i \subset \mathbb{P}_{\kappa(p)}^n$ - although this needs a little thought). Then let $U' = U \setminus \pi(X\cap_i H_i)$, an open subset of $Y$ containing $p$.
To finish, we show $U' \subset Y_r$. Let $q \in Y_r$, and then as before we have a closed embedding $\pi^{-1}(q)\rightarrow \mathbb{P}_{\kappa(q)}^n$ and a map $\mathbb{P}_{\kappa(q)}^n\rightarrow \mathbb{P}_A^n$. Letting $H_i''$ be the hyperplanes of $\mathbb{P}_{\kappa(q)}^n$ corresponding to the pre-images of $H_i$, we have that $\pi^{-1}(q) \cap_i H_i'' = \phi$ and so by $11.3.B$, we must have that the dimension of $\pi^{-1}(q)$ is at most $r$.
A: I have attempted the question and I can give some hints. I may not be correct though, but I will be happy to discuss. Basically Irfan Kadikoylu has given a huge hint but I can write a bit more.
We will show that $\{y\in Y:\dim\pi^{-1}(y)\leq k\}$ is open.
First we assume that $Y$ is affine. 
We may assume that $q\in Y$ is a closed point. This is because every point $y\in Y$ has a closed point $q$ in its specialisation. Then every open set containing $q$ must contain $y$ as a consequence. Otherwise there exists $V$ open neighbourhood of $q$ such that $y\notin V$, and hence $y\in Y-V$ is closed and so $q$ does not lie in the closure of $y$. 
Why do we need $q$ a closed point? So that $\pi^{-1}(q)$ is a closed subscheme of $X$ by the following cartesian diagram
$\require{AMScd}
\begin{CD}
\pi^{-1}(q) @>>> X;\\
@VVV @V{\pi}VV \\
\{q\} @>{\text{closed}}>> Y
\end{CD}$
Since $\pi:X\rightarrow Y$ is projective, hence $\pi^{-1}(q)$ is a closed subscheme in a projective space, say $\mathbb{P}^{n}_{A}$ (where $Y=\text{Spec}A$).
Now:
Thoughts
By exercise 11.3.C(c), we may find $k+1$ hypersurfaces $H_{1}$,...,$H_{k+1}$ such that $H_{1}\cap...\cap H_{k+1}$ avoids $\pi^{-1}(q)$. Then $X\cap H_{1}\cap...\cap H_{k+1}$ is a closed subset of $X$.
Now $\pi(X\cap H_{1}\cap...\cap H_{k+1})$ is closed in $Y$ (why? Because something => proper....). Then we take $Y-W$ where $W=\pi(X\cap...\cap H_{k+1})$. It is an open neighbourhood.
Does it contain $q$?
Let $p\in Y-W$. Then is it true that $\pi^{-1}(p)\subseteq \mathbb{P}^{n}_{A}-H_{1}\cap...\cap H_{k+1}$?
Now: is it true that $\dim \pi^{-1}(p)\leq k?$ Suppose for the sake of fun that $\dim\pi^{-1}(p)\geq k+1$. If you have done Exercise 11.3.C(a) you will find that the intersection should be non-empty (I highly recommend doing this exercise at least ONCE. If you are stuck with 11.3.C(a), I think you can find inspiration from Hartshorne). One way to think of it is that in $\mathbb{A}^{n+1}$, we look at the cone $C(\pi^{-1}(p))$ which is of dimension at least $k+2$. But the codimension of the cone of $H_{1}\cap...\cap H_{k+1}$ remains the same. Now give an algebraic formulation of the statement and use K??ll's Hau??id???satz to count the dimension of the intersection.
Conclusion
Hence if $\dim \pi^{-1}(p)\geq k+1$, it intersects the $k+1$ hypersurfaces. But it must contradict something right?
