Theorem: Zsqrtd.norm_eq_zero
File: Mathlib/NumberTheory/Zsqrtd/Basic.lean

tactic: refine' ⟨fun ha => ext.mpr _, fun h => by rw [h, norm_zero]⟩
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
⊢ norm a = 0 ↔ a = 0

tactic: dsimp only [norm] at ha
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : norm a = 0
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: rw [sub_eq_zero] at ha
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re - d * a.im * a.im = 0
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: by_cases h : 0 ≤ d
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: rw [h, norm_zero]
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
h : a = 0
⊢ norm a = 0

tactic: obtain ⟨d', rfl⟩ := Int.eq_ofNat_of_zero_le h
state_before: case pos
d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
h : 0 ≤ d
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: haveI : Nonsquare d' := ⟨fun n h => h_nonsquare n <| by exact_mod_cast h⟩
state_before: case pos.intro
d' : ℕ
h_nonsquare : ∀ (n : ℤ), ↑d' ≠ n * n
a : ℤ√↑d'
ha : a.re * a.re = ↑d' * a.im * a.im
h : 0 ≤ ↑d'
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: exact divides_sq_eq_zero_z ha
state_before: case pos.intro
d' : ℕ
h_nonsquare : ∀ (n : ℤ), ↑d' ≠ n * n
a : ℤ√↑d'
ha : a.re * a.re = ↑d' * a.im * a.im
h : 0 ≤ ↑d'
this : Nonsquare d'
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: exact_mod_cast h
state_before: d' : ℕ
h_nonsquare : ∀ (n : ℤ), ↑d' ≠ n * n
a : ℤ√↑d'
ha : a.re * a.re = ↑d' * a.im * a.im
h✝ : 0 ≤ ↑d'
n : ℕ
h : d' = n * n
⊢ ↑d' = ↑n * ↑n

tactic: push_neg at h
state_before: case neg
d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
h : ¬0 ≤ d
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: suffices a.re * a.re = 0 by
  rw [eq_zero_of_mul_self_eq_zero this] at ha⊢
  simpa only [true_and_iff, or_self_right, zero_re, zero_im, eq_self_iff_true, zero_eq_mul,
    mul_zero, mul_eq_zero, h.ne, false_or_iff, or_self_iff] using ha
state_before: case neg
d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
h : d < 0
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: apply _root_.le_antisymm _ (mul_self_nonneg _)
state_before: case neg
d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
h : d < 0
⊢ a.re * a.re = 0

tactic: rw [ha, mul_assoc]
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
h : d < 0
⊢ a.re * a.re ≤ 0

tactic: exact mul_nonpos_of_nonpos_of_nonneg h.le (mul_self_nonneg _)
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
h : d < 0
⊢ d * (a.im * a.im) ≤ 0

tactic: rw [eq_zero_of_mul_self_eq_zero this] at ha⊢
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
h : d < 0
this : a.re * a.re = 0
⊢ a.re = 0.re ∧ a.im = 0.im

tactic: simpa only [true_and_iff, or_self_right, zero_re, zero_im, eq_self_iff_true, zero_eq_mul,
  mul_zero, mul_eq_zero, h.ne, false_or_iff, or_self_iff] using ha
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : 0 * 0 = d * a.im * a.im
h : d < 0
this : a.re * a.re = 0
⊢ 0 = 0.re ∧ a.im = 0.im