Theorem: polarCoord_apply
File: Mathlib/Analysis/SpecialFunctions/PolarCoord.lean

Proof steps:
state_before: ⊢ ∀ ⦃x : ℝ × ℝ⦄, x ∈ Ioi 0 ×ˢ Ioo (-π) π → (fun p => (p.1 * cos p.2, p.1 * sin p.2)) x ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
state_after: case mk.intro
r θ : ℝ
hr : (r, θ).1 ∈ Ioi 0
hθ : (r, θ).2 ∈ Ioo (-π) π
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
tactic: rintro ⟨r, θ⟩ ⟨hr, hθ⟩
state_before: case mk.intro
r θ : ℝ
hr : (r, θ).1 ∈ Ioi 0
hθ : (r, θ).2 ∈ Ioo (-π) π
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
state_after: case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
tactic: dsimp at hr hθ
state_before: case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
state_after: case mk.intro.inl
r : ℝ
hr : r ∈ Ioi 0
hθ : 0 ∈ Ioo (-π) π
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, 0) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}

case mk.intro.inr
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
h'θ : θ ≠ 0
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
tactic: rcases eq_or_ne θ 0 with (rfl | h'θ)
state_before: ⊢ ∀ ⦃x : ℝ × ℝ⦄,
    x ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0} →
      (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) x ∈ Ioi 0 ×ˢ Ioo (-π) π
state_after: case mk
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y) ∈ Ioi 0 ×ˢ Ioo (-π) π
tactic: rintro ⟨x, y⟩ hxy
state_before: case mk
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y) ∈ Ioi 0 ×ˢ Ioo (-π) π
state_after: case mk
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ 0 < x ^ 2 + y ^ 2 ∧ (0 ≤ (Complex.equivRealProd.symm (x, y)).re ∨ (Complex.equivRealProd.symm (x, y)).im ≠ 0)
tactic: simp only [prod_mk_mem_set_prod_eq, mem_Ioi, sqrt_pos, mem_Ioo, Complex.neg_pi_lt_arg,
      true_and_iff, Complex.arg_lt_pi_iff]
state_before: case mk
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ 0 < x ^ 2 + y ^ 2 ∧ (0 ≤ (Complex.equivRealProd.symm (x, y)).re ∨ (Complex.equivRealProd.symm (x, y)).im ≠ 0)
state_after: case mk.left
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ 0 < x ^ 2 + y ^ 2

case mk.right
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ 0 ≤ (Complex.equivRealProd.symm (x, y)).re ∨ (Complex.equivRealProd.symm (x, y)).im ≠ 0
tactic: constructor
state_before: ⊢ ∀ ⦃x : ℝ × ℝ⦄,
    x ∈ Ioi 0 ×ˢ Ioo (-π) π →
      (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg))
          ((fun p => (p.1 * cos p.2, p.1 * sin p.2)) x) =
        x
state_after: case mk.intro
r θ : ℝ
hr : (r, θ).1 ∈ Ioi 0
hθ : (r, θ).2 ∈ Ioo (-π) π
⊢ (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg))
      ((fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ)) =
    (r, θ)
tactic: rintro ⟨r, θ⟩ ⟨hr, hθ⟩
state_before: case mk.intro
r θ : ℝ
hr : (r, θ).1 ∈ Ioi 0
hθ : (r, θ).2 ∈ Ioo (-π) π
⊢ (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg))
      ((fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ)) =
    (r, θ)
state_after: case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg))
      ((fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ)) =
    (r, θ)
tactic: dsimp at hr hθ
state_before: case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg))
      ((fun p => (p.1 * cos p.2, p.1 * sin p.2)) (r, θ)) =
    (r, θ)
state_after: case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ √((r * cos θ) ^ 2 + (r * sin θ) ^ 2) = r ∧ (Complex.equivRealProd.symm (r * cos θ, r * sin θ)).arg = θ
tactic: simp only [Prod.mk.inj_iff]
state_before: case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ √((r * cos θ) ^ 2 + (r * sin θ) ^ 2) = r ∧ (Complex.equivRealProd.symm (r * cos θ, r * sin θ)).arg = θ
state_after: case mk.intro.left
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ √((r * cos θ) ^ 2 + (r * sin θ) ^ 2) = r

case mk.intro.right
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (Complex.equivRealProd.symm (r * cos θ, r * sin θ)).arg = θ
tactic: constructor
state_before: ⊢ ∀ ⦃x : ℝ × ℝ⦄,
    x ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0} →
      (fun p => (p.1 * cos p.2, p.1 * sin p.2))
          ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) x) =
        x
state_after: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
tactic: rintro ⟨x, y⟩ _
state_before: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
state_after: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
A : √(x ^ 2 + y ^ 2) = Complex.abs (↑x + ↑y * Complex.I)
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
tactic: have A : √(x ^ 2 + y ^ 2) = Complex.abs (x + y * Complex.I) := by
      rw [Complex.abs_apply, Complex.normSq_add_mul_I]
state_before: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
A : √(x ^ 2 + y ^ 2) = Complex.abs (↑x + ↑y * Complex.I)
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
state_after: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
A : √(x ^ 2 + y ^ 2) = Complex.abs (↑x + ↑y * Complex.I)
Z :
  ↑(Complex.abs (↑x + ↑y * Complex.I)) *
      (Complex.cos ↑(↑x + ↑y * Complex.I).arg + Complex.sin ↑(↑x + ↑y * Complex.I).arg * Complex.I) =
    ↑x + ↑y * Complex.I
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
tactic: have Z := Complex.abs_mul_cos_add_sin_mul_I (x + y * Complex.I)
state_before: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
A : √(x ^ 2 + y ^ 2) = Complex.abs (↑x + ↑y * Complex.I)
Z :
  ↑(Complex.abs (↑x + ↑y * Complex.I)) *
      (Complex.cos ↑(↑x + ↑y * Complex.I).arg + Complex.sin ↑(↑x + ↑y * Complex.I).arg * Complex.I) =
    ↑x + ↑y * Complex.I
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
state_after: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
A : √(x ^ 2 + y ^ 2) = Complex.abs (↑x + ↑y * Complex.I)
Z :
  ↑(Complex.abs (↑x + ↑y * Complex.I) * cos (↑x + ↑y * Complex.I).arg) +
      ↑(Complex.abs (↑x + ↑y * Complex.I) * sin (↑x + ↑y * Complex.I).arg) * Complex.I =
    ↑x + ↑y * Complex.I
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
tactic: simp only [← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ←
      mul_assoc] at Z
state_before: case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
A : √(x ^ 2 + y ^ 2) = Complex.abs (↑x + ↑y * Complex.I)
Z :
  ↑(Complex.abs (↑x + ↑y * Complex.I) * cos (↑x + ↑y * Complex.I).arg) +
      ↑(Complex.abs (↑x + ↑y * Complex.I) * sin (↑x + ↑y * Complex.I).arg) * Complex.I =
    ↑x + ↑y * Complex.I
⊢ (fun p => (p.1 * cos p.2, p.1 * sin p.2))
      ((fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg)) (x, y)) =
    (x, y)
state_after: no goals
tactic: simp [A]
state_before: ⊢ ContinuousOn
    ↑{ toFun := fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π, map_source' := ⋯, map_target' := ⋯, left_inv' := ⋯, right_inv' := ⋯ }
    { toFun := fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π, map_source' := ⋯, map_target' := ⋯, left_inv' := ⋯, right_inv' := ⋯ }.source
state_after: ⊢ ContinuousOn (fun x => (Complex.equivRealProd.symm x).arg)
    { toFun := fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π, map_source' := ⋯, map_target' := ⋯, left_inv' := ⋯, right_inv' := ⋯ }.source
tactic: apply ((continuous_fst.pow 2).add (continuous_snd.pow 2)).sqrt.continuousOn.prod
state_before: ⊢ ContinuousOn (fun x => (Complex.equivRealProd.symm x).arg)
    { toFun := fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π, map_source' := ⋯, map_target' := ⋯, left_inv' := ⋯, right_inv' := ⋯ }.source
state_after: A : MapsTo (⇑Complex.equivRealProd.symm) ({q | 0 < q.1} ∪ {q | q.2 ≠ 0}) Complex.slitPlane
⊢ ContinuousOn (fun x => (Complex.equivRealProd.symm x).arg)
    { toFun := fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π, map_source' := ⋯, map_target' := ⋯, left_inv' := ⋯, right_inv' := ⋯ }.source
tactic: have A : MapsTo Complex.equivRealProd.symm ({q : ℝ × ℝ | 0 < q.1} ∪ {q : ℝ × ℝ | q.2 ≠ 0})
        Complex.slitPlane := by
      rintro ⟨x, y⟩ hxy; simpa only using hxy
state_before: A : MapsTo (⇑Complex.equivRealProd.symm) ({q | 0 < q.1} ∪ {q | q.2 ≠ 0}) Complex.slitPlane
⊢ ContinuousOn (fun x => (Complex.equivRealProd.symm x).arg)
    { toFun := fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π, map_source' := ⋯, map_target' := ⋯, left_inv' := ⋯, right_inv' := ⋯ }.source
state_after: case refine_1
A : MapsTo (⇑Complex.equivRealProd.symm) ({q | 0 < q.1} ∪ {q | q.2 ≠ 0}) Complex.slitPlane
z : ℂ
hz : z ∈ Complex.slitPlane
⊢ ContinuousWithinAt Complex.arg Complex.slitPlane z

case refine_2
A : MapsTo (⇑Complex.equivRealProd.symm) ({q | 0 < q.1} ∪ {q | q.2 ≠ 0}) Complex.slitPlane
⊢ ContinuousOn ⇑Complex.equivRealProd.symm
    { toFun := fun q => (√(q.1 ^ 2 + q.2 ^ 2), (Complex.equivRealProd.symm q).arg),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π, map_source' := ⋯, map_target' := ⋯, left_inv' := ⋯, right_inv' := ⋯ }.source
tactic: refine ContinuousOn.comp (f := Complex.equivRealProd.symm)
      (g := Complex.arg) (fun z hz => ?_) ?_ A