The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V12. Number theory

Mathlib.NumberTheory.SumFourSquares

7 declarations. Mathlib docs · Source

theorem euler_four_squares E1 #

∀ {R : Type u_1} [inst : CommRing R] (a b c d x y z w : R),
  (a * x - b * y - c * z - d * w) ^ 2 + (a * y + b * x + c * w - d * z) ^ 2 + (a * z - b * w + c * x + d * y) ^ 2 +
      (a * w + b * z - c * y + d * x) ^ 2 =
    (a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2)

Euler's four-square identity.

theorem Nat.euler_four_squares E1 #

∀ (a b c d x y z w : ℕ),
  (↑a * ↑x - ↑b * ↑y - ↑c * ↑z - ↑d * ↑w).natAbs ^ 2 + (↑a * ↑y + ↑b * ↑x + ↑c * ↑w - ↑d * ↑z).natAbs ^ 2 +
        (↑a * ↑z - ↑b * ↑w + ↑c * ↑x + ↑d * ↑y).natAbs ^ 2 +
      (↑a * ↑w + ↑b * ↑z - ↑c * ↑y + ↑d * ↑x).natAbs ^ 2 =
    (a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2)

Euler's four-square identity, a version for natural numbers.

theorem Int.sq_add_sq_of_two_mul_sq_add_sq E1 #

∀ {m x y : ℤ}, 2 * m = x ^ 2 + y ^ 2 → m = ((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2

theorem Int.lt_of_sum_four_squares_eq_mul E1 #

∀ {a b c d k m : ℕ}, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = k * m → 2 * a < m → 2 * b < m → 2 * c < m → 2 * d < m → k < m

theorem Int.exists_sq_add_sq_add_one_eq_mul E1 #

∀ (p : ℕ) [hp : Fact (Nat.Prime p)], ∃ a b k, 0 < k ∧ k < p ∧ a ^ 2 + b ^ 2 + 1 = k * p

theorem Nat.Prime.sum_four_squares E1 #

∀ {p : ℕ}, Nat.Prime p → ∃ a b c d, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = p

Lagrange's four squares theorem for a prime number. Use Nat.sum_four_squares instead.

theorem Nat.sum_four_squares E3 #

∀ (n : ℕ), ∃ a b c d, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n

Four squares theorem