\setminted

fontsize=, breaklines, bgcolor=lightgray, framesep=2mm 11institutetext: Yonsei University 11email: [email protected] 22institutetext: University of California, Berkeley 22email: [email protected]

Formalizing Mason–Stothers Theorem and its Corollaries in Lean 4

Jineon Baek 11 0000-0002-5799-4902    Seewoo Lee 22 0000-0002-5710-2257
Abstract

The ABC conjecture implies many conjectures and theorems in number theory, including the celebrated Fermat’s Last Theorem. Mason–Stothers Theorem is a function field analogue of the ABC conjecture that admits a much more elementary proof with many interesting consequences, including a polynomial version of Fermat’s Last Theorem. While years of dedicated effort are expected for a full formalization of Fermat’s Last Theorem, the simple proof of Mason–Stothers Theorem and its corollaries calls for an immediate formalization.

We formalize an elementary proof of by Snyder in Lean 4, and also formalize many consequences of Mason–Stothers, including (i) non-solvability of Fermat–Cartan equations in polynomials, (ii) non-parametrizability of a certain elliptic curve, and (iii) Davenport’s Theorem. We compare our work to existing formalizations of Mason–Stothers by Eberl in Isabelle and Wagemaker in Lean 3 respectively. Our formalization is based on the mathlib4 library of Lean 4, and is currently being ported back to mathlib4.

Keywords:
Formalization Number Theory ABC Conjecture Fermat’s Last Theorem Lean Theorem Prover mathlib

1 Introduction

In 1985, Oesterlé and Masser proposed the ABC conjecture [15, 16]:

Conjecture 1 (ABC conjecture)

For every positive real number ε>0𝜀0\varepsilon>0italic_ε > 0, there exist only finitely many triples of coprime integers (a,b,c)𝑎𝑏𝑐(a,b,c)( italic_a , italic_b , italic_c ) such that a+b=c𝑎𝑏𝑐a+b=citalic_a + italic_b = italic_c and

c>rad(abc)1+ε.𝑐radsuperscript𝑎𝑏𝑐1𝜀c>\mathrm{rad}(abc)^{1+\varepsilon}.italic_c > roman_rad ( italic_a italic_b italic_c ) start_POSTSUPERSCRIPT 1 + italic_ε end_POSTSUPERSCRIPT .

Here, rad(n)=p|nprad𝑛subscriptproductconditional𝑝𝑛𝑝\mathrm{rad}(n)=\prod_{p|n}proman_rad ( italic_n ) = ∏ start_POSTSUBSCRIPT italic_p | italic_n end_POSTSUBSCRIPT italic_p is the product of all prime factors of n𝑛nitalic_n.

The conjecture implies many deep theorems or conjectures in number theory. For example, Fermat’s Last Theorem (FLT) for exponent n6𝑛6n\geq 6italic_n ≥ 6 is a direct corollary of an explicit quantitative version of the ABC conjecture [9], while the currently known proof by Wiles [25] and Taylor-Wiles [22] requires heavy machinery (See [3] for detailed surveys). Also, Roth’s theorem [17] and Faltings’ theorem [8] both follow from the ABC conjecture [23]; note that the proof of each theorem earned its corresponding author a Fields medal.

In number theory, there is a strong analogy between number fields K/𝐾K/\mathbb{Q}italic_K / blackboard_Q (e.g., rational numbers \mathbb{Q}blackboard_Q) and function fields k(X)/k𝑘𝑋𝑘k(X)/kitalic_k ( italic_X ) / italic_k of a smooth projective curve over k𝑘kitalic_k (e.g., rational function field k(t)𝑘𝑡k(t)italic_k ( italic_t )). Under this analogy, profound statements on integers \mathbb{Z}blackboard_Z, such as the Riemann Hypothesis, the Birch and Swinnerton-Dyer conjecture, or the Langlands program, have analogous statements [5, 6, 11, 21] on the integral ring k[t]𝑘delimited-[]𝑡k[t]italic_k [ italic_t ] of the rational function field k(t)𝑘𝑡k(t)italic_k ( italic_t ). The analogs of such conjectures often turn out to be true and easier to prove in general.

In this line, Stothers proved the polynomial analog of the ABC conjecture in 1981 [20], and Mason rediscovered it in a more general form in 1983 [14], even before Osterlé and Masser proposed the ABC conjecture.

Definition 1

Let k𝑘kitalic_k be any field. For any nonzero fk[X]𝑓𝑘delimited-[]𝑋f\in k[X]italic_f ∈ italic_k [ italic_X ], define the radical rad(f)rad𝑓\mathrm{rad}(f)roman_rad ( italic_f ) of f𝑓fitalic_f as the product of all irreducible monic factors of f𝑓fitalic_f not counting multiplicity.

Theorem 1.1 (Mason–Stothers)

Let k𝑘kitalic_k be any field and a,b,ck[t]𝑎𝑏𝑐𝑘delimited-[]𝑡a,b,c\in k[t]italic_a , italic_b , italic_c ∈ italic_k [ italic_t ] be non-zero, pairwise coprime polynomials satisfying a+b+c=0𝑎𝑏𝑐0a+b+c=0italic_a + italic_b + italic_c = 0. Then we either have a=b=c=0superscript𝑎superscript𝑏superscript𝑐0a^{\prime}=b^{\prime}=c^{\prime}=0italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 where fsuperscript𝑓f^{\prime}italic_f start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT denotes the (formal) derivative of fk[t]𝑓𝑘delimited-[]𝑡f\in k[t]italic_f ∈ italic_k [ italic_t ] by t𝑡titalic_t, or

max{deg(a),deg(b),deg(c)}<deg(rad(abc)).degree𝑎degree𝑏degree𝑐degreerad𝑎𝑏𝑐\max\{\deg(a),\deg(b),\deg(c)\}<\deg(\mathrm{rad}(abc)).roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) , roman_deg ( italic_c ) } < roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) .

Mason and Stothers proved the theorem using algebro-geometric methods, and subsequently Snyder discovered a short and purely elementary proof [19]. Like the ABC conjecture, the Mason–Stothers theorem has a lot of interesting consequences as the following.

  1. 1.

    A polynomial version of Fermat’s Last Theorem. More generally, the non-solvability of the Fermat-Catalan equation uap+vbq+wcr=0𝑢superscript𝑎𝑝𝑣superscript𝑏𝑞𝑤superscript𝑐𝑟0ua^{p}+vb^{q}+wc^{r}=0italic_u italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT + italic_v italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT + italic_w italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT = 0 over a,b,ck[t]𝑎𝑏𝑐𝑘delimited-[]𝑡a,b,c\in k[t]italic_a , italic_b , italic_c ∈ italic_k [ italic_t ] with nonzero constants u,v,wk𝑢𝑣𝑤𝑘u,v,w\in kitalic_u , italic_v , italic_w ∈ italic_k and powers p,q,r𝑝𝑞𝑟p,q,r\in\mathbb{N}italic_p , italic_q , italic_r ∈ blackboard_N satisfying 1/p+1/q+1/r11𝑝1𝑞1𝑟11/p+1/q+1/r\leq 11 / italic_p + 1 / italic_q + 1 / italic_r ≤ 1 (Theorem 2.1).

  2. 2.

    Non-parametrizability of the elliptic curve y2=x3+1superscript𝑦2superscript𝑥31y^{2}=x^{3}+1italic_y start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT = italic_x start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + 1 by rational functions x,yk(t)𝑥𝑦𝑘𝑡x,y\in k(t)italic_x , italic_y ∈ italic_k ( italic_t ) (Theorem 2.2).

  3. 3.

    Davenport’s theorem, initially conjectured by Birch et al [2], that for any polynomials f,g[t]𝑓𝑔delimited-[]𝑡f,g\in\mathbb{C}[t]italic_f , italic_g ∈ blackboard_C [ italic_t ] we have deg(f3g2)12degf+1degreesuperscript𝑓3superscript𝑔212degree𝑓1\deg{(f^{3}-g^{2})}\geq\frac{1}{2}\deg{f}+1roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) ≥ divide start_ARG 1 end_ARG start_ARG 2 end_ARG roman_deg italic_f + 1 (Theorem 2.3).

We give a fully documented Lean 4 formalization of the Mason–Stothers theorem on fields of arbitrary characteristic. Also, we formalize the aforementioned corollaries of the theorem to demonstrate the power of Mason–Stothers theorem (Theorem 2.1, 2.2, and 2.3). The code is hosted in

https://github.com/seewoo5/lean-poly-abc.

and is currently being ported to mathlib4 (see Appendix 0.A).

The Mason–Stothers theorem was already formalized by Eberl in Isabelle [7] and Wagemaker in Lean 3 [24]. We give a detailed comparison between our work and theirs in Section 7. In short, our formalization works for arbitrary characteristic (see Section 7.2), is compatible with the mathlib4 library of Lean 4, includes variants of Mason–Stothers (e.g. Theorem 6.1), and formalizes several interesting corollaries including the polynomial FLT with a slightly stronger conclusion than existing formalization (see Section 7.1).

2 Statements of the Theorem and its Corollaries

The precise statement of Mason–Stothers theorem we formalize is Theorem 1.1, which holds for arbitrary field k𝑘kitalic_k. Note that most literature either assumes that k𝑘kitalic_k is of characteristic zero or is algebraically closed [20, 19].

If k𝑘kitalic_k has characteristic zero, the condition a=b=c=0superscript𝑎superscript𝑏superscript𝑐0a^{\prime}=b^{\prime}=c^{\prime}=0italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 in Theorem 1.1 is equivalent to a,b,c𝑎𝑏𝑐a,b,citalic_a , italic_b , italic_c being constants. If k𝑘kitalic_k has characteristic p>0𝑝0p>0italic_p > 0, then the condition f=0superscript𝑓0f^{\prime}=0italic_f start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 for f=a,b,c𝑓𝑎𝑏𝑐f=a,b,citalic_f = italic_a , italic_b , italic_c is equivalent to f(t)=f0(tp)𝑓𝑡subscript𝑓0superscript𝑡𝑝f(t)=f_{0}(t^{p})italic_f ( italic_t ) = italic_f start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( italic_t start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT ) being a polynomial of tpsuperscript𝑡𝑝t^{p}italic_t start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT. Indeed,

(a,b,c)=(1,xp,1+xp)=(1,xp,(1+x)p)𝑎𝑏𝑐1superscript𝑥𝑝1superscript𝑥𝑝1superscript𝑥𝑝superscript1𝑥𝑝(a,b,c)=(-1,-x^{p},1+x^{p})=(-1,-x^{p},(1+x)^{p})( italic_a , italic_b , italic_c ) = ( - 1 , - italic_x start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT , 1 + italic_x start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT ) = ( - 1 , - italic_x start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT , ( 1 + italic_x ) start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT )

is an example satisfying a+b+c=0𝑎𝑏𝑐0a+b+c=0italic_a + italic_b + italic_c = 0 and a=b=c=0superscript𝑎superscript𝑏superscript𝑐0a^{\prime}=b^{\prime}=c^{\prime}=0italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0, but

max{deg(a),deg(b),deg(c)}+1=p+1>2=deg(rad(abc)).degree𝑎degree𝑏degree𝑐1𝑝12degreerad𝑎𝑏𝑐\max\{\deg(a),\deg(b),\deg(c)\}+1=p+1>2=\deg(\mathrm{rad}(abc)).roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) , roman_deg ( italic_c ) } + 1 = italic_p + 1 > 2 = roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) .

We now state the corollaries of the Mason–Stothers theorem mentioned in Section 1 precisely. Their proofs can be found in Section 6.

The Fermat–Catalan conjecture is a generalization of Fermat’s Last Theorem stating that the equation ap+bq=crsuperscript𝑎𝑝superscript𝑏𝑞superscript𝑐𝑟a^{p}+b^{q}=c^{r}italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT + italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT has only finitely many solutions (a,b,c,p,q,r)𝑎𝑏𝑐𝑝𝑞𝑟(a,b,c,p,q,r)( italic_a , italic_b , italic_c , italic_p , italic_q , italic_r ) in positive integers satisfying 1/p+1/q+1/r<11𝑝1𝑞1𝑟11/p+1/q+1/r<11 / italic_p + 1 / italic_q + 1 / italic_r < 1 [9]. The following Theorem 2.1 is a polynomial variant which is true.

Theorem 2.1 (Fermat–Catalan Conjecture for Polynomials)

Let k𝑘kitalic_k be any field. Let p,q,r1𝑝𝑞𝑟1p,q,r\geq 1italic_p , italic_q , italic_r ≥ 1 be integers not divisible by the characteristic of k𝑘kitalic_k such that 1/p+1/q+1/r11𝑝1𝑞1𝑟11/p+1/q+1/r\leq 11 / italic_p + 1 / italic_q + 1 / italic_r ≤ 1. Let u,v,wk𝑢𝑣𝑤𝑘u,v,w\in kitalic_u , italic_v , italic_w ∈ italic_k be arbitrary nonzero constants. Then any triple (a,b,c)𝑎𝑏𝑐(a,b,c)( italic_a , italic_b , italic_c ) of nonzero and pairwise coprime polynomials in k[t]𝑘delimited-[]𝑡k[t]italic_k [ italic_t ] satisfying uap+vbq+wcr=0𝑢superscript𝑎𝑝𝑣superscript𝑏𝑞𝑤superscript𝑐𝑟0ua^{p}+vb^{q}+wc^{r}=0italic_u italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT + italic_v italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT + italic_w italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT = 0 should be constants a,b,ck𝑎𝑏𝑐𝑘a,b,c\in kitalic_a , italic_b , italic_c ∈ italic_k.

Let u=v=w=1𝑢𝑣𝑤1u=v=-w=1italic_u = italic_v = - italic_w = 1 and p=q=r=n3𝑝𝑞𝑟𝑛3p=q=r=n\geq 3italic_p = italic_q = italic_r = italic_n ≥ 3 in Theorem 2.1 to recover the Fermat’s Last Theorem for polynomials.

Corollary 1 (Fermat’s Last Theorem for Polynomials)

Let k𝑘kitalic_k be any field. Let n3𝑛3n\geq 3italic_n ≥ 3 be any integer not divisible by the characteristic of k𝑘kitalic_k. Then any triple (a,b,c)𝑎𝑏𝑐(a,b,c)( italic_a , italic_b , italic_c ) of nonzero and pairwise coprime polynomials in k[t]𝑘delimited-[]𝑡k[t]italic_k [ italic_t ] satisfying an+bn=cnsuperscript𝑎𝑛superscript𝑏𝑛superscript𝑐𝑛a^{n}+b^{n}=c^{n}italic_a start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT + italic_b start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT should be constants a,b,ck𝑎𝑏𝑐𝑘a,b,c\in kitalic_a , italic_b , italic_c ∈ italic_k.

Using Theorem 2.1, we can obtain the following corollary.

Theorem 2.2 (Non-parametrizablility of an Elliptic Curve)

Let k𝑘kitalic_k be a field of characteristic 2,3absent23\neq 2,3≠ 2 , 3. If rational functions f(t),g(t)k(t)𝑓𝑡𝑔𝑡𝑘𝑡f(t),g(t)\in k(t)italic_f ( italic_t ) , italic_g ( italic_t ) ∈ italic_k ( italic_t ) satisfy g(t)2=f(t)3+1𝑔superscript𝑡2𝑓superscript𝑡31g(t)^{2}=f(t)^{3}+1italic_g ( italic_t ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT = italic_f ( italic_t ) start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + 1, then both f(t)𝑓𝑡f(t)italic_f ( italic_t ) and g(t)𝑔𝑡g(t)italic_g ( italic_t ) are constants in k𝑘kitalic_k.

In other words, the elliptic curve defined by the Weierstrass equation y2=x3+1superscript𝑦2superscript𝑥31y^{2}=x^{3}+1italic_y start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT = italic_x start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + 1 is not parametrizable by non-constant rational functions in k(t)𝑘𝑡k(t)italic_k ( italic_t ).

Another interesting corollary of Mason–Stothers theorem is the following theorem by Davenport [4] initially conjectured [2] by Birch et al. This theorem motivated Stothers’ proof of the Mason–Stothers theorem [20].

Theorem 2.3 (Davenport)

Let k𝑘kitalic_k be a field of characteristic zero. Let f(t),g(t)k[t]𝑓𝑡𝑔𝑡𝑘delimited-[]𝑡f(t),g(t)\in k[t]italic_f ( italic_t ) , italic_g ( italic_t ) ∈ italic_k [ italic_t ] be non-constant polynomials such that f3g2superscript𝑓3superscript𝑔2f^{3}\neq g^{2}italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ≠ italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT. Then

deg(f3g2)12deg(f)+1.degreesuperscript𝑓3superscript𝑔212degree𝑓1\deg(f^{3}-g^{2})\geq\frac{1}{2}\deg(f)+1.roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) ≥ divide start_ARG 1 end_ARG start_ARG 2 end_ARG roman_deg ( italic_f ) + 1 .

3 Mathematical Proof of Mason–Stothers Theorem

We summarize the proof of Mason–Stothers theorem (Theorem 1.1) in Lemmermeyer’s note [12] that we formalize.

Definition 2

The Wronskian of two polynomials a,bk[t]𝑎𝑏𝑘delimited-[]𝑡a,b\in k[t]italic_a , italic_b ∈ italic_k [ italic_t ] is W(a,b)=abab𝑊𝑎𝑏𝑎superscript𝑏superscript𝑎𝑏W(a,b)=ab^{\prime}-a^{\prime}bitalic_W ( italic_a , italic_b ) = italic_a italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT - italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT italic_b, where asuperscript𝑎a^{\prime}italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT is the (formal) derivative of a𝑎aitalic_a with respect to t𝑡titalic_t.

From a+b+c=0𝑎𝑏𝑐0a+b+c=0italic_a + italic_b + italic_c = 0 we can check that the values W(a,b)𝑊𝑎𝑏W(a,b)italic_W ( italic_a , italic_b ), W(b,c)𝑊𝑏𝑐W(b,c)italic_W ( italic_b , italic_c ), and W(c,a)𝑊𝑐𝑎W(c,a)italic_W ( italic_c , italic_a ) are all equal. Denote the common value as W𝑊Witalic_W.

Next, we observe the following property.

Lemma 1

For a nonzero polynomial ak[t]𝑎𝑘delimited-[]𝑡a\in k[t]italic_a ∈ italic_k [ italic_t ], a/rad(a)𝑎rad𝑎a/\mathrm{rad}(a)italic_a / roman_rad ( italic_a ) divides asuperscript𝑎a^{\prime}italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT.

For a proof, we can use the prime factorization of a𝑎aitalic_a. Let a=up1e1p2e2pmem𝑎𝑢superscriptsubscript𝑝1subscript𝑒1superscriptsubscript𝑝2subscript𝑒2superscriptsubscript𝑝𝑚subscript𝑒𝑚a=up_{1}^{e_{1}}p_{2}^{e_{2}}\cdots p_{m}^{e_{m}}italic_a = italic_u italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT end_POSTSUPERSCRIPT italic_p start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT end_POSTSUPERSCRIPT ⋯ italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT end_POSTSUPERSCRIPT be a factorization with unit u𝑢uitalic_u and primes pik[x]subscript𝑝𝑖𝑘delimited-[]𝑥p_{i}\in k[x]italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ∈ italic_k [ italic_x ] of exponents ei>0subscript𝑒𝑖0e_{i}>0italic_e start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT > 0. Then the product rule of derivative gives a=i=1mueipip1e1p2e2piei1pmemsuperscript𝑎superscriptsubscript𝑖1𝑚𝑢subscript𝑒𝑖superscriptsubscript𝑝𝑖superscriptsubscript𝑝1subscript𝑒1superscriptsubscript𝑝2subscript𝑒2superscriptsubscript𝑝𝑖subscript𝑒𝑖1superscriptsubscript𝑝𝑚subscript𝑒𝑚a^{\prime}=\sum_{i=1}^{m}ue_{i}p_{i}^{\prime}p_{1}^{e_{1}}p_{2}^{e_{2}}\cdots p% _{i}^{e_{i}-1}\cdots p_{m}^{e_{m}}italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_m end_POSTSUPERSCRIPT italic_u italic_e start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT end_POSTSUPERSCRIPT italic_p start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT end_POSTSUPERSCRIPT ⋯ italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT - 1 end_POSTSUPERSCRIPT ⋯ italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT end_POSTSUPERSCRIPT which is divisible by a/rad(a)=p1e11p2e21pmem1𝑎rad𝑎superscriptsubscript𝑝1subscript𝑒11superscriptsubscript𝑝2subscript𝑒21superscriptsubscript𝑝𝑚subscript𝑒𝑚1a/\mathrm{rad}(a)=p_{1}^{e_{1}-1}p_{2}^{e_{2}-1}\cdots p_{m}^{e_{m}-1}italic_a / roman_rad ( italic_a ) = italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT - 1 end_POSTSUPERSCRIPT italic_p start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT - 1 end_POSTSUPERSCRIPT ⋯ italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT - 1 end_POSTSUPERSCRIPT. An immediate corollary is that

Lemma 2

For any nonzero ak[t]𝑎𝑘delimited-[]𝑡a\in k[t]italic_a ∈ italic_k [ italic_t ], a/rad(a)𝑎rad𝑎a/\mathrm{rad}(a)italic_a / roman_rad ( italic_a ) divides W(a,b)=abab𝑊𝑎𝑏𝑎superscript𝑏superscript𝑎𝑏W(a,b)=ab^{\prime}-a^{\prime}bitalic_W ( italic_a , italic_b ) = italic_a italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT - italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT italic_b

because a/rad(a)𝑎rad𝑎a/\mathrm{rad}(a)italic_a / roman_rad ( italic_a ) divides both a𝑎aitalic_a and asuperscript𝑎a^{\prime}italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT.

The pairwise coprime polynomials a/rad(a)𝑎rad𝑎a/\mathrm{rad}(a)italic_a / roman_rad ( italic_a ), b/rad(b)𝑏rad𝑏b/\mathrm{rad}(b)italic_b / roman_rad ( italic_b ), and c/rad(c)𝑐rad𝑐c/\mathrm{rad}(c)italic_c / roman_rad ( italic_c ) all divide W𝑊Witalic_W. So their product abc/rad(abc)𝑎𝑏𝑐rad𝑎𝑏𝑐abc/\mathrm{rad}(abc)italic_a italic_b italic_c / roman_rad ( italic_a italic_b italic_c ) should also divide W𝑊Witalic_W. This is the key step of the proof. Divide the case into whether W𝑊Witalic_W is zero or not. If W=0𝑊0W=0italic_W = 0, then W(a,b)=0𝑊𝑎𝑏0W(a,b)=0italic_W ( italic_a , italic_b ) = 0 implies ab=ab𝑎superscript𝑏superscript𝑎𝑏ab^{\prime}=a^{\prime}bitalic_a italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT italic_b, and since a𝑎aitalic_a and b𝑏bitalic_b are coprime a𝑎aitalic_a divides asuperscript𝑎a^{\prime}italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT and so a=0superscript𝑎0a^{\prime}=0italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0. Likewise, from W=0𝑊0W=0italic_W = 0 we also get b=c=0superscript𝑏superscript𝑐0b^{\prime}=c^{\prime}=0italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0.

Now assume W0𝑊0W\neq 0italic_W ≠ 0. Then abc/rad(abc)𝑎𝑏𝑐rad𝑎𝑏𝑐abc/\mathrm{rad}(abc)italic_a italic_b italic_c / roman_rad ( italic_a italic_b italic_c ) dividing W𝑊Witalic_W implies

deg(a)+deg(b)+deg(c)deg(rad(abc))=deg(abcrad(abc))degree𝑎degree𝑏degree𝑐degreerad𝑎𝑏𝑐degree𝑎𝑏𝑐rad𝑎𝑏𝑐\displaystyle\deg(a)+\deg(b)+\deg(c)-\deg(\mathrm{rad}(abc))=\deg\left(\frac{% abc}{\mathrm{rad}(abc)}\right)roman_deg ( italic_a ) + roman_deg ( italic_b ) + roman_deg ( italic_c ) - roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) = roman_deg ( divide start_ARG italic_a italic_b italic_c end_ARG start_ARG roman_rad ( italic_a italic_b italic_c ) end_ARG )
degW=degW(a,b)<deg(a)+deg(b).absentdegree𝑊degree𝑊𝑎𝑏degree𝑎degree𝑏\displaystyle\leq\deg W=\deg W(a,b)<\deg(a)+\deg(b).≤ roman_deg italic_W = roman_deg italic_W ( italic_a , italic_b ) < roman_deg ( italic_a ) + roman_deg ( italic_b ) .

The first inequality follows from divisibility, and the second inequality follows from the definition of Wronskian and a0𝑎0a\neq 0italic_a ≠ 0. Hence we have deg(c)<degrad(abc)degree𝑐degreerad𝑎𝑏𝑐\deg(c)<\deg\mathrm{rad}(abc)roman_deg ( italic_c ) < roman_deg roman_rad ( italic_a italic_b italic_c ). The same argument with W=W(b,c)𝑊𝑊𝑏𝑐W=W(b,c)italic_W = italic_W ( italic_b , italic_c ) and W=W(c,a)𝑊𝑊𝑐𝑎W=W(c,a)italic_W = italic_W ( italic_c , italic_a ) gives

max{deg(a),deg(b),deg(c)}+1deg(rad(abc)).degree𝑎degree𝑏degree𝑐1degreerad𝑎𝑏𝑐\max\{\deg(a),\deg(b),\deg(c)\}+1\leq\deg(\mathrm{rad}(abc)).roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) , roman_deg ( italic_c ) } + 1 ≤ roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) .

4 Basic Definitions

Now we explain our formalization of the proof of Mason–Stothers in Section 3. The frst step to develop an interface for the radical (Definition 1) and Wronskian (Definition 2) of polynomials.

4.1 Wronskian

We formalize the Wronskian W(a,b)𝑊𝑎𝑏W(a,b)italic_W ( italic_a , italic_b ) of any two polynomials a,bR[X]𝑎𝑏𝑅delimited-[]𝑋a,b\in R[X]italic_a , italic_b ∈ italic_R [ italic_X ] with coefficients in an arbitrary commutative ring R𝑅Ritalic_R.

{minted}

lean variable R : Type* [CommRing R]

def wronskian (a b : R[X]) : R[X] := a * (derivative b) - (derivative a) * b

The degree of Wronskian W(a,b)𝑊𝑎𝑏W(a,b)italic_W ( italic_a , italic_b ) is strictly smaller than deg(a)+deg(b)degree𝑎degree𝑏\deg(a)+\deg(b)roman_deg ( italic_a ) + roman_deg ( italic_b ), which was one of the last steps in our proof of Theorem 1.1.

{minted}

lean theorem wronskian.natDegree_lt_add a b : R[X] (hw : wronskian a b \neq 0) : natDegree (wronskian a b) ¡ natDegree a + natDegree b

For a polynomial a in Lean 4’s mathlib4, both degree a and natDegree a denote the degree of a. The difference between the two is that the natDegree has type \mathbb{N}blackboard_N of natural numbers, while the degree has type WithBot \mathbb{N}blackboard_N which is \mathbb{N}blackboard_N equipped with -\infty- ∞. The natDegree of zero polynomial is defined as 0, while the degree of that is defined as -\infty- ∞. While degree is mathematically more natural, we opt to use natDegree as its type \mathbb{N}blackboard_N is much easier to work in Lean 4 than the extended type WithBot \mathbb{N}blackboard_N.

We use that W(a,b)=W(b,c)𝑊𝑎𝑏𝑊𝑏𝑐W(a,b)=W(b,c)italic_W ( italic_a , italic_b ) = italic_W ( italic_b , italic_c ) for any a,b,cR[X]𝑎𝑏𝑐𝑅delimited-[]𝑋a,b,c\in R[X]italic_a , italic_b , italic_c ∈ italic_R [ italic_X ] with a+b+c=0𝑎𝑏𝑐0a+b+c=0italic_a + italic_b + italic_c = 0 in our proof. This identity actually holds for any alternating bilinear map B:M×MR:𝐵𝑀𝑀𝑅B:M\times M\to Ritalic_B : italic_M × italic_M → italic_R on any R𝑅Ritalic_R-module M𝑀Mitalic_M. Thus we add the general theorem in the relevant place of mathlib4.111Mathlib.LinearAlgebra.BilinearForm.Properties

{minted}

lean theorem eq_of_add_add_eq_zero [IsCancelAdd R] a b c : M (H : B.IsAlt) (hAdd : a + b + c = 0) : B a b = B b c

Note that the above theorem is stated for a slightly general class of R𝑅Ritalic_R called IsCancelAdd, where the additive structure (R,+)𝑅(R,+)( italic_R , + ) is not necessarily a group but still satisfy the cancellation law: for any x,y,zR𝑥𝑦𝑧𝑅x,y,z\in Ritalic_x , italic_y , italic_z ∈ italic_R, x+z=y+zx=y𝑥𝑧𝑦𝑧𝑥𝑦x+z=y+z\Rightarrow x=yitalic_x + italic_z = italic_y + italic_z ⇒ italic_x = italic_y.

4.2 Radical

Recall that for any field k𝑘kitalic_k and nonzero fk[X]𝑓𝑘delimited-[]𝑋f\in k[X]italic_f ∈ italic_k [ italic_X ], its radical rad(f)rad𝑓\mathrm{rad}(f)roman_rad ( italic_f ) is defined as the product of all irreducible monic factors of f𝑓fitalic_f not counting multiplicity. In fact, such a definition works over any multiplicative monoid M𝑀Mitalic_M with zero that is

  1. 1.

    commutative,

  2. 2.

    cancellative (ab=acb=c𝑎𝑏𝑎𝑐𝑏𝑐ab=ac\Rightarrow b=citalic_a italic_b = italic_a italic_c ⇒ italic_b = italic_c for nonzero a𝑎aitalic_a),

  3. 3.

    a unique factorization monoid, in the sense that each nonzero element admits a unique factorization into irreducible elements, and

  4. 4.

    a normalization monoid, equipped with a map u:M{0}M:𝑢𝑀0superscript𝑀u:M\setminus\{0\}\rightarrow M^{*}italic_u : italic_M ∖ { 0 } → italic_M start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT to the set of units Msuperscript𝑀M^{*}italic_M start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT of M𝑀Mitalic_M preserving multiplication. The map xu(x)1xmaps-to𝑥𝑢superscript𝑥1𝑥x\mapsto u(x)^{-1}xitalic_x ↦ italic_u ( italic_x ) start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT italic_x is then called the normalization map.

In particular, for polynomials M=k[X]𝑀𝑘delimited-[]𝑋M=k[X]italic_M = italic_k [ italic_X ] the map u:k[X]{0}k:𝑢𝑘delimited-[]𝑋0𝑘u:k[X]\setminus\{0\}\rightarrow kitalic_u : italic_k [ italic_X ] ∖ { 0 } → italic_k in (4) reads the leading coefficient of a nonzero polynomial. The corresponding normalization map au(a)1amaps-to𝑎𝑢superscript𝑎1𝑎a\mapsto u(a)^{-1}aitalic_a ↦ italic_u ( italic_a ) start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT italic_a sends a polynomial a𝑎aitalic_a to its scalar multiple which is monic.

In mathlib4, these assumptions can be imposed on a monoid M𝑀Mitalic_M by using the following instances on M𝑀Mitalic_M.

  1. (i)

    CancelCommMonoidWithZero (for 1 and 2)

  2. (ii)

    UniqueFactorizationMonoid (for 3)

  3. (iii)

    NormalizationMonoid (for 4)

To define the radical of aM𝑎𝑀a\in Mitalic_a ∈ italic_M, we first extract the multiset of normalized factors of a𝑎aitalic_a from mathlib4 using normalizedFactors a. Here, a multiset is essentially a set allowing duplicated elements. Then we convert it to a finite set (.toFinset) to get rid of duplicated elements, and multiply them all to get the radical of aM𝑎𝑀a\in Mitalic_a ∈ italic_M.

{minted}

lean variable M : Type* [CancelCommMonoidWithZero M] [UniqueFactorizationMonoid M] [NormalizationMonoid M]

/– Prime factors of ‘a‘ are monic factors of ‘a‘ without duplication. -/ def primeFactors (a : M) : Finset M := (normalizedFactors a).toFinset

/– Radical of ‘a‘ is a product of prime factors of ‘a‘. -/ def radical (a : M) : M := (primeFactors a).prod id

In case of polynomials M=k[X]𝑀𝑘delimited-[]𝑋M=k[X]italic_M = italic_k [ italic_X ], any radical is a monic polynomial, and rad(c)=1rad𝑐1\text{rad}(c)=1rad ( italic_c ) = 1 for any constant ck𝑐𝑘c\in kitalic_c ∈ italic_k including zero.222The set of normalized factors of zero or a unit is an empty set in mathlib. The product of elements in an empty set is then defined as 1 in mathlib.

Radical satisfies the power law: rad(an)=rad(a)radsuperscript𝑎𝑛rad𝑎\text{rad}(a^{n})=\text{rad}(a)rad ( italic_a start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) = rad ( italic_a ) for n1𝑛1n\geq 1italic_n ≥ 1. {minted}lean theorem radical_pow (a : M) n : Nat (hn : 0 ¡ n) : radical (a ^n) = radical a

Also, rad(a)rad𝑎\text{rad}(a)rad ( italic_a ) divides a𝑎aitalic_a. Although this is obvious from unique factorization, Lean is not aware of this intuition. A formal proof uses basic lemmas in mathlib4333e.g., If a multiset A𝐴Aitalic_A is contained in B𝐵Bitalic_B, the product of elements in A𝐴Aitalic_A divides that of B𝐵Bitalic_B (Multiset.prod_dvd_prod_of_le). to boil down the proof to that the Multiset S𝑆Sitalic_S of prime factors of a𝑎aitalic_a contains, as a subset, the same set S𝑆Sitalic_S with duplicated elements removed. {minted}lean theorem radical_dvd_self (a : M) : radical a — a

Once we restrict our attention to a commutative domain R𝑅Ritalic_R with unique factorization, we can also prove multiplicativity of radical for coprime elements a,bR𝑎𝑏𝑅a,b\in Ritalic_a , italic_b ∈ italic_R, i.e. rad(ab)=rad(a)rad(b)rad𝑎𝑏rad𝑎rad𝑏\text{rad}(ab)=\text{rad}(a)\text{rad}(b)rad ( italic_a italic_b ) = rad ( italic_a ) rad ( italic_b ). We also have rad(a)=rad(a)rad𝑎rad𝑎\mathrm{rad}(-a)=\mathrm{rad}(a)roman_rad ( - italic_a ) = roman_rad ( italic_a ). These basic lemmas will be used frequently in the main proof.

{minted}

lean variable R : Type* [CommRing R] [IsDomain R] [NormalizationMonoid R] [UniqueFactorizationMonoid R]

theorem radical_hMul a b : R (hc : IsCoprime a b) : radical (a * b) = (radical a) * (radical b)

theorem radical_neg a : R : radical (-a) = radical a

The following seems obvious to the human eye.

Lemma 3

For any field k𝑘kitalic_k and a polynomial ak[X]𝑎𝑘delimited-[]𝑋a\in k[X]italic_a ∈ italic_k [ italic_X ] of degree 1absent1\geq 1≥ 1, the degree of its radical rad(a)rad𝑎\mathrm{rad}(a)roman_rad ( italic_a ) is also at least one.

A formal proof of Lemma 3 requires more work, however. We need to explicitly take a prime factor p𝑝pitalic_p of a𝑎aitalic_a and show that it is also a prime factor of rad(a)rad𝑎\mathrm{rad}(a)roman_rad ( italic_a ). We first show that for any element a𝑎aitalic_a of a general monoid M𝑀Mitalic_M, a prime p𝑝pitalic_p divides a𝑎aitalic_a if and only if it divides rad(a)rad𝑎\mathrm{rad}(a)roman_rad ( italic_a ); this is done by using that the prime divisors of a𝑎aitalic_a and rad(a)rad𝑎\mathrm{rad}(a)roman_rad ( italic_a ) are the same. {minted}lean theorem prime_dvd_radical_iff a p : M (ha : a \neq 0) (hp : Prime p) : p — radical a \leftrightarrow p — a We then use it to show that nonzero aM𝑎𝑀a\in Mitalic_a ∈ italic_M is a unit if and only if rad(a)rad𝑎\mathrm{rad}(a)roman_rad ( italic_a ) is. Note that an element of M𝑀Mitalic_M is a unit if and only if it has no prime divisor. {minted}lean theorem radical_isUnit_iff a : M (h : a \neq 0) : IsUnit (radical a) \leftrightarrow IsUnit a Then we specialize it to M=k[X]𝑀𝑘delimited-[]𝑋M=k[X]italic_M = italic_k [ italic_X ] and use that nonzero ak[X]𝑎𝑘delimited-[]𝑋a\in k[X]italic_a ∈ italic_k [ italic_X ] is a unit if and only if its degree is zero, proving Lemma 3. {minted}lean lemma natDegree_radical_eq_zero_iff a : k[X] : (radical a).natDegree = 0 \leftrightarrow a.natDegree = 0

The fraction f/rad(f)𝑓rad𝑓f/\mathrm{rad}(f)italic_f / roman_rad ( italic_f ) is a polynomial which will be used frequently in the proof. We define this as divRadical f in our formalization.

{minted}

lean def divRadical (a : k[X]) : k[X] := a / radical a The division notation actually denotes the quotient of two polynomials as in the Euclidean division algorithm. Using that the radical divides the polynomial (radical_dvd_self), we define lemmas that introduces and eliminates divRadical f as it is multiplied by radical f. With this, we do not need to work with division explicitly and only work with multiplications, which is easier to handle with Lean 4 tactics like ring.

{minted}

lean theorem eq_divRadical a x : k[X] (h : (radical a) * x = a) : x = divRadical a

theorem mul_radical_divRadical (a : k[X]) : (radical a) * (divRadical a) = a

Now we need to prove Lemma 1 that for any ak[X]𝑎𝑘delimited-[]𝑋a\in k[X]italic_a ∈ italic_k [ italic_X ], a/rad(a)𝑎rad𝑎a/\mathrm{rad}(a)italic_a / roman_rad ( italic_a ) divides asuperscript𝑎a^{\prime}italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. {minted}lean theorem divRadical_dvd_derivative (a : k[X]) : (divRadical a) — (derivative a) Our formalization does not explicitly use the factorization a=up1e1p2e2pmem𝑎𝑢superscriptsubscript𝑝1subscript𝑒1superscriptsubscript𝑝2subscript𝑒2superscriptsubscript𝑝𝑚subscript𝑒𝑚a=up_{1}^{e_{1}}p_{2}^{e_{2}}\cdots p_{m}^{e_{m}}italic_a = italic_u italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT end_POSTSUPERSCRIPT italic_p start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT end_POSTSUPERSCRIPT ⋯ italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_e start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT end_POSTSUPERSCRIPT which is somewhat cumbersome to work in Lean. Instead, we use the coprime induction in mathlib4.444Available as induction_on_coprime in mathlib4. We first prove the result for units a=u𝑎𝑢a=uitalic_a = italic_u and prime powers a=pe𝑎superscript𝑝𝑒a=p^{e}italic_a = italic_p start_POSTSUPERSCRIPT italic_e end_POSTSUPERSCRIPT. Then we show that for any coprime a,b𝑎𝑏a,bitalic_a , italic_b satisfying the lemma, their product ab𝑎𝑏abitalic_a italic_b also satisfies the lemma. This makes the derivative (ab)=ab+absuperscript𝑎𝑏superscript𝑎𝑏𝑎superscript𝑏(ab)^{\prime}=a^{\prime}b+ab^{\prime}( italic_a italic_b ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT italic_b + italic_a italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT much easier to manipulate than the derivative of full factorization.

5 Formalization of Mason–Stothers theorem

Finally, Mason–Stothers theorem is formalized as follows. Note that k is a field of arbitrary characteristic with only [Field k] assumed.

{minted}

lean variable k : Type* [Field k]

theorem Polynomial.abc a b c : k[X] (ha : a \neq 0) (hb : b \neq 0) (hc : c \neq 0) (hab : IsCoprime a b) (hsum : a + b + c = 0) : (derivative a = 0 \wedge derivative b = 0 \wedge derivative c = 0) \vee Nat.max3 a.natDegree b.natDegree c.natDegree + 1 \leq (radical (a * b * c)).natDegree

We only require coprimality of a𝑎aitalic_a and b𝑏bitalic_b, as gcd(b,c)=gcd(c,a)=1𝑏𝑐𝑐𝑎1\gcd(b,c)=\gcd(c,a)=1roman_gcd ( italic_b , italic_c ) = roman_gcd ( italic_c , italic_a ) = 1 can be deduced from gcd(a,b)𝑎𝑏\gcd(a,b)roman_gcd ( italic_a , italic_b ) and a+b+c=0𝑎𝑏𝑐0a+b+c=0italic_a + italic_b + italic_c = 0. Because a,b,c𝑎𝑏𝑐a,b,citalic_a , italic_b , italic_c are nonzero, there is no difference in using natDegree instead of degree.

To formalize Mason–Stothers, we first formalize the proof of abc/rad(abc)|Wconditional𝑎𝑏𝑐rad𝑎𝑏𝑐𝑊abc/\mathrm{rad}(abc)|Witalic_a italic_b italic_c / roman_rad ( italic_a italic_b italic_c ) | italic_W mentioned as the key step of the proof in Section 3. Then we define an auxiliary lemma below that derives deg(c)<deg(rad(abc))degree𝑐degreerad𝑎𝑏𝑐\deg(c)<\deg(\mathrm{rad}(abc))roman_deg ( italic_c ) < roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) from abc/rad(abc)|Wconditional𝑎𝑏𝑐rad𝑎𝑏𝑐𝑊abc/\mathrm{rad}(abc)|Witalic_a italic_b italic_c / roman_rad ( italic_a italic_b italic_c ) | italic_W.

{minted}

lean private theorem abc_subcall a b c w : k[X] hw : w \neq 0 (wab : w = wronskian a b) (ha : a \neq 0) (hb : b \neq 0) (hc : c \neq 0) (hab : IsCoprime a b) (hbc : IsCoprime b c) (hca : IsCoprime c a) (abc_dr_dvd_w : (a * b * c).divRadical — w) : c.natDegree + 1 \leq (radical (a * b * c)).natDegree

Once the auxiliary lemma is shown, we apply this three times to the permuted triples (a,b,c)𝑎𝑏𝑐(a,b,c)( italic_a , italic_b , italic_c ), (b,c,a)𝑏𝑐𝑎(b,c,a)( italic_b , italic_c , italic_a ), and (c,a,b)𝑐𝑎𝑏(c,a,b)( italic_c , italic_a , italic_b ) to prove the full Mason–Stothers. While it is evident that the conditions of abc_subcall are symmetric, we have to manually permute them in our formalization (e.g., change the product a * b * c to b * c * a in abc_dr_dvd_w). This, however, costs much less than repeating the whole argument for c𝑐citalic_c to a𝑎aitalic_a and b𝑏bitalic_b.

6 Formalization of Corollaries

We also formalize multiple corollaries of Mason–Stothers (Theorems 2.1, 2.2 and 2.3).

6.1 Fermat–Catalan Conjecture for Polynomials (Theorem 2.1)

6.1.1 Mathematical Proof

Theorem 2.1 basically follows from Mason–Stothers applied to the triple (uap,vbq,wcr)𝑢superscript𝑎𝑝𝑣superscript𝑏𝑞𝑤superscript𝑐𝑟(ua^{p},vb^{q},wc^{r})( italic_u italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT , italic_v italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT , italic_w italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ). Let

m=max{deg(uap),deg(vbq),deg(wcr)}=max{pdeg(a),qdeg(b),rdeg(c)}.𝑚degree𝑢superscript𝑎𝑝degree𝑣superscript𝑏𝑞degree𝑤superscript𝑐𝑟𝑝degree𝑎𝑞degree𝑏𝑟degree𝑐m=\max\{\deg(ua^{p}),\deg(vb^{q}),\deg(wc^{r})\}=\max\{p\deg(a),q\deg(b),r\deg% (c)\}.italic_m = roman_max { roman_deg ( italic_u italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT ) , roman_deg ( italic_v italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT ) , roman_deg ( italic_w italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) } = roman_max { italic_p roman_deg ( italic_a ) , italic_q roman_deg ( italic_b ) , italic_r roman_deg ( italic_c ) } .

If the inequality m<deg(rad(apbqcr))𝑚degreeradsuperscript𝑎𝑝superscript𝑏𝑞superscript𝑐𝑟m<\deg(\mathrm{rad}(a^{p}b^{q}c^{r}))italic_m < roman_deg ( roman_rad ( italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) ) holds, then we have

m𝑚\displaystyle mitalic_m <deg(rad(apbqcr))=deg(rad(abc))deg(abc)absentdegreeradsuperscript𝑎𝑝superscript𝑏𝑞superscript𝑐𝑟degreerad𝑎𝑏𝑐degree𝑎𝑏𝑐\displaystyle<\deg(\mathrm{rad}(a^{p}b^{q}c^{r}))=\deg(\mathrm{rad}(abc))\leq% \deg(abc)< roman_deg ( roman_rad ( italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) ) = roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) ≤ roman_deg ( italic_a italic_b italic_c )
=deg(a)+deg(b)+deg(c)=1ppdeg(a)+1qqdeg(b)+1rrdeg(c)absentdegree𝑎degree𝑏degree𝑐1𝑝𝑝degree𝑎1𝑞𝑞degree𝑏1𝑟𝑟degree𝑐\displaystyle=\deg(a)+\deg(b)+\deg(c)=\frac{1}{p}\cdot p\deg(a)+\frac{1}{q}% \cdot q\deg(b)+\frac{1}{r}\cdot r\deg(c)= roman_deg ( italic_a ) + roman_deg ( italic_b ) + roman_deg ( italic_c ) = divide start_ARG 1 end_ARG start_ARG italic_p end_ARG ⋅ italic_p roman_deg ( italic_a ) + divide start_ARG 1 end_ARG start_ARG italic_q end_ARG ⋅ italic_q roman_deg ( italic_b ) + divide start_ARG 1 end_ARG start_ARG italic_r end_ARG ⋅ italic_r roman_deg ( italic_c )
(1p+1q+1r)mabsent1𝑝1𝑞1𝑟𝑚\displaystyle\leq\left(\frac{1}{p}+\frac{1}{q}+\frac{1}{r}\right)m≤ ( divide start_ARG 1 end_ARG start_ARG italic_p end_ARG + divide start_ARG 1 end_ARG start_ARG italic_q end_ARG + divide start_ARG 1 end_ARG start_ARG italic_r end_ARG ) italic_m

which is a contradiction. So by Mason–Stothers it should be that (ap)=(bq)=(cr)=0superscriptsuperscript𝑎𝑝superscriptsuperscript𝑏𝑞superscriptsuperscript𝑐𝑟0(a^{p})^{\prime}=(b^{q})^{\prime}=(c^{r})^{\prime}=0( italic_a start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_b start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_c start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0. As none of p,q,𝑝𝑞p,q,italic_p , italic_q , or r𝑟ritalic_r are zero in k𝑘kitalic_k, we conclude a=b=c=0superscript𝑎superscript𝑏superscript𝑐0a^{\prime}=b^{\prime}=c^{\prime}=0italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0. If the characteristic of k𝑘kitalic_k is zero, then a=b=c=0superscript𝑎superscript𝑏superscript𝑐0a^{\prime}=b^{\prime}=c^{\prime}=0italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 immediately implies that a,b,c𝑎𝑏𝑐a,b,citalic_a , italic_b , italic_c are constants.

If the characteristic \ellroman_ℓ of k𝑘kitalic_k is positive, we need an extra infinite descent argument to show that a,b,c𝑎𝑏𝑐a,b,citalic_a , italic_b , italic_c are constants. For f=a,b,c𝑓𝑎𝑏𝑐f=a,b,citalic_f = italic_a , italic_b , italic_c, that f=0superscript𝑓0f^{\prime}=0italic_f start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 in k[t]𝑘delimited-[]𝑡k[t]italic_k [ italic_t ] implies the existence of f1k[t]subscript𝑓1𝑘delimited-[]𝑡f_{1}\in k[t]italic_f start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∈ italic_k [ italic_t ] such that f(t)=f1(t)𝑓𝑡subscript𝑓1superscript𝑡f(t)=f_{1}(t^{\ell})italic_f ( italic_t ) = italic_f start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_t start_POSTSUPERSCRIPT roman_ℓ end_POSTSUPERSCRIPT ). Hence we have ua1(t)p+vb1(t)q+wc1(t)r=0𝑢subscript𝑎1superscriptsuperscript𝑡𝑝𝑣subscript𝑏1superscriptsuperscript𝑡𝑞𝑤subscript𝑐1superscriptsuperscript𝑡𝑟0ua_{1}(t^{\ell})^{p}+vb_{1}(t^{\ell})^{q}+wc_{1}(t^{\ell})^{r}=0italic_u italic_a start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_t start_POSTSUPERSCRIPT roman_ℓ end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT + italic_v italic_b start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_t start_POSTSUPERSCRIPT roman_ℓ end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT + italic_w italic_c start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_t start_POSTSUPERSCRIPT roman_ℓ end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT = 0. Substitution T=t𝑇superscript𝑡T=t^{\ell}italic_T = italic_t start_POSTSUPERSCRIPT roman_ℓ end_POSTSUPERSCRIPT gives ua1(T)p+vb1(T)q+wc1(T)r=0𝑢subscript𝑎1superscript𝑇𝑝𝑣subscript𝑏1superscript𝑇𝑞𝑤subscript𝑐1superscript𝑇𝑟0ua_{1}(T)^{p}+vb_{1}(T)^{q}+wc_{1}(T)^{r}=0italic_u italic_a start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_T ) start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT + italic_v italic_b start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_T ) start_POSTSUPERSCRIPT italic_q end_POSTSUPERSCRIPT + italic_w italic_c start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_T ) start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT = 0, giving rise to a new nontrivial solution (a1,b1,c1)subscript𝑎1subscript𝑏1subscript𝑐1(a_{1},b_{1},c_{1})( italic_a start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_b start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_c start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) with strictly smaller yet nonzero degrees. Repeated application of this descent in degree leads to contradiction.

6.1.2 Formalization

The full statement of Theorem 2.1 we formalize is the following.

{minted}

lean theorem Polynomial.flt_catalan p q r : \mathbb{N}blackboard_N (hp : 0 ¡ p) (hq : 0 ¡ q) (hr : 0 ¡ r) (hineq : q * r + r * p + p * q \leq p * q * r) (chp : ¬\neg¬ringChar k — p) (chq : ¬\neg¬ringChar k — q) (chr : ¬\neg¬ringChar k — r) a b c : k[X] (ha : a \neq 0) (hb : b \neq 0) (hc : c \neq 0) (hab : IsCoprime a b) u v w : k (hu : u \neq 0) (hv : v \neq 0) (hw : w \neq 0) (heq : C u * a ^p + C v * b ^q + C w * c ^r = 0) : a.natDegree = 0 \wedge b.natDegree = 0 \wedge c.natDegree = 0

We state the inequality 1/p+1/q+1/r11𝑝1𝑞1𝑟11/p+1/q+1/r\leq 11 / italic_p + 1 / italic_q + 1 / italic_r ≤ 1 as qr+rs+sppqr𝑞𝑟𝑟𝑠𝑠𝑝𝑝𝑞𝑟qr+rs+sp\leq pqritalic_q italic_r + italic_r italic_s + italic_s italic_p ≤ italic_p italic_q italic_r instead, as this is expressible purely in integers which is easier to work with in Lean 4. In mathlib, for any element u : k in field k𝑘kitalic_k the notation C u : k[X] denotes the same value in ring k[X]𝑘delimited-[]𝑋k[X]italic_k [ italic_X ].

To formalize Theorem 2.1, we first factor the part of the proof where we show a=b=c=0superscript𝑎superscript𝑏superscript𝑐0a^{\prime}=b^{\prime}=c^{\prime}=0italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0. {minted}lean theorem Polynomial.flt_catalan_deriv /-…same condition as flt_catalan…-/ : derivative a = 0 \wedge derivative b = 0 \wedge derivative c = 0

We then formalize the infinite descent argument in Section 6.1.1 to show that the degree of a𝑎aitalic_a is zero. If the characteristic of k𝑘kitalic_k is nonzero, we apply a strong induction555Nat.case_strong_induction_on in mathlib4 on the degree of a𝑎aitalic_a. {minted}lean theorem Polynomial.flt_catalan_aux /-…same condition as flt_catalan…-/ : a.natDegree = 0 Then we use this auxiliary step three times to formalize Theorem 2.1.

FLT for polynomial (Corollary 1) then immediately follows by considering the case when p=q=r=n3𝑝𝑞𝑟𝑛3p=q=r=n\geq 3italic_p = italic_q = italic_r = italic_n ≥ 3 and u=v=1𝑢𝑣1u=v=1italic_u = italic_v = 1, w=1𝑤1w=-1italic_w = - 1.

{minted}

lean theorem Polynomial.flt n : \mathbb{N}blackboard_N (hn : 3 \leq n) (chn : ¬\neg¬ringChar k — n) a b c : k[X] (ha : a \neq 0) (hb : b \neq 0) (hc : c \neq 0) (hab : IsCoprime a b) (heq : a ^n + b ^n = c ^n) : a.natDegree = 0 \wedge b.natDegree = 0 \wedge c.natDegree = 0

6.2 Non-parametrizability of y2=x3+1superscript𝑦2superscript𝑥31y^{2}=x^{3}+1italic_y start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT = italic_x start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + 1 (Theorem 2.2)

6.2.1 Mathematical proof

As a corollary of Theorem 2.1, we can show that y2=x3+1superscript𝑦2superscript𝑥31y^{2}=x^{3}+1italic_y start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT = italic_x start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + 1 is not parametrizable by rational functions of t𝑡titalic_t, similarly as in [12, Proposition 2.3.1].

Assume that a parametrization exists, so that x=m/M𝑥𝑚𝑀x=m/Mitalic_x = italic_m / italic_M and y=n/N𝑦𝑛𝑁y=n/Nitalic_y = italic_n / italic_N for some m,n,M,Nk[t]𝑚𝑛𝑀𝑁𝑘delimited-[]𝑡m,n,M,N\in k[t]italic_m , italic_n , italic_M , italic_N ∈ italic_k [ italic_t ] with (m,M)=1𝑚𝑀1(m,M)=1( italic_m , italic_M ) = 1 and (n,N)=1𝑛𝑁1(n,N)=1( italic_n , italic_N ) = 1. By clearing denominators, we obtain n2M3=(m3+M3)N2superscript𝑛2superscript𝑀3superscript𝑚3superscript𝑀3superscript𝑁2n^{2}M^{3}=(m^{3}+M^{3})N^{2}italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_M start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT = ( italic_m start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + italic_M start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) italic_N start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT. From this one can show that N2superscript𝑁2N^{2}italic_N start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT and M3superscript𝑀3M^{3}italic_M start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT divide each other. Using the unique factorization of N2=M3superscript𝑁2superscript𝑀3N^{2}=M^{3}italic_N start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT = italic_M start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT, we can find α,βk×𝛼𝛽superscript𝑘\alpha,\beta\in k^{\times}italic_α , italic_β ∈ italic_k start_POSTSUPERSCRIPT × end_POSTSUPERSCRIPT and ek[t]𝑒𝑘delimited-[]𝑡e\in k[t]italic_e ∈ italic_k [ italic_t ] such that M=αe2𝑀𝛼superscript𝑒2M=\alpha e^{2}italic_M = italic_α italic_e start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT and N=βe3𝑁𝛽superscript𝑒3N=\beta e^{3}italic_N = italic_β italic_e start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT. Now the equation reduces to β2m3+α3β2e6=α3n2superscript𝛽2superscript𝑚3superscript𝛼3superscript𝛽2superscript𝑒6superscript𝛼3superscript𝑛2\beta^{2}m^{3}+\alpha^{3}\beta^{2}e^{6}=\alpha^{3}n^{2}italic_β start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_m start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + italic_α start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT italic_β start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_e start_POSTSUPERSCRIPT 6 end_POSTSUPERSCRIPT = italic_α start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT, which is a nontrivial solution for the Fermat-Catalan equation with (p,q,r)=(3,6,2)𝑝𝑞𝑟362(p,q,r)=(3,6,2)( italic_p , italic_q , italic_r ) = ( 3 , 6 , 2 ). This is a contradiction as the characteristic of k𝑘kitalic_k is not 2222 or 3333.

6.2.2 Formalization

The statement can be formalized as follows.

{minted}

lean def IsConst (x : RatFunc k) := \exists c : k, x = RatFunc.C c

theorem no_parametrization_y2_x3_1 (chk : ¬\neg¬ringChar k — 6) x y : RatFunc k (eqn : y ^2 = x ^3 + 1) : IsConst x \wedge IsConst y

The formalization is straightforward, but requires a large body of code for algebraic manipulation. Also, we had to formalize certain number-theoretic properties coming from that k[t]𝑘delimited-[]𝑡k[t]italic_k [ italic_t ] is a UFD. For example, that M2superscript𝑀2M^{2}italic_M start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT and N3superscript𝑁3N^{3}italic_N start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT divides each other impling the existence of c𝑐citalic_c such that M𝑀Mitalic_M and N𝑁Nitalic_N are associated to c3superscript𝑐3c^{3}italic_c start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT and c2superscript𝑐2c^{2}italic_c start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT respectively, which is true for any UFD.

{minted}

lean theorem associated_pow_pow_coprime_iff a b : k[X] (ha : a \neq 0) (hb : b \neq 0) m n : \mathbb{N}blackboard_N (hm : m \neq 0) (hn : n \neq 0) (h : Associated (a ^m) (b ^n)) (hcp : m.Coprime n) : \exists c : k[X], c \neq 0 \wedge Associated a (c ^n) \wedge Associated b (c ^m)

6.3 Davenport’s Theorem (Theorem 2.3)

6.3.1 A Non-coprime Variant of Mason–Stothers Theorem

Davenport’s theorem also almost directly follows from Mason–Stothers theorem. We start with a variant of Mason–Stothers theorem by Stothers [20] that does not require coprimality of a,b,c𝑎𝑏𝑐a,b,citalic_a , italic_b , italic_c.

Theorem 6.1

Let k𝑘kitalic_k be any field of characteristic zero, and a,b,ck[t]𝑎𝑏𝑐𝑘delimited-[]𝑡a,b,c\in k[t]italic_a , italic_b , italic_c ∈ italic_k [ italic_t ] be non-zero polynomials satisfying a+b+c=0𝑎𝑏𝑐0a+b+c=0italic_a + italic_b + italic_c = 0. Then we either have a,b,ck𝑎𝑏𝑐𝑘a,b,c\in kitalic_a , italic_b , italic_c ∈ italic_k or

max{deg(a),deg(b),deg(c)}<deg(rad(a))+deg(rad(b))+deg(c).degree𝑎degree𝑏degree𝑐degreerad𝑎degreerad𝑏degree𝑐\max\{\deg(a),\deg(b),\deg(c)\}<\deg(\mathrm{rad}(a))+\deg(\mathrm{rad}(b))+% \deg(c).roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) , roman_deg ( italic_c ) } < roman_deg ( roman_rad ( italic_a ) ) + roman_deg ( roman_rad ( italic_b ) ) + roman_deg ( italic_c ) .

Note that we need k𝑘kitalic_k to have characteristic zero in Theorem 6.1. If char k=p>0char 𝑘𝑝0\textrm{char }k=p>0char italic_k = italic_p > 0, then a counterexample is (a,b,c)=(tp+1,t(1+t)p,t)𝑎𝑏𝑐superscript𝑡𝑝1𝑡superscript1𝑡𝑝𝑡(a,b,c)=(t^{p+1},-t(1+t)^{p},t)( italic_a , italic_b , italic_c ) = ( italic_t start_POSTSUPERSCRIPT italic_p + 1 end_POSTSUPERSCRIPT , - italic_t ( 1 + italic_t ) start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT , italic_t ).

Proof

Let d𝑑ditalic_d be the gratest common divisor of a𝑎aitalic_a and b𝑏bitalic_b. Then a=a0d,b=b0d,c=c0dformulae-sequence𝑎subscript𝑎0𝑑formulae-sequence𝑏subscript𝑏0𝑑𝑐subscript𝑐0𝑑a=a_{0}d,b=b_{0}d,c=c_{0}ditalic_a = italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT italic_d , italic_b = italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT italic_d , italic_c = italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT italic_d for a0,b0,c0k[t]subscript𝑎0subscript𝑏0subscript𝑐0𝑘delimited-[]𝑡a_{0},b_{0},c_{0}\in k[t]italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∈ italic_k [ italic_t ] with a0+b0+c0=0subscript𝑎0subscript𝑏0subscript𝑐00a_{0}+b_{0}+c_{0}=0italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT + italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT + italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = 0. Moreover, gcd(a0,b0)=1subscript𝑎0subscript𝑏01\gcd(a_{0},b_{0})=1roman_gcd ( italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) = 1 so a0,b0,c0subscript𝑎0subscript𝑏0subscript𝑐0a_{0},b_{0},c_{0}italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT are nonzero and pairwise coprime. By applying Theorem 1.1 to (a0,b0,c0)subscript𝑎0subscript𝑏0subscript𝑐0(a_{0},b_{0},c_{0})( italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ), we either have a0=b0=c0=0superscriptsubscript𝑎0superscriptsubscript𝑏0superscriptsubscript𝑐00a_{0}^{\prime}=b_{0}^{\prime}=c_{0}^{\prime}=0italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 or

max{deg(a0),deg(b0),deg(c0)}<deg(rad(a0))+deg(rad(b0))+deg(rad(c0)).degreesubscript𝑎0degreesubscript𝑏0degreesubscript𝑐0degreeradsubscript𝑎0degreeradsubscript𝑏0degreeradsubscript𝑐0\begin{gathered}\max\{\deg(a_{0}),\deg(b_{0}),\deg(c_{0})\}<\\ \deg(\mathrm{rad}(a_{0}))+\deg(\mathrm{rad}(b_{0}))+\deg(\mathrm{rad}(c_{0})).% \end{gathered}start_ROW start_CELL roman_max { roman_deg ( italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) , roman_deg ( italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) , roman_deg ( italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) } < end_CELL end_ROW start_ROW start_CELL roman_deg ( roman_rad ( italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) ) + roman_deg ( roman_rad ( italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) ) + roman_deg ( roman_rad ( italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) ) . end_CELL end_ROW (1)

Consider the case a0=b0=c0=0superscriptsubscript𝑎0superscriptsubscript𝑏0superscriptsubscript𝑐00a_{0}^{\prime}=b_{0}^{\prime}=c_{0}^{\prime}=0italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0. Since k𝑘kitalic_k have characteristic zero, a0,b0,c0ksubscript𝑎0subscript𝑏0subscript𝑐0𝑘a_{0},b_{0},c_{0}\in kitalic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∈ italic_k. If dk𝑑𝑘d\in kitalic_d ∈ italic_k then the proof is done. Otherwise, deg(d)1degree𝑑1\deg(d)\geq 1roman_deg ( italic_d ) ≥ 1 by Lemma 3 so

max{deg(a),deg(b),deg(c)}=deg(d)degree𝑎degree𝑏degree𝑐degree𝑑\displaystyle\max\{\deg(a),\deg(b),\deg(c)\}=\deg(d)roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) , roman_deg ( italic_c ) } = roman_deg ( italic_d ) <deg(rad(d))+deg(rad(d))+deg(d)absentdegreerad𝑑degreerad𝑑degree𝑑\displaystyle<\deg(\mathrm{rad}(d))+\deg(\mathrm{rad}(d))+\deg(d)< roman_deg ( roman_rad ( italic_d ) ) + roman_deg ( roman_rad ( italic_d ) ) + roman_deg ( italic_d )
=deg(rad(a))+deg(rad(b))+deg(c)absentdegreerad𝑎degreerad𝑏degree𝑐\displaystyle=\deg(\mathrm{rad}(a))+\deg(\mathrm{rad}(b))+\deg(c)= roman_deg ( roman_rad ( italic_a ) ) + roman_deg ( roman_rad ( italic_b ) ) + roman_deg ( italic_c )

and the proof is done too.

Now consider the case where (1) is true. Then

max{deg(a),deg(b),\displaystyle\max\{\deg(a),\deg(b),roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) , deg(c)}=max{deg(a0),deg(b0),deg(c0)}+deg(d)\displaystyle\deg(c)\}=\max\{\deg(a_{0}),\deg(b_{0}),\deg(c_{0})\}+\deg(d)roman_deg ( italic_c ) } = roman_max { roman_deg ( italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) , roman_deg ( italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) , roman_deg ( italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) } + roman_deg ( italic_d )
<deg(rad(a0))+deg(rad(b0))+deg(rad(c0))+deg(d)absentdegreeradsubscript𝑎0degreeradsubscript𝑏0degreeradsubscript𝑐0degree𝑑\displaystyle<\deg(\mathrm{rad}(a_{0}))+\deg(\mathrm{rad}(b_{0}))+\deg(\mathrm% {rad}(c_{0}))+\deg(d)< roman_deg ( roman_rad ( italic_a start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) ) + roman_deg ( roman_rad ( italic_b start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) ) + roman_deg ( roman_rad ( italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) ) + roman_deg ( italic_d )
deg(rad(a))+deg(rad(b))+deg(c0)+deg(d)absentdegreerad𝑎degreerad𝑏degreesubscript𝑐0degree𝑑\displaystyle\leq\deg(\mathrm{rad}(a))+\deg(\mathrm{rad}(b))+\deg(c_{0})+\deg(d)≤ roman_deg ( roman_rad ( italic_a ) ) + roman_deg ( roman_rad ( italic_b ) ) + roman_deg ( italic_c start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) + roman_deg ( italic_d )
=deg(rad(a))+deg(rad(b))+deg(c)absentdegreerad𝑎degreerad𝑏degree𝑐\displaystyle=\deg(\mathrm{rad}(a))+\deg(\mathrm{rad}(b))+\deg(c)= roman_deg ( roman_rad ( italic_a ) ) + roman_deg ( roman_rad ( italic_b ) ) + roman_deg ( italic_c )

completing the proof of Theorem 6.1.

The variant Theorem 6.1 is formalized as following. {minted}lean theorem Polynomial.abc’_char0 [CharZero k] a b c : k[X] (ha : a \neq 0) (hb : b \neq 0) (hc : c \neq 0) (hsum : a + b + c = 0) : (a.natDegree = 0 \wedge b.natDegree = 0 \wedge c.natDegree = 0) \vee Nat.max3 a.natDegree b.natDegree c.natDegree + 1 \leq (radical a).natDegree + (radical b).natDegree + c.natDegree

6.3.2 Mathematical proof

We now prove Davenport’s theorem (Theorem 2.3), mainly following the proof in Stothers’ paper [20].666Our proof is slightly more streamlined; we do not divide the proof into cases on whether deg(f3)=deg(g2)degreesuperscript𝑓3degreesuperscript𝑔2\deg(f^{3})=\deg(g^{2})roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) = roman_deg ( italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) or not. For non-constant polynomials f,gk[t]𝑓𝑔𝑘delimited-[]𝑡f,g\in k[t]italic_f , italic_g ∈ italic_k [ italic_t ] with f3g20superscript𝑓3superscript𝑔20f^{3}-g^{2}\neq 0italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ≠ 0, apply Theorem 6.1 to the zero-sum triple (f3,g2,f3g2)superscript𝑓3superscript𝑔2superscript𝑓3superscript𝑔2(-f^{3},g^{2},f^{3}-g^{2})( - italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT , italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT , italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ). The equality case

(f3)=(g2)=(f3g2)=0superscriptsuperscript𝑓3superscriptsuperscript𝑔2superscriptsuperscript𝑓3superscript𝑔20(f^{3})^{\prime}=(g^{2})^{\prime}=(f^{3}-g^{2})^{\prime}=0( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0

cannot happen since it would imply 3f2f=0=2gg3superscript𝑓2superscript𝑓02𝑔superscript𝑔3f^{2}f^{\prime}=0=2gg^{\prime}3 italic_f start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_f start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 = 2 italic_g italic_g start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT and thus 3=0=23023=0=23 = 0 = 2.

So we get the inequality

max{3deg(f),2deg(g)}3degree𝑓2degree𝑔\displaystyle\max\{3\deg(f),2\deg(g)\}roman_max { 3 roman_deg ( italic_f ) , 2 roman_deg ( italic_g ) } max{deg(f3),deg(g2),deg(f3g2)}absentdegreesuperscript𝑓3degreesuperscript𝑔2degreesuperscript𝑓3superscript𝑔2\displaystyle\leq\max\{\deg(-f^{3}),\deg(g^{2}),\deg(f^{3}-g^{2})\}≤ roman_max { roman_deg ( - italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) , roman_deg ( italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) , roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) }
<deg(rad(f3))+deg(rad(g2))+deg(f3g2)absentdegreeradsuperscript𝑓3degreeradsuperscript𝑔2degreesuperscript𝑓3superscript𝑔2\displaystyle<\deg(\mathrm{rad}(-f^{3}))+\deg(\mathrm{rad}(g^{2}))+\deg(f^{3}-% g^{2})< roman_deg ( roman_rad ( - italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ) ) + roman_deg ( roman_rad ( italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) ) + roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT )
deg(f)+deg(g)+deg(f3g2).absentdegree𝑓degree𝑔degreesuperscript𝑓3superscript𝑔2\displaystyle\leq\deg(f)+\deg(g)+\deg(f^{3}-g^{2}).≤ roman_deg ( italic_f ) + roman_deg ( italic_g ) + roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) .

This gives two inequalities

3deg(f)+13degree𝑓1\displaystyle 3\deg(f)+13 roman_deg ( italic_f ) + 1 deg(f)+deg(g)+deg(f3g2)absentdegree𝑓degree𝑔degreesuperscript𝑓3superscript𝑔2\displaystyle\leq\deg(f)+\deg(g)+\deg(f^{3}-g^{2})≤ roman_deg ( italic_f ) + roman_deg ( italic_g ) + roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT )
2deg(g)+12degree𝑔1\displaystyle 2\deg(g)+12 roman_deg ( italic_g ) + 1 deg(f)+deg(g)+deg(f3g2)absentdegree𝑓degree𝑔degreesuperscript𝑓3superscript𝑔2\displaystyle\leq\deg(f)+\deg(g)+\deg(f^{3}-g^{2})≤ roman_deg ( italic_f ) + roman_deg ( italic_g ) + roman_deg ( italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT )

and adding these two inequalities and rearranging gives the desired inequality.

6.3.3 Formalization

The statement of Davenport’s theorem (Corollary 2.3) can be formalized as follows. {minted}lean theorem Polynomial.davenport [CharZero k] a b : k[X] (ha : a.natDegree ¿ 0) (hb : b.natDegree ¿ 0) (hnz : a ^3 - b ^2 \neq 0) : a.natDegree + 2 \leq 2 * (a ^3 - b ^2).natDegree

We also formalized a variant of Davenport’s theorem that allows arbitrary characteristics, with the cost of assuming coprimality of two polynomials and assuming non-vanishing derivative instead of non-constantness. Note that we cannot remove all of these assumptions; k=𝔽2𝑘subscript𝔽2k=\mathbb{F}_{2}italic_k = blackboard_F start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT with (a,b)=(t4,t6+t)𝑎𝑏superscript𝑡4superscript𝑡6𝑡(a,b)=(t^{4},t^{6}+t)( italic_a , italic_b ) = ( italic_t start_POSTSUPERSCRIPT 4 end_POSTSUPERSCRIPT , italic_t start_POSTSUPERSCRIPT 6 end_POSTSUPERSCRIPT + italic_t ) gives a counterexample.

{minted}

lean theorem Polynomial.davenport’ a b : k[X] (hab : IsCoprime a b) (haderiv : derivative a \neq 0) (hbderiv : derivative b \neq 0) : a.natDegree + 2 \leq 2 * (a ^3 - b ^2).natDegree

7 Comparison with Previous Works

We compare our work to other formalizations of the Mason-Stothers Theorem by Eberl in Isabelle [7] and by Wagemaker in Lean 3 [10, 24].777Note that an unpublished Coq formalization by Assia Mahboubi is also reported in [24, Chapter 5]. We do not compare our work to this as it is not publicly available. All three formalizations, including ours, are based on the same proof by Lemmermeyer’s note [12] on the elementary proof of Snyder [19]. Unlike Snyder’s original proof [19] which assumes that k𝑘kitalic_k is algebraically closed, all formalizations work with any field k𝑘kitalic_k using radicals, following [12, Theorem 2.1.4, Corollary 2.1.5].

Eberl [7] Wagemaker [10] Ours
Radical radical rad radical
(a,b)=1rad(ab)=rad(a)rad(b)𝑎𝑏1rad𝑎𝑏rad𝑎rad𝑏(a,b)=1\Rightarrow\mathrm{rad}(ab)=\mathrm{rad}(a)\mathrm{rad}(b)( italic_a , italic_b ) = 1 ⇒ roman_rad ( italic_a italic_b ) = roman_rad ( italic_a ) roman_rad ( italic_b ) radical_mult_coprime rad_mul_eq_rad_mul_rad_of_coprime radical_hMul
degW(a,b)<deg(a)+deg(b)degree𝑊𝑎𝑏degree𝑎degree𝑏\deg W(a,b)<\deg(a)+\deg(b)roman_deg italic_W ( italic_a , italic_b ) < roman_deg ( italic_a ) + roman_deg ( italic_b ) degree_pderiv_mult_less888Eberl formalized deg(ab)<deg(a)+deg(b)degreesuperscript𝑎𝑏degree𝑎degree𝑏\deg(a^{\prime}b)<\deg(a)+\deg(b)roman_deg ( italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT italic_b ) < roman_deg ( italic_a ) + roman_deg ( italic_b ) instead and used it twice. degree_wron_le natDegree_lt_add
arad(a)|aconditional𝑎rad𝑎superscript𝑎\frac{a}{\mathrm{rad}(a)}|a^{\prime}divide start_ARG italic_a end_ARG start_ARG roman_rad ( italic_a ) end_ARG | italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ([12, Lemma 2.1.2]) poly_div_radical_dvd_pderiv Mason_Stothers_lemma999Doest not exactly prove arad(a)|aconditional𝑎rad𝑎superscript𝑎\frac{a}{\mathrm{rad}(a)}|a^{\prime}divide start_ARG italic_a end_ARG start_ARG roman_rad ( italic_a ) end_ARG | italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT; see Section 7.2 for details. divRadical_dvd_derivative
Mason–Stothers Mason_Stothers Mason_Stothers Polynomial.abc
Mason_Stothers_char_0
Polynomial FLT fermat_poly - Polynomial.flt
fermat_poly_char_0
Table 1: Comparison of definitions and theorems in different formalizations of Mason–Stothers.

7.1 Eberl’s Isabelle formalization

Eberl formalized both the characteristic zero and positive case of Mason–Stothers theorem in Isabelle [7], as a part of the Archive of Formal Proofs (Isabelle-AFP) mathematics library. Consequently, their formalization is reusable with other definitions and theorems in Isabelle-AFP. We compare their formalization to ours as follows.

  1. 1.

    They define the radical rad(a)rad𝑎\mathrm{rad}(a)roman_rad ( italic_a ) on any factoral semiring, which is a commutative ring with unique factorization. We define radical in a slightly more general setting of monoids with unique factorization.

  2. 2.

    They assume the coprimality condition gcd(a,b,c)=1gcd𝑎𝑏𝑐1\mathrm{gcd}(a,b,c)=1roman_gcd ( italic_a , italic_b , italic_c ) = 1101010cop: "Gcd {A, B, C} = 1" in Isabelle in Mason–Stothers, but this is equivalent to pairwise coprimality gcd(a,b)=gcd(b,c)=gcd(c,a)=1gcd𝑎𝑏gcd𝑏𝑐gcd𝑐𝑎1\mathrm{gcd}(a,b)=\mathrm{gcd}(b,c)=\mathrm{gcd}(c,a)=1roman_gcd ( italic_a , italic_b ) = roman_gcd ( italic_b , italic_c ) = roman_gcd ( italic_c , italic_a ) = 1 we assume by a+b+c=0𝑎𝑏𝑐0a+b+c=0italic_a + italic_b + italic_c = 0.

  3. 3.

    Their work also formalizes the polynomial version of FLT for any characteristic. They proved that, when a triple of nonzero coprime polynomials satisfy an+bn+cn=0superscript𝑎𝑛superscript𝑏𝑛superscript𝑐𝑛0a^{n}+b^{n}+c^{n}=0italic_a start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT + italic_b start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT + italic_c start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT = 0 and at least one of (an)superscriptsuperscript𝑎𝑛(a^{n})^{\prime}( italic_a start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT, (bn)superscriptsuperscript𝑏𝑛(b^{n})^{\prime}( italic_b start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT, or (cn)superscriptsuperscript𝑐𝑛(c^{n})^{\prime}( italic_c start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT is nonzero111111deg: "p{A,B,C}. pderiv(pn)=0𝑝A,B,C. pderivsuperscriptp𝑛0\exists p\in\{\texttt{A,B,C}\}\texttt{. pderiv}(\texttt{p}^{n})=0∃ italic_p ∈ { A,B,C } . pderiv ( p start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) = 0 in Isabelle, then n2𝑛2n\leq 2italic_n ≤ 2. In other words, nonzero coprime polynomials a,b,c𝑎𝑏𝑐a,b,citalic_a , italic_b , italic_c satisfying the Fermat’s equation for n3𝑛3n\geq 3italic_n ≥ 3 should have (an)=(bn)=(cn)=0superscriptsuperscript𝑎𝑛superscriptsuperscript𝑏𝑛superscriptsuperscript𝑐𝑛0(a^{n})^{\prime}=(b^{n})^{\prime}=(c^{n})^{\prime}=0( italic_a start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_b start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_c start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0. Our formalization of polynomial FLT (Corollary 1) has a strictly stronger conclusion; either the characteristic of k𝑘kitalic_k divides n𝑛nitalic_n, or a,b,ck𝑎𝑏𝑐𝑘a,b,c\in kitalic_a , italic_b , italic_c ∈ italic_k.121212Our condition implies the conclusion (an)=(bn)=(cn)=0superscriptsuperscript𝑎𝑛superscriptsuperscript𝑏𝑛superscriptsuperscript𝑐𝑛0(a^{n})^{\prime}=(b^{n})^{\prime}=(c^{n})^{\prime}=0( italic_a start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_b start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_c start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 of Eberl’s version immediately. On the other hand, let k𝑘kitalic_k be of characteristic p>0𝑝0p>0italic_p > 0, let n𝑛nitalic_n be any number not divisible by p𝑝pitalic_p, and let a=tp𝑎superscript𝑡𝑝a=t^{p}italic_a = italic_t start_POSTSUPERSCRIPT italic_p end_POSTSUPERSCRIPT. Then (an)=(tnp)=0superscriptsuperscript𝑎𝑛superscriptsuperscript𝑡𝑛𝑝0(a^{n})^{\prime}=(t^{np})^{\prime}=0( italic_a start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = ( italic_t start_POSTSUPERSCRIPT italic_n italic_p end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 0 holds, satisfying the conclusion of Eberl’s, but observe that a𝑎aitalic_a is not a constant. This is achieved by the simple infinite descent argument in Section 6.1.1.

7.2 Wagemaker’s Lean 3 formalization

Wagemaker formalized the Mason–Stothers theorem in Lean 3, in the early days when the Lean mathlib mathematics library was taking shape [10, 24]. Consequently, Hőlzl and Wagemaker built a large body of work (“4/5 of the formalization” according to Wagemaker [24]) that formalizes many fundamental notions such as polynomials, UFDs, greatest common divisor, and coprimality [10]. Their work was then incorporated into the current mathlib/mathlib4 library of Lean 3 and 4. In particular, the design suggestions [24] in Wagemaker’s work shapes a lot of fundamental APIs in the current mathlib implementation of UFDs.131313For an example, he observed that the notion of greatest common divisor in a general UFD R𝑅Ritalic_R should have the type of quotients of R𝑅Ritalic_R modulo associated elements, which is now available as Associates in mathlib4..

Their project was independent of Lean 3’s mathlib, however, as it was incorporated after its completion. In contrast, our work builds on the now-mature mathlib4 of Lean 4, ensuring reusability with existing definitions. In regards to the formalization of Mason–Stothers theorem, we compare their work to ours as follows.

  1. 1.

    They work on fields of characteristic zero only, while our formallization allows arbitrary characteristic.

  2. 2.

    They do not formalize further corollaries of Mason–Stothers such as polynomial FLT.

  3. 3.

    Their work misses the proof that a polynomial ring R[X]𝑅delimited-[]𝑋R[X]italic_R [ italic_X ] over a unique factorization domain R𝑅Ritalic_R is also a unique factorization domain.141414This is represented as a sorry in poly_over_UFD.lean of [10]. In contrast, our formalization on Lean 4 is complete, and is based on the current mathlib4 with the proof that R[X]𝑅delimited-[]𝑋R[X]italic_R [ italic_X ] is UFD (and many more).

  4. 4.

    They do not define a/rad(a)𝑎rad𝑎a/\mathrm{rad}(a)italic_a / roman_rad ( italic_a ) explicitly but instead use gcd(a,a)𝑎superscript𝑎\gcd(a,a^{\prime})roman_gcd ( italic_a , italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) to avoid polynomial division. Then they prove

    deg(a)deg(gcd(a,a))+deg(rad(a))degree𝑎degree𝑎superscript𝑎degreerad𝑎\deg(a)\leq\deg(\gcd(a,a^{\prime}))+\deg(\mathrm{rad}(a))roman_deg ( italic_a ) ≤ roman_deg ( roman_gcd ( italic_a , italic_a start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) ) + roman_deg ( roman_rad ( italic_a ) )

    as a lemma [24, Lemma 2.3.1], instead of Lemma 1 in our work.

Eberl [7] Wagemaker [10, 24] Ours
Language Isabelle Lean 3 Lean 4
Complete O X O
Mason-Stothers char=0char0\text{char}=0char = 0 O O O151515Includes a non-coprime variant (Theorem 6.1) by Stothers.
char>0char0\text{char}>0char > 0 O X O
Poly-FLT char=0char0\text{char}=0char = 0 O X O
char>0char0\text{char}>0char > 0 O X O161616Stronger conclusion than Eberl [7] as described in Section 7.1.
Other corollaries X X O
Table 2: Comparison of Formalizations of Mason–Stothers Theorem

8 Future Works

We suggest further directions in formalizing generalizations of Mason–Stothers theorem.

  • Bayat et al. [1] extends the Mason–Stothers theorem to more than three polynomials, using the Wronskian of more than two polynomials.

  • In algebraic geometry, it is known that rational maps from the projective line to a curve exist only if the curve has genus 0. This immediately proves both FLT for polynomials and non-parametrizability of any elliptic curves, as the Fermat curve xn+yn=1superscript𝑥𝑛superscript𝑦𝑛1x^{n}+y^{n}=1italic_x start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT + italic_y start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT = 1 (n3𝑛3n\geq 3italic_n ≥ 3) and elliptic curve y2=x3+ax+bsuperscript𝑦2superscript𝑥3𝑎𝑥𝑏y^{2}=x^{3}+ax+bitalic_y start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT = italic_x start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT + italic_a italic_x + italic_b have genus >0absent0>0> 0 [12]. However, the current mathlib4 does not have enough theorems to prove this result (e.g. Riemann–Hurwitz formula).

  • Mason–Stothers theorem can be thought as the most basic case of ABC over a function field k(C)𝑘𝐶k(C)italic_k ( italic_C ) of a smooth projective curve C𝐶Citalic_C, when the curve C𝐶Citalic_C is the projective line over k𝑘kitalic_k. Mason [13] proved the following more general result:

    Theorem 8.1 (Mason)

    Let k𝑘kitalic_k be an algebraically closed field and C𝐶Citalic_C be a smooth projective curve over k𝑘kitalic_k. Let a,bk(C)𝑎𝑏𝑘𝐶a,b\in k(C)italic_a , italic_b ∈ italic_k ( italic_C ) satisfying a+b=1𝑎𝑏1a+b=1italic_a + italic_b = 1, and S𝑆Sitalic_S be a finite subset of points in C(k)𝐶𝑘C(k)italic_C ( italic_k ) containing all the zeros and poles of a𝑎aitalic_a and b𝑏bitalic_b. Then either a,bk×𝑎𝑏superscript𝑘a,b\in k^{\times}italic_a , italic_b ∈ italic_k start_POSTSUPERSCRIPT × end_POSTSUPERSCRIPT or

    max{deg(a),deg(b)}2g2+|S|.degree𝑎degree𝑏2𝑔2𝑆\max\{\deg(a),\deg(b)\}\leq 2g-2+|S|.roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) } ≤ 2 italic_g - 2 + | italic_S | .

    When C=1𝐶superscript1C=\mathbb{P}^{1}italic_C = blackboard_P start_POSTSUPERSCRIPT 1 end_POSTSUPERSCRIPT, this reduces to the Mason–Stothers theorem: a zero-sum coprime triple a,b,c𝑎𝑏𝑐a,b,citalic_a , italic_b , italic_c of polynomials gives (a/c)+(b/c)=1𝑎𝑐𝑏𝑐1(-a/c)+(-b/c)=1( - italic_a / italic_c ) + ( - italic_b / italic_c ) = 1, and the above inequality becomes

    max{deg(a),deg(b),deg(c)}degree𝑎degree𝑏degree𝑐\displaystyle\max\{\deg(a),\deg(b),\deg(c)\}roman_max { roman_deg ( italic_a ) , roman_deg ( italic_b ) , roman_deg ( italic_c ) }
    =max{deg(ac),deg(bc)}absentdegree𝑎𝑐degree𝑏𝑐\displaystyle=\max\left\{\deg\left(-\frac{a}{c}\right),\deg\left(-\frac{b}{c}% \right)\right\}= roman_max { roman_deg ( - divide start_ARG italic_a end_ARG start_ARG italic_c end_ARG ) , roman_deg ( - divide start_ARG italic_b end_ARG start_ARG italic_c end_ARG ) }
    2+|S|=deg(rad(abc))1,absent2𝑆degreerad𝑎𝑏𝑐1\displaystyle\leq-2+|S|=\deg(\mathrm{rad}(abc))-1,≤ - 2 + | italic_S | = roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) - 1 ,

    where S={zeros of abc}{}𝑆zeros of 𝑎𝑏𝑐S=\{\text{zeros of }abc\}\cup\{\infty\}italic_S = { zeros of italic_a italic_b italic_c } ∪ { ∞ } and |S|=deg(rad(abc))+1𝑆degreerad𝑎𝑏𝑐1|S|=\deg(\mathrm{rad}(abc))+1| italic_S | = roman_deg ( roman_rad ( italic_a italic_b italic_c ) ) + 1. Silverman [18] gives a short proof of the theorem using Riemann-Hurwitz formula.

Acknowledgement

We thank Kevin Buzzard for suggesting the project. Also, we thank Thomas Browning for his help in simplifying the formalization of Davenport’s theorem. We also thank the reviewers of mathlib4 who helped improving our codes and porting them into mathlib4, including Johan Commelin, Yaël Dillies, and Eric Weiser. Jineon Baek acknowledges the support from Korea Foundation for Advanced Studies during the completion of this work.

Appendix 0.A Porting to mathlib4

We are in the process of integrating our formalization of the Mason–Stothers theorem to the mathlib4 library. Table 3 lists the pull requests made so far to mathlib4 as of August 23, 2024.

Topic PR Descriptions
Wronskian 14281 Prove B(a,b)+B(b,c)+B(c,a)=0𝐵𝑎𝑏𝐵𝑏𝑐𝐵𝑐𝑎0B(a,b)+B(b,c)+B(c,a)=0italic_B ( italic_a , italic_b ) + italic_B ( italic_b , italic_c ) + italic_B ( italic_c , italic_a ) = 0 for alternating bilinear B𝐵Bitalic_B.
14243 Define Wronskian of polynomials and prove relevant theorems.
Radical 14873 Define radical of elements.
15531 Prove theorems on radicals of coprime elements.
Mason–Stothers 15706 Proof of Mason–Stothers theorem.
Polynomial FLT 16060 Statement of FLT for semirings, allowing nonzero unit solutions.
Table 3: List of pull requests to mathlib4.

References

  • [1] Bayat, M., Teimoori, H., Hassani, M.: An extension of ABC-theorem. Sci. Magna 1(2), 81–88 (2005)
  • [2] Birch, B.J., Chowla, S., Hall, Jr., M., Schinzel, A.: On the difference x3y2superscript𝑥3superscript𝑦2x^{3}-y^{2}italic_x start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT - italic_y start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT. Norske Vid. Selsk. Forh. (Trondheim) 38, 65–69 (1965)
  • [3] Cornell, G., Silverman, J.H., Stevens, G.: Modular forms and Fermat’s last theorem. Springer Science & Business Media (2013)
  • [4] Davenport, H.: On f3(t)g2(t)superscript𝑓3𝑡superscript𝑔2𝑡f^{3}\,(t)-g^{2}\,(t)italic_f start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT ( italic_t ) - italic_g start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ( italic_t ). Norske Vid. Selsk. Forh. (Trondheim) 38, 86–87 (1965)
  • [5] Deligne, P.: La conjecture de Weil. I. Inst. Hautes Études Sci. Publ. Math. pp. 273–307 (1974)
  • [6] Deligne, P.: La conjecture de Weil. II. Inst. Hautes Études Sci. Publ. Math. pp. 137–252 (1980)
  • [7] Eberl, M.: The mason–stothers theorem. Archive of Formal Proofs (December 2017), https://isa-afp.org/entries/Mason_Stothers.html, Formal proof development
  • [8] Faltings, G.: Endlichkeitssätze für abelsche Varietäten über Zahlkörpern. Invent. Math. 73(3), 349–366 (1983)
  • [9] Granville, A., Tucker, T.J.: It’s as easy as abc𝑎𝑏𝑐abcitalic_a italic_b italic_c. Notices Amer. Math. Soc. 49(10), 1224–1231 (2002)
  • [10] Hölzl, J., Wagemaker, J.: mason-stother. https://github.com/johoelzl/mason-stother (2017)
  • [11] Lafforgue, L.: Chtoucas de Drinfeld et correspondance de Langlands. Invent. Math. 147(1), 1–241 (2002)
  • [12] Lemmermeyer, F.: Mason’s theorem. https://www.fen.bilkent.edu.tr/~franz/ag05/ag-02.pdf
  • [13] Mason, R.C.: The hyperelliptic equation over function fields. Math. Proc. Cambridge Philos. Soc. 93(2), 219–230 (1983)
  • [14] Mason, R.C.: Diophantine equations over function fields, London Mathematical Society Lecture Note Series, vol. 96. Cambridge University Press, Cambridge (1984)
  • [15] Masser, D.W.: Open problems. In: Proceedings of the symposium on Analytic Number Theory, London, 1985. Imperial College (1985)
  • [16] Oesterlé, J.: Nouvelles approches du “théoreme” de fermat. Astérisque 161(162), 165–186 (1988)
  • [17] Roth, K.F.: Rational approximations to algebraic numbers. Mathematika 2, 1–20; corrigendum, 168 (1955)
  • [18] Silverman, J.H.: The S𝑆Sitalic_S-unit equation over function fields. Math. Proc. Cambridge Philos. Soc. 95(1),  3–4 (1984)
  • [19] Snyder, N.: An alternate proof of Mason’s theorem. Elem. Math. 55(3), 93–94 (2000)
  • [20] Stothers, W.W.: Polynomial identities and Hauptmoduln. Quart. J. Math. Oxford Ser. (2) 32(127), 349–370 (1981)
  • [21] Tate, J.: On the conjectures of Birch and Swinnerton-Dyer and a geometric analog. In: Séminaire Bourbaki, Vol. 9, pp. Exp. No. 306, 415–440. Soc. Math. France, Paris (1995)
  • [22] Taylor, R., Wiles, A.: Ring-theoretic properties of certain Hecke algebras. Ann. of Math. (2) 141(3), 553–572 (1995)
  • [23] Van Frankenhuysen, M.: The abc conjecture implies roth’s theorem and mordell’s conjecture. Mat. Contemp 16, 45–72 (1999)
  • [24] Wagemaker, J.: A formally verified proof of the mason-stothers theorem in lean (2018), https://matryoshka-project.github.io/pubs/wagemaker_bsc_thesis.pdf
  • [25] Wiles, A.: Modular elliptic curves and Fermat’s last theorem. Ann. of Math. (2) 141(3), 443–551 (1995)