[proofplan]
We reduce the exponent $n \geq 3$ to the two essential cases: exponent $4$ and odd prime exponent $p$. The exponent $4$ case is excluded by Fermat's descent. For an odd prime exponent, a primitive solution produces the Frey curve $E_{a,b,p}$, which is semistable; Wiles's theorem makes this curve modular, while [Ribet's theorem](/theorems/4516) says the same curve is not modular. The contradiction eliminates all odd prime exponent solutions, and the exponent reduction then eliminates every exponent $n \geq 3$.
[/proofplan]
[step:Reduce an arbitrary exponent to exponent $4$ or an odd prime exponent]
Assume, for contradiction, that [Fermat's Last Theorem](/theorems/4789) fails. Then there exist an integer $n \geq 3$ and positive integers $x,y,z \in \mathbb{N}$ such that
\begin{align*}
x^n + y^n = z^n.
\end{align*}
We distinguish two cases.
If $4 \mid n$, define $q_4 \in \mathbb{N}$ by
\begin{align*}
q_4 := \frac{n}{4}.
\end{align*}
Define positive integers $X,Y,Z \in \mathbb{N}$ by
\begin{align*}
X := x^{q_4}, \qquad Y := y^{q_4}, \qquad Z := z^{q_4}.
\end{align*}
Then
\begin{align*}
X^4 + Y^4 = Z^4,
\end{align*}
contradicting Fermat's descent for exponent $4$ (citing a result not yet in the wiki: Fermat's descent for exponent $4$).
If $4 \nmid n$, then $n$ has an odd prime divisor $p$. Define $q_p \in \mathbb{N}$ by
\begin{align*}
q_p := \frac{n}{p}.
\end{align*}
Define positive integers $A,B,C \in \mathbb{N}$ by
\begin{align*}
A := x^{q_p}, \qquad B := y^{q_p}, \qquad C := z^{q_p}.
\end{align*}
Then
\begin{align*}
A^p + B^p = C^p.
\end{align*}
Thus it remains to exclude positive integer solutions for every odd prime exponent $p$.
[guided]
Suppose a counterexample exists for some exponent $n \geq 3$. The purpose of this step is to show that such a counterexample automatically gives a counterexample either for exponent $4$ or for an odd prime exponent.
First suppose $4 \mid n$. Define $q_4 \in \mathbb{N}$ by
\begin{align*}
q_4 := \frac{n}{4}.
\end{align*}
The definitions
\begin{align*}
X := x^{q_4}, \qquad Y := y^{q_4}, \qquad Z := z^{q_4}
\end{align*}
produce positive integers $X,Y,Z \in \mathbb{N}$. Raising each definition to the fourth power gives
\begin{align*}
X^4 = x^n, \qquad Y^4 = y^n, \qquad Z^4 = z^n.
\end{align*}
Substituting into $x^n+y^n=z^n$ gives
\begin{align*}
X^4 + Y^4 = Z^4.
\end{align*}
This contradicts Fermat's descent for exponent $4$ (citing a result not yet in the wiki: Fermat's descent for exponent $4$).
Now suppose $4 \nmid n$. Since $n \geq 3$, either $n$ is odd or $n=2m$ with $m$ odd and $m \geq 2$. In both cases, the prime factorization of $n$ contains an odd prime divisor $p$. Because $p \mid n$, define $q_p \in \mathbb{N}$ by
\begin{align*}
q_p := \frac{n}{p}.
\end{align*}
Define
\begin{align*}
A := x^{q_p}, \qquad B := y^{q_p}, \qquad C := z^{q_p}.
\end{align*}
Then $A,B,C \in \mathbb{N}$ and
\begin{align*}
A^p = x^n, \qquad B^p = y^n, \qquad C^p = z^n.
\end{align*}
Substitution again gives
\begin{align*}
A^p + B^p = C^p.
\end{align*}
Therefore any counterexample with exponent not divisible by $4$ yields a counterexample with odd prime exponent.
[/guided]
[/step]
[step:Pass to a primitive solution for an odd prime exponent]
Let $p$ be an odd prime. Suppose, for contradiction, that there exist positive integers $A,B,C \in \mathbb{N}$ such that
\begin{align*}
A^p + B^p = C^p.
\end{align*}
Let $d := \gcd(A,B,C)$. Define positive integers $a,b,c \in \mathbb{N}$ by
\begin{align*}
a := A/d, \qquad b := B/d, \qquad c := C/d.
\end{align*}
Since $d^p$ divides each term in the equation, division by $d^p$ gives
\begin{align*}
a^p + b^p = c^p.
\end{align*}
Moreover $\gcd(a,b,c)=1$. If a prime $\ell$ divided both $a$ and $b$, then $\ell$ would divide $c^p=a^p+b^p$, hence $\ell$ would divide $c$, contradicting $\gcd(a,b,c)=1$. The same argument applied to the pairs $(a,c)$ and $(b,c)$ shows that $a,b,c$ are pairwise coprime.
[/step]
[step:Attach the semistable Frey curve to the primitive solution]
Define the Frey curve $E_{a,b,p}$ over $\mathbb{Q}$ by the affine Weierstrass equation
\begin{align*}
E_{a,b,p}: y^2 = x(x-a^p)(x+b^p).
\end{align*}
The three roots of the cubic on the right are $0$, $a^p$, and $-b^p$. They are distinct because $a,b \in \mathbb{N}$, so $a^p>0$, $-b^p<0$, and $0$ lies strictly between them. Hence the displayed Weierstrass equation is nonsingular and defines an elliptic curve over $\mathbb{Q}$.
By the semistability input in the theorem statement, for every odd prime $p$ and every pairwise coprime positive integer solution $a,b,c \in \mathbb{N}$ of $a^p+b^p=c^p$, the Frey curve defined by $y^2=x(x-a^p)(x+b^p)$ is a semistable elliptic curve over $\mathbb{Q}$. The present integers $a,b,c$ satisfy exactly these hypotheses, so $E_{a,b,p}$ is semistable over $\mathbb{Q}$.
[guided]
The point of introducing $E_{a,b,p}$ is that this curve converts an arithmetic solution of the Fermat equation into an object governed by modularity theorems. We define the curve explicitly by
\begin{align*}
E_{a,b,p}: y^2 = x(x-a^p)(x+b^p).
\end{align*}
To see that this equation defines an elliptic curve over $\mathbb{Q}$, we check nonsingularity. The roots of the cubic polynomial $x(x-a^p)(x+b^p)$ are $0$, $a^p$, and $-b^p$. Since $a,b \in \mathbb{N}$, these three rational numbers are distinct. A Weierstrass equation of the form $y^2=(x-r_1)(x-r_2)(x-r_3)$ with distinct roots is nonsingular, so $E_{a,b,p}$ is an elliptic curve over $\mathbb{Q}$.
The semistability input is now one of the theorem's stated assumptions. It says: for every odd prime $p$ and every pairwise coprime positive integer solution $a,b,c \in \mathbb{N}$ of
\begin{align*}
a^p+b^p=c^p,
\end{align*}
the Frey curve $y^2=x(x-a^p)(x+b^p)$ is semistable over $\mathbb{Q}$. We verify each hypothesis in the present situation: $p$ is an odd prime by the reduction step, $a,b,c$ are positive integers, the equation above holds, and the previous step proved that $a,b,c$ are pairwise coprime. Therefore the semistability input applies and yields that $E_{a,b,p}$ is semistable over $\mathbb{Q}$.
[/guided]
[/step]
[step:Use Wiles's theorem and Ribet's theorem to get a contradiction]
Since $E_{a,b,p}$ is a semistable elliptic curve over $\mathbb{Q}$, Wiles's modularity theorem for semistable elliptic curves implies that $E_{a,b,p}$ is modular.
On the other hand, the Ribet input in the theorem statement is the following precise assertion: for every odd prime $p$, including $p=3$, and every pairwise coprime positive integer solution $a,b,c \in \mathbb{N}$ of $a^p+b^p=c^p$, the Frey curve $E_{a,b,p}$ is not modular. The hypotheses hold here: $p$ is an odd prime, with no exclusion of $p=3$, and $a,b,c$ are pairwise coprime positive integers satisfying $a^p+b^p=c^p$. Hence Ribet's theorem gives that $E_{a,b,p}$ is not modular. This contradicts Wiles's conclusion that $E_{a,b,p}$ is modular. Hence no positive integer solution exists for any odd prime exponent $p$.
[guided]
We now use the two modularity inputs, and we check their hypotheses separately.
First, Wiles's modularity theorem for semistable elliptic curves says that every semistable elliptic curve over $\mathbb{Q}$ is modular. The curve $E_{a,b,p}$ is an elliptic curve over $\mathbb{Q}$ by construction, and the previous step established that it is semistable. Therefore Wiles's theorem applies and gives:
\begin{align*}
E_{a,b,p} \text{ is modular.}
\end{align*}
Second, we use Ribet's theorem in the precise form assumed in the theorem statement. It says that for every odd prime $p$, including the small prime $p=3$, if $a,b,c \in \mathbb{N}$ are pairwise coprime and satisfy
\begin{align*}
a^p+b^p=c^p,
\end{align*}
then the associated Frey curve $E_{a,b,p}$ is not modular. We verify the hypotheses: $p$ is an odd prime, the statement explicitly includes $p=3$, the integers $a,b,c$ are positive and pairwise coprime, and the Fermat equation above holds. Ribet's theorem therefore gives:
\begin{align*}
E_{a,b,p} \text{ is not modular.}
\end{align*}
The same curve cannot both be modular and not modular. This contradiction shows that the assumed primitive solution for exponent $p$ cannot exist. Because the Ribet input covers every odd prime, including $p=3$, the conclusion applies to all odd prime exponents. Therefore there are no positive integer solutions to $x^p+y^p=z^p$ for any odd prime $p$.
[/guided]
[/step]
[step:Conclude Fermat's Last Theorem for every exponent $n \geq 3$]
The first step showed that any positive integer solution for an exponent $n \geq 3$ yields either a positive integer solution for exponent $4$ or a positive integer solution for some odd prime exponent $p$. Fermat's descent excludes exponent $4$, and the preceding contradiction excludes every odd prime exponent. Therefore, for every integer $n \geq 3$, there do not exist positive integers $x,y,z \in \mathbb{N}$ satisfying
\begin{align*}
x^n+y^n=z^n.
\end{align*}
This proves Fermat's Last Theorem under the stated assumptions.
[guided]
We assemble the reductions. Suppose there were positive integers $x,y,z \in \mathbb{N}$ and an integer $n \geq 3$ satisfying
\begin{align*}
x^n+y^n=z^n.
\end{align*}
The exponent-reduction step showed that this would produce either a positive integer solution to exponent $4$ or a positive integer solution to exponent $p$ for some odd prime $p$. The first alternative is impossible by Fermat's descent for exponent $4$. The second alternative is impossible by the contradiction obtained from the Frey curve, Wiles's theorem, and Ribet's theorem. Hence neither alternative can occur, so no such $x,y,z,n$ exist. This is exactly Fermat's Last Theorem under the stated assumptions.
[/guided]
[/step]