TITLE: Quotient of the ring of integers of a number field by a prime ideal
QUESTION [13 upvotes]: There is something I do not understand in my lecture notes, mainly because I do not understand quotients very well. We consider a number field $K = \mathbb{Q}(\sqrt{d})$ where $d$ is squarefree. 
If $\mathcal{O}_K$ denotes the ring of integers of $K$, it has a basis $\langle 1, \omega \rangle$ where $\omega$ is either $\sqrt d$ or $\frac{1+\sqrt{d}}{2}$ depending on $d \bmod 4$. We let $f(x) \in \mathbb{Z}[x]$ be the minimal polynomial of $\omega$ (so $f$ is monic of degree 2).
What I do not understand is first of all that we can write 
$
\mathcal{O}_K = \mathbb{Z}[x] / f(x)
$. Also, if $p \in \mathbb{Z}$ is prime, the notes then say
$$
\frac{\mathcal{O}_K}{(p)} = \frac{\mathbb{Z}[x]}{(p,f(x))} = \frac{\mathbb{F}_p[x]}{f(x) \bmod p}
$$
I do understand how to go from the first expression to the second(trivial when you know the above) but not how to go from the second to the third.
Also, the lecturer then gives the expression $\frac{\mathcal{O}_K}{(p)}$ when $p$ is ramified, split or inert. I do not really see why, in the sense how does it help to know that when $p$ is inert then 
$$
\frac{\mathcal{O}_K}{(p)} = \frac{\mathbf{F}_p}{f(x)} = \mathbf{F}_{p^2}
$$
for example ?
Thank you very much for your help !

REPLY [11 votes]: First, let us show that $\mathcal{O}_K$ is isomorphic to $\mathbb{Z}[x]/(f(x))$, with notation as in your question. Define a map:
$$\psi:\mathbb{Z}[x]/(f(x)) \to \mathcal{O}_K$$
by sending $x$ to $\omega$, and extend by $\mathbb{Z}$-linearity, i.e.,
$$\psi(q(x) \bmod (f(x))) = q(\omega),$$
for any $q(x)\in\mathbb{Z}[x]$. Then, $\psi$ is well defined (if $q(x)$ and $q'(x)$ are congruent modulo $(f(x))$ then they differ by a multiple of $f(x)$, but $f(\omega)=0$), it is a ring homomorphism, and its kernel is trivial (if $q(\omega)=0$, then the minimal polynomial of $\omega$, which is $f(x)$, must divide $q(x)$). The map is clearly surjective ($\psi(a+bx)=a+b\omega$), so it is an isomorphism.
For your second question, notice that if $p$ is in the ideal in the quotient, then this affects the coefficients of every polynomial, and in effect reduces each coefficient modulo $p$. Thus, 
$$\mathbb{Z}[x]/(p,f(x)) \cong (\mathbb{Z}/p\mathbb{Z})[x]/(f(x) \bmod p\mathbb{Z}[x]) \cong \mathbb{F}_p[x]/(\tilde{f}(x)),$$
where $\tilde{f}(x)$ is the polynomial we obtain when we reduce each coefficient of $f(x)$ modulo $p$, and consider each coefficient in $\mathbb{F}_p$.
If $f(x)$ is irreducible over $\mathbb{F}_p[x]$, then $(\tilde{f}(x))$ is a prime ideal (and also a maximal ideal). Hence, the quotient $\mathbb{F}_p[x]/(\tilde{f}(x))$ is a field. Since $f(x)$ is of degree $2$, this field is isomorphic to $\mathbb{F}_{p^2}$. Hence,
$$\mathcal{O}_K/(p) \cong \mathbb{Z}[x]/(p,f(x)) \cong \mathbb{F}_p[x]/(\tilde{f}(x)) \cong \mathbb{F}_{p^2}.$$