mathlib documentation

data.​zsqrtd.​basic

data.​zsqrtd.​basic

structure zsqrtd  :
ℤ → Type

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, but of course both parts are real here since d is nonnegative.

@[instance]

Equations
theorem zsqrtd.​ext {d : ℤ} {z w : ℤ√d} :
z = w ↔ z.re = w.re ∧ z.im = w.im

def zsqrtd.​of_int {d : ℤ} :
ℤ → ℤ√d

Convert an integer to a ℤ√d

Equations
theorem zsqrtd.​of_int_re {d : ℤ} (n : ℤ) :

theorem zsqrtd.​of_int_im {d : ℤ} (n : ℤ) :

def zsqrtd.​zero {d : ℤ} :

The zero of the ring

Equations
@[instance]

Equations
@[simp]
theorem zsqrtd.​zero_re {d : ℤ} :
0.re = 0

@[simp]
theorem zsqrtd.​zero_im {d : ℤ} :
0.im = 0

@[instance]

Equations
def zsqrtd.​one {d : ℤ} :

The one of the ring

Equations
@[instance]

Equations
@[simp]
theorem zsqrtd.​one_re {d : ℤ} :
1.re = 1

@[simp]
theorem zsqrtd.​one_im {d : ℤ} :
1.im = 0

def zsqrtd.​sqrtd {d : ℤ} :

The representative of √d in the ring

Equations
@[simp]
theorem zsqrtd.​sqrtd_re {d : ℤ} :

@[simp]
theorem zsqrtd.​sqrtd_im {d : ℤ} :

def zsqrtd.​add {d : ℤ} :
ℤ√d → ℤ√d → ℤ√d

Addition of elements of ℤ√d

Equations
@[instance]

Equations
@[simp]
theorem zsqrtd.​add_def {d : ℤ} (x y x' y' : ℤ) :
{re := x, im := y} + {re := x', im := y'} = {re := x + x', im := y + y'}

@[simp]
theorem zsqrtd.​add_re {d : ℤ} (z w : ℤ√d) :
(z + w).re = z.re + w.re

@[simp]
theorem zsqrtd.​add_im {d : ℤ} (z w : ℤ√d) :
(z + w).im = z.im + w.im

@[simp]
theorem zsqrtd.​bit0_re {d : ℤ} (z : ℤ√d) :
(bit0 z).re = bit0 z.re

@[simp]
theorem zsqrtd.​bit0_im {d : ℤ} (z : ℤ√d) :
(bit0 z).im = bit0 z.im

@[simp]
theorem zsqrtd.​bit1_re {d : ℤ} (z : ℤ√d) :
(bit1 z).re = bit1 z.re

@[simp]
theorem zsqrtd.​bit1_im {d : ℤ} (z : ℤ√d) :
(bit1 z).im = bit0 z.im

def zsqrtd.​neg {d : ℤ} :

Negation in ℤ√d

Equations
@[instance]

Equations
@[simp]
theorem zsqrtd.​neg_re {d : ℤ} (z : ℤ√d) :
(-z).re = -z.re

@[simp]
theorem zsqrtd.​neg_im {d : ℤ} (z : ℤ√d) :
(-z).im = -z.im

def zsqrtd.​conj {d : ℤ} :

Conjugation in ℤ√d. The conjugate of a + b √d is a - b √d.

Equations
@[simp]
theorem zsqrtd.​conj_re {d : ℤ} (z : ℤ√d) :
z.conj.re = z.re

@[simp]
theorem zsqrtd.​conj_im {d : ℤ} (z : ℤ√d) :
z.conj.im = -z.im

def zsqrtd.​mul {d : ℤ} :
ℤ√d → ℤ√d → ℤ√d

Multiplication in ℤ√d

Equations
@[instance]

Equations
@[simp]
theorem zsqrtd.​mul_re {d : ℤ} (z w : ℤ√d) :
(z * w).re = z.re * w.re + d * z.im * w.im

@[simp]
theorem zsqrtd.​mul_im {d : ℤ} (z w : ℤ√d) :
(z * w).im = z.re * w.im + z.im * w.re

@[instance]
def zsqrtd.​monoid {d : ℤ} :

Equations
@[instance]
def zsqrtd.​ring {d : ℤ} :

Equations
@[instance]

Equations
@[instance]

Equations
@[simp]
theorem zsqrtd.​coe_nat_re {d : ℤ} (n : ℕ) :

@[simp]
theorem zsqrtd.​coe_nat_im {d : ℤ} (n : ℕ) :
↑n.im = 0

theorem zsqrtd.​coe_nat_val {d : ℤ} (n : ℕ) :
↑n = {re := ↑n, im := 0}

@[simp]
theorem zsqrtd.​coe_int_re {d : ℤ} (n : ℤ) :
↑n.re = n

@[simp]
theorem zsqrtd.​coe_int_im {d : ℤ} (n : ℤ) :
↑n.im = 0

theorem zsqrtd.​coe_int_val {d : ℤ} (n : ℤ) :
↑n = {re := n, im := 0}

@[instance]

Equations
@[simp]
theorem zsqrtd.​of_int_eq_coe {d : ℤ} (n : ℤ) :

@[simp]
theorem zsqrtd.​smul_val {d : ℤ} (n x y : ℤ) :
↑n * {re := x, im := y} = {re := n * x, im := n * y}

@[simp]
theorem zsqrtd.​muld_val {d : ℤ} (x y : ℤ) :
zsqrtd.sqrtd * {re := x, im := y} = {re := d * y, im := x}

@[simp]
theorem zsqrtd.​smuld_val {d : ℤ} (n x y : ℤ) :
zsqrtd.sqrtd * ↑n * {re := x, im := y} = {re := d * n * y, im := n * x}

theorem zsqrtd.​decompose {d x y : ℤ} :
{re := x, im := y} = ↑x + zsqrtd.sqrtd * ↑y

theorem zsqrtd.​mul_conj {d x y : ℤ} :
{re := x, im := y} * {re := x, im := y}.conj = ↑x * ↑x - ↑d * ↑y * ↑y

theorem zsqrtd.​conj_mul {d : ℤ} {a b : ℤ√d} :
(a * b).conj = a.conj * b.conj

theorem zsqrtd.​coe_int_add {d : ℤ} (m n : ℤ) :
↑(m + n) = ↑m + ↑n

theorem zsqrtd.​coe_int_sub {d : ℤ} (m n : ℤ) :
↑(m - n) = ↑m - ↑n

theorem zsqrtd.​coe_int_mul {d : ℤ} (m n : ℤ) :
↑(m * n) = ↑m * ↑n

theorem zsqrtd.​coe_int_inj {d m n : ℤ} :
↑m = ↑n → m = n

def zsqrtd.​sq_le  :
ℕ → ℕ → ℕ → ℕ → Prop

Read sq_le a c b d as a √c ≤ b √d

Equations
theorem zsqrtd.​sq_le_of_le {c d x y z w : ℕ} :
z ≤ x → y ≤ w → zsqrtd.sq_le x c y d → zsqrtd.sq_le z c w d

theorem zsqrtd.​sq_le_add_mixed {c d x y z w : ℕ} :
zsqrtd.sq_le x c y d → zsqrtd.sq_le z c w d → c * (x * z) ≤ d * (y * w)

theorem zsqrtd.​sq_le_add {c d x y z w : ℕ} :
zsqrtd.sq_le x c y d → zsqrtd.sq_le z c w d → zsqrtd.sq_le (x + z) c (y + w) d

theorem zsqrtd.​sq_le_cancel {c d x y z w : ℕ} :
zsqrtd.sq_le y d x c → zsqrtd.sq_le (x + z) c (y + w) d → zsqrtd.sq_le z c w d

theorem zsqrtd.​sq_le_smul {c d x y : ℕ} (n : ℕ) :
zsqrtd.sq_le x c y d → zsqrtd.sq_le (n * x) c (n * y) d

theorem zsqrtd.​sq_le_mul {d x y z w : ℕ} :
(zsqrtd.sq_le x 1 y d → zsqrtd.sq_le z 1 w d → zsqrtd.sq_le (x * w + y * z) d (x * z + d * y * w) 1) ∧ (zsqrtd.sq_le x 1 y d → zsqrtd.sq_le w d z 1 → zsqrtd.sq_le (x * z + d * y * w) 1 (x * w + y * z) d) ∧ (zsqrtd.sq_le y d x 1 → zsqrtd.sq_le z 1 w d → zsqrtd.sq_le (x * z + d * y * w) 1 (x * w + y * z) d) ∧ (zsqrtd.sq_le y d x 1 → zsqrtd.sq_le w d z 1 → zsqrtd.sq_le (x * w + y * z) d (x * z + d * y * w) 1)

def zsqrtd.​nonnegg  :
ℕ → ℕ → ℤ → ℤ → Prop

"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
theorem zsqrtd.​nonnegg_comm {c d : ℕ} {x y : ℤ} :

theorem zsqrtd.​nonnegg_neg_pos {c d a b : ℕ} :

theorem zsqrtd.​nonnegg_pos_neg {c d a b : ℕ} :

theorem zsqrtd.​nonnegg_cases_right {c d a : ℕ} {b : ℤ} :
(∀ (x : ℕ), b = -↑x → zsqrtd.sq_le x c a d) → zsqrtd.nonnegg c d ↑a b

theorem zsqrtd.​nonnegg_cases_left {c d b : ℕ} {a : ℤ} :
(∀ (x : ℕ), a = -↑x → zsqrtd.sq_le x d b c) → zsqrtd.nonnegg c d a ↑b

def zsqrtd.​norm {d : ℤ} :
ℤ√d → ℤ

Equations
@[simp]
theorem zsqrtd.​norm_zero {d : ℤ} :
0.norm = 0

@[simp]
theorem zsqrtd.​norm_one {d : ℤ} :
1.norm = 1

@[simp]
theorem zsqrtd.​norm_int_cast {d : ℤ} (n : ℤ) :
↑n.norm = n * n

@[simp]
theorem zsqrtd.​norm_nat_cast {d : ℤ} (n : ℕ) :

@[simp]
theorem zsqrtd.​norm_mul {d : ℤ} (n m : ℤ√d) :
(n * m).norm = n.norm * m.norm

theorem zsqrtd.​norm_eq_mul_conj {d : ℤ} (n : ℤ√d) :
↑(n.norm) = n * n.conj

theorem zsqrtd.​norm_nonneg {d : ℤ} (hd : d ≤ 0) (n : ℤ√d) :
0 ≤ n.norm

def zsqrtd.​nonneg {d : ℕ} :
ℤ√↑d → Prop

Nonnegativity of an element of ℤ√d.

Equations
def zsqrtd.​le {d : ℕ} :
ℤ√↑d → ℤ√↑d → Prop

Equations
@[instance]

Equations
def zsqrtd.​lt {d : ℕ} :
ℤ√↑d → ℤ√↑d → Prop

Equations
@[instance]

Equations
@[instance]
def zsqrtd.​decidable_nonnegg (c d : ℕ) (a b : ℤ) :

Equations
@[instance]

Equations
@[instance]
def zsqrtd.​decidable_le {d : ℕ} (a b : ℤ√↑d) :

Equations
theorem zsqrtd.​nonneg_cases {d : ℕ} {a : ℤ√↑d} :
a.nonneg → (∃ (x y : ℕ), a = {re := ↑x, im := ↑y} ∨ a = {re := ↑x, im := -↑y} ∨ a = {re := -↑x, im := ↑y})

theorem zsqrtd.​nonneg_add_lem {d x y z w : ℕ} :
{re := ↑x, im := -↑y}.nonneg → {re := -↑z, im := ↑w}.nonneg → ({re := ↑x, im := -↑y} + {re := -↑z, im := ↑w}).nonneg

theorem zsqrtd.​nonneg_add {d : ℕ} {a b : ℤ√↑d} :
a.nonneg → b.nonneg → (a + b).nonneg

theorem zsqrtd.​le_refl {d : ℕ} (a : ℤ√↑d) :
a ≤ a

theorem zsqrtd.​le_trans {d : ℕ} {a b c : ℤ√↑d} :
a ≤ b → b ≤ c → a ≤ c

theorem zsqrtd.​le_of_le_le {d : ℕ} {x y z w : ℤ} :
x ≤ z → y ≤ w → {re := x, im := y} ≤ {re := z, im := w}

theorem zsqrtd.​le_arch {d : ℕ} (a : ℤ√↑d) :
∃ (n : ℕ), a ≤ ↑n

theorem zsqrtd.​nonneg_total {d : ℕ} (a : ℤ√↑d) :

theorem zsqrtd.​le_total {d : ℕ} (a b : ℤ√↑d) :
a ≤ b ∨ b ≤ a

@[instance]

Equations
theorem zsqrtd.​add_le_add_left {d : ℕ} (a b : ℤ√↑d) (ab : a ≤ b) (c : ℤ√↑d) :
c + a ≤ c + b

theorem zsqrtd.​le_of_add_le_add_left {d : ℕ} (a b c : ℤ√↑d) :
c + a ≤ c + b → a ≤ b

theorem zsqrtd.​add_lt_add_left {d : ℕ} (a b : ℤ√↑d) (h : a < b) (c : ℤ√↑d) :
c + a < c + b

theorem zsqrtd.​nonneg_smul {d : ℕ} {a : ℤ√↑d} {n : ℕ} :
a.nonneg → (↑n * a).nonneg

theorem zsqrtd.​nonneg_muld {d : ℕ} {a : ℤ√↑d} :

theorem zsqrtd.​nonneg_mul_lem {d x y : ℕ} {a : ℤ√↑d} :
a.nonneg → ({re := ↑x, im := ↑y} * a).nonneg

theorem zsqrtd.​nonneg_mul {d : ℕ} {a b : ℤ√↑d} :
a.nonneg → b.nonneg → (a * b).nonneg

theorem zsqrtd.​mul_nonneg {d : ℕ} (a b : ℤ√↑d) :
0 ≤ a → 0 ≤ b → 0 ≤ a * b

theorem zsqrtd.​not_sq_le_succ (c d y : ℕ) :
0 < c → ¬zsqrtd.sq_le (y + 1) c 0 d

@[class]
structure zsqrtd.​nonsquare  :
ℕ → Prop

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
theorem zsqrtd.​d_pos {d : ℕ} [dnsq : zsqrtd.nonsquare d] :
0 < d

theorem zsqrtd.​divides_sq_eq_zero {d : ℕ} [dnsq : zsqrtd.nonsquare d] {x y : ℕ} :
x * x = d * y * y → x = 0 ∧ y = 0

theorem zsqrtd.​divides_sq_eq_zero_z {d : ℕ} [dnsq : zsqrtd.nonsquare d] {x y : ℤ} :
x * x = ↑d * y * y → x = 0 ∧ y = 0

theorem zsqrtd.​not_divides_square {d : ℕ} [dnsq : zsqrtd.nonsquare d] (x y : ℕ) :
(x + 1) * (x + 1) ≠ d * (y + 1) * (y + 1)

theorem zsqrtd.​nonneg_antisymm {d : ℕ} [dnsq : zsqrtd.nonsquare d] {a : ℤ√↑d} :
a.nonneg → (-a).nonneg → a = 0

theorem zsqrtd.​le_antisymm {d : ℕ} [dnsq : zsqrtd.nonsquare d] {a b : ℤ√↑d} :
a ≤ b → b ≤ a → a = b

theorem zsqrtd.​eq_zero_or_eq_zero_of_mul_eq_zero {d : ℕ} [dnsq : zsqrtd.nonsquare d] {a b : ℤ√↑d} :
a * b = 0 → a = 0 ∨ b = 0

theorem zsqrtd.​mul_pos {d : ℕ} [dnsq : zsqrtd.nonsquare d] (a b : ℤ√↑d) :
0 < a → 0 < b → 0 < a * b