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.Basic

162 declarations. Mathlib docs · Source

ℤ[√d]

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.

theorem Zsqrtd.Nonnegg.match_1.congr_eq_4 E1 #

∀ (motive : ℤ → ℤ → Sort u_1) (x x_1 : ℤ) (h_1 : (a b : ℕ) → motive (Int.ofNat a) (Int.ofNat b))
  (h_2 : (a b : ℕ) → motive (Int.ofNat a) (Int.negSucc b)) (h_3 : (a b : ℕ) → motive (Int.negSucc a) (Int.ofNat b))
  (h_4 : (a a_1 : ℕ) → motive (Int.negSucc a) (Int.negSucc a_1)) (a a_1 : ℕ),
  x = Int.negSucc a →
    x_1 = Int.negSucc a_1 →
      (match x, x_1 with
        | Int.ofNat a, Int.ofNat b => h_1 a b
        | Int.ofNat a, Int.negSucc b => h_2 a b
        | Int.negSucc a, Int.ofNat b => h_3 a b
        | Int.negSucc a, Int.negSucc a_2 => h_4 a a_2) ≍
        h_4 a a_1

theorem Zsqrtd.Nonnegg.match_1.congr_eq_2 E1 #

∀ (motive : ℤ → ℤ → Sort u_1) (x x_1 : ℤ) (h_1 : (a b : ℕ) → motive (Int.ofNat a) (Int.ofNat b))
  (h_2 : (a b : ℕ) → motive (Int.ofNat a) (Int.negSucc b)) (h_3 : (a b : ℕ) → motive (Int.negSucc a) (Int.ofNat b))
  (h_4 : (a a_1 : ℕ) → motive (Int.negSucc a) (Int.negSucc a_1)) (a b : ℕ),
  x = Int.ofNat a →
    x_1 = Int.negSucc b →
      (match x, x_1 with
        | Int.ofNat a, Int.ofNat b => h_1 a b
        | Int.ofNat a, Int.negSucc b => h_2 a b
        | Int.negSucc a, Int.ofNat b => h_3 a b
        | Int.negSucc a, Int.negSucc a_1 => h_4 a a_1) ≍
        h_2 a b

theorem Zsqrtd.Nonnegg.match_1.congr_eq_3 E1 #

∀ (motive : ℤ → ℤ → Sort u_1) (x x_1 : ℤ) (h_1 : (a b : ℕ) → motive (Int.ofNat a) (Int.ofNat b))
  (h_2 : (a b : ℕ) → motive (Int.ofNat a) (Int.negSucc b)) (h_3 : (a b : ℕ) → motive (Int.negSucc a) (Int.ofNat b))
  (h_4 : (a a_1 : ℕ) → motive (Int.negSucc a) (Int.negSucc a_1)) (a b : ℕ),
  x = Int.negSucc a →
    x_1 = Int.ofNat b →
      (match x, x_1 with
        | Int.ofNat a, Int.ofNat b => h_1 a b
        | Int.ofNat a, Int.negSucc b => h_2 a b
        | Int.negSucc a, Int.ofNat b => h_3 a b
        | Int.negSucc a, Int.negSucc a_1 => h_4 a a_1) ≍
        h_3 a b

theorem Zsqrtd.mk.inj E1 #

∀ {d re im re_1 im_1 : ℤ}, { re := re, im := im } = { re := re_1, im := im_1 } → re = re_1 ∧ im = im_1

theorem Zsqrtd.Nonnegg.match_1.congr_eq_1 E1 #

∀ (motive : ℤ → ℤ → Sort u_1) (x x_1 : ℤ) (h_1 : (a b : ℕ) → motive (Int.ofNat a) (Int.ofNat b))
  (h_2 : (a b : ℕ) → motive (Int.ofNat a) (Int.negSucc b)) (h_3 : (a b : ℕ) → motive (Int.negSucc a) (Int.ofNat b))
  (h_4 : (a a_1 : ℕ) → motive (Int.negSucc a) (Int.negSucc a_1)) (a b : ℕ),
  x = Int.ofNat a →
    x_1 = Int.ofNat b →
      (match x, x_1 with
        | Int.ofNat a, Int.ofNat b => h_1 a b
        | Int.ofNat a, Int.negSucc b => h_2 a b
        | Int.negSucc a, Int.ofNat b => h_3 a b
        | Int.negSucc a, Int.negSucc a_1 => h_4 a a_1) ≍
        h_1 a b

theorem Zsqrtd.Nonneg.match_1.congr_eq_1 E1 #

∀ {d : ℕ} (motive : ℤ√↑d → Sort u_1) (x : ℤ√↑d) (h_1 : (a b : ℤ) → motive { re := a, im := b }) (a b : ℤ),
  x = { re := a, im := b } →
    (match x with
      | { re := a, im := b } => h_1 a b) ≍
      h_1 a b

def Zsqrtd.ctorIdx E1 #

{d : ℤ} → ℤ√d → ℕ

theorem Zsqrtd.mk.injEq E0 #

∀ {d : ℤ} (re im re_1 im_1 : ℤ), ({ re := re, im := im } = { re := re_1, im := im_1 }) = (re = re_1 ∧ im = im_1)

structure Zsqrtd E1 #

ℤ → 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.

theorem Zsqrtd.ext E1 #

∀ {d : ℤ} {x y : ℤ√d}, x.re = y.re → x.im = y.im → x = y

theorem Zsqrtd.ext_iff E0 #

∀ {d : ℤ} {x y : ℤ√d}, x = y ↔ x.re = y.re ∧ x.im = y.im

ctor Zsqrtd.mk E0 #

{d : ℤ} → ℤ → ℤ → ℤ√d

abbrev Zsqrtd.re E1 #

{d : ℤ} → ℤ√d → ℤ

Component of the integer not multiplied by √d

abbrev Zsqrtd.im E1 #

{d : ℤ} → ℤ√d → ℤ

Component of the integer multiplied by √d

def instDecidableEqZsqrtd.decEq E1 #

{d : ℤ} → (x x_1 : ℤ√d) → Decidable (x = x_1)

instance instDecidableEqZsqrtd E0 #

{d : ℤ} → DecidableEq (ℤ√d)

def «termℤ√_» E1 #

Lean.ParserDescr

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.

def Zsqrtd.ofInt E1 #

{d : ℤ} → ℤ → ℤ√d

Convert an integer to a ℤ√d

theorem Zsqrtd.re_ofInt E1 #

∀ {d : ℤ} (n : ℤ), (Zsqrtd.ofInt n).re = n

theorem Zsqrtd.im_ofInt E1 #

∀ {d : ℤ} (n : ℤ), (Zsqrtd.ofInt n).im = 0

instance Zsqrtd.instZero E0 #

{d : ℤ} → Zero (ℤ√d)

The zero of the ring

theorem Zsqrtd.re_zero E0 #

∀ {d : ℤ}, Zsqrtd.re 0 = 0

theorem Zsqrtd.im_zero E0 #

∀ {d : ℤ}, Zsqrtd.im 0 = 0

instance Zsqrtd.instInhabited E0 #

{d : ℤ} → Inhabited (ℤ√d)

instance Zsqrtd.instOne E0 #

{d : ℤ} → One (ℤ√d)

The one of the ring

theorem Zsqrtd.re_one E0 #

∀ {d : ℤ}, Zsqrtd.re 1 = 1

theorem Zsqrtd.im_one E0 #

∀ {d : ℤ}, Zsqrtd.im 1 = 0

def Zsqrtd.sqrtd E1 #

{d : ℤ} → ℤ√d

The representative of √d in the ring

theorem Zsqrtd.re_sqrtd E0 #

∀ {d : ℤ}, Zsqrtd.sqrtd.re = 0

theorem Zsqrtd.im_sqrtd E0 #

∀ {d : ℤ}, Zsqrtd.sqrtd.im = 1

instance Zsqrtd.instAdd E0 #

{d : ℤ} → Add (ℤ√d)

Addition of elements of ℤ√d

theorem Zsqrtd.add_def E0 #

∀ {d : ℤ} (x y x' y' : ℤ), { re := x, im := y } + { re := x', im := y' } = { re := x + x', im := y + y' }

theorem Zsqrtd.re_add E0 #

∀ {d : ℤ} (z w : ℤ√d), (z + w).re = z.re + w.re

theorem Zsqrtd.im_add E0 #

∀ {d : ℤ} (z w : ℤ√d), (z + w).im = z.im + w.im

instance Zsqrtd.instNeg E0 #

{d : ℤ} → Neg (ℤ√d)

Negation in ℤ√d

theorem Zsqrtd.re_neg E0 #

∀ {d : ℤ} (z : ℤ√d), (-z).re = -z.re

theorem Zsqrtd.im_neg E0 #

∀ {d : ℤ} (z : ℤ√d), (-z).im = -z.im

instance Zsqrtd.instMul E0 #

{d : ℤ} → Mul (ℤ√d)

Multiplication in ℤ√d

theorem Zsqrtd.re_mul E0 #

∀ {d : ℤ} (z w : ℤ√d), (z * w).re = z.re * w.re + d * z.im * w.im

theorem Zsqrtd.im_mul E0 #

∀ {d : ℤ} (z w : ℤ√d), (z * w).im = z.re * w.im + z.im * w.re

instance Zsqrtd.addCommGroup E0 #

{d : ℤ} → AddCommGroup (ℤ√d)

theorem Zsqrtd.re_sub E0 #

∀ {d : ℤ} (z w : ℤ√d), (z - w).re = z.re - w.re

theorem Zsqrtd.im_sub E0 #

∀ {d : ℤ} (z w : ℤ√d), (z - w).im = z.im - w.im

instance Zsqrtd.addGroupWithOne E0 #

{d : ℤ} → AddGroupWithOne (ℤ√d)

instance Zsqrtd.commRing E0 #

{d : ℤ} → CommRing (ℤ√d)

instance Zsqrtd.instAddMonoid E0 #

{d : ℤ} → AddMonoid (ℤ√d)

instance Zsqrtd.instMonoid E0 #

{d : ℤ} → Monoid (ℤ√d)

instance Zsqrtd.instCommMonoid E0 #

{d : ℤ} → CommMonoid (ℤ√d)

instance Zsqrtd.instCommSemigroup E0 #

{d : ℤ} → CommSemigroup (ℤ√d)

instance Zsqrtd.instSemigroup E0 #

{d : ℤ} → Semigroup (ℤ√d)

instance Zsqrtd.instAddCommSemigroup E0 #

{d : ℤ} → AddCommSemigroup (ℤ√d)

instance Zsqrtd.instAddSemigroup E0 #

{d : ℤ} → AddSemigroup (ℤ√d)

instance Zsqrtd.instCommSemiring E0 #

{d : ℤ} → CommSemiring (ℤ√d)

instance Zsqrtd.instSemiring E0 #

{d : ℤ} → Semiring (ℤ√d)

instance Zsqrtd.instRing E0 #

{d : ℤ} → Ring (ℤ√d)

instance Zsqrtd.instDistrib E0 #

{d : ℤ} → Distrib (ℤ√d)

instance Zsqrtd.instStar E0 #

{d : ℤ} → Star (ℤ√d)

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

theorem Zsqrtd.star_mk E0 #

∀ {d : ℤ} (x y : ℤ), star { re := x, im := y } = { re := x, im := -y }

theorem Zsqrtd.re_star E0 #

∀ {d : ℤ} (z : ℤ√d), (star z).re = z.re

theorem Zsqrtd.im_star E0 #

∀ {d : ℤ} (z : ℤ√d), (star z).im = -z.im

instance Zsqrtd.instStarRing E0 #

{d : ℤ} → StarRing (ℤ√d)

instance Zsqrtd.nontrivial E0 #

∀ {d : ℤ}, Nontrivial (ℤ√d)

theorem Zsqrtd.re_natCast E0 #

∀ {d : ℤ} (n : ℕ), (↑n).re = ↑n

theorem Zsqrtd.re_ofNat E0 #

∀ {d : ℤ} (n : ℕ) [inst : n.AtLeastTwo], (OfNat.ofNat n).re = ↑n

theorem Zsqrtd.im_natCast E0 #

∀ {d : ℤ} (n : ℕ), (↑n).im = 0

theorem Zsqrtd.im_ofNat E0 #

∀ {d : ℤ} (n : ℕ) [inst : n.AtLeastTwo], (OfNat.ofNat n).im = 0

theorem Zsqrtd.natCast_val E0 #

∀ {d : ℤ} (n : ℕ), ↑n = { re := ↑n, im := 0 }

theorem Zsqrtd.re_intCast E0 #

∀ {d : ℤ} (n : ℤ), (↑n).re = n

theorem Zsqrtd.im_intCast E0 #

∀ {d : ℤ} (n : ℤ), (↑n).im = 0

theorem Zsqrtd.intCast_val E0 #

∀ {d : ℤ} (n : ℤ), ↑n = { re := n, im := 0 }

instance Zsqrtd.instCharZero E0 #

∀ {d : ℤ}, CharZero (ℤ√d)

theorem Zsqrtd.ofInt_eq_intCast E0 #

∀ {d : ℤ} (n : ℤ), Zsqrtd.ofInt n = ↑n

theorem Zsqrtd.nsmul_val E0 #

∀ {d : ℤ} (n : ℕ) (x y : ℤ), ↑n * { re := x, im := y } = { re := ↑n * x, im := ↑n * y }

theorem Zsqrtd.smul_val E0 #

∀ {d : ℤ} (n x y : ℤ), ↑n * { re := x, im := y } = { re := n * x, im := n * y }

theorem Zsqrtd.re_smul E1 #

∀ {d : ℤ} (a : ℤ) (b : ℤ√d), (↑a * b).re = a * b.re

theorem Zsqrtd.im_smul E1 #

∀ {d : ℤ} (a : ℤ) (b : ℤ√d), (↑a * b).im = a * b.im

theorem Zsqrtd.muld_val E0 #

∀ {d : ℤ} (x y : ℤ), Zsqrtd.sqrtd * { re := x, im := y } = { re := d * y, im := x }

theorem Zsqrtd.dmuld E0 #

∀ {d : ℤ}, Zsqrtd.sqrtd * Zsqrtd.sqrtd = ↑d

theorem Zsqrtd.smuld_val E0 #

∀ {d : ℤ} (n x y : ℤ), Zsqrtd.sqrtd * ↑n * { re := x, im := y } = { re := d * n * y, im := n * x }

theorem Zsqrtd.decompose E1 #

∀ {d x y : ℤ}, { re := x, im := y } = ↑x + Zsqrtd.sqrtd * ↑y

theorem Zsqrtd.mul_star E1 #

∀ {d x y : ℤ}, { re := x, im := y } * star { re := x, im := y } = ↑x * ↑x - ↑d * ↑y * ↑y

theorem Zsqrtd.intCast_dvd E1 #

∀ {d : ℤ} (z : ℤ) (a : ℤ√d), ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im

theorem Zsqrtd.intCast_dvd_intCast E0 #

∀ {d : ℤ} (a b : ℤ), ↑a ∣ ↑b ↔ a ∣ b

theorem Zsqrtd.gcd_eq_zero_iff E0 #

∀ {d : ℤ} (a : ℤ√d), a.re.gcd a.im = 0 ↔ a = 0

theorem Zsqrtd.gcd_pos_iff E0 #

∀ {d : ℤ} (a : ℤ√d), 0 < a.re.gcd a.im ↔ a ≠ 0

theorem Zsqrtd.isCoprime_of_dvd_isCoprime E1 #

∀ {d : ℤ} {a b : ℤ√d}, IsCoprime a.re a.im → b ∣ a → IsCoprime b.re b.im

theorem Zsqrtd.exists_coprime_of_gcd_pos E1 #

∀ {d : ℤ} {a : ℤ√d}, 0 < a.re.gcd a.im → ∃ b, a = ↑↑(a.re.gcd a.im) * b ∧ IsCoprime b.re b.im

def Zsqrtd.SqLe E1 #

ℕ → ℕ → ℕ → ℕ → Prop

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

theorem Zsqrtd.sqLe_of_le E1 #

∀ {c d x y z w : ℕ}, z ≤ x → y ≤ w → Zsqrtd.SqLe x c y d → Zsqrtd.SqLe z c w d

theorem Zsqrtd.sqLe_add_mixed E1 #

∀ {c d x y z w : ℕ}, Zsqrtd.SqLe x c y d → Zsqrtd.SqLe z c w d → c * (x * z) ≤ d * (y * w)

theorem Zsqrtd.sqLe_add E1 #

∀ {c d x y z w : ℕ}, Zsqrtd.SqLe x c y d → Zsqrtd.SqLe z c w d → Zsqrtd.SqLe (x + z) c (y + w) d

theorem Zsqrtd.sqLe_cancel E1 #

∀ {c d x y z w : ℕ}, Zsqrtd.SqLe y d x c → Zsqrtd.SqLe (x + z) c (y + w) d → Zsqrtd.SqLe z c w d

theorem Zsqrtd.sqLe_smul E1 #

∀ {c d x y : ℕ} (n : ℕ), Zsqrtd.SqLe x c y d → Zsqrtd.SqLe (n * x) c (n * y) d

theorem Zsqrtd.sqLe_mul E1 #

∀ {d x y z w : ℕ},
  (Zsqrtd.SqLe x 1 y d → Zsqrtd.SqLe z 1 w d → Zsqrtd.SqLe (x * w + y * z) d (x * z + d * y * w) 1) ∧
    (Zsqrtd.SqLe x 1 y d → Zsqrtd.SqLe w d z 1 → Zsqrtd.SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧
      (Zsqrtd.SqLe y d x 1 → Zsqrtd.SqLe z 1 w d → Zsqrtd.SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧
        (Zsqrtd.SqLe y d x 1 → Zsqrtd.SqLe w d z 1 → Zsqrtd.SqLe (x * w + y * z) d (x * z + d * y * w) 1)

def Zsqrtd.Nonnegg E1 #

ℕ → ℕ → ℤ → ℤ → 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

theorem Zsqrtd.nonnegg_comm E1 #

∀ {c d : ℕ} {x y : ℤ}, Zsqrtd.Nonnegg c d x y = Zsqrtd.Nonnegg d c y x

theorem Zsqrtd.nonnegg_neg_pos E1 #

∀ {c d a b : ℕ}, Zsqrtd.Nonnegg c d (-↑a) ↑b ↔ Zsqrtd.SqLe a d b c

theorem Zsqrtd.nonnegg_pos_neg E1 #

∀ {c d a b : ℕ}, Zsqrtd.Nonnegg c d (↑a) (-↑b) ↔ Zsqrtd.SqLe b c a d

theorem Zsqrtd.nonnegg_cases_right E1 #

∀ {c d a : ℕ} {b : ℤ}, (∀ (x : ℕ), b = -↑x → Zsqrtd.SqLe x c a d) → Zsqrtd.Nonnegg c d (↑a) b

theorem Zsqrtd.nonnegg_cases_left E1 #

∀ {c d b : ℕ} {a : ℤ}, (∀ (x : ℕ), a = -↑x → Zsqrtd.SqLe x d b c) → Zsqrtd.Nonnegg c d a ↑b

def Zsqrtd.norm E1 #

{d : ℤ} → ℤ√d → ℤ

The norm of an element of ℤ[√d].

theorem Zsqrtd.norm_def E0 #

∀ {d : ℤ} (n : ℤ√d), n.norm = n.re * n.re - d * n.im * n.im

theorem Zsqrtd.norm_zero E0 #

∀ {d : ℤ}, Zsqrtd.norm 0 = 0

theorem Zsqrtd.norm_one E0 #

∀ {d : ℤ}, Zsqrtd.norm 1 = 1

theorem Zsqrtd.norm_intCast E0 #

∀ {d : ℤ} (n : ℤ), (↑n).norm = n * n

theorem Zsqrtd.norm_natCast E0 #

∀ {d : ℤ} (n : ℕ), (↑n).norm = ↑n * ↑n

theorem Zsqrtd.norm_mul E0 #

∀ {d : ℤ} (n m : ℤ√d), (n * m).norm = n.norm * m.norm

def Zsqrtd.normMonoidHom E1 #

{d : ℤ} → ℤ√d →* ℤ

norm as a MonoidHom.

theorem Zsqrtd.norm_eq_mul_conj E1 #

∀ {d : ℤ} (n : ℤ√d), ↑n.norm = n * star n

theorem Zsqrtd.norm_neg E0 #

∀ {d : ℤ} (x : ℤ√d), (-x).norm = x.norm

theorem Zsqrtd.norm_conj E0 #

∀ {d : ℤ} (x : ℤ√d), (star x).norm = x.norm

theorem Zsqrtd.norm_nonneg E1 #

∀ {d : ℤ}, d ≤ 0 → ∀ (n : ℤ√d), 0 ≤ n.norm

theorem Zsqrtd.abs_norm E0 #

∀ {d : ℤ}, d ≤ 0 → ∀ (n : ℤ√d), |n.norm| = n.norm

theorem Zsqrtd.norm_eq_one_iff E0 #

∀ {d : ℤ} {x : ℤ√d}, x.norm.natAbs = 1 ↔ IsUnit x

theorem Zsqrtd.isUnit_iff_norm_isUnit E1 #

∀ {d : ℤ} (z : ℤ√d), IsUnit z ↔ IsUnit z.norm

theorem Zsqrtd.norm_eq_one_iff' E1 #

∀ {d : ℤ}, d ≤ 0 → ∀ (z : ℤ√d), z.norm = 1 ↔ IsUnit z

theorem Zsqrtd.norm_eq_zero_iff E0 #

∀ {d : ℤ}, d < 0 → ∀ (z : ℤ√d), z.norm = 0 ↔ z = 0

theorem Zsqrtd.norm_eq_of_associated E1 #

∀ {d : ℤ}, d ≤ 0 → ∀ {x y : ℤ√d}, Associated x y → x.norm = y.norm

def Zsqrtd.Nonneg E1 #

{d : ℕ} → ℤ√↑d → Prop

Nonnegativity of an element of ℤ√d.

instance Zsqrtd.instLECastInt E0 #

{d : ℕ} → LE (ℤ√↑d)

instance Zsqrtd.instLTCastInt E0 #

{d : ℕ} → LT (ℤ√↑d)

instance Zsqrtd.decidableNonnegg E0 #

(c d : ℕ) → DecidableRel (Zsqrtd.Nonnegg c d)

instance Zsqrtd.decidableNonneg E0 #

{d : ℕ} → (a : ℤ√↑d) → Decidable a.Nonneg

instance Zsqrtd.decidableLE E0 #

{d : ℕ} → DecidableLE (ℤ√↑d)

theorem Zsqrtd.nonneg_cases E1 #

∀ {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 E1 #

∀ {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 E1 #

∀ {d : ℕ} {a b : ℤ√↑d}, a.Nonneg → b.Nonneg → (a + b).Nonneg

theorem Zsqrtd.nonneg_iff_zero_le E1 #

∀ {d : ℕ} {a : ℤ√↑d}, a.Nonneg ↔ 0 ≤ a

theorem Zsqrtd.le_of_le_le E1 #

∀ {d : ℕ} {x y z w : ℤ}, x ≤ z → y ≤ w → { re := x, im := y } ≤ { re := z, im := w }

theorem Zsqrtd.nonneg_total E1 #

∀ {d : ℕ} (a : ℤ√↑d), a.Nonneg ∨ (-a).Nonneg

instance Zsqrtd.preorder E0 #

{d : ℕ} → Preorder (ℤ√↑d)

theorem Zsqrtd.le_arch E1 #

∀ {d : ℕ} (a : ℤ√↑d), ∃ n, a ≤ ↑n

theorem Zsqrtd.nonneg_smul E1 #

∀ {d : ℕ} {a : ℤ√↑d} {n : ℕ}, a.Nonneg → (↑n * a).Nonneg

theorem Zsqrtd.nonneg_muld E1 #

∀ {d : ℕ} {a : ℤ√↑d}, a.Nonneg → (Zsqrtd.sqrtd * a).Nonneg

theorem Zsqrtd.nonneg_mul_lem E1 #

∀ {d x y : ℕ} {a : ℤ√↑d}, a.Nonneg → ({ re := ↑x, im := ↑y } * a).Nonneg

theorem Zsqrtd.nonneg_mul E1 #

∀ {d : ℕ} {a b : ℤ√↑d}, a.Nonneg → b.Nonneg → (a * b).Nonneg

theorem Zsqrtd.mul_nonneg E1 #

∀ {d : ℕ} (a b : ℤ√↑d), 0 ≤ a → 0 ≤ b → 0 ≤ a * b

theorem Zsqrtd.not_sqLe_succ E1 #

∀ (c d y : ℕ), 0 < c → ¬Zsqrtd.SqLe (y + 1) c 0 d

class Zsqrtd.Nonsquare E1 #

ℕ → 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.

ctor Zsqrtd.Nonsquare.mk E0 #

∀ {x : ℕ}, (∀ (n : ℕ), x ≠ n * n) → Zsqrtd.Nonsquare x

theorem Zsqrtd.Nonsquare.ns E1 #

∀ (x : ℕ) [self : Zsqrtd.Nonsquare x] (n : ℕ), x ≠ n * n

theorem Zsqrtd.d_pos E1 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d], 0 < d

theorem Zsqrtd.divides_sq_eq_zero E1 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d] {x y : ℕ}, x * x = d * y * y → x = 0 ∧ y = 0

theorem Zsqrtd.divides_sq_eq_zero_z E1 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d] {x y : ℤ}, x * x = ↑d * y * y → x = 0 ∧ y = 0

theorem Zsqrtd.not_divides_sq E1 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d] (x y : ℕ), (x + 1) * (x + 1) ≠ d * (y + 1) * (y + 1)

theorem Zsqrtd.nonneg_antisymm E1 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d] {a : ℤ√↑d}, a.Nonneg → (-a).Nonneg → a = 0

instance Zsqrtd.linearOrder E0 #

{d : ℕ} → [dnsq : Zsqrtd.Nonsquare d] → LinearOrder (ℤ√↑d)

instance Zsqrtd.instNoZeroDivisorsCastInt E0 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d], NoZeroDivisors (ℤ√↑d)

instance Zsqrtd.instIsDomainCastInt E0 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d], IsDomain (ℤ√↑d)

theorem Zsqrtd.mul_pos E1 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d] (a b : ℤ√↑d), 0 < a → 0 < b → 0 < a * b

instance Zsqrtd.instZeroLEOneClassCastInt E0 #

∀ {d : ℕ}, ZeroLEOneClass (ℤ√↑d)

instance Zsqrtd.instIsOrderedAddMonoidCastInt E0 #

∀ {d : ℕ}, IsOrderedAddMonoid (ℤ√↑d)

instance Zsqrtd.instIsStrictOrderedRingCastInt E0 #

∀ {d : ℕ} [dnsq : Zsqrtd.Nonsquare d], IsStrictOrderedRing (ℤ√↑d)

theorem Zsqrtd.norm_eq_zero E1 #

∀ {d : ℤ}, (∀ (n : ℤ), d ≠ n * n) → ∀ (a : ℤ√d), a.norm = 0 ↔ a = 0

theorem Zsqrtd.hom_ext_iff E0 #

∀ {R : Type u_1} [inst : NonAssocRing R] {d : ℤ} {f g : ℤ√d →+* R}, f = g ↔ f Zsqrtd.sqrtd = g Zsqrtd.sqrtd

theorem Zsqrtd.hom_ext E1 #

∀ {R : Type u_1} [inst : NonAssocRing R] {d : ℤ} (f g : ℤ√d →+* R), f Zsqrtd.sqrtd = g Zsqrtd.sqrtd → f = g

def Zsqrtd.lift E1 #

{R : Type u_1} → [inst : CommRing R] → {d : ℤ} → { r // r * r = ↑d } ≃ (ℤ√d →+* R)

The unique RingHom 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.

theorem Zsqrtd.lift_symm_apply_coe E0 #

∀ {R : Type u_1} [inst : CommRing R] {d : ℤ} (f : ℤ√d →+* R), ↑(Zsqrtd.lift.symm f) = f Zsqrtd.sqrtd

theorem Zsqrtd.lift_apply_apply E0 #

∀ {R : Type u_1} [inst : CommRing R] {d : ℤ} (r : { r // r * r = ↑d }) (a : ℤ√d), (Zsqrtd.lift r) a = ↑a.re + ↑a.im * ↑r

theorem Zsqrtd.lift_injective E1 #

∀ {R : Type u_1} [inst : CommRing R] [CharZero R] {d : ℤ} (r : { r // r * r = ↑d }),
  (∀ (n : ℤ), d ≠ n * n) → Function.Injective ⇑(Zsqrtd.lift r)

lift r is injective if d is non-square, and R has characteristic zero (that is, the map from ℤ into R is injective).

theorem Zsqrtd.norm_eq_one_iff_mem_unitary E1 #

∀ {d : ℤ} {a : ℤ√d}, a.norm = 1 ↔ a ∈ unitary (ℤ√d)

An element of ℤ√d has norm equal to 1 if and only if it is contained in the submonoid of unitary elements.

theorem Zsqrtd.mker_norm_eq_unitary E1 #

∀ {d : ℤ}, MonoidHom.mker Zsqrtd.normMonoidHom = unitary (ℤ√d)

The kernel of the norm map on ℤ√d equals the submonoid of unitary elements.