The Ramanujan-Nagell equation #
Stuff
Summary
PROVIDED SOLUTION
We begin by applying main_factorisation_lemma below. The relationship between m here and n there is m = n - 2.
We then have the factorization
((x + √-7)/2) * ((x - √-7)/2) = 2^m = ((1 + √-7)/2)^m * ((1 - √-7)/2)^m
which is written in Lean as ((↑x + 2*(↑θ : K) - 1) / 2) * ((↑x - 2*(↑θ : K) + 1) / 2) = (↑θ : K) ^ m * (1 - (↑θ : K)) ^ m.
This is a factorization into irreducible elements in the ring of integers of ℚ(√-7) (which is ℤ[θ]).
Since the class number is 1, we have unique factorization into irreducibles. Equivalently, the prime elements are the same as the irreducible elements.
One shows that the two factors (↑x + 2*(↑θ : K) - 1) / 2) and ((↑x - 2*(↑θ : K) + 1) / 2) are coprime as follows: by uniqueness of factorization,
we only need to consider the elements θ and (1 - θ) (the prime factors of 2 in this ring). If either of these divided both factors, then it would divide their difference,
which is 2*θ - 1 = √-7, which by taking norms is seen to not be the case. Therefore, by unique factorization, each factor must be equal to one of the two factors on the right up to multiplication by a unit.
The units in this ring are just ±1 (use units_pm_one above). Therefore, we obtain the important equation
(x ± √-7)/2 = \pm ((1 ± √-7)/2)^m.
Eliminating x by taking the difference of these two equations, we obtain the two cases stated in the lemma. There might be several similar
cases to deal with at the end to keep track of the signs.
The relevant results about unique factorization and UFDs can be found in the NumberTheory and RingTheory folders of mathlib.
Exercise 2: The conjugate factors are coprime in R. The only prime factors of 2
in R are θ and θ' (since 2 = θ·θ' by two_factorisation_R). If either
divided both α and β, it would divide their difference 2θ-1 = √(-7), but
N(√-7) = 7 is not divisible by N(θ) = 2 or N(θ') = 2.
Exercise 4: From α = ±θ^m or α = ±θ'^m, use the product relation to determine β, then take the difference α - β = 2θ-1 to eliminate x and obtain the conclusion.
If we know one of (2θ - 1 = θ^m - θ'^m) ∨ (-2θ + 1 = θ^m - θ'^m), then in fact the minus sign must hold: -2*θ + 1 = θ^m - θ'^m. This is proved by reducing modulo θ'^2 and checking which sign is consistent.
From -2*θ + 1 = θ^m - θ'^m, expand via the binomial theorem and reduce modulo 7 to obtain -2^(m-1) ≡ m (mod 7).
Key consequence of unique factorization in ℤ[(1+√-7)/2]: For odd n ≥ 5, if x² + 7 = 2ⁿ, then setting m = n - 2, we have -2^(m-1) ≡ m (mod 7).
This follows from the factorization in the ring of integers: ((x+√-7)/2)((x-√-7)/2) = 2^m = ((1+√-7)/2)^m ((1-√-7)/2)^m and unique factorization implies (x±√-7)/2 = ±((1±√-7)/2)^m. The negative sign must occur (proved by considering mod b² where b = (1-√-7)/2). Expanding via binomial theorem yields -2^(m-1) ≡ m (mod 7).
Skeleton for the uniqueness argument #
The following lemmas establish that each residue class mod 42 has at most one solution,
via a 7-adic contradiction argument. Together with the mod 42 constraint and known
solutions at m = 3, 5, 13, this completes the proof of odd_case_only_three_values.
Corollary C: Any two solutions of the Ramanujan-Nagell equation produce the same
theta expression θ^m - θ'^m = -2θ + 1, since main_m_condition shows the RHS
is independent of the particular solution.
The odd-indexed binomial sum: B_d = Σ_{j=0}^{(d-1)/2} C(d, 2j+1) · (-7)^j. This arises from expanding (1+√-7)^d = A_d + √-7 · B_d.
Equations
- binomial_B d = ∑ j ∈ Finset.range ((d + 1) / 2), ↑(d.choose (2 * j + 1)) * (-7) ^ j
Instances For
Lemma A: The 7-adic valuation of B_d is exactly l when 7^l ∥ d. The j=0 term of B_d equals d (valuation l), and all higher terms have strictly larger 7-adic valuation (≥ l+1), so by the ultrametric property the sum has valuation exactly l.
Lemma B: Same valuation result as Lemma A, used for the conjugate θ'. The sign difference (- instead of +) in (1-√-7)^d = A_d - √-7·B_d is what creates the contradiction when combined with Corollary C.
The even-indexed binomial sum A'd = Σ{j=0}^{d/2-1} C(d, 2(j+1)) · (-7)^j. This arises from the even-index part of the expansion of (1+√-7)^d.
Equations
- binomial_A' d = ∑ j ∈ Finset.range (d / 2), ↑(d.choose (2 * (j + 1))) * (-7) ^ j
Instances For
The trace sequence cast into R equals θ^n + θ'^n.
If two solutions m₁, m₂ satisfy m₁ ≡ m₂ (mod 42) and both give θ^m - θ'^m = -2θ+1, then m₁ = m₂. This is proved by contradiction: if m₁ ≠ m₂, the difference d = |m₂ - m₁| is divisible by 42 (hence by 7), and the 7-adic analysis of Lemmas A and B combined with Corollary C yields a contradiction on the valuation of √-7 · B_d.
PROVIDED SOLUTION
- WLOG m₂ > m₁ (else swap or they're equal). │
- Let d = m₂ - m₁, which is divisible by 42, hence by 7. │
- Let l = v₇(d). │
- From corollary_C (via h₁_theta, h₂_theta): θ^m₁ - θ'^m₁ = θ^m₂ - θ'^m₂. │
- Expand using binomial sums: this forces B_{m₂} = 2^d · B_{m₁}, equivalently B_d has certain 7-adic properties. │
- From lemma_A_binomial_valuation: v₇(B_d) = l exactly. │
- The identity (2θ-1)² = -7 means v_p(√-7) = 1 where p = (2θ-1). │
- For d ∈ ℤ: v_p(d) = 2·v₇(d) = 2l (always even). │
- Need v_p(d · √-7) ≥ 2(l+1) but v_p(d · √-7) = 2l+1 < 2l+2. Contradiction.
Verification: m = 3 (i.e. n = 5) is a solution, via x = 5: (25+7)/4 = 8 = 2³.
Verification: m = 5 (i.e. n = 7) is a solution, via x = 11: (121+7)/4 = 32 = 2⁵.
Verification: m = 13 (i.e. n = 15) is a solution, via x = 181: (32761+7)/4 = 8192 = 2¹³.
For the original equation x² + 7 = 2ⁿ with odd n ≥ 5, the only possible values of n are 5, 7, and 15.
PROOF: From the mod 42 constraint, m = n-2 is congruent to 3, 5, or 13 mod 42.
The verification lemmas show these are actual solutions (at m=3,5,13).
The uniqueness lemma at_most_one_m_per_class shows each residue class has at most
one solution. Therefore n ∈ {5, 7, 15}.
The Ramanujan-Nagell theorem: If x and n are integers satisfying x ^ 2 + 7 = 2 ^ n, then
(x, n) = (±1, 3), (±3, 4), (±5, 5), (±11, 7) or (±181, 15).