[proofplan]
We first reduce [Fermat's Last Theorem](/theorems/4789) to the cases of exponent $4$ and odd prime exponent $p$. The exponent $4$ case is handled by Fermat's classical infinite descent. For an odd prime exponent, a hypothetical primitive Fermat solution produces the Frey elliptic curve; semistable modularity makes this curve modular, while [Ribet's level-lowering theorem](/theorems/4774) forces the associated residual representation to come from a weight $2$ newform of level $2$. Since there are no such cusp forms, the hypothetical solution cannot exist.
[/proofplan]
[step:Reduce the theorem to exponent $4$ and odd prime exponents]
Let $\mathbb{N}=\{1,2,3,\dots\}$ denote the set of positive integers. Suppose that [Fermat's Last Theorem](/theorems/4789) fails for some integer exponent $n>2$. Then there exist nonzero integers $a,b,c \in \mathbb{Z}$ satisfying
\begin{align*}
a^n+b^n=c^n.
\end{align*}
If $n$ has an odd prime divisor $p$, write $n=pm$ with $m \in \mathbb{N}$. Since $p$ is odd, after moving negative terms to the other side if necessary and replacing the resulting integers by their absolute values, the equation gives a positive integer solution of the form
\begin{align*}
x^p+y^p=z^p
\end{align*}
with $x,y,z \in \mathbb{N}$.
If $n$ has no odd prime divisor, then $n=2^k$ for some integer $k \geq 2$. Setting
\begin{align*}
x &= |a|^{2^{k-2}},&
y &= |b|^{2^{k-2}},&
z &= |c|^{2^{k-2}},
\end{align*}
we obtain
\begin{align*}
x^4+y^4=z^4.
\end{align*}
Thus it is enough to rule out exponent $4$ and every odd prime exponent $p$.
[/step]
[step:Rule out exponent $4$ by infinite descent]
We prove the stronger assertion that there are no positive integers $x,y,z \in \mathbb{N}$ satisfying
\begin{align*}
x^4+y^4=z^2.
\end{align*}
Assume otherwise, and choose such a triple with $z$ minimal. Dividing by the common divisor of $x$ and $y$ if necessary, we may assume $\gcd(x,y)=1$. Then
\begin{align*}
(x^2)^2+(y^2)^2=z^2,
\end{align*}
so $(x^2,y^2,z)$ is a primitive Pythagorean triple. Interchanging $x$ and $y$ if necessary, assume $y$ is even. The standard parametrisation of primitive Pythagorean triples gives coprime integers $r>s>0$ of opposite parity such that
\begin{align*}
x^2 &= r^2-s^2,\\
y^2 &= 2rs,\\
z &= r^2+s^2.
\end{align*}
For completeness, this parametrisation follows from
\begin{align*}
(z+x^2)(z-x^2)=y^4,
\end{align*}
where the two factors have greatest common divisor $2$; hence each half is a square.
Since $r$ and $s$ are coprime of opposite parity, the positive odd integers $r-s$ and $r+s$ are coprime. Their product is
\begin{align*}
(r-s)(r+s)=r^2-s^2=x^2.
\end{align*}
Therefore there exist coprime odd integers $u,v \in \mathbb{N}$ with $v>u$ such that
\begin{align*}
r-s &= u^2,\\
r+s &= v^2.
\end{align*}
Define
\begin{align*}
m &= \frac{v-u}{2},&
n &= \frac{v+u}{2}.
\end{align*}
Then $m,n \in \mathbb{N}$, $\gcd(m,n)=1$, and
\begin{align*}
s &= 2mn,\\
r &= m^2+n^2.
\end{align*}
Using $y^2=2rs$, we get
\begin{align*}
\left(\frac{y}{2}\right)^2=mn(m^2+n^2).
\end{align*}
The three integers $m$, $n$, and $m^2+n^2$ are pairwise coprime, so each is a square. Hence there exist $\alpha,\beta,\gamma \in \mathbb{N}$ such that
\begin{align*}
m &= \alpha^2,\\
n &= \beta^2,\\
m^2+n^2 &= \gamma^2.
\end{align*}
Therefore
\begin{align*}
\alpha^4+\beta^4=\gamma^2.
\end{align*}
But $\gamma^2=m^2+n^2=r<r^2+s^2=z$, producing a smaller positive solution to $X^4+Y^4=Z^2$. This contradicts the minimal choice of $z$. Thus exponent $4$ is impossible.
[/step]
[step:Pass from a prime exponent solution to a primitive Frey curve]
Let $p>2$ be an odd prime. Suppose, toward a contradiction, that there are positive integers $a,b,c \in \mathbb{N}$ satisfying
\begin{align*}
a^p+b^p=c^p.
\end{align*}
Dividing by the common divisor of $a$, $b$, and $c$, we may assume
\begin{align*}
\gcd(a,b,c)=1.
\end{align*}
This implies the pairwise coprimality conditions
\begin{align*}
\gcd(a,b)=\gcd(a,c)=\gcd(b,c)=1.
\end{align*}
Indeed, any prime dividing two of $a$, $b$, and $c$ divides the third by the equation $a^p+b^p=c^p$, contradicting $\gcd(a,b,c)=1$. Also the three rational numbers $0$, $a^p$, and $-b^p$ are pairwise distinct, since $a$ and $b$ are nonzero.
Define $E_{a,b,p}$ to be the smooth projective curve over $\mathbb{Q}$ obtained by projectivising the affine plane curve
\begin{align*}
Y^2=X(X-a^p)(X+b^p)
\end{align*}
in the affine coordinates $X,Y \in \mathbb{Q}$. The cubic polynomial
\begin{align*}
X(X-a^p)(X+b^p)
\end{align*}
has distinct roots $0$, $a^p$, and $-b^p$, so the affine cubic is nonsingular. Hence $E_{a,b,p}$ is an elliptic curve over $\mathbb{Q}$.
We invoke the Frey semistability theorem for primitive Fermat solutions: if $p>2$ is prime and $a,b,c \in \mathbb{N}$ are pairwise coprime with $a^p+b^p=c^p$, then the Frey curve $E_{a,b,p}$ is semistable over $\mathbb{Q}$ and its bad reduction is controlled by the primes dividing $2abc$. The hypotheses have just been verified: $p>2$ by assumption, $a,b,c$ are positive integers, the Fermat equation holds, and the pairwise coprimality follows from $\gcd(a,b,c)=1$. Therefore $E_{a,b,p}$ is semistable over $\mathbb{Q}$.
[/step]
[step:Use semistable modularity and Ribet level lowering]
By the hypothesis of the theorem, every semistable elliptic curve over $\mathbb{Q}$ is modular. Since $E_{a,b,p}$ is semistable, $E_{a,b,p}$ is modular.
Let $\overline{\mathbb{Q}}$ denote an [algebraic closure](/page/Algebraic%20Closure) of $\mathbb{Q}$, let $\operatorname{Gal}(\overline{\mathbb{Q}}/\mathbb{Q})$ denote the absolute [Galois group](/page/Galois%20Group) of $\mathbb{Q}$, let $\mathbb{F}_p$ denote the finite field with $p$ elements, and let $GL_2(\mathbb{F}_p)$ denote the group of invertible $2 \times 2$ matrices over $\mathbb{F}_p$. Let
\begin{align*}
\rho_{E,p}: \operatorname{Gal}(\overline{\mathbb{Q}}/\mathbb{Q}) \to GL_2(\mathbb{F}_p)
\end{align*}
denote the mod $p$ Galois representation on the $p$-torsion subgroup $E_{a,b,p}[p]$. Modularity of $E_{a,b,p}$ implies that $\rho_{E,p}$ arises from a weight $2$ modular newform whose level is the conductor of $E_{a,b,p}$.
We now invoke Ribet's level-lowering theorem in its Frey-curve form: for the Frey curve $E_{a,b,p}$ attached to a primitive solution of $a^p+b^p=c^p$ with $p>2$, the residual representation $\rho_{E,p}$ is irreducible, satisfies the required minimality and local ramification hypotheses away from $2$, and every prime dividing $abc$ is removed from the modular level; consequently the residual representation arises from a weight $2$ newform of level $2$. The hypotheses of this Frey-curve form are met because $p>2$, the solution has been normalized to be pairwise coprime, $E_{a,b,p}$ is the associated semistable Frey curve, and modularity of $E_{a,b,p}$ has just been obtained from the semistable modularity hypothesis. Hence $\rho_{E,p}$ must arise from a weight $2$ newform on $\Gamma_0(2)$, where $\Gamma_0(2)$ denotes the congruence subgroup of $SL_2(\mathbb{Z})$ consisting of matrices whose lower-left entry is divisible by $2$.
[/step]
[step:Contradict the vanishing of weight $2$ cusp forms of level $2$]
Let $S_2(\Gamma_0(2))$ denote the complex [vector space](/page/Vector%20Space) of weight $2$ cusp forms for the congruence subgroup $\Gamma_0(2)$. This space is zero:
\begin{align*}
S_2(\Gamma_0(2))=\{0\}
\end{align*}
(citing a result not yet in the wiki: vanishing of $S_2(\Gamma_0(2))$). Therefore there is no weight $2$ newform of level $2$.
This contradicts the conclusion of Ribet's level-lowering theorem that $\rho_{E,p}$ arises from such a newform. Hence no primitive positive solution exists for the odd prime exponent $p$.
[/step]
[step:Conclude Fermat's Last Theorem for all exponents greater than $2$]
The exponent $4$ case is impossible by infinite descent, and every odd prime exponent $p>2$ is impossible by the Frey-Ribet-Wiles contradiction. By the reduction step, any nonzero integer solution for an exponent $n>2$ would yield either a solution for exponent $4$ or a solution for some odd prime exponent. Both alternatives have been ruled out.
Therefore, for every integer $n>2$, there are no nonzero integers $a,b,c \in \mathbb{Z}$ satisfying
\begin{align*}
a^n+b^n=c^n.
\end{align*}
This proves Fermat's Last Theorem under the semistable modularity hypothesis.
[/step]