l3lab/ntp-mathlib huggingface dataset:
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ b✝ c✝ : ℂ
⊢ (a✝.re * b✝.re - 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 - b✝.im * c✝.im)

Next tactic:
ring
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by 

Proof state:
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
⊢ ∀ (a : ℂ), 1 * a = a

Next tactic:
intros
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; 

Proof state:
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ : ℂ
⊢ 1 * a✝ = a✝

Next tactic:
ext
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ : ℂ
⊢ (1 * a✝).re = a✝.re

Next tactic:
simp [one_mul]
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ : ℂ
⊢ (1 * a✝).im = a✝.im

Next tactic:
simp [one_mul]
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by 

Proof state:
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
⊢ ∀ (a : ℂ), a * 1 = a

Next tactic:
intros
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; 

Proof state:
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ : ℂ
⊢ a✝ * 1 = a✝

Next tactic:
ext
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; ext <;> 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ : ℂ
⊢ (a✝ * 1).re = a✝.re

Next tactic:
simp [mul_one]
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; ext <;> 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ : ℂ
⊢ (a✝ * 1).im = a✝.im

Next tactic:
simp [mul_one]
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; ext <;> simp [mul_one]
    mul_comm := by 

Proof state:
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
⊢ ∀ (a b : ℂ), a * b = b * a

Next tactic:
intros
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; ext <;> simp [mul_one]
    mul_comm := by intros; 

Proof state:
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ b✝ : ℂ
⊢ a✝ * b✝ = b✝ * a✝

Next tactic:
ext
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; ext <;> simp [mul_one]
    mul_comm := by intros; ext <;> 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ b✝ : ℂ
⊢ (a✝ * b✝).re = (b✝ * a✝).re

Next tactic:
simp [mul_comm]
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; ext <;> simp [mul_one]
    mul_comm := by intros; ext <;> 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ b✝ : ℂ
⊢ (a✝ * b✝).im = (b✝ * a✝).im

Next tactic:
simp [mul_comm]
instance commRing : CommRing ℂ :=
  { Complex.addGroupWithOne with
    mul := (· * ·)
    npow := @npowRec _ ⟨(1 : ℂ)⟩ ⟨(· * ·)⟩
    add_comm := by intros; ext <;> simp [add_comm]
    left_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    right_distrib := by
      intros; ext <;> simp [mul_re, mul_im] <;> ring
    zero_mul := by intros; ext <;> simp [zero_mul]
    mul_zero := by intros; ext <;> simp [mul_zero]
    mul_assoc := by intros; ext <;> simp [mul_assoc] <;> ring
    one_mul := by intros; ext <;> simp [one_mul]
    mul_one := by intros; ext <;> simp [mul_one]
    mul_comm := by intros; ext <;> simp [mul_comm]; 

Proof state:
case a
src✝ : AddGroupWithOne ℂ := Complex.addGroupWithOne
a✝ b✝ : ℂ
⊢ a✝.re * b✝.im + b✝.re * a✝.im = b✝.re * a✝.im + a✝.re * b✝.im

Next tactic:
ring
/-- This shortcut instance ensures we do not find `Ring` via the noncomputable `Complex.field`
instance. -/
instance : Ring ℂ := by 

Proof state:
⊢ Ring ℂ

Next tactic:
infer_instance
@[simp]
theorem I_pow_bit0 (n : ℕ) : I ^ bit0 n = (-1 : ℂ) ^ n := by 

Proof state:
n : ℕ
⊢ I ^ bit0 n = (-1) ^ n

Next tactic:
rw [pow_bit0', Complex.I_mul_I]
@[simp]
theorem I_pow_bit1 (n : ℕ) : I ^ bit1 n = (-1 : ℂ) ^ n * I := by 

Proof state:
n : ℕ
⊢ I ^ bit1 n = (-1) ^ n * I

Next tactic:
rw [pow_bit1', Complex.I_mul_I]
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by 

Proof state:
x : ℂ
⊢ star (star x) = x

Next tactic:
simp only [eta, neg_neg]
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by 

Proof state:
a b : ℂ
⊢ star (a * b) = star b * star a

Next tactic:
ext
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by ext <;> 

Proof state:
case a
a b : ℂ
⊢ (star (a * b)).re = (star b * star a).re

Next tactic:
simp [add_comm]
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by ext <;> 

Proof state:
case a
a b : ℂ
⊢ (star (a * b)).im = (star b * star a).im

Next tactic:
simp [add_comm]
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by ext <;> simp [add_comm] <;> 

Proof state:
case a
a b : ℂ
⊢ a.re * b.re - a.im * b.im = b.re * a.re - b.im * a.im

Next tactic:
ring
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by ext <;> simp [add_comm] <;> 

Proof state:
case a
a b : ℂ
⊢ -(a.re * b.im) + -(a.im * b.re) = -(b.re * a.im) + -(b.im * a.re)

Next tactic:
ring
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by ext <;> simp [add_comm] <;> ring
  star_add a b := by 

Proof state:
a b : ℂ
⊢ star (a + b) = star a + star b

Next tactic:
ext
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by ext <;> simp [add_comm] <;> ring
  star_add a b := by ext <;> 

Proof state:
case a
a b : ℂ
⊢ (star (a + b)).re = (star a + star b).re

Next tactic:
simp [add_comm]
/-- This defines the complex conjugate as the `star` operation of the `StarRing ℂ`. It
is recommended to use the ring endomorphism version `starRingEnd`, available under the
notation `conj` in the locale `ComplexConjugate`. -/
instance : StarRing ℂ where
  star z := ⟨z.re, -z.im⟩
  star_involutive x := by simp only [eta, neg_neg]
  star_mul a b := by ext <;> simp [add_comm] <;> ring
  star_add a b := by ext <;> 

Proof state:
case a
a b : ℂ
⊢ (star (a + b)).im = (star a + star b).im

Next tactic:
simp [add_comm]
theorem conj_ofReal (r : ℝ) : conj (r : ℂ) = r :=
  ext_iff.2 <| by 

Proof state:
r : ℝ
⊢ ((starRingEnd ℂ) ↑r).re = (↑r).re ∧ ((starRingEnd ℂ) ↑r).im = (↑r).im

Next tactic:
simp [star]
@[simp]
theorem conj_I : conj I = -I :=
  ext_iff.2 <| by 

Proof state:
⊢ ((starRingEnd ℂ) I).re = (-I).re ∧ ((starRingEnd ℂ) I).im = (-I).im

Next tactic:
simp
theorem conj_bit0 (z : ℂ) : conj (bit0 z) = bit0 (conj z) :=
  ext_iff.2 <| by 

Proof state:
z : ℂ
⊢ ((starRingEnd ℂ) (bit0 z)).re = (bit0 ((starRingEnd ℂ) z)).re ∧
    ((starRingEnd ℂ) (bit0 z)).im = (bit0 ((starRingEnd ℂ) z)).im

Next tactic:
simp [bit0]
theorem conj_bit1 (z : ℂ) : conj (bit1 z) = bit1 (conj z) :=
  ext_iff.2 <| by 

Proof state:
z : ℂ
⊢ ((starRingEnd ℂ) (bit1 z)).re = (bit1 ((starRingEnd ℂ) z)).re ∧
    ((starRingEnd ℂ) (bit1 z)).im = (bit1 ((starRingEnd ℂ) z)).im

Next tactic:
simp [bit0]
theorem conj_neg_I : conj (-I) = I :=
  ext_iff.2 <| by 

Proof state:
⊢ ((starRingEnd ℂ) (-I)).re = I.re ∧ ((starRingEnd ℂ) (-I)).im = I.im

Next tactic:
simp
theorem conj_eq_iff_real {z : ℂ} : conj z = z ↔ ∃ r : ℝ, z = r :=
  ⟨fun h => ⟨z.re, ext rfl <| eq_zero_of_neg_eq (congr_arg im h)⟩, fun ⟨h, e⟩ => by
    

Proof state:
z : ℂ
x✝ : ∃ r, z = ↑r
h : ℝ
e : z = ↑h
⊢ (starRingEnd ℂ) z = z

Next tactic:
rw [e, conj_ofReal]
theorem conj_eq_iff_re {z : ℂ} : conj z = z ↔ (z.re : ℂ) = z :=
  conj_eq_iff_real.trans ⟨by 

Proof state:
z : ℂ
⊢ (∃ r, z = ↑r) → ↑z.re = z

Next tactic:
rintro ⟨r, rfl⟩
theorem conj_eq_iff_re {z : ℂ} : conj z = z ↔ (z.re : ℂ) = z :=
  conj_eq_iff_real.trans ⟨by rintro ⟨r, rfl⟩; 

Proof state:
case intro
r : ℝ
⊢ ↑(↑r).re = ↑r

Next tactic:
simp [ofReal']
/-- The norm squared function. -/
-- Porting note: `@[pp_nodot]` not found
-- @[pp_nodot]
def normSq : ℂ →*₀ ℝ where
  toFun z := z.re * z.re + z.im * z.im
  map_zero' := by 

Proof state:
⊢ (fun z => z.re * z.re + z.im * z.im) 0 = 0

Next tactic:
simp
/-- The norm squared function. -/
-- Porting note: `@[pp_nodot]` not found
-- @[pp_nodot]
def normSq : ℂ →*₀ ℝ where
  toFun z := z.re * z.re + z.im * z.im
  map_zero' := by simp
  map_one' := by 

Proof state:
⊢ ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } 1 = 1

Next tactic:
simp
/-- The norm squared function. -/
-- Porting note: `@[pp_nodot]` not found
-- @[pp_nodot]
def normSq : ℂ →*₀ ℝ where
  toFun z := z.re * z.re + z.im * z.im
  map_zero' := by simp
  map_one' := by simp
  map_mul' z w := by
    

Proof state:
z w : ℂ
⊢ ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } (z * w) =
    ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } z *
      ZeroHom.toFun { toFun := fun z => z.re * z.re + z.im * z.im, map_zero' := (_ : 0 * 0 + 0 * 0 = 0) } w

Next tactic:
dsimp
/-- The norm squared function. -/
-- Porting note: `@[pp_nodot]` not found
-- @[pp_nodot]
def normSq : ℂ →*₀ ℝ where
  toFun z := z.re * z.re + z.im * z.im
  map_zero' := by simp
  map_one' := by simp
  map_mul' z w := by
    dsimp
    

Proof state:
z w : ℂ
⊢ (z.re * w.re - z.im * w.im) * (z.re * w.re - z.im * w.im) +
      (z.re * w.im + z.im * w.re) * (z.re * w.im + z.im * w.re) =
    (z.re * z.re + z.im * z.im) * (w.re * w.re + w.im * w.im)

Next tactic:
ring
@[simp]
theorem normSq_ofReal (r : ℝ) : normSq r = r * r := by
  

Proof state:
r : ℝ
⊢ normSq ↑r = r * r

Next tactic:
simp [normSq, ofReal']
theorem normSq_add_mul_I (x y : ℝ) : normSq (x + y * I) = x ^ 2 + y ^ 2 := by
  

Proof state:
x y : ℝ
⊢ normSq (↑x + ↑y * I) = x ^ 2 + y ^ 2

Next tactic:
rw [← mk_eq_add_mul_I, normSq_mk, sq, sq]
theorem normSq_eq_conj_mul_self {z : ℂ} : (normSq z : ℂ) = conj z * z := by
  

Proof state:
z : ℂ
⊢ ↑(normSq z) = (starRingEnd ℂ) z * z

Next tactic:
ext
theorem normSq_eq_conj_mul_self {z : ℂ} : (normSq z : ℂ) = conj z * z := by
  ext <;> 

Proof state:
case a
z : ℂ
⊢ (↑(normSq z)).re = ((starRingEnd ℂ) z * z).re

Next tactic:
simp [normSq, mul_comm, ofReal']
theorem normSq_eq_conj_mul_self {z : ℂ} : (normSq z : ℂ) = conj z * z := by
  ext <;> 

Proof state:
case a
z : ℂ
⊢ (↑(normSq z)).im = ((starRingEnd ℂ) z * z).im

Next tactic:
simp [normSq, mul_comm, ofReal']
@[simp]
theorem normSq_I : normSq I = 1 := by 

Proof state:
⊢ normSq I = 1

Next tactic:
simp [normSq]
@[simp]
theorem normSq_neg (z : ℂ) : normSq (-z) = normSq z := by 

Proof state:
z : ℂ
⊢ normSq (-z) = normSq z

Next tactic:
simp [normSq]
@[simp]
theorem normSq_conj (z : ℂ) : normSq (conj z) = normSq z := by 

Proof state:
z : ℂ
⊢ normSq ((starRingEnd ℂ) z) = normSq z

Next tactic:
simp [normSq]
theorem normSq_add (z w : ℂ) : normSq (z + w) = normSq z + normSq w + 2 * (z * conj w).re := by
  

Proof state:
z w : ℂ
⊢ normSq (z + w) = normSq z + normSq w + 2 * (z * (starRingEnd ℂ) w).re

Next tactic:
dsimp [normSq]
theorem normSq_add (z w : ℂ) : normSq (z + w) = normSq z + normSq w + 2 * (z * conj w).re := by
  dsimp [normSq]; 

Proof state:
z w : ℂ
⊢ (z.re + w.re) * (z.re + w.re) + (z.im + w.im) * (z.im + w.im) =
    z.re * z.re + z.im * z.im + (w.re * w.re + w.im * w.im) + 2 * (z.re * w.re - z.im * -w.im)

Next tactic:
ring
theorem mul_conj (z : ℂ) : z * conj z = normSq z :=
  ext_iff.2 <| by 

Proof state:
z : ℂ
⊢ (z * (starRingEnd ℂ) z).re = (↑(normSq z)).re ∧ (z * (starRingEnd ℂ) z).im = (↑(normSq z)).im

Next tactic:
simp [normSq, mul_comm, sub_eq_neg_add, add_comm, ofReal']
theorem add_conj (z : ℂ) : z + conj z = (2 * z.re : ℝ) :=
  ext_iff.2 <| by 

Proof state:
z : ℂ
⊢ (z + (starRingEnd ℂ) z).re = (↑(2 * z.re)).re ∧ (z + (starRingEnd ℂ) z).im = (↑(2 * z.re)).im

Next tactic:
simp [two_mul, ofReal']
@[simp]
theorem I_sq : I ^ 2 = -1 := by 

Proof state:
⊢ I ^ 2 = -1

Next tactic:
rw [sq, I_mul_I]
@[simp, norm_cast]
theorem ofReal_sub (r s : ℝ) : ((r - s : ℝ) : ℂ) = r - s :=
  ext_iff.2 <| by 

Proof state:
r s : ℝ
⊢ (↑(r - s)).re = (↑r - ↑s).re ∧ (↑(r - s)).im = (↑r - ↑s).im

Next tactic:
simp [ofReal']
@[simp, norm_cast]
theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : ℂ) = (r : ℂ) ^ n := by
  

Proof state:
r : ℝ
n : ℕ
⊢ ↑(r ^ n) = ↑r ^ n

Next tactic:
induction n
@[simp, norm_cast]
theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : ℂ) = (r : ℂ) ^ n := by
  induction n <;> 

Proof state:
case zero
r : ℝ
⊢ ↑(r ^ Nat.zero) = ↑r ^ Nat.zero

Next tactic:
simp [*, ofReal_mul, pow_succ]
@[simp, norm_cast]
theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : ℂ) = (r : ℂ) ^ n := by
  induction n <;> 

Proof state:
case succ
r : ℝ
n✝ : ℕ
n_ih✝ : ↑(r ^ n✝) = ↑r ^ n✝
⊢ ↑(r ^ Nat.succ n✝) = ↑r ^ Nat.succ n✝

Next tactic:
simp [*, ofReal_mul, pow_succ]
theorem sub_conj (z : ℂ) : z - conj z = (2 * z.im : ℝ) * I :=
  ext_iff.2 <| by 

Proof state:
z : ℂ
⊢ (z - (starRingEnd ℂ) z).re = (↑(2 * z.im) * I).re ∧ (z - (starRingEnd ℂ) z).im = (↑(2 * z.im) * I).im

Next tactic:
simp [two_mul, sub_eq_add_neg, ofReal']
theorem normSq_sub (z w : ℂ) : normSq (z - w) = normSq z + normSq w - 2 * (z * conj w).re := by
  

Proof state:
z w : ℂ
⊢ normSq (z - w) = normSq z + normSq w - 2 * (z * (starRingEnd ℂ) w).re

Next tactic:
rw [sub_eq_add_neg, normSq_add]
theorem normSq_sub (z w : ℂ) : normSq (z - w) = normSq z + normSq w - 2 * (z * conj w).re := by
  rw [sub_eq_add_neg, normSq_add]
  

Proof state:
z w : ℂ
⊢ normSq z + normSq (-w) + 2 * (z * (starRingEnd ℂ) (-w)).re = normSq z + normSq w - 2 * (z * (starRingEnd ℂ) w).re

Next tactic:
simp only [RingHom.map_neg, mul_neg, neg_re, normSq_neg]
theorem normSq_sub (z w : ℂ) : normSq (z - w) = normSq z + normSq w - 2 * (z * conj w).re := by
  rw [sub_eq_add_neg, normSq_add]
  simp only [RingHom.map_neg, mul_neg, neg_re, normSq_neg]
  

Proof state:
z w : ℂ
⊢ normSq z + normSq w + -(2 * (z * (starRingEnd ℂ) w).re) = normSq z + normSq w - 2 * (z * (starRingEnd ℂ) w).re

Next tactic:
ring
@[simp]
theorem inv_re (z : ℂ) : z⁻¹.re = z.re / normSq z := by 

Proof state:
z : ℂ
⊢ z⁻¹.re = z.re / normSq z

Next tactic:
simp [inv_def, division_def, ofReal']
@[simp]
theorem inv_im (z : ℂ) : z⁻¹.im = -z.im / normSq z := by 

Proof state:
z : ℂ
⊢ z⁻¹.im = -z.im / normSq z

Next tactic:
simp [inv_def, division_def, ofReal']
@[simp, norm_cast]
theorem ofReal_inv (r : ℝ) : ((r⁻¹ : ℝ) : ℂ) = (r : ℂ)⁻¹ :=
  ext_iff.2 <| by 

Proof state:
r : ℝ
⊢ (↑r⁻¹).re = (↑r)⁻¹.re ∧ (↑r⁻¹).im = (↑r)⁻¹.im

Next tactic:
simp [ofReal']
protected theorem inv_zero : (0⁻¹ : ℂ) = 0 := by
  

Proof state:
⊢ 0⁻¹ = 0

Next tactic:
rw [← ofReal_zero, ← ofReal_inv, inv_zero]
protected theorem mul_inv_cancel {z : ℂ} (h : z ≠ 0) : z * z⁻¹ = 1 := by
  

Proof state:
z : ℂ
h : z ≠ 0
⊢ z * z⁻¹ = 1

Next tactic:
rw [inv_def, ← mul_assoc, mul_conj, ← ofReal_mul, mul_inv_cancel (mt normSq_eq_zero.1 h),
    ofReal_one]
noncomputable instance instField : Field ℂ :=
{ qsmul := fun n z => n • z
  qsmul_eq_mul' := fun n z => ext_iff.2 <| by simp [Rat.smul_def, smul_re, smul_im]
  ratCast_mk := fun n d hd h2 => by 

Proof state:
n : ℤ
d : ℕ
hd : d ≠ 0
h2 : Nat.Coprime (Int.natAbs n) d
⊢ ↑(Rat.mk' n d) = ↑n * (↑d)⁻¹

Next tactic:
ext
noncomputable instance instField : Field ℂ :=
{ qsmul := fun n z => n • z
  qsmul_eq_mul' := fun n z => ext_iff.2 <| by simp [Rat.smul_def, smul_re, smul_im]
  ratCast_mk := fun n d hd h2 => by ext <;> 

Proof state:
case a
n : ℤ
d : ℕ
hd : d ≠ 0
h2 : Nat.Coprime (Int.natAbs n) d
⊢ (↑(Rat.mk' n d)).re = (↑n * (↑d)⁻¹).re

Next tactic:
simp [Field.ratCast_mk]
noncomputable instance instField : Field ℂ :=
{ qsmul := fun n z => n • z
  qsmul_eq_mul' := fun n z => ext_iff.2 <| by simp [Rat.smul_def, smul_re, smul_im]
  ratCast_mk := fun n d hd h2 => by ext <;> 

Proof state:
case a
n : ℤ
d : ℕ
hd : d ≠ 0
h2 : Nat.Coprime (Int.natAbs n) d
⊢ (↑(Rat.mk' n d)).im = (↑n * (↑d)⁻¹).im

Next tactic:
simp [Field.ratCast_mk]