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.Zsqrtd.GaussianInt

44 declarations. Mathlib docs · Source

Gaussian integers

The Gaussian integers are complex integer, complex numbers whose real and imaginary parts are both integers.

Main definitions

The Euclidean domain structure on ℤ[i] is defined in this file.

The homomorphism GaussianInt.toComplex into the complex numbers is also defined in this file.

See also

See NumberTheory.Zsqrtd.QuadraticReciprocity for:

  • prime_iff_mod_four_eq_three_of_nat_prime: A prime natural number is prime in ℤ[i] if and only if it is 3 mod 4

Notation

This file uses the local notation ℤ[i] for GaussianInt

Implementation notes

Gaussian integers are implemented using the more general definition Zsqrtd, the type of integers adjoined a square root of d, in this case -1. The definition is reducible, so that properties and definitions about Zsqrtd can easily be used.

abbrev GaussianInt E1 #

Type

The Gaussian integers, defined as ℤ√(-1).

instance GaussianInt.instRepr E0 #

Repr GaussianInt

instance GaussianInt.instCommRing E0 #

CommRing GaussianInt

def GaussianInt.toComplex E3 #

GaussianInt →+* ℂ

The embedding of the Gaussian integers into the complex numbers, as a ring homomorphism.

instance GaussianInt.instCoeComplex E0 #

Coe GaussianInt ℂ

theorem GaussianInt.toComplex_def E0 #

∀ (x : GaussianInt), GaussianInt.toComplex x = ↑x.re + ↑x.im * Complex.I

theorem GaussianInt.toComplex_def' E1 #

∀ (x y : ℤ), GaussianInt.toComplex { re := x, im := y } = ↑x + ↑y * Complex.I

theorem GaussianInt.toComplex_def₂ E1 #

∀ (x : GaussianInt), GaussianInt.toComplex x = { re := ↑x.re, im := ↑x.im }

theorem GaussianInt.intCast_re E0 #

∀ (x : GaussianInt), ↑x.re = (GaussianInt.toComplex x).re

theorem GaussianInt.intCast_im E0 #

∀ (x : GaussianInt), ↑x.im = (GaussianInt.toComplex x).im

theorem GaussianInt.re_toComplex E0 #

∀ (x y : ℤ), (GaussianInt.toComplex { re := x, im := y }).re = ↑x

theorem GaussianInt.im_toComplex E0 #

∀ (x y : ℤ), (GaussianInt.toComplex { re := x, im := y }).im = ↑y

theorem GaussianInt.toComplex_add E1 #

∀ (x y : GaussianInt), GaussianInt.toComplex (x + y) = GaussianInt.toComplex x + GaussianInt.toComplex y

theorem GaussianInt.toComplex_mul E1 #

∀ (x y : GaussianInt), GaussianInt.toComplex (x * y) = GaussianInt.toComplex x * GaussianInt.toComplex y

theorem GaussianInt.toComplex_one E1 #

GaussianInt.toComplex 1 = 1

theorem GaussianInt.toComplex_zero E1 #

GaussianInt.toComplex 0 = 0

theorem GaussianInt.toComplex_neg E1 #

∀ (x : GaussianInt), GaussianInt.toComplex (-x) = -GaussianInt.toComplex x

theorem GaussianInt.toComplex_sub E1 #

∀ (x y : GaussianInt), GaussianInt.toComplex (x - y) = GaussianInt.toComplex x - GaussianInt.toComplex y

theorem GaussianInt.toComplex_star E0 #

∀ (x : GaussianInt), GaussianInt.toComplex (star x) = (starRingEnd ℂ) (GaussianInt.toComplex x)

theorem GaussianInt.toComplex_inj E0 #

∀ {x y : GaussianInt}, GaussianInt.toComplex x = GaussianInt.toComplex y ↔ x = y

theorem GaussianInt.toComplex_injective E1 #

Function.Injective ⇑GaussianInt.toComplex

theorem GaussianInt.toComplex_eq_zero E0 #

∀ {x : GaussianInt}, GaussianInt.toComplex x = 0 ↔ x = 0

theorem GaussianInt.intCast_real_norm E0 #

∀ (x : GaussianInt), ↑(Zsqrtd.norm x) = Complex.normSq (GaussianInt.toComplex x)

theorem GaussianInt.intCast_complex_norm E0 #

∀ (x : GaussianInt), ↑(Zsqrtd.norm x) = ↑(Complex.normSq (GaussianInt.toComplex x))

theorem GaussianInt.norm_nonneg E1 #

∀ (x : GaussianInt), 0 ≤ Zsqrtd.norm x

theorem GaussianInt.norm_eq_zero E0 #

∀ {x : GaussianInt}, Zsqrtd.norm x = 0 ↔ x = 0

theorem GaussianInt.norm_pos E1 #

∀ {x : GaussianInt}, 0 < Zsqrtd.norm x ↔ x ≠ 0

theorem GaussianInt.abs_natCast_norm E1 #

∀ (x : GaussianInt), ↑(Zsqrtd.norm x).natAbs = Zsqrtd.norm x

theorem GaussianInt.natCast_natAbs_norm E1 #

∀ {α : Type u_1} [inst : AddGroupWithOne α] (x : GaussianInt), ↑(Zsqrtd.norm x).natAbs = ↑(Zsqrtd.norm x)

theorem GaussianInt.natAbs_norm_eq E0 #

∀ (x : GaussianInt), (Zsqrtd.norm x).natAbs = x.re.natAbs * x.re.natAbs + x.im.natAbs * x.im.natAbs

instance GaussianInt.instDiv E0 #

Div GaussianInt

theorem GaussianInt.div_def E0 #

∀ (x y : GaussianInt),
  x / y = { re := round (↑(x * star y).re / ↑(Zsqrtd.norm y)), im := round (↑(x * star y).im / ↑(Zsqrtd.norm y)) }

theorem GaussianInt.toComplex_re_div E1 #

∀ (x y : GaussianInt),
  (GaussianInt.toComplex (x / y)).re = ↑(round (GaussianInt.toComplex x / GaussianInt.toComplex y).re)

theorem GaussianInt.toComplex_im_div E1 #

∀ (x y : GaussianInt),
  (GaussianInt.toComplex (x / y)).im = ↑(round (GaussianInt.toComplex x / GaussianInt.toComplex y).im)

theorem GaussianInt.normSq_le_normSq_of_re_le_of_im_le E1 #

∀ {x y : ℂ}, |x.re| ≤ |y.re| → |x.im| ≤ |y.im| → Complex.normSq x ≤ Complex.normSq y

theorem GaussianInt.normSq_div_sub_div_lt_one E1 #

∀ (x y : GaussianInt),
  Complex.normSq (GaussianInt.toComplex x / GaussianInt.toComplex y - GaussianInt.toComplex (x / y)) < 1

instance GaussianInt.instMod E0 #

Mod GaussianInt

theorem GaussianInt.mod_def E0 #

∀ (x y : GaussianInt), x % y = x - y * (x / y)

theorem GaussianInt.norm_mod_lt E1 #

∀ (x : GaussianInt) {y : GaussianInt}, y ≠ 0 → Zsqrtd.norm (x % y) < Zsqrtd.norm y

theorem GaussianInt.natAbs_norm_mod_lt E1 #

∀ (x : GaussianInt) {y : GaussianInt}, y ≠ 0 → (Zsqrtd.norm (x % y)).natAbs < (Zsqrtd.norm y).natAbs

theorem GaussianInt.norm_le_norm_mul_left E1 #

∀ (x : GaussianInt) {y : GaussianInt}, y ≠ 0 → (Zsqrtd.norm x).natAbs ≤ (Zsqrtd.norm (x * y)).natAbs

instance GaussianInt.instNontrivial E0 #

Nontrivial GaussianInt

instance GaussianInt.instEuclideanDomain E0 #

EuclideanDomain GaussianInt

theorem GaussianInt.sq_add_sq_of_nat_prime_of_not_irreducible E1 #

∀ (p : ℕ) [hp : Fact (Nat.Prime p)], ¬Irreducible ↑p → ∃ a b, a ^ 2 + b ^ 2 = p