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

tactic: refine ⟨fun ha => (Zsqrtd.ext_iff _ _).mpr ?_, fun h => by rw [h, norm_zero]⟩
state_before: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
⊢ a.norm = 0 ↔ a = 0
state_after: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.norm = 0
⊢ a.re = re 0 ∧ a.im = im 0

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

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 = re 0 ∧ a.im = im 0
state_after: d : ℤ
h_nonsquare : ∀ (n : ℤ), d ≠ n * n
a : ℤ√d
ha : a.re * a.re = d * a.im * a.im
⊢ a.re = re 0 ∧ a.im = im 0

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 = re 0 ∧ a.im = im 0
state_after: 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 = re 0 ∧ a.im = im 0

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 = re 0 ∧ a.im = im 0

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

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 = re 0 ∧ a.im = im 0
state_after: 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 = re 0 ∧ a.im = im 0

tactic: haveI : Nonsquare d' := ⟨fun n h => h_nonsquare n <| 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 = re 0 ∧ a.im = im 0
state_after: 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 = re 0 ∧ a.im = im 0

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 = re 0 ∧ a.im = im 0
state_after: no goals

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 = re 0 ∧ a.im = im 0
state_after: 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 = re 0 ∧ a.im = im 0

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 = re 0 ∧ a.im = im 0
state_after: 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: 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
state_after: 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
state_after: 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: 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
state_after: no goals

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 = re 0 ∧ a.im = im 0
state_after: 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 = re 0 ∧ a.im = im 0

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 = re 0 ∧ a.im = im 0
state_after: no goals