Principal prime ideal is generated by irreducible element 
$R$ is an integral domain, $x\in R$ and $(x)=I$ is a prime ideal. Prove that $x$ is an irreducible element of $R$.

So I assume $ab\in I$, with $a, b \in R$. Since $I$ is a prime ideal, either $a$ is in $I$ or $b$ is in $I$. Assume $a\in I$. Then $a = xr$ for some $r \in R$. But $ab$ is also an element of $I$, so $ab = xr$. Subbing in for $a$, we obtain $(xr)b=xr$, so $b$ must be a unit and therefore $x$ is irreducible.
So the reason I think this might be wrong is because $r$ doesn't have to be the same $r$ for both $a$ and $ab \in I$, but I don't know. Would appreciate a little guidance.
 A: While it is true that, for all $y\in I,$ there is some $r\in R$ such that $y=xr,$ it does not have to be the same $r$ for every $y.$ In fact, the only way it can be the same for every $y\in I$ is if there is only one $y\in I$, which means that $x=0$.
More formally, we have the following:

Suppose $R$ is a ring, $x\in R,$ and $I=(x).$ then the following are equivalent:
-There exists some $r\in R$ such that $y=xr$ for all $y\in I.$
-There is exactly one element in $I.$
-$x=0.$

Suppose $y_1,y_2\in I.$ If some $r\in R$ exists as described in the first statement, then $y_1=xr=y_2,$ meaning that all elements of $I$ are equal, which (since ideals are never empty) means that $I$ has one element.
Now, if $I$ has exactly one element, it must be $x$ by definition of $I,$ but it must be $0$ since $I$ is an additive subgroup of $R$ (as all ideals of $R$ are), and so $x=0.$
I leave the last implication to you.

You cannot conclude that $b$ is an irreducible element, because it isn't necessarily true. Consider $R=\Bbb Z,$ $x=3,$ $a=15,$ and $b=4$. Now, $I=(x)$ is a prime ideal, and both $a,ab\in I,$ but $b$ is not irreducible.

Now, on to the result that you're trying to prove. Instead, suppose that $x=ab$ for some $a,b\in R.$ Show that $a$ or $b$ must be a unit, and so $x$ is irreducible. (Hint: Since $ab=x\in I$ and $I$ is a prime ideal, then....)
