Gaussian integers #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 to_complex
into the complex numbers is also defined in this file.
See also #
See number_theory.zsqrtd.gaussian_int
for:
prime_iff_mod_four_eq_three_of_nat_prime
: A prime natural number is prime inℤ[i]
if and only if it is3
mod4
Notations #
This file uses the local notation ℤ[i]
for gaussian_int
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.
Equations
The embedding of the Gaussian integers into the complex numbers, as a ring homomorphism.
Equations
- gaussian_int.to_complex = ⇑zsqrtd.lift ⟨complex.I, gaussian_int.to_complex._proof_1⟩
Equations
Equations
- gaussian_int.has_div = {div := λ (x y : gaussian_int), let n : ℚ := (↑(zsqrtd.norm y))⁻¹, c : gaussian_int := has_star.star y in {re := round (↑((x * c).re) * n), im := round (↑((x * c).im) * n)}}
Equations
- gaussian_int.has_mod = {mod := λ (x y : gaussian_int), x - y * (x / y)}
Equations
- gaussian_int.euclidean_domain = {to_comm_ring := {add := comm_ring.add gaussian_int.comm_ring, add_assoc := _, zero := comm_ring.zero gaussian_int.comm_ring, zero_add := _, add_zero := _, nsmul := comm_ring.nsmul gaussian_int.comm_ring, nsmul_zero' := _, nsmul_succ' := _, neg := comm_ring.neg gaussian_int.comm_ring, sub := comm_ring.sub gaussian_int.comm_ring, sub_eq_add_neg := _, zsmul := comm_ring.zsmul gaussian_int.comm_ring, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, add_left_neg := _, add_comm := _, int_cast := comm_ring.int_cast gaussian_int.comm_ring, nat_cast := comm_ring.nat_cast gaussian_int.comm_ring, one := comm_ring.one gaussian_int.comm_ring, nat_cast_zero := _, nat_cast_succ := _, int_cast_of_nat := _, int_cast_neg_succ_of_nat := _, mul := comm_ring.mul gaussian_int.comm_ring, mul_assoc := _, one_mul := _, mul_one := _, npow := comm_ring.npow gaussian_int.comm_ring, npow_zero' := _, npow_succ' := _, left_distrib := _, right_distrib := _, mul_comm := _}, to_nontrivial := gaussian_int.euclidean_domain._proof_1, quotient := has_div.div gaussian_int.has_div, quotient_zero := gaussian_int.euclidean_domain._proof_2, remainder := has_mod.mod gaussian_int.has_mod, quotient_mul_add_remainder_eq := gaussian_int.euclidean_domain._proof_3, r := measure (int.nat_abs ∘ zsqrtd.norm), r_well_founded := gaussian_int.euclidean_domain._proof_4, remainder_lt := gaussian_int.nat_abs_norm_mod_lt, mul_left_not_lt := gaussian_int.euclidean_domain._proof_5}