File: Mathlib/NumberTheory/Zsqrtd/Basic.lean

full_name: Zsqrtd.re
code: /-- 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. -/
@[ext]
structure Zsqrtd (d : ℤ) where
  re : ℤ
  im : ℤ
  deriving DecidableEq
goal: ℤ

full_name: Zsqrtd
code: /-- 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. -/
@[ext]
structure Zsqrtd (d : ℤ) where
  re : ℤ
  im : ℤ
  deriving DecidableEq
goal: Type

full_name: Zsqrtd.im
code: /-- 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. -/
@[ext]
structure Zsqrtd (d : ℤ) where
  re : ℤ
  im : ℤ
  deriving DecidableEq
goal: ℤ

full_name: «_aux_Mathlib_NumberTheory_Zsqrtd_Basic___macroRules_termℤ√__1»
code: prefix:100 "ℤ√" => Zsqrtd
goal: Lean.Macro

full_name: _aux_Mathlib_NumberTheory_Zsqrtd_Basic___unexpand_Zsqrtd_1
code: prefix:100 "ℤ√" => Zsqrtd
goal: Lean.PrettyPrinter.Unexpander

full_name: Zsqrtd.ofInt
code: /-- Convert an integer to a `ℤ√d` -/
def ofInt (n : ℤ) : ℤ√d 
goal: ℤ√d

full_name: Zsqrtd.ofInt_re
code: theorem ofInt_re (n : ℤ) : (ofInt n : ℤ√d).re = n 
goal: (Zsqrtd.ofInt n).re = n

full_name: Zsqrtd.ofInt_im
code: theorem ofInt_im (n : ℤ) : (ofInt n : ℤ√d).im = 0 
goal: (Zsqrtd.ofInt n).im = 0

full_name: Zsqrtd.instZero
code: /-- The zero of the ring -/
instance : Zero (ℤ√d) 
goal: Zero (ℤ√d)

full_name: Zsqrtd.zero_re
code: @[simp]
theorem zero_re : (0 : ℤ√d).re = 0 
goal: Zsqrtd.re 0 = 0

full_name: Zsqrtd.zero_im
code: @[simp]
theorem zero_im : (0 : ℤ√d).im = 0 
goal: Zsqrtd.im 0 = 0

full_name: Zsqrtd.instInhabited
code: instance : Inhabited (ℤ√d) 
goal: Inhabited (ℤ√d)

full_name: Zsqrtd.instOne
code: /-- The one of the ring -/
instance : One (ℤ√d) 
goal: One (ℤ√d)

full_name: Zsqrtd.one_re
code: @[simp]
theorem one_re : (1 : ℤ√d).re = 1 
goal: Zsqrtd.re 1 = 1

full_name: Zsqrtd.one_im
code: @[simp]
theorem one_im : (1 : ℤ√d).im = 0 
goal: Zsqrtd.im 1 = 0

full_name: Zsqrtd.sqrtd
code: /-- The representative of `√d` in the ring -/
def sqrtd : ℤ√d 
goal: ℤ√d

full_name: Zsqrtd.sqrtd_re
code: @[simp]
theorem sqrtd_re : (sqrtd : ℤ√d).re = 0 
goal: Zsqrtd.sqrtd.re = 0

full_name: Zsqrtd.sqrtd_im
code: @[simp]
theorem sqrtd_im : (sqrtd : ℤ√d).im = 1 
goal: Zsqrtd.sqrtd.im = 1

full_name: Zsqrtd.instAdd
code: /-- Addition of elements of `ℤ√d` -/
instance : Add (ℤ√d) 
goal: Add (ℤ√d)

full_name: Zsqrtd.add_def
code: @[simp]
theorem add_def (x y x' y' : ℤ) : (⟨x, y⟩ + ⟨x', y'⟩ : ℤ√d) = ⟨x + x', y + y'⟩ 
goal: { re := x, im := y } + { re := x', im := y' } = { re := x + x', im := y + y' }

full_name: Zsqrtd.add_re
code: @[simp]
theorem add_re (z w : ℤ√d) : (z + w).re = z.re + w.re 
goal: (z + w).re = z.re + w.re

full_name: Zsqrtd.add_im
code: @[simp]
theorem add_im (z w : ℤ√d) : (z + w).im = z.im + w.im 
goal: (z + w).im = z.im + w.im

full_name: Zsqrtd.instNeg
code: /-- Negation in `ℤ√d` -/
instance : Neg (ℤ√d) 
goal: Neg (ℤ√d)

full_name: Zsqrtd.neg_re
code: @[simp]
theorem neg_re (z : ℤ√d) : (-z).re = -z.re 
goal: (-z).re = -z.re

full_name: Zsqrtd.neg_im
code: @[simp]
theorem neg_im (z : ℤ√d) : (-z).im = -z.im 
goal: (-z).im = -z.im

full_name: Zsqrtd.instMul
code: /-- Multiplication in `ℤ√d` -/
instance : Mul (ℤ√d) 
goal: Mul (ℤ√d)

full_name: Zsqrtd.mul_re
code: @[simp]
theorem mul_re (z w : ℤ√d) : (z * w).re = z.re * w.re + d * z.im * w.im 
goal: (z * w).re = z.re * w.re + d * z.im * w.im

full_name: Zsqrtd.mul_im
code: @[simp]
theorem mul_im (z w : ℤ√d) : (z * w).im = z.re * w.im + z.im * w.re 
goal: (z * w).im = z.re * w.im + z.im * w.re

full_name: Zsqrtd.addCommGroup
code: instance addCommGroup : AddCommGroup (ℤ√d) 
goal: AddCommGroup (ℤ√d)

full_name: Zsqrtd.sub_re
code: @[simp]
theorem sub_re (z w : ℤ√d) : (z - w).re = z.re - w.re 
goal: (z - w).re = z.re - w.re

full_name: Zsqrtd.sub_im
code: @[simp]
theorem sub_im (z w : ℤ√d) : (z - w).im = z.im - w.im 
goal: (z - w).im = z.im - w.im

full_name: Zsqrtd.addGroupWithOne
code: instance addGroupWithOne : AddGroupWithOne (ℤ√d) 
goal: AddGroupWithOne (ℤ√d)

full_name: Zsqrtd.commRing
code: instance commRing : CommRing (ℤ√d) 
goal: CommRing (ℤ√d)

full_name: Zsqrtd.instAddMonoid
code: instance : AddMonoid (ℤ√d) 
goal: AddMonoid (ℤ√d)

full_name: Zsqrtd.instMonoid
code: instance : Monoid (ℤ√d) 
goal: Monoid (ℤ√d)

full_name: Zsqrtd.instCommMonoid
code: instance : CommMonoid (ℤ√d) 
goal: CommMonoid (ℤ√d)

full_name: Zsqrtd.instCommSemigroup
code: instance : CommSemigroup (ℤ√d) 
goal: CommSemigroup (ℤ√d)

full_name: Zsqrtd.instSemigroup
code: instance : Semigroup (ℤ√d) 
goal: Semigroup (ℤ√d)

full_name: Zsqrtd.instAddCommSemigroup
code: instance : AddCommSemigroup (ℤ√d) 
goal: AddCommSemigroup (ℤ√d)

full_name: Zsqrtd.instAddSemigroup
code: instance : AddSemigroup (ℤ√d) 
goal: AddSemigroup (ℤ√d)

full_name: Zsqrtd.instCommSemiring
code: instance : CommSemiring (ℤ√d) 
goal: CommSemiring (ℤ√d)

full_name: Zsqrtd.instSemiring
code: instance : Semiring (ℤ√d) 
goal: Semiring (ℤ√d)

full_name: Zsqrtd.instRing
code: instance : Ring (ℤ√d) 
goal: Ring (ℤ√d)

full_name: Zsqrtd.instDistrib
code: instance : Distrib (ℤ√d) 
goal: Distrib (ℤ√d)

full_name: Zsqrtd.instStar
code: /-- Conjugation in `ℤ√d`. The conjugate of `a + b √d` is `a - b √d`. -/
instance : Star (ℤ√d) 
goal: Star (ℤ√d)

full_name: Zsqrtd.star_mk
code: @[simp]
theorem star_mk (x y : ℤ) : star (⟨x, y⟩ : ℤ√d) = ⟨x, -y⟩ 
goal: star { re := x, im := y } = { re := x, im := -y }

full_name: Zsqrtd.star_re
code: @[simp]
theorem star_re (z : ℤ√d) : (star z).re = z.re 
goal: (star z).re = z.re

full_name: Zsqrtd.star_im
code: @[simp]
theorem star_im (z : ℤ√d) : (star z).im = -z.im 
goal: (star z).im = -z.im

full_name: Zsqrtd.instStarRing
code: instance : StarRing (ℤ√d) 
goal: StarRing (ℤ√d)

full_name: Zsqrtd.nontrivial
code: instance nontrivial : Nontrivial (ℤ√d) 
goal: Nontrivial (ℤ√d)

full_name: Zsqrtd.natCast_re
code: @[simp]
theorem natCast_re (n : ℕ) : (n : ℤ√d).re = n 
goal: (↑n).re = ↑n

full_name: Zsqrtd.ofNat_re
code: @[simp]
theorem ofNat_re (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n) : ℤ√d).re = n 
goal: (OfNat.ofNat n).re = ↑n

full_name: Zsqrtd.natCast_im
code: @[simp]
theorem natCast_im (n : ℕ) : (n : ℤ√d).im = 0 
goal: (↑n).im = 0

full_name: Zsqrtd.ofNat_im
code: @[simp]
theorem ofNat_im (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n) : ℤ√d).im = 0 
goal: (OfNat.ofNat n).im = 0

full_name: Zsqrtd.natCast_val
code: theorem natCast_val (n : ℕ) : (n : ℤ√d) = ⟨n, 0⟩ 
goal: ↑n = { re := ↑n, im := 0 }

full_name: Zsqrtd.intCast_re
code: @[simp]
theorem intCast_re (n : ℤ) : (n : ℤ√d).re = n 
goal: (↑n).re = n

full_name: Zsqrtd.intCast_im
code: @[simp]
theorem intCast_im (n : ℤ) : (n : ℤ√d).im = 0 
goal: (↑n).im = 0

full_name: Zsqrtd.intCast_val
code: theorem intCast_val (n : ℤ) : (n : ℤ√d) = ⟨n, 0⟩ 
goal: ↑n = { re := n, im := 0 }

full_name: Zsqrtd.instCharZero
code: instance : CharZero (ℤ√d) 
goal: CharZero (ℤ√d)

full_name: Zsqrtd.ofInt_eq_intCast
code: @[simp]
theorem ofInt_eq_intCast (n : ℤ) : (ofInt n : ℤ√d) = n 
goal: Zsqrtd.ofInt n = ↑n

full_name: Zsqrtd.smul_val
code: @[simp]
theorem smul_val (n x y : ℤ) : (n : ℤ√d) * ⟨x, y⟩ = ⟨n * x, n * y⟩ 
goal: ↑n * { re := x, im := y } = { re := n * x, im := n * y }

full_name: Zsqrtd.smul_re
code: theorem smul_re (a : ℤ) (b : ℤ√d) : (↑a * b).re = a * b.re 
goal: (↑a * b).re = a * b.re

full_name: Zsqrtd.smul_im
code: theorem smul_im (a : ℤ) (b : ℤ√d) : (↑a * b).im = a * b.im 
goal: (↑a * b).im = a * b.im

full_name: Zsqrtd.muld_val
code: @[simp]
theorem muld_val (x y : ℤ) : sqrtd (d := d) * ⟨x, y⟩ = ⟨d * y, x⟩ 
goal: Zsqrtd.sqrtd * { re := x, im := y } = { re := d * y, im := x }

full_name: Zsqrtd.dmuld
code: @[simp]
theorem dmuld : sqrtd (d := d) * sqrtd (d := d) = d 
goal: Zsqrtd.sqrtd * Zsqrtd.sqrtd = ↑d

full_name: Zsqrtd.smuld_val
code: @[simp]
theorem smuld_val (n x y : ℤ) : sqrtd * (n : ℤ√d) * ⟨x, y⟩ = ⟨d * n * y, n * x⟩ 
goal: Zsqrtd.sqrtd * ↑n * { re := x, im := y } = { re := d * n * y, im := n * x }

full_name: Zsqrtd.decompose
code: theorem decompose {x y : ℤ} : (⟨x, y⟩ : ℤ√d) = x + sqrtd (d := d) * y 
goal: { re := x, im := y } = ↑x + Zsqrtd.sqrtd * ↑y

full_name: Zsqrtd.mul_star
code: theorem mul_star {x y : ℤ} : (⟨x, y⟩ * star ⟨x, y⟩ : ℤ√d) = x * x - d * y * y 
goal: { re := x, im := y } * star { re := x, im := y } = ↑x * ↑x - ↑d * ↑y * ↑y

full_name: Zsqrtd.intCast_dvd
code: theorem intCast_dvd (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im 
goal: ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im

full_name: Zsqrtd.intCast_dvd_intCast
code: @[simp, norm_cast]
theorem intCast_dvd_intCast (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b 
goal: ↑a ∣ ↑b ↔ a ∣ b

full_name: Zsqrtd.eq_of_smul_eq_smul_left
code: protected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) :
    b = c 
goal: b = c

full_name: Zsqrtd.gcd_eq_zero_iff
code: theorem gcd_eq_zero_iff (a : ℤ√d) : Int.gcd a.re a.im = 0 ↔ a = 0 
goal: a.re.gcd a.im = 0 ↔ a = 0

full_name: Zsqrtd.gcd_pos_iff
code: theorem gcd_pos_iff (a : ℤ√d) : 0 < Int.gcd a.re a.im ↔ a ≠ 0 
goal: 0 < a.re.gcd a.im ↔ a ≠ 0

full_name: Zsqrtd.coprime_of_dvd_coprime
code: theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im 
goal: IsCoprime b.re b.im

full_name: Zsqrtd.exists_coprime_of_gcd_pos
code: theorem exists_coprime_of_gcd_pos {a : ℤ√d} (hgcd : 0 < Int.gcd a.re a.im) :
    ∃ b : ℤ√d, a = ((Int.gcd a.re a.im : ℤ) : ℤ√d) * b ∧ IsCoprime b.re b.im 
goal: ∃ b, a = ↑↑(a.re.gcd a.im) * b ∧ IsCoprime b.re b.im

full_name: Zsqrtd.SqLe
code: /-- Read `SqLe a c b d` as `a √c ≤ b √d` -/
def SqLe (a c b d : ℕ) : Prop 
goal: Prop

full_name: Zsqrtd.sqLe_of_le
code: theorem sqLe_of_le {c d x y z w : ℕ} (xz : z ≤ x) (yw : y ≤ w) (xy : SqLe x c y d) : SqLe z c w d 
goal: Zsqrtd.SqLe z c w d

full_name: Zsqrtd.sqLe_add_mixed
code: theorem sqLe_add_mixed {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) :
    c * (x * z) ≤ d * (y * w) 
goal: c * (x * z) ≤ d * (y * w)

full_name: Zsqrtd.sqLe_add
code: theorem sqLe_add {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) :
    SqLe (x + z) c (y + w) d 
goal: Zsqrtd.SqLe (x + z) c (y + w) d

full_name: Zsqrtd.sqLe_cancel
code: theorem sqLe_cancel {c d x y z w : ℕ} (zw : SqLe y d x c) (h : SqLe (x + z) c (y + w) d) :
    SqLe z c w d 
goal: Zsqrtd.SqLe z c w d

full_name: Zsqrtd.sqLe_smul
code: theorem sqLe_smul {c d x y : ℕ} (n : ℕ) (xy : SqLe x c y d) : SqLe (n * x) c (n * y) d 
goal: Zsqrtd.SqLe (n * x) c (n * y) d

full_name: Zsqrtd.sqLe_mul
code: theorem sqLe_mul {d x y z w : ℕ} :
    (SqLe x 1 y d → SqLe z 1 w d → SqLe (x * w + y * z) d (x * z + d * y * w) 1) ∧
      (SqLe x 1 y d → SqLe w d z 1 → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧
        (SqLe y d x 1 → SqLe z 1 w d → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧
          (SqLe y d x 1 → SqLe w d z 1 → SqLe (x * w + y * z) d (x * z + d * y * w) 1) 
goal: (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)

full_name: Zsqrtd.Nonnegg
code: /-- "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 -/
def Nonnegg (c d : ℕ) : ℤ → ℤ → Prop
  
goal: ℤ → ℤ → Prop

full_name: Zsqrtd.nonnegg_comm
code: theorem nonnegg_comm {c d : ℕ} {x y : ℤ} : Nonnegg c d x y = Nonnegg d c y x 
goal: Zsqrtd.Nonnegg c d x y = Zsqrtd.Nonnegg d c y x

full_name: Zsqrtd.nonnegg_neg_pos
code: theorem nonnegg_neg_pos {c d} : ∀ {a b : ℕ}, Nonnegg c d (-a) b ↔ SqLe a d b c
  
goal: Zsqrtd.Nonnegg c d (-↑a) ↑b ↔ Zsqrtd.SqLe a d b c

full_name: Zsqrtd.nonnegg_pos_neg
code: theorem nonnegg_pos_neg {c d} {a b : ℕ} : Nonnegg c d a (-b) ↔ SqLe b c a d 
goal: Zsqrtd.Nonnegg c d (↑a) (-↑b) ↔ Zsqrtd.SqLe b c a d

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

full_name: Zsqrtd.nonnegg_cases_left
code: theorem nonnegg_cases_left {c d} {b : ℕ} {a : ℤ} (h : ∀ x : ℕ, a = -x → SqLe x d b c) :
    Nonnegg c d a b 
goal: Zsqrtd.Nonnegg c d a ↑b

full_name: Zsqrtd.norm
code: /-- The norm of an element of `ℤ[√d]`. -/
def norm (n : ℤ√d) : ℤ 
goal: ℤ

full_name: Zsqrtd.norm_def
code: theorem norm_def (n : ℤ√d) : n.norm = n.re * n.re - d * n.im * n.im 
goal: n.norm = n.re * n.re - d * n.im * n.im

full_name: Zsqrtd.norm_zero
code: @[simp]
theorem norm_zero : norm (0 : ℤ√d) = 0 
goal: Zsqrtd.norm 0 = 0

full_name: Zsqrtd.norm_one
code: @[simp]
theorem norm_one : norm (1 : ℤ√d) = 1 
goal: Zsqrtd.norm 1 = 1

full_name: Zsqrtd.norm_intCast
code: @[simp]
theorem norm_intCast (n : ℤ) : norm (n : ℤ√d) = n * n 
goal: (↑n).norm = n * n

full_name: Zsqrtd.norm_natCast
code: @[simp]
theorem norm_natCast (n : ℕ) : norm (n : ℤ√d) = n * n 
goal: (↑n).norm = ↑n * ↑n

full_name: Zsqrtd.norm_mul
code: @[simp]
theorem norm_mul (n m : ℤ√d) : norm (n * m) = norm n * norm m 
goal: (n * m).norm = n.norm * m.norm

full_name: Zsqrtd.normMonoidHom
code: /-- `norm` as a `MonoidHom`. -/
def normMonoidHom : ℤ√d →* ℤ 
goal: ℤ√d →* ℤ

full_name: Zsqrtd.norm_eq_mul_conj
code: theorem norm_eq_mul_conj (n : ℤ√d) : (norm n : ℤ√d) = n * star n 
goal: ↑n.norm = n * star n

full_name: Zsqrtd.norm_neg
code: @[simp]
theorem norm_neg (x : ℤ√d) : (-x).norm = x.norm 
goal: (-x).norm = x.norm

full_name: Zsqrtd.norm_conj
code: @[simp]
theorem norm_conj (x : ℤ√d) : (star x).norm = x.norm 
goal: (star x).norm = x.norm

full_name: Zsqrtd.norm_nonneg
code: theorem norm_nonneg (hd : d ≤ 0) (n : ℤ√d) : 0 ≤ n.norm 
goal: 0 ≤ n.norm

full_name: Zsqrtd.norm_eq_one_iff
code: theorem norm_eq_one_iff {x : ℤ√d} : x.norm.natAbs = 1 ↔ IsUnit x 
goal: x.norm.natAbs = 1 ↔ IsUnit x

full_name: Zsqrtd.isUnit_iff_norm_isUnit
code: theorem isUnit_iff_norm_isUnit {d : ℤ} (z : ℤ√d) : IsUnit z ↔ IsUnit z.norm 
goal: IsUnit z ↔ IsUnit z.norm

full_name: Zsqrtd.norm_eq_one_iff'
code: theorem norm_eq_one_iff' {d : ℤ} (hd : d ≤ 0) (z : ℤ√d) : z.norm = 1 ↔ IsUnit z 
goal: z.norm = 1 ↔ IsUnit z

full_name: Zsqrtd.norm_eq_zero_iff
code: theorem norm_eq_zero_iff {d : ℤ} (hd : d < 0) (z : ℤ√d) : z.norm = 0 ↔ z = 0 
goal: z.norm = 0 ↔ z = 0

full_name: Zsqrtd.norm_eq_of_associated
code: theorem norm_eq_of_associated {d : ℤ} (hd : d ≤ 0) {x y : ℤ√d} (h : Associated x y) :
    x.norm = y.norm 
goal: x.norm = y.norm

full_name: Zsqrtd.Nonneg
code: /-- Nonnegativity of an element of `ℤ√d`. -/
def Nonneg : ℤ√d → Prop
  
goal: ℤ√↑d → Prop

full_name: Zsqrtd.instLECastInt
code: instance : LE (ℤ√d) 
goal: LE (ℤ√↑d)

full_name: Zsqrtd.instLTCastInt
code: instance : LT (ℤ√d) 
goal: LT (ℤ√↑d)

full_name: Zsqrtd.decidableNonnegg
code: instance decidableNonnegg (c d a b) : Decidable (Nonnegg c d a b) 
goal: Decidable (Zsqrtd.Nonnegg c d a b)

full_name: Zsqrtd.decidableNonneg
code: instance decidableNonneg : ∀ a : ℤ√d, Decidable (Nonneg a)
  
goal: Decidable a.Nonneg

full_name: Zsqrtd.decidableLE
code: instance decidableLE : @DecidableRel (ℤ√d) (· ≤ ·) 
goal: DecidableRel fun x x_1 => x ≤ x_1

full_name: Zsqrtd.nonneg_cases
code: theorem nonneg_cases : ∀ {a : ℤ√d}, Nonneg a → ∃ x y : ℕ, a = ⟨x, y⟩ ∨ a = ⟨x, -y⟩ ∨ a = ⟨-x, y⟩
  
goal: a.Nonneg → ∃ x y, a = { re := ↑x, im := ↑y } ∨ a = { re := ↑x, im := -↑y } ∨ a = { re := -↑x, im := ↑y }

full_name: Zsqrtd.nonneg_add_lem
code: theorem nonneg_add_lem {x y z w : ℕ} (xy : Nonneg (⟨x, -y⟩ : ℤ√d)) (zw : Nonneg (⟨-z, w⟩ : ℤ√d)) :
    Nonneg (⟨x, -y⟩ + ⟨-z, w⟩ : ℤ√d) 
goal: ({ re := ↑x, im := -↑y } + { re := -↑z, im := ↑w }).Nonneg

full_name: Zsqrtd.Nonneg.add
code: theorem Nonneg.add {a b : ℤ√d} (ha : Nonneg a) (hb : Nonneg b) : Nonneg (a + b) 
goal: (a + b).Nonneg

full_name: Zsqrtd.nonneg_iff_zero_le
code: theorem nonneg_iff_zero_le {a : ℤ√d} : Nonneg a ↔ 0 ≤ a 
goal: a.Nonneg ↔ 0 ≤ a

full_name: Zsqrtd.le_of_le_le
code: theorem le_of_le_le {x y z w : ℤ} (xz : x ≤ z) (yw : y ≤ w) : (⟨x, y⟩ : ℤ√d) ≤ ⟨z, w⟩ 
goal: { re := x, im := y } ≤ { re := z, im := w }

full_name: Zsqrtd.nonneg_total
code: protected theorem nonneg_total : ∀ a : ℤ√d, Nonneg a ∨ Nonneg (-a)
  
goal: a.Nonneg ∨ (-a).Nonneg

full_name: Zsqrtd.le_total
code: protected theorem le_total (a b : ℤ√d) : a ≤ b ∨ b ≤ a 
goal: a ≤ b ∨ b ≤ a

full_name: Zsqrtd.preorder
code: instance preorder : Preorder (ℤ√d) 
goal: Preorder (ℤ√↑d)

full_name: Zsqrtd.le_arch
code: theorem le_arch (a : ℤ√d) : ∃ n : ℕ, a ≤ n 
goal: ∃ n, a ≤ ↑n

full_name: Zsqrtd.add_le_add_left
code: protected theorem add_le_add_left (a b : ℤ√d) (ab : a ≤ b) (c : ℤ√d) : c + a ≤ c + b 
goal: c + a ≤ c + b

full_name: Zsqrtd.le_of_add_le_add_left
code: protected theorem le_of_add_le_add_left (a b c : ℤ√d) (h : c + a ≤ c + b) : a ≤ b 
goal: a ≤ b

full_name: Zsqrtd.add_lt_add_left
code: protected theorem add_lt_add_left (a b : ℤ√d) (h : a < b) (c) : c + a < c + b 
goal: c + a < c + b

full_name: Zsqrtd.nonneg_smul
code: theorem nonneg_smul {a : ℤ√d} {n : ℕ} (ha : Nonneg a) : Nonneg ((n : ℤ√d) * a) 
goal: (↑n * a).Nonneg

full_name: Zsqrtd.nonneg_muld
code: theorem nonneg_muld {a : ℤ√d} (ha : Nonneg a) : Nonneg (sqrtd * a) 
goal: (Zsqrtd.sqrtd * a).Nonneg

full_name: Zsqrtd.nonneg_mul_lem
code: theorem nonneg_mul_lem {x y : ℕ} {a : ℤ√d} (ha : Nonneg a) : Nonneg (⟨x, y⟩ * a) 
goal: ({ re := ↑x, im := ↑y } * a).Nonneg

full_name: Zsqrtd.nonneg_mul
code: theorem nonneg_mul {a b : ℤ√d} (ha : Nonneg a) (hb : Nonneg b) : Nonneg (a * b) 
goal: (a * b).Nonneg

full_name: Zsqrtd.mul_nonneg
code: protected theorem mul_nonneg (a b : ℤ√d) : 0 ≤ a → 0 ≤ b → 0 ≤ a * b 
goal: 0 ≤ a → 0 ≤ b → 0 ≤ a * b

full_name: Zsqrtd.not_sqLe_succ
code: theorem not_sqLe_succ (c d y) (h : 0 < c) : ¬SqLe (y + 1) c 0 d 
goal: ¬Zsqrtd.SqLe (y + 1) c 0 d

full_name: Zsqrtd.Nonsquare.ns'
code: /-- 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. -/
class Nonsquare (x : ℕ) : Prop where
  ns' : ∀ n : ℕ, x ≠ n * n
goal: x ≠ n * n

full_name: Zsqrtd.Nonsquare
code: /-- 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. -/
class Nonsquare (x : ℕ) : Prop where
  ns' : ∀ n : ℕ, x ≠ n * n
goal: Prop

full_name: Zsqrtd.Nonsquare.ns
code: theorem Nonsquare.ns (x : ℕ) [Nonsquare x] : ∀ n : ℕ, x ≠ n * n 
goal: x ≠ n * n

full_name: Zsqrtd.d_pos
code: theorem d_pos : 0 < d 
goal: 0 < d

full_name: Zsqrtd.divides_sq_eq_zero
code: theorem divides_sq_eq_zero {x y} (h : x * x = d * y * y) : x = 0 ∧ y = 0 
goal: x = 0 ∧ y = 0

full_name: Zsqrtd.divides_sq_eq_zero_z
code: theorem divides_sq_eq_zero_z {x y : ℤ} (h : x * x = d * y * y) : x = 0 ∧ y = 0 
goal: x = 0 ∧ y = 0

full_name: Zsqrtd.not_divides_sq
code: theorem not_divides_sq (x y) : (x + 1) * (x + 1) ≠ d * (y + 1) * (y + 1) 
goal: (x + 1) * (x + 1) ≠ d * (y + 1) * (y + 1)

full_name: Zsqrtd.nonneg_antisymm
code: theorem nonneg_antisymm : ∀ {a : ℤ√d}, Nonneg a → Nonneg (-a) → a = 0
  
goal: a.Nonneg → (-a).Nonneg → a = 0

full_name: Zsqrtd.le_antisymm
code: theorem le_antisymm {a b : ℤ√d} (ab : a ≤ b) (ba : b ≤ a) : a = b 
goal: a = b

full_name: Zsqrtd.linearOrder
code: instance linearOrder : LinearOrder (ℤ√d) 
goal: LinearOrder (ℤ√↑d)

full_name: Zsqrtd.eq_zero_or_eq_zero_of_mul_eq_zero
code: protected theorem eq_zero_or_eq_zero_of_mul_eq_zero : ∀ {a b : ℤ√d}, a * b = 0 → a = 0 ∨ b = 0
  
goal: a * b = 0 → a = 0 ∨ b = 0

full_name: Zsqrtd.instNoZeroDivisorsCastInt
code: instance : NoZeroDivisors (ℤ√d) 
goal: NoZeroDivisors (ℤ√↑d)

full_name: Zsqrtd.instIsDomainCastInt
code: instance : IsDomain (ℤ√d) 
goal: IsDomain (ℤ√↑d)

full_name: Zsqrtd.mul_pos
code: protected theorem mul_pos (a b : ℤ√d) (a0 : 0 < a) (b0 : 0 < b) : 0 < a * b 
goal: 0 < a * b

full_name: Zsqrtd.instLinearOrderedCommRingCastInt
code: instance : LinearOrderedCommRing (ℤ√d) 
goal: LinearOrderedCommRing (ℤ√↑d)

full_name: Zsqrtd.instLinearOrderedRingCastInt
code: instance : LinearOrderedRing (ℤ√d) 
goal: LinearOrderedRing (ℤ√↑d)

full_name: Zsqrtd.instOrderedRingCastInt
code: instance : OrderedRing (ℤ√d) 
goal: OrderedRing (ℤ√↑d)

full_name: Zsqrtd.norm_eq_zero
code: theorem norm_eq_zero {d : ℤ} (h_nonsquare : ∀ n : ℤ, d ≠ n * n) (a : ℤ√d) : norm a = 0 ↔ a = 0 
goal: a.norm = 0 ↔ a = 0

full_name: Zsqrtd.hom_ext
code: @[ext]
theorem hom_ext [Ring R] {d : ℤ} (f g : ℤ√d →+* R) (h : f sqrtd = g sqrtd) : f = g 
goal: f = g

full_name: Zsqrtd.lift_symm_apply_coe
code: /-- 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`. -/
@[simps]
def lift {d : ℤ} : { r : R // r * r = ↑d } ≃ (ℤ√d →+* R) 
goal: ↑(Zsqrtd.lift.symm f) = f Zsqrtd.sqrtd

full_name: Zsqrtd.lift_apply_apply
code: /-- 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`. -/
@[simps]
def lift {d : ℤ} : { r : R // r * r = ↑d } ≃ (ℤ√d →+* R) 
goal: (Zsqrtd.lift r) a = ↑a.re + ↑a.im * ↑r

full_name: Zsqrtd.lift
code: /-- 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`. -/
@[simps]
def lift {d : ℤ} : { r : R // r * r = ↑d } ≃ (ℤ√d →+* R) 
goal: { r // r * r = ↑d } ≃ (ℤ√d →+* R)

full_name: Zsqrtd.lift_injective
code: /-- `lift r` is injective if `d` is non-square, and R has characteristic zero (that is, the map from
`ℤ` into `R` is injective). -/
theorem lift_injective [CharZero R] {d : ℤ} (r : { r : R // r * r = ↑d })
    (hd : ∀ n : ℤ, d ≠ n * n) : Function.Injective (lift r) 
goal: Function.Injective ⇑(Zsqrtd.lift r)

full_name: Zsqrtd.norm_eq_one_iff_mem_unitary
code: /-- An element of `ℤ√d` has norm equal to `1` if and only if it is contained in the submonoid
of unitary elements. -/
theorem norm_eq_one_iff_mem_unitary {d : ℤ} {a : ℤ√d} : a.norm = 1 ↔ a ∈ unitary (ℤ√d) 
goal: a.norm = 1 ↔ a ∈ unitary (ℤ√d)

full_name: Zsqrtd.mker_norm_eq_unitary
code: /-- The kernel of the norm map on `ℤ√d` equals the submonoid of unitary elements. -/
theorem mker_norm_eq_unitary {d : ℤ} : MonoidHom.mker (@normMonoidHom d) = unitary (ℤ√d) 
goal: MonoidHom.mker Zsqrtd.normMonoidHom = unitary (ℤ√d)