TITLE: The congruence $a^p+b^p\equiv 1\;(\text{mod}\;p^2)$
QUESTION [8 upvotes]: For each prime $p$, let
$
X_p=\{(a,b)\in\{1,...,p-1\}^2{\,{\large{\mid}}\,}a^p+b^p\equiv 1\;(\text{mod}\;p^2)\}
$.

Based on limited data testing, the following conjectures appear to hold:

$(1)\;\;X_p\ne{\large{\varnothing}}\;$for all primes$\;p\equiv 1\;(\text{mod}\;6)$.

$(2)\;\;X_p={\large{\varnothing}}\;$for infinitely many primes$\;p\equiv -1\;(\text{mod}\;6)$.

Any thoughts about the validity of these claims?

REPLY [3 votes]: This is not a complete answer. We have
$$(x + kp)^p \equiv x^p + {p \choose 1} x^{p-1} kp \equiv x^p \bmod p^2$$
which gives that if $a \equiv b \bmod p$ then $a^p \equiv b^p \bmod p^2$. (A special case of lifting the exponent.) Reducing the equation $\bmod p$ gives $a + b \equiv 1 \bmod p$, hence
$$a^p + b^p \equiv a^p + (1 - a)^p \equiv 1 \bmod p^2.$$
We know that this always holds $\bmod p$ so to investigate it $\bmod p^2$ we need to investigate the behavior of the function $D(a) = \frac{a^p - a}{p} \bmod p$. This is a function from $\mathbb{Z}/p^2$ to $\mathbb{Z}/p$, and the above equation is equivalent to $D(a) + D(1 - a) \equiv 0 \bmod p$.

Lemma: $D$ satisfies $D(ab) = D(a) b + a D(b)$. (So it's almost a derivation, except that it isn't additive.)

Proof. We have $(a^p - a)(b^p - b) \equiv 0 \bmod p^2$, which gives
$$(ab)^p - a b^p - a^p b + ab \equiv 0 \bmod p^2.$$
Rearranging this a bit gives
$$(ab)^p - ab \equiv a(b^p - b) + (a^p - a) b \bmod p^2$$
which is the desired identity. $\Box$
From here we need to assume that $p$ is odd, so note that the case $p = 2$ can be done by hand: we have $a^2 \equiv 0, 1 \bmod 4$ so the equation has no nontrivial solutions. Now suppose $p$ is odd so that $\mathbb{Z}/p^2$ has a primitive root $g$. Induction gives
$$D(g^n) = ng^{n-1} D(g)$$
which determines $D$ in terms of $D(g)$ on $(\mathbb{Z}/p^2)^{\times}$. Note that $D(g) = g \frac{g^{p-1} - 1}{p}$ is invertible $\bmod p^2$. It remains to determine $D$ on $p \mathbb{Z}/p^2$, but this is easy: if $a = pk$ then $D(a) \equiv -k \bmod p$. Now we split into cases.
Case 1: $1 - a \in p \mathbb{Z}/p^2$. Write $a = 1 + kp$, so $a \equiv 1 \bmod p$ gives $a^p \equiv 1 \bmod p^2$, so $D(a) = 0$ and $D(1 - a) = k$, which gives
$$D(a) + D(1 - a) \equiv k \equiv 0 \bmod p.$$
This gives $a \equiv 1 \bmod p^2, b \equiv 0 \bmod p^2$ so there are no nontrivial solutions in this case. By symmetry this also takes care of the case that $a \in p \mathbb{Z}/p^2$.
Case 2: Neither $a$ nor $1 - a$ is in $p \mathbb{Z}/p^2$. Then they're both powers of $g$. Write $a = g^n, 1 - a = g^m$, where $1 \le n, m \le p(p-1)$. Then
$$D(a) + D(1 - a) = ng^{n-1} D(g) + mg^{m-1} D(g) \equiv 0 \bmod p.$$
Dividing by $D(g)$ and multiplying by $g$ we get the system of equations
$$\boxed{ g^n + g^m \equiv 1 \bmod p^2 \\ ng^n + mg^m \equiv 0 \bmod p. }$$
Equivalently, write $\log_g$ for the discrete logarithm $\log_g g^n = n$ on $(\mathbb{Z}/p^2)^{\times}$, taking values in $\mathbb{Z}/(p(p-1))$. Then the equation $D(a) + D(1-a) \equiv 0 \bmod p$ becomes
$$\boxed{ a \log_g(a) + (1 - a) \log_g(1 - a) \equiv 0 \bmod p }.$$
This is a funny kind of "entropy $\bmod p$," so maybe Leinster's Entropy modulo a prime is relevant.
Edit: Looking at the linked question it looks like I made things too hard for myself. If $p \equiv 1 \bmod 6$ then we can take $a = \omega$ to be a primitive sixth root of unity $\bmod p^2$. This gives $1 - a = 1 - \omega = - \omega^2$ and hence
$$a^p + (1 - a)^p \equiv \omega^p + (-\omega^2)^p \equiv \omega - \omega^2 \equiv 1 \bmod p^2.$$
We have $- \omega^2 = \omega^{-1}$ which suggests taking $m = -n$. At this point it becomes clear that I made a mistake earlier (which has now been fixed): I assumed that $m, n$ couldn't be divisible by $p$, but this isn't true and in fact if $p \mid m, n$ then the second equation is trivial. If $a = \omega$ is a primitive sixth root of unity $\bmod p^2$ then $a = g^n$ where $n = \frac{p(p-1)}{6}$ and in particular $p \mid n$.