ℤ[√d] #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
The ring of integers adjoined with a square root of d : ℤ
.
After defining the norm, we show that it is a linearly ordered commutative ring, as well as an integral domain.
We provide the universal property, that ring homomorphisms ℤ√d →+* R
correspond
to choices of square roots of d
in R
.
The ring of integers adjoined with a square root of d
.
These have the form a + b √d
where a b : ℤ
. The components
are called re
and im
by analogy to the negative d
case.
Instances for zsqrtd
- zsqrtd.has_sizeof_inst
- zsqrtd.has_zero
- zsqrtd.inhabited
- zsqrtd.has_one
- zsqrtd.has_add
- zsqrtd.has_neg
- zsqrtd.has_mul
- zsqrtd.add_comm_group
- zsqrtd.add_group_with_one
- zsqrtd.comm_ring
- zsqrtd.add_monoid
- zsqrtd.monoid
- zsqrtd.comm_monoid
- zsqrtd.comm_semigroup
- zsqrtd.semigroup
- zsqrtd.add_comm_semigroup
- zsqrtd.add_semigroup
- zsqrtd.comm_semiring
- zsqrtd.semiring
- zsqrtd.ring
- zsqrtd.distrib
- zsqrtd.has_star
- zsqrtd.star_ring
- zsqrtd.nontrivial
- zsqrtd.char_zero
- zsqrtd.has_le
- zsqrtd.has_lt
- zsqrtd.preorder
- zsqrtd.linear_order
- zsqrtd.no_zero_divisors
- zsqrtd.is_domain
- zsqrtd.linear_ordered_comm_ring
- zsqrtd.linear_ordered_ring
- zsqrtd.ordered_ring
- pell.solution₁.zsqrtd.has_coe
- gaussian_int.has_repr
- gaussian_int.comm_ring
- gaussian_int.complex.has_coe
- gaussian_int.has_div
- gaussian_int.has_mod
- gaussian_int.nontrivial
- gaussian_int.euclidean_domain
Equations
- zsqrtd.decidable_eq = id (λ (_v : ℤ√d), _v.cases_on (λ (re im : ℤ) (w : ℤ√d), w.cases_on (λ (w_re w_im : ℤ), decidable.by_cases (λ (ᾰ : re = w_re), eq.rec (decidable.by_cases (λ (ᾰ : im = w_im), eq.rec (decidable.is_true _) ᾰ) (λ (ᾰ : ¬im = w_im), decidable.is_false _)) ᾰ) (λ (ᾰ : ¬re = w_re), decidable.is_false _))))
Convert an integer to a ℤ√d
Equations
- zsqrtd.of_int n = {re := n, im := 0}
Equations
- zsqrtd.inhabited = {default := 0}
The representative of √d
in the ring
Equations
- zsqrtd.sqrtd = {re := 0, im := 1}
Equations
- zsqrtd.add_comm_group = {add := has_add.add zsqrtd.has_add, add_assoc := _, zero := 0, zero_add := _, add_zero := _, nsmul := nsmul_rec {add := has_add.add zsqrtd.has_add}, nsmul_zero' := _, nsmul_succ' := _, neg := has_neg.neg zsqrtd.has_neg, sub := λ (a b : ℤ√d), a + -b, sub_eq_add_neg := _, zsmul := zsmul_rec {neg := has_neg.neg zsqrtd.has_neg}, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, add_left_neg := _, add_comm := _}
Equations
- zsqrtd.add_group_with_one = {int_cast := zsqrtd.of_int d, add := add_comm_group.add zsqrtd.add_comm_group, add_assoc := _, zero := add_comm_group.zero zsqrtd.add_comm_group, zero_add := _, add_zero := _, nsmul := add_comm_group.nsmul zsqrtd.add_comm_group, nsmul_zero' := _, nsmul_succ' := _, neg := add_comm_group.neg zsqrtd.add_comm_group, sub := add_comm_group.sub zsqrtd.add_comm_group, sub_eq_add_neg := _, zsmul := add_comm_group.zsmul zsqrtd.add_comm_group, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, add_left_neg := _, nat_cast := λ (n : ℕ), zsqrtd.of_int ↑n, one := 1, nat_cast_zero := _, nat_cast_succ := _, int_cast_of_nat := _, int_cast_neg_succ_of_nat := _}
Equations
- zsqrtd.comm_ring = {add := has_add.add zsqrtd.has_add, add_assoc := _, zero := 0, zero_add := _, add_zero := _, nsmul := add_group_with_one.nsmul zsqrtd.add_group_with_one, nsmul_zero' := _, nsmul_succ' := _, neg := add_group_with_one.neg zsqrtd.add_group_with_one, sub := add_group_with_one.sub zsqrtd.add_group_with_one, sub_eq_add_neg := _, zsmul := add_group_with_one.zsmul zsqrtd.add_group_with_one, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, add_left_neg := _, add_comm := _, int_cast := add_group_with_one.int_cast zsqrtd.add_group_with_one, nat_cast := add_group_with_one.nat_cast zsqrtd.add_group_with_one, one := 1, nat_cast_zero := _, nat_cast_succ := _, int_cast_of_nat := _, int_cast_neg_succ_of_nat := _, mul := has_mul.mul zsqrtd.has_mul, mul_assoc := _, one_mul := _, mul_one := _, npow := npow_rec {mul := has_mul.mul zsqrtd.has_mul}, npow_zero' := _, npow_succ' := _, left_distrib := _, right_distrib := _, mul_comm := _}
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Equations
- zsqrtd.star_ring = {to_star_semigroup := {to_has_involutive_star := {to_has_star := zsqrtd.has_star d, star_involutive := _}, star_mul := _}, star_add := _}
"Generalized" nonneg
. nonnegg c d x y
means a √c + b √d ≥ 0
;
we are interested in the case c = 1
but this is more symmetric
Equations
- zsqrtd.nonnegg c d -[1+ a] -[1+ b] = false
- zsqrtd.nonnegg c d -[1+ a] ↑b = zsqrtd.sq_le (a + 1) d b c
- zsqrtd.nonnegg c d ↑a -[1+ b] = zsqrtd.sq_le (b + 1) c a d
- zsqrtd.nonnegg c d ↑a ↑b = true
Instances for zsqrtd.nonnegg
norm
as a monoid_hom
.
Equations
- zsqrtd.norm_monoid_hom = {to_fun := zsqrtd.norm d, map_one' := _, map_mul' := _}
Nonnegativity of an element of ℤ√d
.
Instances for zsqrtd.nonneg
Equations
- zsqrtd.decidable_nonnegg c d a b = a.cases_on (λ (a : ℕ), b.cases_on (λ (b : ℕ), _.mpr (_.mpr (_.mpr decidable.true))) (λ (b : ℕ), _.mpr (_.mpr ((c * (b + 1) * (b + 1)).decidable_le (d * a * a))))) (λ (a : ℕ), b.cases_on (λ (b : ℕ), _.mpr (_.mpr ((d * (a + 1) * (a + 1)).decidable_le (c * b * b)))) (λ (b : ℕ), _.mpr decidable.false))
Equations
- {re := a, im := b}.decidable_nonneg = zsqrtd.decidable_nonnegg d 1 a b
Equations
- zsqrtd.decidable_le = λ (_x _x_1 : ℤ√↑d), (_x_1 - _x).decidable_nonneg
Equations
- zsqrtd.preorder = {le := has_le.le zsqrtd.has_le, lt := has_lt.lt zsqrtd.has_lt, le_refl := _, le_trans := _, lt_iff_le_not_le := _}
A nonsquare is a natural number that is not equal to the square of an integer. This is implemented as a typeclass because it's a necessary condition for much of the Pell equation theory.
Instances of this typeclass
Equations
- zsqrtd.linear_order = {le := preorder.le zsqrtd.preorder, lt := preorder.lt zsqrtd.preorder, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := zsqrtd.decidable_le d, decidable_eq := decidable_eq_of_decidable_le zsqrtd.decidable_le, decidable_lt := decidable_lt_of_decidable_le zsqrtd.decidable_le, max := max_default (λ (a b : ℤ√↑d), zsqrtd.decidable_le a b), max_def := _, min := min_default (λ (a b : ℤ√↑d), zsqrtd.decidable_le a b), min_def := _}
Equations
- zsqrtd.linear_ordered_comm_ring = {add := comm_ring.add zsqrtd.comm_ring, add_assoc := _, zero := comm_ring.zero zsqrtd.comm_ring, zero_add := _, add_zero := _, nsmul := comm_ring.nsmul zsqrtd.comm_ring, nsmul_zero' := _, nsmul_succ' := _, neg := comm_ring.neg zsqrtd.comm_ring, sub := comm_ring.sub zsqrtd.comm_ring, sub_eq_add_neg := _, zsmul := comm_ring.zsmul zsqrtd.comm_ring, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, add_left_neg := _, add_comm := _, int_cast := comm_ring.int_cast zsqrtd.comm_ring, nat_cast := comm_ring.nat_cast zsqrtd.comm_ring, one := comm_ring.one zsqrtd.comm_ring, nat_cast_zero := _, nat_cast_succ := _, int_cast_of_nat := _, int_cast_neg_succ_of_nat := _, mul := comm_ring.mul zsqrtd.comm_ring, mul_assoc := _, one_mul := _, mul_one := _, npow := comm_ring.npow zsqrtd.comm_ring, npow_zero' := _, npow_succ' := _, left_distrib := _, right_distrib := _, le := linear_order.le zsqrtd.linear_order, lt := linear_order.lt zsqrtd.linear_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := _, exists_pair_ne := _, zero_le_one := _, mul_pos := _, le_total := _, decidable_le := linear_order.decidable_le zsqrtd.linear_order, decidable_eq := linear_order.decidable_eq zsqrtd.linear_order, decidable_lt := linear_order.decidable_lt zsqrtd.linear_order, max := linear_order.max zsqrtd.linear_order, max_def := _, min := linear_order.min zsqrtd.linear_order, min_def := _, mul_comm := _}
The unique ring_hom
from ℤ√d
to a ring R
, constructed by replacing √d
with the provided
root. Conversely, this associates to every mapping ℤ√d →+* R
a value of √d
in R
.
The kernel of the norm map on ℤ√d
equals the submonoid of unitary elements.