I have a question on a proof in Algebraic Geometry by Robin Hartshorne. Here is the proof:

Theorem. Let $\displaystyle Y \subseteq \mathbb{A}^n$ be an affine variety with affine coordinate ring $\displaystyle A(Y)$. Then $\displaystyle \mathcal{O}(Y) \cong A(Y)$.

Proof. We define a map $\displaystyle \alpha : A(Y) \rightarrow \mathcal{O}(Y)$. Every polynomial $\displaystyle f \in A = k[x_1, \ldots, x_n]$ defines a regular function on $\displaystyle \mathbb{A}^n$ and hence on $\displaystyle Y$. Thus we have a homomorphism $\displaystyle A \rightarrow \mathcal{O}(Y)$. Its kernel is $\displaystyle I(Y)$, so we have an injective homomorphism $\displaystyle \alpha : A(Y) \rightarrow \mathcal{O}(Y)$.

Now note that $\displaystyle \mathcal{O}(Y) \subseteq \displaystyle \bigcap_{P \in Y} \mathcal{O}_P$, where all our rings are regarded as subrings of $\displaystyle K(Y)$. Now by Theorem 3.2 in Hartshorne parts (b) and (c) we have $\displaystyle A(Y) \subseteq \mathcal{O}(Y) \subseteq \displaystyle \bigcap_{m} A(Y)_m $, where $\displaystyle m$ runs over all maximal ideals of $\displaystyle A(Y)$. Equality now follows from the algebraic fact that if $\displaystyle B$ is an integral domain, then $\displaystyle B$ is equal to the intersection (inside its quotient field) of its localizations at all maximal ideals.

I don't understand this part:

Its kernel is $\displaystyle I(Y)$, so we have an injective homomorphism $\displaystyle \alpha : A(Y) \rightarrow \mathcal{O}(Y)$.

Why is the kernel $\displaystyle I(Y)$? Also, why is this an injective homomorphism? Thanks in advance.