/- Copyright 2025 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ import FormalConjecturesUtil

Infinitude of Wall–Sun–Sun primes

Reference: Wikipedia

open Algebra (IsQuadraticExtension)open NumberFieldnamespace QuadraticAlgebravariable {d : } [Fact <| Squarefree d] [Fact <| d 1]

The discriminant of ℚ[√d] for d ≥ 2 squarefree congruent to 1 mod 4 is d.

@[category textbook, AMS 11, simp] lemma discr_rat_of_modEq_one (hd₄ : d 1 [ZMOD 4]) : discr (QuadraticAlgebra d 0) = d := d:inst✝¹:Fact (Squarefree d)inst✝:Fact (d 1)hd₄:d 1 [ZMOD 4]discr (QuadraticAlgebra (↑d) 0) = d All goals completed! 🐙

The discriminant of ℚ[√d] for d ≥ 2 squarefree not congruent to 1 mod 4 is 4 * d.

@[category textbook, AMS 11, simp] lemma discr_rat_of_not_modEq_one (hd₄ : ¬ d 1 [ZMOD 4]) : discr (QuadraticAlgebra d 0) = 4 * d := d:inst✝¹:Fact (Squarefree d)inst✝:Fact (d 1)hd₄:¬d 1 [ZMOD 4]discr (QuadraticAlgebra (↑d) 0) = 4 * d All goals completed! 🐙end QuadraticAlgebranamespace Algebravariable {K L : Type*} [Field K] [Field L] [Algebra K L]variable (K L) in

A quadratic algebra L over a field K is isomorphic to the explicit quadratic algebra QuadraticAlgebra K a b for some a b : K.

@[category textbook, AMS 11] lemma exists_quadraticAlgebra_of_isQuadraticExtension [IsQuadraticExtension K L] : a b, Nonempty (L ≃ₐ[K] QuadraticAlgebra K a b) := K:Type u_1L:Type u_2inst✝³:Field Kinst✝²:Field Linst✝¹:Algebra K Linst✝:IsQuadraticExtension K L a b, Nonempty (L ≃ₐ[K] QuadraticAlgebra K a b) All goals completed! 🐙

An algebra L is quadratic over a field K iff it is isomorphic to the explicit quadratic algebra QuadraticAlgebra K a b for some a b : K.

@[category textbook, AMS 11] lemma isQuadraticExtension_iff_exists_quadraticAlgebra : IsQuadraticExtension K L a b, Nonempty (L ≃ₐ[K] QuadraticAlgebra K a b) where mp _ := exists_quadraticAlgebra_of_isQuadraticExtension .. mpr := K:Type u_1L:Type u_2inst✝²:Field Kinst✝¹:Field Linst✝:Algebra K L(∃ a b, Nonempty (L ≃ₐ[K] QuadraticAlgebra K a b)) IsQuadraticExtension K L K:Type u_1L:Type u_2inst✝²:Field Kinst✝¹:Field Linst✝:Algebra K La:Kb:Ke:L ≃ₐ[K] QuadraticAlgebra K a bIsQuadraticExtension K L; All goals completed! 🐙end Algebranamespace NumberFieldvariable {K : Type*} [Field K] [NumberField K]variable (K) in

A quadratic number field K is isomorphic to the explicit quadratic field QuadraticAlgebra ℚ d 0 for some squarefree d : ℤ not equal to 1.

@[category textbook, AMS 11] lemma exists_quadraticAlgebra_of_isQuadraticExtension [IsQuadraticExtension K] : d (1 : ), Squarefree d Nonempty (K ≃+* QuadraticAlgebra d 0) := K:Type u_1inst✝²:Field Kinst✝¹:NumberField Kinst✝:IsQuadraticExtension K d, d 1 Squarefree d Nonempty (K ≃+* QuadraticAlgebra (↑d) 0) All goals completed! 🐙

A number field K is quadratic iff it is isomorphic to the explicit quadratic field QuadraticAlgebra ℚ d 0 for some squarefree d : ℤ not equal to 1.

@[category textbook, AMS 11] lemma isQuadraticExtension_iff_exists_quadraticAlgebra : IsQuadraticExtension K d (1 : ), Squarefree d Nonempty (K ≃+* QuadraticAlgebra d 0) where mp _ := exists_quadraticAlgebra_of_isQuadraticExtension _ mpr := K:Type u_1inst✝¹:Field Kinst✝:NumberField K(∃ d, d 1 Squarefree d Nonempty (K ≃+* QuadraticAlgebra (↑d) 0)) IsQuadraticExtension K K:Type u_1inst✝¹:Field Kinst✝:NumberField Kd:hd₁:d 1hd:Squarefree de:K ≃+* QuadraticAlgebra (↑d) 0IsQuadraticExtension K; All goals completed! 🐙

An integer D is a fundamental discriminant iff it is the discriminant of the explicit quadratic field QuadraticAlgebra ℚ d 0 for some squarefree d : ℤ not equal to 1.

d:hD:Squarefree dhD₄:¬d 1 [ZMOD 4]this:Fact (d 1) d_1, (x : Fact (d_1 1)) (x_1 : Fact (Squarefree d_1)), discr (QuadraticAlgebra (↑d_1) 0) = 4 * d d:hD:Squarefree dhD₄:¬d 1 [ZMOD 4]this✝:Fact (d 1)this:Fact (Squarefree d) d_1, (x : Fact (d_1 1)) (x_1 : Fact (Squarefree d_1)), discr (QuadraticAlgebra (↑d_1) 0) = 4 * d All goals completed! 🐙 D:hD₁:D 1hD₄:D 1 [ZMOD 4]hD:Squarefree D d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D D:hD₁:D 1hD₄:D 1 [ZMOD 4]hD:Squarefree Dthis:Fact (D 1) d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D D:hD₁:D 1hD₄:D 1 [ZMOD 4]hD:Squarefree Dthis✝:Fact (D 1)this:Fact (Squarefree D) d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D All goals completed! 🐙 mpr := D:(∃ d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D) IsFundamentalDiscr D d:w✝¹:Fact (d 1)w✝:Fact (Squarefree d)IsFundamentalDiscr (discr (QuadraticAlgebra (↑d) 0)); d:w✝¹:Fact (d 1)w✝:Fact (Squarefree d)hd₄:d 1 [ZMOD 4]IsFundamentalDiscr (discr (QuadraticAlgebra (↑d) 0))d:w✝¹:Fact (d 1)w✝:Fact (Squarefree d)hd₄:¬d 1 [ZMOD 4]IsFundamentalDiscr (discr (QuadraticAlgebra (↑d) 0)) d:w✝¹:Fact (d 1)w✝:Fact (Squarefree d)hd₄:d 1 [ZMOD 4]IsFundamentalDiscr (discr (QuadraticAlgebra (↑d) 0))d:w✝¹:Fact (d 1)w✝:Fact (Squarefree d)hd₄:¬d 1 [ZMOD 4]IsFundamentalDiscr (discr (QuadraticAlgebra (↑d) 0)) All goals completed! 🐙

An integer D is a fundamental discriminant iff it is the discriminant of some number field.

D:(∃ d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D) K x, (x_1 : NumberField K), IsQuadraticExtension K discr K = D D:(∃ d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D) K x, (x_1 : NumberField K), IsQuadraticExtension K discr K = DD:(∃ K x, (x_1 : NumberField K), IsQuadraticExtension K discr K = D) d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D D:(∃ d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D) K x, (x_1 : NumberField K), IsQuadraticExtension K discr K = D d:w✝¹:Fact (d 1)w✝:Fact (Squarefree d) K x, (x_1 : NumberField K), IsQuadraticExtension K discr K = discr (QuadraticAlgebra (↑d) 0) All goals completed! 🐙 D:(∃ K x, (x_1 : NumberField K), IsQuadraticExtension K discr K = D) d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = D K:Typew✝¹:Field Kw✝:NumberField Kleft✝:IsQuadraticExtension K d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = discr K K:Typew✝¹:Field Kw✝:NumberField Kleft✝:IsQuadraticExtension Kd:hd₁:d 1hd:Squarefree de:K ≃+* QuadraticAlgebra (↑d) 0 d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = discr K K:Typew✝¹:Field Kw✝:NumberField Kleft✝:IsQuadraticExtension Kd:hd₁:d 1hd:Squarefree de:K ≃+* QuadraticAlgebra (↑d) 0this:Fact (d 1) d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = discr K K:Typew✝¹:Field Kw✝:NumberField Kleft✝:IsQuadraticExtension Kd:hd₁:d 1hd:Squarefree de:K ≃+* QuadraticAlgebra (↑d) 0this✝:Fact (d 1)this:Fact (Squarefree d) d, (x : Fact (d 1)) (x_1 : Fact (Squarefree d)), discr (QuadraticAlgebra (↑d) 0) = discr K All goals completed! 🐙end NumberFieldnamespace WallSunSun

A prime $p$ is a Wall–Sun–Sun prime if and only if $L_p \equiv 1 \pmod{p^2}$, where $L_p$ is the $p$-th Lucas number. It is conjectured that there is at least one Wall–Sun–Sun prime.

@[category research open, AMS 11] theorem exists_isWallSunSunPrime : p, IsWallSunSunPrime p := p, IsWallSunSunPrime p All goals completed! 🐙

A prime $p$ is a Wall–Sun–Sun prime if and only if $L_p \equiv 1 \pmod{p^2}$, where $L_p$ is the $p$-th Lucas number. It is conjectured that there are infinitely many Wall-Sun-Sun primes.

@[category research open, AMS 11] theorem infinite_isWallSunSunPrime : {p : | IsWallSunSunPrime p}.Infinite := {p | IsWallSunSunPrime p}.Infinite All goals completed! 🐙

A Lucas–Wieferich prime associated with $(a,b)$ is an odd prime $p$, not dividing $a^2 - 4b$, such that $U_{p-\varepsilon}(a,b) \equiv 0 \pmod{p^2}$ where $U(a,b)$ is the Lucas sequence of the first kind and $\varepsilon$ is the Legendre symbol $\left({\tfrac {a^2-4b}{p}}\right)$. The discriminant of this number is the quantity $a^2 - 4b$. It is conjectured that there are infinitely many Lucas–Wieferich primes of any given non-one fundamental discriminant.

TODO: Source this conjecture

@[category research open, AMS 11] theorem infinite_isWallSunSunPrime_of_disc_eq {D : } (hD : IsFundamentalDiscr D) (hD₁ : D 1) : {p : | a b, a ^ 2 - 4 * b = D IsLucasWieferichPrime a b p}.Infinite := D:hD:IsFundamentalDiscr DhD₁:D 1{p | a b, a ^ 2 - 4 * b = D IsLucasWieferichPrime a b p}.Infinite All goals completed! 🐙end WallSunSun