l3lab/ntp-mathlib huggingface dataset:
@[simp, isROrC_simps]
theorem I_im' (z : K) : im (I : K) * im z = im z := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ im I * im z = im z

Next tactic:
rw [mul_comm, I_im]
@[isROrC_simps] -- porting note: was `simp`
theorem I_mul_re (z : K) : re (I * z) = -im z := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ re (I * z) = -im z

Next tactic:
simp only [I_re, zero_sub, I_im', zero_mul, mul_re]
@[simp, isROrC_simps]
theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
r : ℝ
⊢ (starRingEnd K) ↑r = ↑r

Next tactic:
rw [ext_iff]
@[simp, isROrC_simps]
theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by
  rw [ext_iff]
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
r : ℝ
⊢ re ((starRingEnd K) ↑r) = re ↑r ∧ im ((starRingEnd K) ↑r) = im ↑r

Next tactic:
simp only [ofReal_im, conj_im, eq_self_iff_true, conj_re, and_self_iff, neg_zero]
@[isROrC_simps] -- porting note: was a `simp` but `simp` can prove it
theorem conj_neg_I : conj (-I) = (I : K) := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
⊢ (starRingEnd K) (-I) = I

Next tactic:
rw [map_neg, conj_I, neg_neg]
theorem conj_eq_re_sub_im (z : K) : conj z = re z - im z * I :=
  (congr_arg conj (re_add_im z).symm).trans <| by
    

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ (starRingEnd K) (↑(re z) + ↑(im z) * I) = ↑(re z) - ↑(im z) * I

Next tactic:
rw [map_add, map_mul, conj_I, conj_ofReal, conj_ofReal, mul_neg, sub_eq_add_neg]
theorem sub_conj (z : K) : z - conj z = 2 * im z * I :=
  calc
    z - conj z = re z + im z * I - (re z - im z * I) := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ z - (starRingEnd K) z = ↑(re z) + ↑(im z) * I - (↑(re z) - ↑(im z) * I)

Next tactic:
rw [re_add_im, ← conj_eq_re_sub_im]
theorem sub_conj (z : K) : z - conj z = 2 * im z * I :=
  calc
    z - conj z = re z + im z * I - (re z - im z * I) := by rw [re_add_im, ← conj_eq_re_sub_im]
    _ = 2 * im z * I := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ ↑(re z) + ↑(im z) * I - (↑(re z) - ↑(im z) * I) = 2 * ↑(im z) * I

Next tactic:
rw [add_sub_sub_cancel, ← two_mul, mul_assoc]
@[isROrC_simps]
theorem conj_smul (r : ℝ) (z : K) : conj (r • z) = r • conj z := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
r : ℝ
z : K
⊢ (starRingEnd K) (r • z) = r • (starRingEnd K) z

Next tactic:
rw [conj_eq_re_sub_im, conj_eq_re_sub_im, smul_re, smul_im, ofReal_mul, ofReal_mul,
    real_smul_eq_coe_mul r (_ - _), mul_sub, mul_assoc]
theorem add_conj (z : K) : z + conj z = 2 * re z :=
  calc
    z + conj z = re z + im z * I + (re z - im z * I) := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ z + (starRingEnd K) z = ↑(re z) + ↑(im z) * I + (↑(re z) - ↑(im z) * I)

Next tactic:
rw [re_add_im, conj_eq_re_sub_im]
theorem add_conj (z : K) : z + conj z = 2 * re z :=
  calc
    z + conj z = re z + im z * I + (re z - im z * I) := by rw [re_add_im, conj_eq_re_sub_im]
    _ = 2 * re z := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ ↑(re z) + ↑(im z) * I + (↑(re z) - ↑(im z) * I) = 2 * ↑(re z)

Next tactic:
rw [add_add_sub_cancel, two_mul]
theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ ↑(re z) = (z + (starRingEnd K) z) / 2

Next tactic:
rw [add_conj, mul_div_cancel_left (re z : K) two_ne_zero]
theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ ↑(im z) = I * ((starRingEnd K) z - z) / 2

Next tactic:
rw [← neg_inj, ← ofReal_neg, ← I_mul_re, re_eq_add_conj, map_mul, conj_I, ← neg_div, ← mul_neg,
    neg_sub, mul_sub, neg_mul, sub_eq_add_neg]
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ TFAE [(starRingEnd K) z = z, ∃ r, ↑r = z, ↑(re z) = z, im z = 0]

Next tactic:
tfae_have 1 → 4
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · 

Proof state:
case tfae_1_to_4
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ (starRingEnd K) z = z → im z = 0

Next tactic:
intro h
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    

Proof state:
case tfae_1_to_4
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
h : (starRingEnd K) z = z
⊢ im z = 0

Next tactic:
rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
⊢ TFAE [(starRingEnd K) z = z, ∃ r, ↑r = z, ↑(re z) = z, im z = 0]

Next tactic:
tfae_have 4 → 3
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · 

Proof state:
case tfae_4_to_3
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
⊢ im z = 0 → ↑(re z) = z

Next tactic:
intro h
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · intro h
    

Proof state:
case tfae_4_to_3
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
h : im z = 0
⊢ ↑(re z) = z

Next tactic:
conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · intro h
    conv_rhs => 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
h : im z = 0
| z

Next tactic:
rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · intro h
    conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
tfae_4_to_3 : im z = 0 → ↑(re z) = z
⊢ TFAE [(starRingEnd K) z = z, ∃ r, ↑r = z, ↑(re z) = z, im z = 0]

Next tactic:
tfae_have 3 → 2
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · intro h
    conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
  tfae_have 3 → 2; 

Proof state:
case tfae_3_to_2
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
tfae_4_to_3 : im z = 0 → ↑(re z) = z
⊢ ↑(re z) = z → ∃ r, ↑r = z
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
tfae_4_to_3 : im z = 0 → ↑(re z) = z
tfae_3_to_2 : ↑(re z) = z → ∃ r, ↑r = z
⊢ TFAE [(starRingEnd K) z = z, ∃ r, ↑r = z, ↑(re z) = z, im z = 0]

Next tactic:
exact fun h => ⟨_, h⟩
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · intro h
    conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
  tfae_have 3 → 2; exact fun h => ⟨_, h⟩
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
tfae_4_to_3 : im z = 0 → ↑(re z) = z
tfae_3_to_2 : ↑(re z) = z → ∃ r, ↑r = z
⊢ TFAE [(starRingEnd K) z = z, ∃ r, ↑r = z, ↑(re z) = z, im z = 0]

Next tactic:
tfae_have 2 → 1
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · intro h
    conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
  tfae_have 3 → 2; exact fun h => ⟨_, h⟩
  tfae_have 2 → 1; 

Proof state:
case tfae_2_to_1
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
tfae_4_to_3 : im z = 0 → ↑(re z) = z
tfae_3_to_2 : ↑(re z) = z → ∃ r, ↑r = z
⊢ (∃ r, ↑r = z) → (starRingEnd K) z = z
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
tfae_4_to_3 : im z = 0 → ↑(re z) = z
tfae_3_to_2 : ↑(re z) = z → ∃ r, ↑r = z
tfae_2_to_1 : (∃ r, ↑r = z) → (starRingEnd K) z = z
⊢ TFAE [(starRingEnd K) z = z, ∃ r, ↑r = z, ↑(re z) = z, im z = 0]

Next tactic:
exact fun ⟨r, hr⟩ => hr ▸ conj_ofReal _
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
  tfae_have 1 → 4
  · intro h
    rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
      ofReal_zero]
  tfae_have 4 → 3
  · intro h
    conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
  tfae_have 3 → 2; exact fun h => ⟨_, h⟩
  tfae_have 2 → 1; exact fun ⟨r, hr⟩ => hr ▸ conj_ofReal _
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
tfae_1_to_4 : (starRingEnd K) z = z → im z = 0
tfae_4_to_3 : im z = 0 → ↑(re z) = z
tfae_3_to_2 : ↑(re z) = z → ∃ r, ↑r = z
tfae_2_to_1 : (∃ r, ↑r = z) → (starRingEnd K) z = z
⊢ TFAE [(starRingEnd K) z = z, ∃ r, ↑r = z, ↑(re z) = z, im z = 0]

Next tactic:
tfae_finish
theorem conj_eq_iff_real {z : K} : conj z = z ↔ ∃ r : ℝ, z = (r : K) :=
  ((is_real_TFAE z).out 0 1).trans <| by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ (∃ r, ↑r = z) ↔ ∃ r, z = ↑r

Next tactic:
simp only [eq_comm]
/-- The norm squared function. -/
def normSq : K →*₀ ℝ where
  toFun z := re z * re z + im z * im z
  map_zero' := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
⊢ (fun z => re z * re z + im z * im z) 0 = 0

Next tactic:
simp only [add_zero, mul_zero, map_zero]
/-- The norm squared function. -/
def normSq : K →*₀ ℝ where
  toFun z := re z * re z + im z * im z
  map_zero' := by simp only [add_zero, mul_zero, map_zero]
  map_one' := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
⊢ ZeroHom.toFun { toFun := fun z => re z * re z + im z * im z, map_zero' := (_ : re 0 * re 0 + im 0 * im 0 = 0) } 1 = 1

Next tactic:
simp only [one_im, add_zero, mul_one, one_re, mul_zero]
/-- The norm squared function. -/
def normSq : K →*₀ ℝ where
  toFun z := re z * re z + im z * im z
  map_zero' := by simp only [add_zero, mul_zero, map_zero]
  map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero]
  map_mul' z w := by
    

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z w : K
⊢ ZeroHom.toFun { toFun := fun z => re z * re z + im z * im z, map_zero' := (_ : re 0 * re 0 + im 0 * im 0 = 0) }
      (z * w) =
    ZeroHom.toFun { toFun := fun z => re z * re z + im z * im z, map_zero' := (_ : re 0 * re 0 + im 0 * im 0 = 0) } z *
      ZeroHom.toFun { toFun := fun z => re z * re z + im z * im z, map_zero' := (_ : re 0 * re 0 + im 0 * im 0 = 0) } w

Next tactic:
simp only [mul_im, mul_re]
/-- The norm squared function. -/
def normSq : K →*₀ ℝ where
  toFun z := re z * re z + im z * im z
  map_zero' := by simp only [add_zero, mul_zero, map_zero]
  map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero]
  map_mul' z w := by
    simp only [mul_im, mul_re]
    

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z w : K
⊢ (re z * re w - im z * im w) * (re z * re w - im z * im w) +
      (re z * im w + im z * re w) * (re z * im w + im z * re w) =
    (re z * re z + im z * im z) * (re w * re w + im w * im w)

Next tactic:
ring
@[simp, isROrC_simps]
theorem normSq_pos {z : K} : 0 < normSq z ↔ z ≠ 0 := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ 0 < normSq z ↔ z ≠ 0

Next tactic:
rw [lt_iff_le_and_ne, Ne, eq_comm]
@[simp, isROrC_simps]
theorem normSq_pos {z : K} : 0 < normSq z ↔ z ≠ 0 := by
  rw [lt_iff_le_and_ne, Ne, eq_comm]; 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ 0 ≤ normSq z ∧ ¬normSq z = 0 ↔ z ≠ 0

Next tactic:
simp [normSq_nonneg]
@[simp, isROrC_simps]
theorem normSq_neg (z : K) : normSq (-z) = normSq z := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ normSq (-z) = normSq z

Next tactic:
simp only [normSq_eq_def', norm_neg]
@[simp, isROrC_simps]
theorem normSq_conj (z : K) : normSq (conj z) = normSq z := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ normSq ((starRingEnd K) z) = normSq z

Next tactic:
simp only [normSq_apply, neg_mul, mul_neg, neg_neg, isROrC_simps]
theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z w : K
⊢ normSq (z + w) = normSq z + normSq w + 2 * re (z * (starRingEnd K) w)

Next tactic:
simp only [normSq_apply, map_add, isROrC_simps]
theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by
  simp only [normSq_apply, map_add, isROrC_simps]
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z w : K
⊢ (re z + re w) * (re z + re w) + (im z + im w) * (im z + im w) =
    re z * re z + im z * im z + (re w * re w + im w * im w) + 2 * (re z * re w - im z * -im w)

Next tactic:
ring
theorem mul_conj (z : K) : z * conj z = (normSq z : K) := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ z * (starRingEnd K) z = ↑(normSq z)

Next tactic:
apply ext
theorem mul_conj (z : K) : z * conj z = (normSq z : K) := by
  apply ext <;> 

Proof state:
case hre
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ re (z * (starRingEnd K) z) = re ↑(normSq z)

Next tactic:
simp only [normSq_apply, isROrC_simps, map_add, mul_zero]
theorem mul_conj (z : K) : z * conj z = (normSq z : K) := by
  apply ext <;> 

Proof state:
case him
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ im (z * (starRingEnd K) z) = im ↑(normSq z)

Next tactic:
simp only [normSq_apply, isROrC_simps, map_add, mul_zero]
theorem mul_conj (z : K) : z * conj z = (normSq z : K) := by
  apply ext <;> simp only [normSq_apply, isROrC_simps, map_add, mul_zero] <;> 

Proof state:
case hre
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ re z * re z - im z * -im z = re z * re z - 0 + (im z * im z - 0)

Next tactic:
ring
theorem mul_conj (z : K) : z * conj z = (normSq z : K) := by
  apply ext <;> simp only [normSq_apply, isROrC_simps, map_add, mul_zero] <;> 

Proof state:
case him
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ re z * -im z + im z * re z = 0 + 0 * re z + (0 + 0 * im z)

Next tactic:
ring
theorem conj_mul (x : K) : conj x * x = (normSq x : K) := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
x : K
⊢ (starRingEnd K) x * x = ↑(normSq x)

Next tactic:
rw [mul_comm, mul_conj]
theorem normSq_sub (z w : K) : normSq (z - w) = normSq z + normSq w - 2 * re (z * conj w) := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z w : K
⊢ normSq (z - w) = normSq z + normSq w - 2 * re (z * (starRingEnd K) w)

Next tactic:
simp only [normSq_add, sub_eq_add_neg, map_neg, mul_neg, normSq_neg, map_neg]
theorem sqrt_normSq_eq_norm {z : K} : Real.sqrt (normSq z) = ‖z‖ := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ Real.sqrt (normSq z) = ‖z‖

Next tactic:
rw [normSq_eq_def', Real.sqrt_sq (norm_nonneg _)]
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ z⁻¹ = (starRingEnd K) z * ↑(‖z‖ ^ 2)⁻¹

Next tactic:
rcases eq_or_ne z 0 with (rfl | h₀)
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
  rcases eq_or_ne z 0 with (rfl | h₀)
  · 

Proof state:
case inl
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
⊢ 0⁻¹ = (starRingEnd K) 0 * ↑(‖0‖ ^ 2)⁻¹

Next tactic:
simp
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
  rcases eq_or_ne z 0 with (rfl | h₀)
  · simp
  · 

Proof state:
case inr
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
h₀ : z ≠ 0
⊢ z⁻¹ = (starRingEnd K) z * ↑(‖z‖ ^ 2)⁻¹

Next tactic:
apply inv_eq_of_mul_eq_one_right
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
  rcases eq_or_ne z 0 with (rfl | h₀)
  · simp
  · apply inv_eq_of_mul_eq_one_right
    

Proof state:
case inr.a
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
h₀ : z ≠ 0
⊢ z * ((starRingEnd K) z * ↑(‖z‖ ^ 2)⁻¹) = 1

Next tactic:
rw [← mul_assoc, mul_conj, ofReal_inv, ← normSq_eq_def', mul_inv_cancel]
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
  rcases eq_or_ne z 0 with (rfl | h₀)
  · simp
  · apply inv_eq_of_mul_eq_one_right
    rw [← mul_assoc, mul_conj, ofReal_inv, ← normSq_eq_def', mul_inv_cancel]
    

Proof state:
case inr.a
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
h₀ : z ≠ 0
⊢ ↑(normSq z) ≠ 0

Next tactic:
rwa [ofReal_ne_zero, Ne.def, normSq_eq_zero]
@[simp, isROrC_simps]
theorem inv_re (z : K) : re z⁻¹ = re z / normSq z := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ re z⁻¹ = re z / normSq z

Next tactic:
rw [inv_def, normSq_eq_def', mul_comm, ofReal_mul_re, conj_re, div_eq_inv_mul]
@[simp, isROrC_simps]
theorem inv_im (z : K) : im z⁻¹ = -im z / normSq z := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ im z⁻¹ = -im z / normSq z

Next tactic:
rw [inv_def, normSq_eq_def', mul_comm, ofReal_mul_im, conj_im, div_eq_inv_mul]
theorem div_re (z w : K) : re (z / w) = re z * re w / normSq w + im z * im w / normSq w := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z w : K
⊢ re (z / w) = re z * re w / normSq w + im z * im w / normSq w

Next tactic:
simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, neg_mul, mul_neg, neg_neg, map_neg,
    isROrC_simps]
theorem div_im (z w : K) : im (z / w) = im z * re w / normSq w - re z * im w / normSq w := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z w : K
⊢ im (z / w) = im z * re w / normSq w - re z * im w / normSq w

Next tactic:
simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, neg_mul, mul_neg, map_neg,
    isROrC_simps]
theorem div_re_ofReal {z : K} {r : ℝ} : re (z / r) = re z / r := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
r : ℝ
⊢ re (z / ↑r) = re z / r

Next tactic:
rw [div_eq_inv_mul, div_eq_inv_mul, ← ofReal_inv, ofReal_mul_re]
@[simp, isROrC_simps]
theorem inv_I : (I : K)⁻¹ = -I := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
⊢ I⁻¹ = -I

Next tactic:
by_cases h : (I : K) = 0
@[simp, isROrC_simps]
theorem inv_I : (I : K)⁻¹ = -I := by
  by_cases h : (I : K) = 0
  · 

Proof state:
case pos
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
h : I = 0
⊢ I⁻¹ = -I

Next tactic:
simp [h]
@[simp, isROrC_simps]
theorem inv_I : (I : K)⁻¹ = -I := by
  by_cases h : (I : K) = 0
  · simp [h]
  · 

Proof state:
case neg
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
h : ¬I = 0
⊢ I⁻¹ = -I

Next tactic:
field_simp [I_mul_I_of_nonzero h]
@[simp, isROrC_simps]
theorem div_I (z : K) : z / I = -(z * I) := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ z / I = -(z * I)

Next tactic:
rw [div_eq_mul_inv, inv_I, mul_neg]
@[isROrC_simps] -- porting note: was `simp`
theorem norm_conj {z : K} : ‖conj z‖ = ‖z‖ := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ ‖(starRingEnd K) z‖ = ‖z‖

Next tactic:
simp only [← sqrt_normSq_eq_norm, normSq_conj]
@[simp, isROrC_simps] -- porting note: removed `norm_cast`
theorem natCast_re (n : ℕ) : re (n : K) = n := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
n : ℕ
⊢ re ↑n = ↑n

Next tactic:
rw [← ofReal_natCast, ofReal_re]
@[simp, isROrC_simps, norm_cast]
theorem natCast_im (n : ℕ) : im (n : K) = 0 := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
n : ℕ
⊢ im ↑n = 0

Next tactic:
rw [← ofReal_natCast, ofReal_im]
theorem ofNat_mul_re (n : ℕ) [n.AtLeastTwo] (z : K) :
    re (OfNat.ofNat n * z) = OfNat.ofNat n * re z := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝¹ : IsROrC K
n : ℕ
inst✝ : Nat.AtLeastTwo n
z : K
⊢ re (OfNat.ofNat n * z) = OfNat.ofNat n * re z

Next tactic:
rw [← ofReal_ofNat, ofReal_mul_re]
theorem ofNat_mul_im (n : ℕ) [n.AtLeastTwo] (z : K) :
    im (OfNat.ofNat n * z) = OfNat.ofNat n * im z := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝¹ : IsROrC K
n : ℕ
inst✝ : Nat.AtLeastTwo n
z : K
⊢ im (OfNat.ofNat n * z) = OfNat.ofNat n * im z

Next tactic:
rw [← ofReal_ofNat, ofReal_mul_im]
@[simp, isROrC_simps] -- porting note: removed `norm_cast`
theorem intCast_re (n : ℤ) : re (n : K) = n := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
n : ℤ
⊢ re ↑n = ↑n

Next tactic:
rw [← ofReal_intCast, ofReal_re]
@[simp, isROrC_simps, norm_cast]
theorem intCast_im (n : ℤ) : im (n : K) = 0 := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
n : ℤ
⊢ im ↑n = 0

Next tactic:
rw [← ofReal_intCast, ofReal_im]
@[simp, isROrC_simps] -- porting note: removed `norm_cast`
theorem ratCast_re (q : ℚ) : re (q : K) = q := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
q : ℚ
⊢ re ↑q = ↑q

Next tactic:
rw [← ofReal_ratCast, ofReal_re]
@[simp, isROrC_simps, norm_cast]
theorem ratCast_im (q : ℚ) : im (q : K) = 0 := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
q : ℚ
⊢ im ↑q = 0

Next tactic:
rw [← ofReal_ratCast, ofReal_im]
@[simp, isROrC_simps, norm_cast]
theorem norm_natCast (n : ℕ) : ‖(n : K)‖ = n := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
n : ℕ
⊢ ‖↑n‖ = ↑n

Next tactic:
rw [← ofReal_natCast]
@[simp, isROrC_simps, norm_cast]
theorem norm_natCast (n : ℕ) : ‖(n : K)‖ = n := by
  rw [← ofReal_natCast]
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
n : ℕ
⊢ ‖↑↑n‖ = ↑n

Next tactic:
exact norm_of_nonneg (Nat.cast_nonneg n)
theorem mul_self_norm (z : K) : ‖z‖ * ‖z‖ = normSq z := by 

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ ‖z‖ * ‖z‖ = normSq z

Next tactic:
rw [normSq_eq_def', sq]
theorem abs_re_le_norm (z : K) : |re z| ≤ ‖z‖ := by
  

Proof state:
K : Type u_1
E : Type u_2
inst✝ : IsROrC K
z : K
⊢ |re z| ≤ ‖z‖

Next tactic:
rw [mul_self_le_mul_self_iff (abs_nonneg _) (norm_nonneg _), abs_mul_abs_self, mul_self_norm]