defining a dominant rational map from an algebra homomorphism (Theorem I 4.4 in Hartshorne) The following shows up in the proof of theorem I 4.4 in Hartshorne.
Let $X,Y$ be varieties and $\theta: K(Y) \rightarrow K(X)$ a homomorphism of $k$-algebras. We want to construct a dominant rational map $X \rightarrow Y$. We can assume that $Y$ is affine with coordinate ring $A(Y)$. Let $y_1,\cdots,y_n$ be $k$-algebra generators of $A(Y)$. Then $\theta(y_1),\cdots,\theta(y_n) \in K(X)$ and we can find an open set $U$ of $X$ such that $\theta(y_i)$ is regular on $U$. Then by restricting $\theta$ on $A(Y)$ we obtain a $k$-algebra homomorphism $A(Y) \rightarrow \mathcal{O}(U)$. 
So far, i have clear understanding.
But then Hartshorne says that the homomorphism $A(Y) \rightarrow \mathcal{O}(U)$ is injective, and this is where i am stuck. Here is my effort: Let $p(y)$ be inside the kernel. Then $\theta|_{A(Y)}(p(y))=0 \Rightarrow p(\theta(y))=0 \Rightarrow p(\theta(y_1)(P),\cdots,\theta(y_n)(P))=0, \forall P \in X \Rightarrow (\theta(y_1)(P),\cdots,\theta(y_n)(P)) \in \mathcal{Z}(p)$. 
The goal should be to show that $p$ actually vanishes on $Y$, which would be true if every point of $Y$ can be written in the form $(\theta(y_1)(P),\cdots,\theta(y_n)(P))$. But why would this be true?
Edit: Additionally, how do we see that the induced morphism of varieties $U \rightarrow Y$ gives a dominant rational map $X \rightarrow Y$?
 A: While it is technically correct that once we have a morphism $K(Y) \to K(X)$, it is necessarily injective, and hence the map on subrings $A(Y) \to \mathcal O(U)$ is also injective, phrasing things this way is to some extent getting the underlying logic backwards.
The more basic question is: when we have a dominant rational map $X \to Y$, why does it induce a map $K(Y) \to K(X)$?  Again, let's assume $Y$ is affine, and replace $X$ by a sufficiently small affine open subset so that the rational map is actually regular on $U$.  Then, we are asking: given a dominant morphism
$U \to Y$, why does it induce a morphism $K(Y) \to K(U)$ ($= K(X)$)?
The reason is because the assumption of dominance implies that
$A(Y) \to A(U)$ ($= \mathcal O(U)$) is injective!
(And an injection of integral domains always induces a map, necessarily injective, of the associated fraction fields.)
Why is this map injective?  Because any element in the kernel would vanish identically on the image of $U$ (since the map if just pull-back of functions), and hence on the closure of the image of $U$ (by def'n of the Zariksi topology).  But since our morphism is dominant, the image of $U$ is dense in $Y$.  Thus any element in the kernel vanishes on all of $Y$, i.e. vanishes identically, i.e. the kernel is trivial, i.e. the map $A(Y) \to A(U)$ is injective.
[Indeed, this reasoning shows that $A(Y) \to A(U)$ being injective is equivalent to $U \to Y$ having dense image, i.e. being dominant, because if the image is not dense, then there will be some function on $Y$ that vanishes on the image but not on all of $Y$, again by def'n of the Zariksi topology. See my answer here for an elaboration on this point.]
A: I believe he is using the fact that the homomorphism $A(Y)\to K(X)$ factors through $K(Y)$, which by assumption is the fraction field of the domain $A(Y)$, as $Y$ is taken to be affine. Since $K(Y)\to K(X)$ is necessarily injective, the composition is injective. Then, he claims there exists $\mathcal O(U)$, a subring of $K(X)$, such that the map $A(Y)\to K(X)$ factors through $\mathcal O(U)$.
