-- Mathlib/Analysis/SpecialFunctions/Complex/Arctan.lean
/-- `cos z` is nonzero when the bounds in `arctan_tan` are met (`z` lies in the vertical strip
`-π / 2 < z.re < π / 2` and `z ≠ π / 2`). -/
lemma cos_ne_zero_of_arctan_bounds {z : ℂ} (h₀ : z ≠ π / 2) (h₁ : -(π / 2) < z.re)
    (h₂ : z.re ≤ π / 2) : cos z ≠ 0

Proof state:
case inl.h
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
nr : ¬z.re = π / 2
⊢ ¬z.re = ↑(2 * k + 1) * π / 2

Tactic:
contrapose! nr

Result:
case inl.h
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ z.re = π / 2

Proof state:
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
h₀ : ¬z.re = π / 2 ∨ ¬z.im = 0
⊢ ¬z.re = ↑(2 * k + 1) * π / 2 ∨ ¬z.im = 0

Tactic:
rcases h₀ with nr | ni

Result:
case inl
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
nr : ¬z.re = π / 2
⊢ ¬z.re = ↑(2 * k + 1) * π / 2 ∨ ¬z.im = 0

case inr
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
ni : ¬z.im = 0
⊢ ¬z.re = ↑(2 * k + 1) * π / 2 ∨ ¬z.im = 0

Proof state:
case inl.h
z : ℂ
h₂ : z.re ≤ π / 2
k : ℤ
h₁ : -1 < ↑(2 * k + 1)
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ z.re = π / 2

Tactic:
rw [nr, ← one_mul (π / 2), mul_div_assoc, mul_le_mul_iff_of_pos_right (by positivity)] at h₂

Result:
case inl.h
z : ℂ
k : ℤ
h₂ : ↑(2 * k + 1) ≤ 1
h₁ : -1 < ↑(2 * k + 1)
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ z.re = π / 2

Proof state:
z : ℂ
h₀ : ¬z.re = (↑π / 2).re ∨ ¬z.im = (↑π / 2).im
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
⊢ ¬z.re = ((2 * ↑k + 1) * ↑π / 2).re ∨ ¬z.im = ((2 * ↑k + 1) * ↑π / 2).im

Tactic:
norm_cast at h₀ ⊢

Result:
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
h₀ : ¬z.re = π / 2 ∨ ¬z.im = 0
⊢ ¬z.re = ↑(2 * k + 1) * π / 2 ∨ ¬z.im = 0

Proof state:
case inr
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
ni : ¬z.im = 0
⊢ ¬z.re = ↑(2 * k + 1) * π / 2 ∨ ¬z.im = 0

Tactic:
exact Or.inr ni

Result:
no goals

Proof state:
case inl
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
nr : ¬z.re = π / 2
⊢ ¬z.re = ↑(2 * k + 1) * π / 2 ∨ ¬z.im = 0

Tactic:
left

Result:
case inl.h
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
nr : ¬z.re = π / 2
⊢ ¬z.re = ↑(2 * k + 1) * π / 2

Proof state:
case inl.h
z : ℂ
k : ℤ
nr : z.re = ↑(2 * k + 1) * π / 2
h₁ : Int.negSucc 0 < 2 * k + 1
h₂ : 2 * k + 1 ≤ 1
⊢ z.re = π / 2

Tactic:
change -1 < _ at h₁

Result:
case inl.h
z : ℂ
k : ℤ
nr : z.re = ↑(2 * k + 1) * π / 2
h₂ : 2 * k + 1 ≤ 1
h₁ : -1 < 2 * k + 1
⊢ z.re = π / 2

Proof state:
z : ℂ
h₀ : z ≠ ↑π / 2
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
⊢ cos z ≠ 0

Tactic:
refine cos_ne_zero_iff.mpr (fun k ↦ ?_)

Result:
z : ℂ
h₀ : z ≠ ↑π / 2
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
⊢ z ≠ (2 * ↑k + 1) * ↑π / 2

Proof state:
z : ℂ
h₀ : z ≠ ↑π / 2
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
⊢ z ≠ (2 * ↑k + 1) * ↑π / 2

Tactic:
rw [ne_eq, Complex.ext_iff, not_and_or] at h₀ ⊢

Result:
z : ℂ
h₀ : ¬z.re = (↑π / 2).re ∨ ¬z.im = (↑π / 2).im
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
⊢ ¬z.re = ((2 * ↑k + 1) * ↑π / 2).re ∨ ¬z.im = ((2 * ↑k + 1) * ↑π / 2).im

Proof state:
z : ℂ
h₂ : z.re ≤ π / 2
k : ℤ
h₁ : -1 * (π / 2) < ↑(2 * k + 1) * (π / 2)
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ 0 < π / 2

Tactic:
positivity

Result:
no goals

Proof state:
case inl.h
z : ℂ
k : ℤ
h₂ : ↑(2 * k + 1) ≤ 1
h₁ : -1 < ↑(2 * k + 1)
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ z.re = π / 2

Tactic:
norm_cast at h₁ h₂

Result:
case inl.h
z : ℂ
k : ℤ
nr : z.re = ↑(2 * k + 1) * π / 2
h₁ : Int.negSucc 0 < 2 * k + 1
h₂ : 2 * k + 1 ≤ 1
⊢ z.re = π / 2

Proof state:
z : ℂ
k : ℤ
h₂ : ↑(2 * k + 1) * (π / 2) ≤ 1 * (π / 2)
h₁ : -1 < ↑(2 * k + 1)
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ 0 < π / 2

Tactic:
positivity

Result:
no goals

Proof state:
case inl.h
z : ℂ
h₁ : -(π / 2) < z.re
h₂ : z.re ≤ π / 2
k : ℤ
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ z.re = π / 2

Tactic:
rw [nr, mul_div_assoc, neg_eq_neg_one_mul, mul_lt_mul_iff_of_pos_right (by positivity)] at h₁

Result:
case inl.h
z : ℂ
h₂ : z.re ≤ π / 2
k : ℤ
h₁ : -1 < ↑(2 * k + 1)
nr : z.re = ↑(2 * k + 1) * π / 2
⊢ z.re = π / 2

Proof state:
case inl.h
z : ℂ
k : ℤ
nr : z.re = ↑(2 * k + 1) * π / 2
h₂ : 2 * k + 1 ≤ 1
h₁ : -1 < 2 * k + 1
⊢ z.re = π / 2

Tactic:
rwa [show 2 * k + 1 = 1 by omega, Int.cast_one, one_mul] at nr

Result:
no goals

Proof state:
z : ℂ
k : ℤ
nr : z.re = ↑(2 * k + 1) * π / 2
h₂ : 2 * k + 1 ≤ 1
h₁ : -1 < 2 * k + 1
⊢ 2 * k + 1 = 1

Tactic:
omega

Result:
no goals