l3lab/ntp-mathlib huggingface dataset:
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_1.refine_1
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ : ℤ√d
⊢ a✝.re + b✝.re = b✝.re + a✝.re

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_1.refine_2
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ : ℤ√d
⊢ a✝.im + b✝.im = b✝.im + a✝.im

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_2.refine_1
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ c✝ : ℤ√d
⊢ a✝.re * (b✝.re + c✝.re) + d * a✝.im * (b✝.im + c✝.im) =
    a✝.re * b✝.re + d * a✝.im * b✝.im + (a✝.re * c✝.re + d * a✝.im * c✝.im)

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_2.refine_2
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ c✝ : ℤ√d
⊢ a✝.re * (b✝.im + c✝.im) + a✝.im * (b✝.re + c✝.re) = a✝.re * b✝.im + a✝.im * b✝.re + (a✝.re * c✝.im + a✝.im * c✝.re)

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_3.refine_1
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ c✝ : ℤ√d
⊢ (a✝.re + b✝.re) * c✝.re + d * (a✝.im + b✝.im) * c✝.im =
    a✝.re * c✝.re + d * a✝.im * c✝.im + (b✝.re * c✝.re + d * b✝.im * c✝.im)

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_3.refine_2
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ c✝ : ℤ√d
⊢ (a✝.re + b✝.re) * c✝.im + (a✝.im + b✝.im) * c✝.re = a✝.re * c✝.im + a✝.im * c✝.re + (b✝.re * c✝.im + b✝.im * c✝.re)

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_6.refine_1
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ c✝ : ℤ√d
⊢ (a✝.re * b✝.re + d * a✝.im * b✝.im) * c✝.re + d * (a✝.re * b✝.im + a✝.im * b✝.re) * c✝.im =
    a✝.re * (b✝.re * c✝.re + d * b✝.im * c✝.im) + d * a✝.im * (b✝.re * c✝.im + b✝.im * c✝.re)

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_6.refine_2
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ c✝ : ℤ√d
⊢ (a✝.re * b✝.re + d * a✝.im * b✝.im) * c✝.im + (a✝.re * b✝.im + a✝.im * b✝.re) * c✝.re =
    a✝.re * (b✝.re * c✝.im + b✝.im * c✝.re) + a✝.im * (b✝.re * c✝.re + d * b✝.im * c✝.im)

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_9.refine_1
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ : ℤ√d
⊢ a✝.re * b✝.re + d * a✝.im * b✝.im = b✝.re * a✝.re + d * b✝.im * a✝.im

Next tactic:
ring
instance commRing : CommRing (ℤ√d) := by
  refine
  { Zsqrtd.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩,
    add_comm := ?_
    left_distrib := ?_
    right_distrib := ?_
    zero_mul := ?_
    mul_zero := ?_
    mul_assoc := ?_
    one_mul := ?_
    mul_one := ?_
    mul_comm := ?_ } <;>
  intros <;>
  refine ext.mpr ⟨?_, ?_⟩ <;>
  simp <;>
  

Proof state:
case refine_9.refine_2
d : ℤ
src✝ : AddGroupWithOne (ℤ√d) := addGroupWithOne
a✝ b✝ : ℤ√d
⊢ a✝.re * b✝.im + a✝.im * b✝.re = b✝.re * a✝.im + b✝.im * a✝.re

Next tactic:
ring
instance : AddMonoid (ℤ√d) := by 

Proof state:
d : ℤ
⊢ AddMonoid (ℤ√d)

Next tactic:
infer_instance
instance : Monoid (ℤ√d) := by 

Proof state:
d : ℤ
⊢ Monoid (ℤ√d)

Next tactic:
infer_instance
instance : CommMonoid (ℤ√d) := by 

Proof state:
d : ℤ
⊢ CommMonoid (ℤ√d)

Next tactic:
infer_instance
instance : CommSemigroup (ℤ√d) := by 

Proof state:
d : ℤ
⊢ CommSemigroup (ℤ√d)

Next tactic:
infer_instance
instance : Semigroup (ℤ√d) := by 

Proof state:
d : ℤ
⊢ Semigroup (ℤ√d)

Next tactic:
infer_instance
instance : AddCommSemigroup (ℤ√d) := by 

Proof state:
d : ℤ
⊢ AddCommSemigroup (ℤ√d)

Next tactic:
infer_instance
instance : AddSemigroup (ℤ√d) := by 

Proof state:
d : ℤ
⊢ AddSemigroup (ℤ√d)

Next tactic:
infer_instance
instance : CommSemiring (ℤ√d) := by 

Proof state:
d : ℤ
⊢ CommSemiring (ℤ√d)

Next tactic:
infer_instance
instance : Semiring (ℤ√d) := by 

Proof state:
d : ℤ
⊢ Semiring (ℤ√d)

Next tactic:
infer_instance
instance : Ring (ℤ√d) := by 

Proof state:
d : ℤ
⊢ Ring (ℤ√d)

Next tactic:
infer_instance
instance : Distrib (ℤ√d) := by 

Proof state:
d : ℤ
⊢ Distrib (ℤ√d)

Next tactic:
infer_instance
instance : StarRing (ℤ√d) where
  star_involutive x := ext.mpr ⟨rfl, neg_neg _⟩
  star_mul a b := ext.mpr ⟨by 

Proof state:
d : ℤ
a b : ℤ√d
⊢ (star (a * b)).re = (star b * star a).re

Next tactic:
simp
instance : StarRing (ℤ√d) where
  star_involutive x := ext.mpr ⟨rfl, neg_neg _⟩
  star_mul a b := ext.mpr ⟨by simp; 

Proof state:
d : ℤ
a b : ℤ√d
⊢ a.re * b.re + d * a.im * b.im = b.re * a.re + d * b.im * a.im

Next tactic:
ring
instance : StarRing (ℤ√d) where
  star_involutive x := ext.mpr ⟨rfl, neg_neg _⟩
  star_mul a b := ext.mpr ⟨by simp; ring, by 

Proof state:
d : ℤ
a b : ℤ√d
⊢ (star (a * b)).im = (star b * star a).im

Next tactic:
simp
instance : StarRing (ℤ√d) where
  star_involutive x := ext.mpr ⟨rfl, neg_neg _⟩
  star_mul a b := ext.mpr ⟨by simp; ring, by simp; 

Proof state:
d : ℤ
a b : ℤ√d
⊢ -(a.im * b.re) + -(a.re * b.im) = -(b.re * a.im) + -(b.im * a.re)

Next tactic:
ring
instance nontrivial : Nontrivial (ℤ√d) :=
  ⟨⟨0, 1, ext.not.mpr <| by 

Proof state:
d : ℤ
⊢ ¬(0.re = 1.re ∧ 0.im = 1.im)

Next tactic:
simp
@[simp]
theorem coe_int_re (n : ℤ) : (n : ℤ√d).re = n := by 

Proof state:
d n : ℤ
⊢ (↑n).re = n

Next tactic:
cases n
@[simp]
theorem coe_int_re (n : ℤ) : (n : ℤ√d).re = n := by cases n <;> 

Proof state:
case ofNat
d : ℤ
a✝ : ℕ
⊢ (↑(Int.ofNat a✝)).re = Int.ofNat a✝

Next tactic:
rfl
@[simp]
theorem coe_int_re (n : ℤ) : (n : ℤ√d).re = n := by cases n <;> 

Proof state:
case negSucc
d : ℤ
a✝ : ℕ
⊢ (↑(Int.negSucc a✝)).re = Int.negSucc a✝

Next tactic:
rfl
@[simp]
theorem coe_int_im (n : ℤ) : (n : ℤ√d).im = 0 := by 

Proof state:
d n : ℤ
⊢ (↑n).im = 0

Next tactic:
cases n
@[simp]
theorem coe_int_im (n : ℤ) : (n : ℤ√d).im = 0 := by cases n <;> 

Proof state:
case ofNat
d : ℤ
a✝ : ℕ
⊢ (↑(Int.ofNat a✝)).im = 0

Next tactic:
rfl
@[simp]
theorem coe_int_im (n : ℤ) : (n : ℤ√d).im = 0 := by cases n <;> 

Proof state:
case negSucc
d : ℤ
a✝ : ℕ
⊢ (↑(Int.negSucc a✝)).im = 0

Next tactic:
rfl
theorem coe_int_val (n : ℤ) : (n : ℤ√d) = ⟨n, 0⟩ := by 

Proof state:
d n : ℤ
⊢ ↑n = { re := n, im := 0 }

Next tactic:
simp [ext]
instance : CharZero (ℤ√d) where cast_injective m n := by 

Proof state:
d : ℤ
m n : ℕ
⊢ ↑m = ↑n → m = n

Next tactic:
simp [ext]
@[simp]
theorem ofInt_eq_coe (n : ℤ) : (ofInt n : ℤ√d) = n := by 

Proof state:
d n : ℤ
⊢ ofInt n = ↑n

Next tactic:
simp [ext, ofInt_re, ofInt_im]
@[simp]
theorem smul_val (n x y : ℤ) : (n : ℤ√d) * ⟨x, y⟩ = ⟨n * x, n * y⟩ := by 

Proof state:
d n x y : ℤ
⊢ ↑n * { re := x, im := y } = { re := n * x, im := n * y }

Next tactic:
simp [ext]
theorem smul_re (a : ℤ) (b : ℤ√d) : (↑a * b).re = a * b.re := by 

Proof state:
d a : ℤ
b : ℤ√d
⊢ (↑a * b).re = a * b.re

Next tactic:
simp
theorem smul_im (a : ℤ) (b : ℤ√d) : (↑a * b).im = a * b.im := by 

Proof state:
d a : ℤ
b : ℤ√d
⊢ (↑a * b).im = a * b.im

Next tactic:
simp
@[simp]
theorem muld_val (x y : ℤ) : sqrtd (d := d) * ⟨x, y⟩ = ⟨d * y, x⟩ := by 

Proof state:
d x y : ℤ
⊢ sqrtd * { re := x, im := y } = { re := d * y, im := x }

Next tactic:
simp [ext]
@[simp]
theorem dmuld : sqrtd (d := d) * sqrtd (d := d) = d := by 

Proof state:
d : ℤ
⊢ sqrtd * sqrtd = ↑d

Next tactic:
simp [ext]
@[simp]
theorem smuld_val (n x y : ℤ) : sqrtd * (n : ℤ√d) * ⟨x, y⟩ = ⟨d * n * y, n * x⟩ := by 

Proof state:
d n x y : ℤ
⊢ sqrtd * ↑n * { re := x, im := y } = { re := d * n * y, im := n * x }

Next tactic:
simp [ext]
theorem decompose {x y : ℤ} : (⟨x, y⟩ : ℤ√d) = x + sqrtd (d := d) * y := by 

Proof state:
d x y : ℤ
⊢ { re := x, im := y } = ↑x + sqrtd * ↑y

Next tactic:
simp [ext]
theorem mul_star {x y : ℤ} : (⟨x, y⟩ * star ⟨x, y⟩ : ℤ√d) = x * x - d * y * y := by
  

Proof state:
d x y : ℤ
⊢ { re := x, im := y } * star { re := x, im := y } = ↑x * ↑x - ↑d * ↑y * ↑y

Next tactic:
simp [ext, sub_eq_add_neg, mul_comm]
protected theorem coe_int_inj {m n : ℤ} (h : (↑m : ℤ√d) = ↑n) : m = n := by
  

Proof state:
d m n : ℤ
h : ↑m = ↑n
⊢ m = n

Next tactic:
simpa using congr_arg re h
theorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by
  

Proof state:
d z : ℤ
a : ℤ√d
⊢ ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im

Next tactic:
constructor
theorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by
  constructor
  · 

Proof state:
case mp
d z : ℤ
a : ℤ√d
⊢ ↑z ∣ a → z ∣ a.re ∧ z ∣ a.im

Next tactic:
rintro ⟨x, rfl⟩
theorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by
  constructor
  · rintro ⟨x, rfl⟩
    

Proof state:
case mp.intro
d z : ℤ
x : ℤ√d
⊢ z ∣ (↑z * x).re ∧ z ∣ (↑z * x).im

Next tactic:
simp only [add_zero, coe_int_re, zero_mul, mul_im, dvd_mul_right, and_self_iff,
      mul_re, mul_zero, coe_int_im]
theorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by
  constructor
  · rintro ⟨x, rfl⟩
    simp only [add_zero, coe_int_re, zero_mul, mul_im, dvd_mul_right, and_self_iff,
      mul_re, mul_zero, coe_int_im]
  · 

Proof state:
case mpr
d z : ℤ
a : ℤ√d
⊢ z ∣ a.re ∧ z ∣ a.im → ↑z ∣ a

Next tactic:
rintro ⟨⟨r, hr⟩, ⟨i, hi⟩⟩
theorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by
  constructor
  · rintro ⟨x, rfl⟩
    simp only [add_zero, coe_int_re, zero_mul, mul_im, dvd_mul_right, and_self_iff,
      mul_re, mul_zero, coe_int_im]
  · rintro ⟨⟨r, hr⟩, ⟨i, hi⟩⟩
    

Proof state:
case mpr.intro.intro.intro
d z : ℤ
a : ℤ√d
r : ℤ
hr : a.re = z * r
i : ℤ
hi : a.im = z * i
⊢ ↑z ∣ a

Next tactic:
use ⟨r, i⟩
theorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by
  constructor
  · rintro ⟨x, rfl⟩
    simp only [add_zero, coe_int_re, zero_mul, mul_im, dvd_mul_right, and_self_iff,
      mul_re, mul_zero, coe_int_im]
  · rintro ⟨⟨r, hr⟩, ⟨i, hi⟩⟩
    use ⟨r, i⟩
    

Proof state:
case h
d z : ℤ
a : ℤ√d
r : ℤ
hr : a.re = z * r
i : ℤ
hi : a.im = z * i
⊢ a = ↑z * { re := r, im := i }

Next tactic:
rw [smul_val, ext]
theorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by
  constructor
  · rintro ⟨x, rfl⟩
    simp only [add_zero, coe_int_re, zero_mul, mul_im, dvd_mul_right, and_self_iff,
      mul_re, mul_zero, coe_int_im]
  · rintro ⟨⟨r, hr⟩, ⟨i, hi⟩⟩
    use ⟨r, i⟩
    rw [smul_val, ext]
    

Proof state:
case h
d z : ℤ
a : ℤ√d
r : ℤ
hr : a.re = z * r
i : ℤ
hi : a.im = z * i
⊢ a.re = { re := z * r, im := z * i }.re ∧ a.im = { re := z * r, im := z * i }.im

Next tactic:
exact ⟨hr, hi⟩
@[simp, norm_cast]
theorem coe_int_dvd_coe_int (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by
  

Proof state:
d a b : ℤ
⊢ ↑a ∣ ↑b ↔ a ∣ b

Next tactic:
rw [coe_int_dvd_iff]
@[simp, norm_cast]
theorem coe_int_dvd_coe_int (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by
  rw [coe_int_dvd_iff]
  

Proof state:
d a b : ℤ
⊢ a ∣ (↑b).re ∧ a ∣ (↑b).im ↔ a ∣ b

Next tactic:
constructor
@[simp, norm_cast]
theorem coe_int_dvd_coe_int (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by
  rw [coe_int_dvd_iff]
  constructor
  · 

Proof state:
case mp
d a b : ℤ
⊢ a ∣ (↑b).re ∧ a ∣ (↑b).im → a ∣ b

Next tactic:
rintro ⟨hre, -⟩
@[simp, norm_cast]
theorem coe_int_dvd_coe_int (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by
  rw [coe_int_dvd_iff]
  constructor
  · rintro ⟨hre, -⟩
    

Proof state:
case mp.intro
d a b : ℤ
hre : a ∣ (↑b).re
⊢ a ∣ b

Next tactic:
rwa [coe_int_re] at hre
@[simp, norm_cast]
theorem coe_int_dvd_coe_int (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by
  rw [coe_int_dvd_iff]
  constructor
  · rintro ⟨hre, -⟩
    rwa [coe_int_re] at hre
  · 

Proof state:
case mpr
d a b : ℤ
⊢ a ∣ b → a ∣ (↑b).re ∧ a ∣ (↑b).im

Next tactic:
rw [coe_int_re, coe_int_im]
@[simp, norm_cast]
theorem coe_int_dvd_coe_int (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by
  rw [coe_int_dvd_iff]
  constructor
  · rintro ⟨hre, -⟩
    rwa [coe_int_re] at hre
  · rw [coe_int_re, coe_int_im]
    

Proof state:
case mpr
d a b : ℤ
⊢ a ∣ b → a ∣ b ∧ a ∣ 0

Next tactic:
exact fun hc => ⟨hc, dvd_zero a⟩
protected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) :
    b = c := by
  

Proof state:
d a : ℤ
b c : ℤ√d
ha : a ≠ 0
h : ↑a * b = ↑a * c
⊢ b = c

Next tactic:
rw [ext] at h ⊢
protected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) :
    b = c := by
  rw [ext] at h ⊢
  

Proof state:
d a : ℤ
b c : ℤ√d
ha : a ≠ 0
h : (↑a * b).re = (↑a * c).re ∧ (↑a * b).im = (↑a * c).im
⊢ b.re = c.re ∧ b.im = c.im

Next tactic:
apply And.imp _ _ h
protected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) :
    b = c := by
  rw [ext] at h ⊢
  apply And.imp _ _ h <;> 

Proof state:
d a : ℤ
b c : ℤ√d
ha : a ≠ 0
h : (↑a * b).re = (↑a * c).re ∧ (↑a * b).im = (↑a * c).im
⊢ (↑a * b).re = (↑a * c).re → b.re = c.re

Next tactic:
simpa only [smul_re, smul_im] using mul_left_cancel₀ ha
protected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) :
    b = c := by
  rw [ext] at h ⊢
  apply And.imp _ _ h <;> 

Proof state:
d a : ℤ
b c : ℤ√d
ha : a ≠ 0
h : (↑a * b).re = (↑a * c).re ∧ (↑a * b).im = (↑a * c).im
⊢ (↑a * b).im = (↑a * c).im → b.im = c.im

Next tactic:
simpa only [smul_re, smul_im] using mul_left_cancel₀ ha
theorem gcd_eq_zero_iff (a : ℤ√d) : Int.gcd a.re a.im = 0 ↔ a = 0 := by
  

Proof state:
d : ℤ
a : ℤ√d
⊢ Int.gcd a.re a.im = 0 ↔ a = 0

Next tactic:
simp only [Int.gcd_eq_zero_iff, ext, eq_self_iff_true, zero_im, zero_re]
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  

Proof state:
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
⊢ IsCoprime b.re b.im

Next tactic:
apply isCoprime_of_dvd
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · 

Proof state:
case nonzero
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
⊢ ¬(b.re = 0 ∧ b.im = 0)

Next tactic:
rintro ⟨hre, him⟩
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    

Proof state:
case nonzero.intro
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
hre : b.re = 0
him : b.im = 0
⊢ False

Next tactic:
obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      

Proof state:
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
hre : b.re = 0
him : b.im = 0
⊢ b = 0

Next tactic:
simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    

Proof state:
case nonzero.intro
d : ℤ
a : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : 0 ∣ a
hre : 0.re = 0
him : 0.im = 0
⊢ False

Next tactic:
rw [zero_dvd_iff] at hdvd
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    

Proof state:
case nonzero.intro
d : ℤ
a : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : a = 0
hre : 0.re = 0
him : 0.im = 0
⊢ False

Next tactic:
simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · 

Proof state:
case H
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
⊢ ∀ z ∈ nonunits ℤ, z ≠ 0 → z ∣ b.re → ¬z ∣ b.im

Next tactic:
rintro z hz - hzdvdu hzdvdv
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · rintro z hz - hzdvdu hzdvdv
    

Proof state:
case H
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
z : ℤ
hz : z ∈ nonunits ℤ
hzdvdu : z ∣ b.re
hzdvdv : z ∣ b.im
⊢ False

Next tactic:
apply hz
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · rintro z hz - hzdvdu hzdvdv
    apply hz
    

Proof state:
case H
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
z : ℤ
hz : z ∈ nonunits ℤ
hzdvdu : z ∣ b.re
hzdvdv : z ∣ b.im
⊢ IsUnit z

Next tactic:
obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im := by
      rw [← coe_int_dvd_iff]
      apply dvd_trans _ hdvd
      rw [coe_int_dvd_iff]
      exact ⟨hzdvdu, hzdvdv⟩
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · rintro z hz - hzdvdu hzdvdv
    apply hz
    obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im := by
      

Proof state:
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
z : ℤ
hz : z ∈ nonunits ℤ
hzdvdu : z ∣ b.re
hzdvdv : z ∣ b.im
⊢ z ∣ a.re ∧ z ∣ a.im

Next tactic:
rw [← coe_int_dvd_iff]
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · rintro z hz - hzdvdu hzdvdv
    apply hz
    obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im := by
      rw [← coe_int_dvd_iff]
      

Proof state:
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
z : ℤ
hz : z ∈ nonunits ℤ
hzdvdu : z ∣ b.re
hzdvdv : z ∣ b.im
⊢ ↑z ∣ a

Next tactic:
apply dvd_trans _ hdvd
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · rintro z hz - hzdvdu hzdvdv
    apply hz
    obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im := by
      rw [← coe_int_dvd_iff]
      apply dvd_trans _ hdvd
      

Proof state:
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
z : ℤ
hz : z ∈ nonunits ℤ
hzdvdu : z ∣ b.re
hzdvdv : z ∣ b.im
⊢ ↑z ∣ b

Next tactic:
rw [coe_int_dvd_iff]
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · rintro z hz - hzdvdu hzdvdv
    apply hz
    obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im := by
      rw [← coe_int_dvd_iff]
      apply dvd_trans _ hdvd
      rw [coe_int_dvd_iff]
      

Proof state:
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
z : ℤ
hz : z ∈ nonunits ℤ
hzdvdu : z ∣ b.re
hzdvdv : z ∣ b.im
⊢ z ∣ b.re ∧ z ∣ b.im

Next tactic:
exact ⟨hzdvdu, hzdvdv⟩
theorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :
    IsCoprime b.re b.im := by
  apply isCoprime_of_dvd
  · rintro ⟨hre, him⟩
    obtain rfl : b = 0 := by
      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]
    rw [zero_dvd_iff] at hdvd
    simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime
  · rintro z hz - hzdvdu hzdvdv
    apply hz
    obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im := by
      rw [← coe_int_dvd_iff]
      apply dvd_trans _ hdvd
      rw [coe_int_dvd_iff]
      exact ⟨hzdvdu, hzdvdv⟩
    

Proof state:
case H.intro
d : ℤ
a b : ℤ√d
hcoprime : IsCoprime a.re a.im
hdvd : b ∣ a
z : ℤ
hz : z ∈ nonunits ℤ
hzdvdu : z ∣ b.re
hzdvdv : z ∣ b.im
ha : z ∣ a.re
hb : z ∣ a.im
⊢ IsUnit z

Next tactic:
exact hcoprime.isUnit_of_dvd' ha hb