This has been asked here and here before, but not to my satisfaction - the first answer is not incredibly detailed to my mind, neither is the second - so hopefully this will be allowed as a question on its own. Specifically, I have tried to write out in detail the proof, and am looking for feedback on improvement/where I've totally misunderstood something. The question is exercise 2.5.1 of Smith's Invitation to Algebraic Geometry.
I'll use $ F: V \to W $ to denote a morphism of affine algebraic varieties, and $ F^* : \mathbb{C}[W] \to \mathbb{C}[V] $ the pullback of $F$ on the coordinate rings. The question: show that $F^*$ is injective if and only if $F(V)$ is dense in $W$. To do so we need to use the characterisation of density as having nonempty intersection with all open sets of $W$. In both directions I prove it by contradiction, which is (kind of) gross.
Assume $F^*$ is not injective, so that there exists $ g \in \mathbb{C}[W]$ such that $g \neq 0$ on $W$ and $ (gF)(x) = 0 $ for all $ x \in \mathbb{C}[V]$. We seek a contradiction of the second statement. Consider the open set $ U = \{y \in W : g(y) \neq 0\}$. If $ y \in U \cap F(V)$, then there exists $ x \in V $ so that $y = F(x)$, and $ g(y) \neq 0$. Thus $(gF)(x) \neq 0$, a contradiction.
Now assume $F(V)$ is not dense, i.e. there exists some nonempty open set $U \subseteq W$ so that $U\cap F(V) = \emptyset$. So there exists some family of polynomials $p_i$ with $i \in I$ so that $U = \{y \in W : p_i(y) \neq 0, i \in I\}$. Hence $U \cap F(V) = \emptyset$ implies that $(p_i F)(x) = 0$ for all $ i \in I$ and $x \in V$, which by the injectivity of $F$ means $p_i = 0$, i.e. $U = \emptyset$, a contradiction. End of proof.
I'm fairly confident in my writeup, but I'm also not sure if there might be better (maybe easier) ways of arguing the proof. I would like to avoid (if possible) more machinery than necessary, since at this point in time in the text Smith has not (formally) introduced many concepts. Any critique is welcome!
Your proofs are correct. There are a few minor improvements we could consider making.
For the first proof, we can rephrase it to avoid it being by contradiction without too much trouble. Consider the following:
In the second proof, the idea is good but the phrasing with the $p_i$ bugs me a little. Here's how I'd rephrase it to be a little more straightforwards while keeping the same idea.
If we wanted to run the proof in the forwards direction instead, here's how we might want to do that:
Personally, I like the first version of part 2 better, but the second version can also be instructive.