TITLE: Exercise on separable polynomials over fields of prime characteristic
QUESTION [7 upvotes]: Having learned about separable polynomials today in class, I tried to do the following exercise concerning separable polynomials, namely:

Suppose $f$ is the minimal polynomial of $a$ over a field $F$ of prime characteristic. Let $K = F[a]$. Then $f$ is separable iff $F[a^p] = K$.

Now one direction I have proved, that is not separable implies $F[a^p] \subsetneqq F[a]$. For the other direction, I have some trouble at the end( which I will describe).
Suppose $f$ is separable and let $g$ be the minimal polynomial of $a$ over $F[a^p]$. We show that $g$ has degree one so that $a \in F[a^p]$, proving that $F[a] = F[a^p]$. Suppose we consider $g,f$ as polynomials in $\big(F[a]\big)[x]$. Then $g(a) = f(a) = 0$ in $\big(F[a]\big)[x]$. Since
$$[F[a]:F] > \bigg[F[a]:F[a^p] \bigg],$$
this means that $g |f$. Now write $f(x) = (x-a)u$ where $u$ is some polynomial with coefficients in $F[a]$. Then we observe that since $a$ is algebraic over $F$, $F[a] = F(a)$ that is a field, hence trivially a UFD. Therefore the polynomial ring $\big( F[a] \big)[x]$ is a UFD so that $g$ being irreducible is actually prime. Now what I want to do now is to show that if $g|f$, then $g$ must divide $(x-a)$ forcing $g = (x-a)$ up to multiplication by a unit.
Suppose $g \nmid (x-a)$ so that $g|u$ by $g$ being a prime element in $\big(F[a]\big)[x]$. Since $f$ is separable its derivative is not zero, so that if $g$ divides $f'(x) = (x-a)u' + u$ then I will have my desired contradiction. This is because we will have $g|u$ and $g|u'$ implying that $u$ has a multiple root, contradicting $f$ having no multiple roots.
The problem now is how do I know that $g|f'(x)$? If it is not true here that $g|f'(x)$, can the approach I have done above be salvaged?
For reference, the following theorem may be useful: Let $f$ be an irreducible polynomial in $F[x]$. The following are equivalent:

(1) $f(x)$ is not separable.
(2) $f'(x) = 0$
(3) $\operatorname{Char} F = p >0$ and $f$ is a polynomial in $x^p$

REPLY [12 votes]: If $F[a]=F[a^p]$, then $a=P(a^p)$ for some $P(X)\in F[X]$. Therefore $f(X) \mid P(X^p)-X$. The latter polynomial is separable (i.e. no multiple root in an algebraic closure of $F$) because its derivative is $1\ne 0$. So $f(X)$ is also separable. 
Conversely, if $F[a]\ne F[a^p]$, then the extension $F[a^p] \to F[a]$ is purely inseparable and $a$ is inseparable over $F[a^p]$, thus inseparable over $F$. 
Edit Some more details on the converse. Denote by $b=a^p$. As $a\notin F[b]$, $X^p-b\in F[b][X]$ is irreducible (any factor is of the form $(X-a)^r$ for some $r\ge 1$. But $(X-a)^r\in F[b][X]$ implies that $r=p$). So it is the minimal polynomial of $a$ over $F[b][X]$. As it divides $f(X)$, the latter is inseparable.