Documentation

RamanujanNagell.Helpers

@[reducible, inline]
abbrev R :

The integer ring ℤ[(1 + √-7)/2], packaged as QuadraticAlgebra ℤ (-2) 1.

Equations
Instances For
    def θ :

    θ = (1 + √-7)/2, the generator of R.

    Equations
    • θ = { re := 0, im := 1 }
    Instances For
      def θ' :

      θ' = (1 - √-7)/2 = 1 - θ, the Galois conjugate of θ.

      Equations
      Instances For

        Stoll's rfl claims #

        theorem theta_sq :
        θ ^ 2 = θ - 2
        theorem two_factorisation_R :
        θ * (1 - θ) = 2

        For backward compatibility with the old Helpers API.

        Norm form and positivity #

        norm ⟨x, y⟩ = x² + xy + 2y²; the key identity is 4·N = (2x + y)² + 7y².

        theorem norm_eq (x y : ) :
        QuadraticAlgebra.norm { re := x, im := y } = x ^ 2 + x * y + 2 * y ^ 2
        theorem four_norm_eq (z : R) :
        4 * QuadraticAlgebra.norm z = (2 * z.re + z.im) ^ 2 + 7 * z.im ^ 2

        The completing-the-square identity.

        theorem norm_pos {z : R} (hz : z 0) :

        Units are ±1 #

        theorem units_pm_one (u : Rˣ) :
        u = 1 u = -1

        θ and θ' are irreducible #

        EuclideanDomain instance via smart rounding #

        R = ℤ[(1+√-7)/2] with norm N(x, y) = x² + xy + 2y². To divide a by b ≠ 0, we want q such that N(a - b·q) < N(b). Naive independent rounding of (a/b) in the (re, im) basis can leave N = 1 exactly at the fundamental-domain corner; the fix is to round im first, then re-round re shifted by half the im residual. With that choice 16·N(rem) ≤ 11·N(b).

        noncomputable def quot (a b : R) :

        Smart-rounded quotient.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          noncomputable def rem (a b : R) :
          Equations
          Instances For
            @[simp]
            theorem quot_zero (a : R) :
            quot a 0 = 0
            theorem quot_mul_add_rem_eq (a b : R) :
            b * quot a b + rem a b = a
            @[implicit_reducible]
            noncomputable instance instEuclideanDomain :

            R is a Euclidean domain. Division of a by b ≠ 0 uses smart rounding of a · star b / N(b) (round the im coordinate first, then shift-round re), which guarantees 16 · N(rem) ≤ 11 · N(b), hence a strictly smaller norm.

            Equations
            • One or more equations did not get rendered due to their size.

            R is a principal ideal ring, since every Euclidean domain is one.

            R is a unique factorization domain, since every principal ideal ring is one.

            θ, θ' are prime #

            UFD scaffolding for the Ramanujan-Nagell argument #

            These lemmas combine units_pm_one with UniqueFactorizationMonoid R to give the key dichotomy α * β = θ^m · θ'^m ∧ IsCoprime α β → α = ±θ^m ∨ α = ±θ'^m.

            theorem theta_pow_dvd_of_coprime_prod (α β : R) (m : ) (h_prod : α * β = θ ^ m * θ' ^ m) (h_coprime : IsCoprime α β) :
            θ ^ m α θ ^ m β
            theorem associated_of_theta_pow_dvd (α β : R) (m : ) (h_prod : α * β = θ ^ m * θ' ^ m) (h_coprime : IsCoprime α β) (_hα : ¬IsUnit α) ( : ¬IsUnit β) (h_dvd : θ ^ m α) :
            Associated α (θ ^ m)
            theorem associated_of_theta_pow_dvd_right (α β : R) (m : ) (h_prod : α * β = θ ^ m * θ' ^ m) (h_coprime : IsCoprime α β) ( : ¬IsUnit α) (_hβ : ¬IsUnit β) (h_dvd : θ ^ m β) :
            theorem ufd_associated_dichotomy (α β : R) (m : ) (h_prod : α * β = θ ^ m * θ' ^ m) (h_coprime : IsCoprime α β) ( : ¬IsUnit α) ( : ¬IsUnit β) :
            Associated α (θ ^ m) Associated α (θ' ^ m)
            theorem associated_eq_or_neg (α γ : R) (h : Associated α γ) :
            α = γ α = -γ
            theorem ufd_power_association (α β : R) (m : ) (h_prod : α * β = θ ^ m * θ' ^ m) (h_coprime : IsCoprime α β) ( : ¬IsUnit α) ( : ¬IsUnit β) :
            (α = θ ^ m α = -θ ^ m) α = θ' ^ m α = -θ' ^ m