If $p=0$ and $df=0$, is $f$ a $p$th power?

This question is a follow-up to When does the relative differential $df=0$ imply that $f$ comes from the base?. There it was asked, for an $A$-algebra $B$, under what conditions does $df=0$ (in the module of relative differentials $\Omega_{B/A}$) imply that $f$ is constant", i.e. lies in $A$. The answer relied on a characteristic 0 assumption. My question is about rings $A$ in which $p=0$ for a prime $p$.

Assume that $p=0$ in $A$. Let's also assume that $A$ is perfect in the sense that $A^p=A$. I don't want to assume, however, that $A$ is integral or even reduced. Let $B$ be an $A$-algebra. Let $f\in B$ be such that $df=0$ in $\Omega_{B/A}$.

Under what conditions on $A$ and $B$ may we deduce that $f\in B^p$?

Notice that the converse is always true, because $d(f^p)=pf^{p-1}df=0$. Also notice that if $f\in A$, then of course $df=0$, but by our hypothesis on $A$ we have $f\in A=A^p\subset B^p$.

The conclusion is true, for instance, when $B$ is a polynomial ring over $A$, and also (I think) when $B$ is etale over $A$.

-
Suppose we take an arbitrary perfect algebra and adjoin two elements, $x$ and $y$, satisfying $y^p=x^2+x+1$. Then $(2x+1)dx=0$ so $dx=0$ but $x$ is not in $B^p$. So I think you need to assume that $B^p$ is algebraically closed in $B$, or something. If you have that then I think you're done. Proof sketch: Consider first the algebra $A[f]$. If $f$ is algebraic over $A$, by the algebraic closure, we're done. So we can assume it's transcendental, so we construct a derivation that is nonzero on $f$. Then simply extend this derivation to the whole ring by adjoining elements in the right order. – Will Sawin Nov 18 '11 at 5:37