cfahlgren1's picture
download
raw
57.4 kB
17
def f (x : ℝ) : ℝ := if x = 0 then 1 else x / Real.sinh x
19
def b (x : ℝ) : ℝ := f x * Real.cosh x
21
@[simp] theorem f_zero : f 0 = 1 := by simp [f]
22
@[simp] theorem b_zero : b 0 = 1 := by simp [b]
24
theorem f_of_ne_zero {x : ℝ} (hx : x ≠ 0) : f x = x / Real.sinh x := by
proof · 1 line
  simp [f, hx]
27
@[simp] theorem f_neg (x : ℝ) : f (-x) = f x := by
proof · 3 lines
  by_cases hx : x = 0
  · simp [hx]
  · simp [f, hx, Real.sinh_neg]
32
@[simp] theorem b_neg (x : ℝ) : b (-x) = b x := by
proof · 1 line
  simp [b, Real.cosh_neg]
35
theorem f_pos (x : ℝ) : 0 < f x := by
proof · 6 lines
  rcases lt_trichotomy x 0 with hx | hx | hx
  · rw [← f_neg, f_of_ne_zero (neg_ne_zero.mpr hx.ne)]
    exact div_pos (neg_pos.mpr hx) (Real.sinh_pos_iff.mpr (neg_pos.mpr hx))
  · simp [hx]
  · rw [f_of_ne_zero hx.ne']
    exact div_pos hx (Real.sinh_pos_iff.mpr hx)
43
theorem b_pos (x : ℝ) : 0 < b x := mul_pos (f_pos x) (Real.cosh_pos x)
45
theorem f_mul_sinh (x : ℝ) : f x * Real.sinh x = x := by
proof · 3 lines
  by_cases hx : x = 0
  · simp [hx]
  · rw [f_of_ne_zero hx, div_mul_cancel₀ _ (Real.sinh_ne_zero.mpr hx)]
50
theorem b_sq (x : ℝ) : b x ^ 2 = f x ^ 2 + x ^ 2 := by
proof · 5 lines
  have h := Real.cosh_sq_sub_sinh_sq x
  have hx := f_mul_sinh x
  dsimp [b]
  nlinarith [sq_nonneg (f x), sq_nonneg (Real.sinh x),
    congrArg (fun t : ℝ => t ^ 2) hx]
57
theorem f_mul_exp (x : ℝ) : f x * Real.exp x = b x + x := by
proof · 5 lines
  have h : Real.exp x = Real.cosh x + Real.sinh x := by
    rw [Real.cosh_eq, Real.sinh_eq]
    ring
  rw [h, mul_add, f_mul_sinh]
  rfl
64
theorem f_mul_exp_neg (x : ℝ) : f x * Real.exp (-x) = b x - x := by
proof · 1 line
  simpa [sub_eq_add_neg] using f_mul_exp (-x)
67
def fourWeightTarget (m x y : ℝ) : ℝ := m * f x * f y / f (x + y)
69
theorem fourWeightTarget_pos {m : ℝ} (hm : 0 < m) (x y : ℝ) :
    0 < fourWeightTarget m x y := by
proof · 1 line
  exact div_pos (mul_pos (mul_pos hm (f_pos x)) (f_pos y)) (f_pos (x + y))
93
theorem target_mul_add (x y : ℝ) :
    (f x * f y / f (x + y)) * (x + y) = y * b x + x * b y := by
proof · 16 lines
  calc
    (f x * f y / f (x + y)) * (x + y) =
      (f x * f y / f (x + y)) * (f (x + y) * Real.sinh (x + y)) := by
        congr 1
        exact (f_mul_sinh (x + y)).symm
    _ = f x * f y * Real.sinh (x + y) := by
      rw [← mul_assoc, div_mul_cancel₀ _ (ne_of_gt (f_pos (x + y)))]
    _ = f x * f y * (Real.sinh x * Real.cosh y + Real.cosh x * Real.sinh y) := by
      rw [Real.sinh_add]
    _ =
      f y * (f x * Real.sinh x) * Real.cosh y +
      (f y * Real.sinh y) * (f x * Real.cosh x) := by ring
    _ = y * b x + x * b y := by
      rw [f_mul_sinh, f_mul_sinh]
      dsimp [b]
      ring
112
theorem target_eq_of_add_ne_zero {x y : ℝ} (hxy : x + y ≠ 0) :
    f x * f y / f (x + y) = (y * b x + x * b y) / (x + y) := by
proof · 1 line
  exact (eq_div_iff hxy).mpr (target_mul_add x y)
116
theorem target_opposite (x : ℝ) : f x * f (-x) / f (x + -x) = f x ^ 2 := by
proof · 1 line
  simp [pow_two]
119
theorem f_eq_inv_dslope (x : ℝ) : f x = (dslope Real.sinh 0 x)⁻¹ := by
proof · 4 lines
  by_cases hx : x = 0
  · simp [hx, dslope_same, Real.deriv_sinh]
  · rw [f_of_ne_zero hx, dslope_of_ne _ hx]
    simp [slope, div_eq_mul_inv, mul_comm]
125
theorem continuous_f : Continuous f := by
proof · 13 lines
  apply continuous_iff_continuousAt.mpr
  intro x
  change ContinuousAt (fun u => f u) x
  simp_rw [f_eq_inv_dslope]
  apply ContinuousAt.inv₀
  · by_cases hx : x = 0
    · subst x
      exact continuousAt_dslope_same.mpr Real.differentiableAt_sinh
    · exact (continuousAt_dslope_of_ne hx).mpr Real.continuous_sinh.continuousAt
  · by_cases hx : x = 0
    · simp [hx, dslope_same, Real.deriv_sinh]
    · rw [dslope_of_ne _ hx]
      simp [slope, hx, Real.sinh_ne_zero.mpr hx]
140
theorem continuous_b : Continuous b := continuous_f.mul Real.continuous_cosh
142
theorem f_le_one (x : ℝ) : f x ≤ 1 := by
proof · 8 lines
  have h (y : ℝ) (hy : 0 ≤ y) : f y ≤ 1 := by
    rcases hy.eq_or_lt with hy | hy
    · simp [← hy]
    · rw [f_of_ne_zero hy.ne', div_le_one (Real.sinh_pos_iff.mpr hy)]
      exact Real.self_le_sinh_iff.mpr hy.le
  rcases le_total 0 x with hx | hx
  · exact h x hx
  · simpa using h (-x) (neg_nonneg.mpr hx)
152
theorem f_lt_one {x : ℝ} (hx : x ≠ 0) : f x < 1 := by
proof · 6 lines
  have h (y : ℝ) (hy : 0 < y) : f y < 1 := by
    rw [f_of_ne_zero hy.ne', div_lt_one (Real.sinh_pos_iff.mpr hy)]
    exact Real.self_lt_sinh_iff.mpr hy
  rcases lt_or_gt_of_ne hx with hneg | hpos
  · simpa using h (-x) (neg_pos.mpr hneg)
  · exact h x hpos
160
theorem sinh_lt_mul_cosh {x : ℝ} (hx : 0 < x) : Real.sinh x < x * Real.cosh x := by
proof · 11 lines
  have hmono : StrictMonoOn (fun u : ℝ => u * Real.cosh u - Real.sinh u) (Ici 0) := by
    apply strictMonoOn_of_deriv_pos (convex_Ici 0)
      ((continuous_id.mul Real.continuous_cosh).sub Real.continuous_sinh).continuousOn
    intro u hu
    rw [interior_Ici, mem_Ioi] at hu
    have hd := ((hasDerivAt_id u).mul (Real.hasDerivAt_cosh u)).sub
      (Real.hasDerivAt_sinh u)
    rw [hd.deriv]
    simpa using mul_pos hu (Real.sinh_pos_iff.mpr hu)
  have h := hmono (show (0 : ℝ) ∈ Ici 0 by simp) hx.le hx
  simpa using h
173
theorem one_lt_b {x : ℝ} (hx : x ≠ 0) : 1 < b x := by
proof · 7 lines
  have h (y : ℝ) (hy : 0 < y) : 1 < b y := by
    rw [b, f_of_ne_zero hy.ne', div_mul_eq_mul_div,
      lt_div_iff₀ (Real.sinh_pos_iff.mpr hy)]
    simpa using sinh_lt_mul_cosh hy
  rcases lt_or_gt_of_ne hx with hneg | hpos
  · simpa using h (-x) (neg_pos.mpr hneg)
  · exact h x hpos
182
theorem hasDerivAt_f {x : ℝ} (hx : x ≠ 0) :
    HasDerivAt f ((Real.sinh x - x * Real.cosh x) / Real.sinh x ^ 2) x := by
proof · 5 lines
  have hd := (hasDerivAt_id x).div (Real.hasDerivAt_sinh x) (Real.sinh_ne_zero.mpr hx)
  simp only [one_mul, id_eq] at hd
  apply hd.congr_of_eventuallyEq
  filter_upwards [eventually_ne_nhds hx] with y hy
  exact f_of_ne_zero hy
190
theorem strictAntiOn_f : StrictAntiOn f (Ici 0) := by
proof · 6 lines
  apply strictAntiOn_of_deriv_neg (convex_Ici 0) continuous_f.continuousOn
  intro x hx
  rw [interior_Ici, mem_Ioi] at hx
  rw [(hasDerivAt_f hx.ne').deriv]
  exact div_neg_of_neg_of_pos (sub_neg.mpr (sinh_lt_mul_cosh hx))
    (sq_pos_of_pos (Real.sinh_pos_iff.mpr hx))
198
theorem f_injOn_nonneg : InjOn f (Ici 0) := strictAntiOn_f.injOn
200
theorem hasDerivAt_b {x : ℝ} (hx : x ≠ 0) :
    HasDerivAt b ((b x - f x ^ 2) / x) x := by
proof · 9 lines
  have hd := (hasDerivAt_f hx).mul (Real.hasDerivAt_cosh x)
  change HasDerivAt b _ x at hd
  convert! hd using 1
  dsimp [b]
  rw [f_of_ne_zero hx]
  have hs := Real.sinh_ne_zero.mpr hx
  have hi := Real.cosh_sq_sub_sinh_sq x
  field_simp
  nlinarith [congrArg (fun z : ℝ => x * z) hi]
212
theorem hasDerivAt_f_sq {x : ℝ} (hx : x ≠ 0) :
    HasDerivAt (fun u => f u ^ 2) (2 * f x ^ 2 * (1 - b x) / x) x := by
proof · 5 lines
  convert! (hasDerivAt_f hx).pow 2 using 1
  dsimp [b]
  rw [f_of_ne_zero hx]
  have hs := Real.sinh_ne_zero.mpr hx
  field_simp
220
theorem strictAntiOn_f_sq : StrictAntiOn (fun u => f u ^ 2) (Ici 0) := by
proof · 2 lines
  intro x hx y hy hxy
  exact sq_lt_sq₀ (f_pos y).le (f_pos x).le |>.mpr (strictAntiOn_f hx hy hxy)
224
theorem f_eq_exp {x : ℝ} (hx : 0 < x) :
    f x = (2 * (x * Real.exp (-x))) / (1 - Real.exp (-x) ^ 2) := by
proof · 11 lines
  have he : Real.exp (-x) < 1 := Real.exp_lt_one_iff.mpr (neg_neg_of_pos hx)
  have hep : 0 < Real.exp (-x) := Real.exp_pos _
  have hden : 1 - Real.exp (-x) ^ 2 ≠ 0 := by nlinarith
  rw [f_of_ne_zero hx.ne', Real.sinh_eq]
  have hs : Real.exp x - Real.exp (-x) ≠ 0 := by
    have : 0 < Real.sinh x := Real.sinh_pos_iff.mpr hx
    rw [Real.sinh_eq] at this
    linarith
  have hm : Real.exp x * Real.exp (-x) = 1 := by rw [← Real.exp_add]; simp
  field_simp
  nlinarith [congrArg (fun t : ℝ => 2 * x * t) hm]
238
theorem tendsto_f_atTop : Tendsto f atTop (𝓝 0) := by
proof · 13 lines
  have he : Tendsto (fun x : ℝ => Real.exp (-x)) atTop (𝓝 0) :=
    Real.tendsto_exp_atBot.comp tendsto_neg_atTop_atBot
  have hxe : Tendsto (fun x : ℝ => x * Real.exp (-x)) atTop (𝓝 0) := by
    simpa using Real.tendsto_pow_mul_exp_neg_atTop_nhds_zero 1
  have hfrac := (hxe.const_mul 2).div (tendsto_const_nhds.sub (he.pow 2))
    (show (1 : ℝ) - 0 ^ 2 ≠ 0 by norm_num)
  have heq : f =ᶠ[atTop] (fun x : ℝ => (2 * (x * Real.exp (-x))) / (1 - Real.exp (-x) ^ 2)) := by
    filter_upwards [eventually_gt_atTop (0 : ℝ)] with x hx
    exact f_eq_exp hx
  have ht : Tendsto (fun x : ℝ => (2 * (x * Real.exp (-x))) /
      (1 - Real.exp (-x) ^ 2)) atTop (𝓝 0) := by
    convert! hfrac using 1; norm_num
  exact ht.congr' heq.symm
253
theorem range_f_nonneg : f '' Ici 0 = Ioc 0 1 := by
proof · 11 lines
  apply Subset.antisymm
  · rintro _ ⟨x, _, rfl⟩
    exact ⟨f_pos x, f_le_one x⟩
  · intro y hy
    obtain ⟨x, hx, hxy⟩ : ∃ x : ℝ, 0 ≤ x ∧ f x < y := by
      have h := (tendsto_order.mp tendsto_f_atTop).2 y hy.1
      obtain ⟨x, hx, hxy⟩ := (eventually_ge_atTop (0 : ℝ)).and h |>.exists
      exact ⟨x, hx, hxy⟩
    have hsurj := continuous_f.continuousOn.surjOn_Icc
      (s := Ici (0 : ℝ)) hx (show (0 : ℝ) ∈ Ici 0 by simp)
    exact hsurj ⟨hxy.le, by simpa using hy.2⟩
266
theorem existsUnique_f_sq_parameter {s : ℝ} (hs : s ∈ Ioc 0 1) :
    ∃! x : ℝ, 0 ≤ x ∧ f x ^ 2 = s := by
proof · 10 lines
  have hroot : Real.sqrt s ∈ f '' Ici 0 := by
    rw [range_f_nonneg]
    exact ⟨Real.sqrt_pos.2 hs.1, Real.sqrt_le_one.2 hs.2⟩
  obtain ⟨x, hx, hfx⟩ := hroot
  refine ⟨x, ⟨hx, ?_⟩, ?_⟩
  · rw [hfx, Real.sq_sqrt hs.1.le]
  · intro y hy
    apply strictAntiOn_f_sq.injOn hy.1 hx
    change f y ^ 2 = f x ^ 2
    rw [hy.2, hfx, Real.sq_sqrt hs.1.le]
279
theorem mul_cos_lt_sin {x : ℝ} (hx : x ∈ Ioo 0 Real.pi) :
    x * Real.cos x < Real.sin x := by
proof · 13 lines
  have hmono : StrictMonoOn (fun t : ℝ => Real.sin t - t * Real.cos t) (Icc 0 Real.pi) := by
    apply strictMonoOn_of_deriv_pos (convex_Icc _ _)
      (Real.continuous_sin.sub (continuous_id.mul Real.continuous_cos)).continuousOn
    intro t ht
    rw [interior_Icc, mem_Ioo] at ht
    have hd := (Real.hasDerivAt_sin t).sub ((hasDerivAt_id t).mul (Real.hasDerivAt_cos t))
    rw [hd.deriv]
    simp only [id_eq, one_mul]
    have hs := Real.sin_pos_of_pos_of_lt_pi ht.1 ht.2
    nlinarith [mul_pos ht.1 hs]
  have h := hmono (show (0 : ℝ) ∈ Icc 0 Real.pi by exact ⟨le_rfl, Real.pi_pos.le⟩)
    ⟨hx.1.le, hx.2.le⟩ hx.1
  simpa using h
295
def bParameter (s : ℝ) : ℝ := Function.invFunOn (fun x : ℝ => f x ^ 2) (Ici 0) s
297
def B (s : ℝ) : ℝ := b (bParameter s)
299
theorem bParameter_nonneg {s : ℝ} (hs : s ∈ Ioc 0 1) : 0 ≤ bParameter s := by
proof · 3 lines
  apply Function.invFunOn_mem
  obtain ⟨x, hx, _⟩ := existsUnique_f_sq_parameter hs
  exact ⟨x, hx⟩
304
theorem f_sq_bParameter {s : ℝ} (hs : s ∈ Ioc 0 1) : f (bParameter s) ^ 2 = s := by
proof · 4 lines
  change (fun x : ℝ => f x ^ 2) (Function.invFunOn (fun x : ℝ => f x ^ 2) (Ici 0) s) = s
  apply Function.invFunOn_eq (f := fun x : ℝ => f x ^ 2) (s := Ici (0 : ℝ))
  obtain ⟨x, hx, _⟩ := existsUnique_f_sq_parameter hs
  exact ⟨x, hx⟩
310
theorem f_sq_mem {x : ℝ} (_hx : 0 ≤ x) : f x ^ 2 ∈ Ioc (0 : ℝ) 1 := by
proof · 1 line
  exact ⟨sq_pos_of_pos (f_pos x), by nlinarith [f_pos x, f_le_one x]⟩
313
theorem bParameter_f_sq {x : ℝ} (hx : 0 ≤ x) : bParameter (f x ^ 2) = x := by
proof · 2 lines
  apply strictAntiOn_f_sq.injOn (bParameter_nonneg (f_sq_mem hx)) hx
  exact f_sq_bParameter (f_sq_mem hx)
317
theorem B_f_sq {x : ℝ} (hx : 0 ≤ x) : B (f x ^ 2) = b x := by
proof · 1 line
  rw [B, bParameter_f_sq hx]
320
@[simp] theorem bParameter_one : bParameter 1 = 0 := by
proof · 1 line
  simpa using bParameter_f_sq (x := 0) le_rfl
323
@[simp] theorem B_one : B 1 = 1 := by simp [B]
325
theorem bParameter_pos {s : ℝ} (hs : s ∈ Ioo 0 1) : 0 < bParameter s := by
proof · 6 lines
  have hn := bParameter_nonneg ⟨hs.1, hs.2.le⟩
  have he := f_sq_bParameter ⟨hs.1, hs.2.le⟩
  by_contra h
  have : bParameter s = 0 := le_antisymm (not_lt.mp h) hn
  simp [this] at he
  linarith [hs.2]
333
theorem strictAntiOn_bParameter : StrictAntiOn bParameter (Ioc 0 1) := by
proof · 6 lines
  intro s hs t ht hst
  by_contra h
  have hle := strictAntiOn_f_sq.antitoneOn (bParameter_nonneg hs)
    (bParameter_nonneg ht) (not_lt.mp h)
  rw [f_sq_bParameter hs, f_sq_bParameter ht] at hle
  exact (not_le_of_gt hst) hle
341
theorem range_bParameter : bParameter '' Ioo 0 1 = Ioi (0 : ℝ) := by
proof · 8 lines
  apply Subset.antisymm
  · rintro _ ⟨s, hs, rfl⟩
    exact bParameter_pos hs
  · intro x hx
    refine ⟨f x ^ 2, ?_, bParameter_f_sq hx.le⟩
    refine ⟨sq_pos_of_pos (f_pos x), ?_⟩
    have hf := f_lt_one hx.ne'
    nlinarith [f_pos x]
351
theorem continuousAt_bParameter {s : ℝ} (hs : s ∈ Ioo 0 1) :
    ContinuousAt bParameter s := by
proof · 6 lines
  have hm : StrictAntiOn bParameter (Ioo 0 1) :=
    strictAntiOn_bParameter.mono Ioo_subset_Ioc_self
  apply hm.dual_right.continuousAt_of_image_mem_nhds (Ioo_mem_nhds hs.1 hs.2)
  change bParameter '' Ioo 0 1 ∈ 𝓝 (bParameter s)
  rw [range_bParameter]
  exact Ioi_mem_nhds (bParameter_pos hs)
360
theorem hasDerivAt_bParameter {s : ℝ} (hs : s ∈ Ioo 0 1) :
    HasDerivAt bParameter
      (2 * s * (1 - B s) / bParameter s)⁻¹ s := by
proof · 8 lines
  have hp := bParameter_pos hs
  have hd := hasDerivAt_f_sq hp.ne'
  rw [f_sq_bParameter ⟨hs.1, hs.2.le⟩] at hd
  apply HasDerivAt.of_local_left_inverse (continuousAt_bParameter hs) hd
  · exact div_ne_zero (mul_ne_zero (mul_ne_zero (by norm_num) hs.1.ne')
      (sub_ne_zero.mpr (one_lt_b hp.ne').ne)) hp.ne'
  · filter_upwards [Ioo_mem_nhds hs.1 hs.2] with t ht
    exact f_sq_bParameter ⟨ht.1, ht.2.le⟩
372
theorem hasDerivAt_B {s : ℝ} (hs : s ∈ Ioo 0 1) :
    HasDerivAt B ((B s - s) / (2 * s * (1 - B s))) s := by
proof · 7 lines
  have hp := bParameter_pos hs
  have hd := (hasDerivAt_b hp.ne').comp s (hasDerivAt_bParameter hs)
  rw [f_sq_bParameter ⟨hs.1, hs.2.le⟩] at hd
  convert! hd using 1
  change (B s - s) / (2 * s * (1 - B s)) =
    ((B s - s) / bParameter s) * (2 * s * (1 - B s) / bParameter s)⁻¹
  field_simp [hp.ne']
382
def sineParameter (z : ℂ) : ℂ := Complex.sin z / z
384
def cotParameter (z : ℂ) : ℂ := z * Complex.cos z / Complex.sin z
386
theorem normSq_sin (z : ℂ) :
    Complex.normSq (Complex.sin z) = Real.sin z.re ^ 2 + Real.sinh z.im ^ 2 := by
proof · 11 lines
  rw [Complex.sin_eq]
  simp only [Complex.normSq_apply, Complex.add_re, Complex.add_im, Complex.mul_re,
    Complex.mul_im, Complex.I_re, Complex.I_im, Complex.sin_ofReal_re,
    Complex.sin_ofReal_im, Complex.cos_ofReal_re, Complex.cos_ofReal_im,
    Complex.sinh_ofReal_re, Complex.sinh_ofReal_im, Complex.cosh_ofReal_re,
    Complex.cosh_ofReal_im, mul_zero, zero_mul, add_zero, zero_add, sub_zero,
    mul_one]
  have ht := Real.sin_sq_add_cos_sq z.re
  have hh := Real.cosh_sq_sub_sinh_sq z.im
  nlinarith [congrArg (fun t : ℝ => Real.sin z.re ^ 2 * t) hh,
    congrArg (fun t : ℝ => Real.sinh z.im ^ 2 * t) ht]
400
theorem sin_ne_zero_of_im_pos {z : ℂ} (hz : 0 < z.im) : Complex.sin z ≠ 0 := by
proof · 3 lines
  apply Complex.normSq_pos.mp
  rw [normSq_sin]
  exact add_pos_of_nonneg_of_pos (sq_nonneg _) (sq_pos_of_pos (Real.sinh_pos_iff.mpr hz))
405
theorem cotParameter_im (z : ℂ) :
    (cotParameter z).im =
      (z.im * Real.sin z.re * Real.cos z.re - z.re * Real.sinh z.im * Real.cosh z.im) /
        (Real.sin z.re ^ 2 + Real.sinh z.im ^ 2) := by
proof · 14 lines
  dsimp [cotParameter]
  rw [Complex.div_im, normSq_sin, Complex.sin_eq, Complex.cos_eq]
  simp only [Complex.add_re, Complex.add_im, Complex.sub_re, Complex.sub_im,
    Complex.mul_re, Complex.mul_im, Complex.I_re, Complex.I_im,
    Complex.sin_ofReal_re, Complex.sin_ofReal_im, Complex.cos_ofReal_re,
    Complex.cos_ofReal_im, Complex.sinh_ofReal_re, Complex.sinh_ofReal_im,
    Complex.cosh_ofReal_re, Complex.cosh_ofReal_im, mul_zero, zero_mul,
    add_zero, zero_add, sub_zero, mul_one, zero_sub]
  rw [← sub_div]
  congr 1
  have ht := Real.sin_sq_add_cos_sq z.re
  have hh := Real.cosh_sq_sub_sinh_sq z.im
  nlinarith [congrArg (fun t : ℝ => z.im * Real.sin z.re * Real.cos z.re * t) hh,
    congrArg (fun t : ℝ => z.re * Real.sinh z.im * Real.cosh z.im * t) ht]
424
theorem cotParameter_im_neg {z : ℂ} (hr : 0 < z.re) (hi : 0 < z.im) :
    (cotParameter z).im < 0 := by
proof · 9 lines
  rw [cotParameter_im]
  apply div_neg_of_neg_of_pos
  · have ht := Real.sin_le (show 0 ≤ 2 * z.re by positivity)
    have hh := Real.self_lt_sinh_iff.mpr (show 0 < 2 * z.im by positivity)
    rw [Real.sin_two_mul] at ht
    rw [Real.sinh_two_mul] at hh
    nlinarith [mul_le_mul_of_nonneg_left ht hi.le, mul_lt_mul_of_pos_left hh hr]
  · exact add_pos_of_nonneg_of_pos (sq_nonneg _)
      (sq_pos_of_pos (Real.sinh_pos_iff.mpr hi))
436
theorem hasDerivAt_sineParameter {z : ℂ} (hz : z ≠ 0) :
    HasDerivAt sineParameter ((z * Complex.cos z - Complex.sin z) / z ^ 2) z := by
proof · 2 lines
  convert! (Complex.hasDerivAt_sin z).div (hasDerivAt_id z) hz using 1
  simp [mul_comm]
441
theorem deriv_sineParameter_ne_zero {z : ℂ} (hr : 0 < z.re) (hi : 0 < z.im) :
    deriv sineParameter z ≠ 0 := by
proof · 9 lines
  have hz : z ≠ 0 := by intro h; simp [h] at hr
  rw [(hasDerivAt_sineParameter hz).deriv]
  apply div_ne_zero _ (pow_ne_zero _ hz)
  intro h
  have hc : cotParameter z = 1 := by
    dsimp [cotParameter]
    rw [sub_eq_zero.mp h, div_self (sin_ne_zero_of_im_pos hi)]
  have hn := cotParameter_im_neg hr hi
  simp [hc] at hn
453
theorem covering_bijective_of_simplyConnected
    {E X : Type*} [TopologicalSpace E] [TopologicalSpace X]
    [PreconnectedSpace E] [Nonempty E]
    [SimplyConnectedSpace X] [LocallyPathConnectedSpace X]
    {p : E → X} (hp : IsCoveringMap p) : Function.Bijective p := by
proof · 18 lines
  classical
  let e₀ : E := Classical.choice inferInstance
  obtain ⟨F, ⟨hF₀, hF⟩, _⟩ := hp.existsUnique_continuousMap_lifts
    (ContinuousMap.id X) (p e₀) e₀ rfl
  have hright : p ∘ F = id := hF
  have hleft : F ∘ p = id := by
    apply hp.eq_of_comp_eq (F.continuous.comp hp.continuous) continuous_id _ e₀ hF₀
    ext e
    exact congrFun hright (p e)
  constructor
  · intro e e' h
    have he := congrFun hleft e
    have he' := congrFun hleft e'
    change F (p e) = e at he
    change F (p e') = e' at he'
    exact he.symm.trans ((congrArg F h).trans he')
  · intro x
    exact ⟨F x, congrFun hright x⟩
477
def csinc : ℂ → ℂ := dslope Complex.sin 0
479
theorem csinc_zero : csinc 0 = 1 := by
proof · 2 lines
  rw [csinc, dslope_same, (Complex.hasDerivAt_sin 0).deriv]
  simp
483
theorem csinc_of_ne {z : ℂ} (hz : z ≠ 0) : csinc z = sineParameter z := by
proof · 1 line
  simp [csinc, dslope_of_ne _ hz, slope, sineParameter, div_eq_mul_inv, mul_comm]
486
theorem analyticAt_csinc (z : ℂ) : AnalyticAt ℂ csinc z := by
proof · 9 lines
  rcases eq_or_ne z 0 with rfl | hz
  · apply Complex.analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt
    · filter_upwards [self_mem_nhdsWithin] with z hz
      exact (differentiableAt_dslope_of_ne hz).mpr (Complex.differentiableAt_sin)
    · exact continuousAt_dslope_same.mpr (Complex.differentiableAt_sin)
  · have he : csinc =ᶠ[𝓝 z] sineParameter := by
      filter_upwards [eventually_ne_nhds hz] with w hw
      exact csinc_of_ne hw
    exact ((Complex.analyticAt_sin).div analyticAt_id hz).congr he.symm
497
theorem continuous_csinc : Continuous csinc := continuous_iff_continuousAt.mpr
proof · 1 line
  (fun z => (analyticAt_csinc z).continuousAt)
500
theorem sin_sub_mul_cos_pos {p : ℝ} (hp : p ∈ Ioo 0 Real.pi) :
    0 < Real.sin p - p * Real.cos p := by
proof · 13 lines
  have hm : StrictMonoOn (fun u : ℝ => Real.sin u - u * Real.cos u) (Icc 0 Real.pi) := by
    apply strictMonoOn_of_deriv_pos (convex_Icc 0 Real.pi)
      (Real.continuous_sin.sub (continuous_id.mul Real.continuous_cos)).continuousOn
    intro u hu
    rw [interior_Icc, mem_Ioo] at hu
    have hd := (Real.hasDerivAt_sin u).sub ((hasDerivAt_id u).mul (Real.hasDerivAt_cos u))
    rw [hd.deriv]
    have hs := Real.sin_pos_of_pos_of_lt_pi hu.1 hu.2
    simp only [id_eq] at *
    nlinarith [mul_pos hu.1 hs]
  have he := hm (show (0 : ℝ) ∈ Icc 0 Real.pi from ⟨le_rfl, Real.pi_pos.le⟩)
    ⟨hp.1.le, hp.2.le⟩ hp.1
  simpa using he
516
theorem sineParameter_re (z : ℂ) :
    (sineParameter z).re =
      (z.re * Real.sin z.re * Real.cosh z.im + z.im * Real.cos z.re * Real.sinh z.im) /
        (z.re ^ 2 + z.im ^ 2) := by
proof · 7 lines
  rw [sineParameter, Complex.div_re, Complex.sin_eq]
  simp only [Complex.add_re, Complex.add_im, Complex.mul_re, Complex.mul_im,
    Complex.I_re, Complex.I_im, Complex.sin_ofReal_re, Complex.sin_ofReal_im,
    Complex.cos_ofReal_re, Complex.cos_ofReal_im, Complex.sinh_ofReal_re,
    Complex.sinh_ofReal_im, Complex.cosh_ofReal_re, Complex.cosh_ofReal_im,
    mul_zero, zero_mul, add_zero, zero_add, sub_zero, mul_one, Complex.normSq_apply]
  ring
528
theorem sineParameter_im (z : ℂ) :
    (sineParameter z).im =
      (z.re * Real.cos z.re * Real.sinh z.im - z.im * Real.sin z.re * Real.cosh z.im) /
        (z.re ^ 2 + z.im ^ 2) := by
proof · 7 lines
  rw [sineParameter, Complex.div_im, Complex.sin_eq]
  simp only [Complex.add_re, Complex.add_im, Complex.mul_re, Complex.mul_im,
    Complex.I_re, Complex.I_im, Complex.sin_ofReal_re, Complex.sin_ofReal_im,
    Complex.cos_ofReal_re, Complex.cos_ofReal_im, Complex.sinh_ofReal_re,
    Complex.sinh_ofReal_im, Complex.cosh_ofReal_re, Complex.cosh_ofReal_im,
    mul_zero, zero_mul, add_zero, zero_add, sub_zero, mul_one, Complex.normSq_apply]
  ring
540
theorem sineParameter_im_neg {z : ℂ} (hp : z.re ∈ Ioo 0 Real.pi) (hq : 0 < z.im) :
    (sineParameter z).im < 0 := by
proof · 15 lines
  rw [sineParameter_im]
  have hs := Real.sin_pos_of_pos_of_lt_pi hp.1 hp.2
  have hsh := Real.sinh_pos_iff.mpr hq
  have hch := Real.cosh_pos z.im
  apply div_neg_of_neg_of_pos _ (add_pos_of_pos_of_nonneg (sq_pos_of_pos hp.1) (sq_nonneg _))
  rcases le_or_gt (Real.cos z.re) 0 with hc | hc
  · have h₁ := mul_nonpos_of_nonneg_of_nonpos hp.1.le hc
    have h₂ := mul_nonpos_of_nonpos_of_nonneg h₁ hsh.le
    have h₃ := mul_pos (mul_pos hq hs) hch
    linarith
  · have h₁ := sinh_lt_mul_cosh hq
    have h₂ := sin_sub_mul_cos_pos hp
    have h₃ := mul_lt_mul_of_pos_left h₁ (mul_pos hp.1 hc)
    have h₄ := mul_lt_mul_of_pos_right (sub_pos.mp h₂) (mul_pos hq hch)
    nlinarith
558
theorem half_sq_le_sinh {x : ℝ} (hx : 0 ≤ x) : x ^ 2 / 2 ≤ Real.sinh x := by
proof · 16 lines
  have hm : MonotoneOn (fun u : ℝ => Real.sinh u - u ^ 2 / 2) (Ici 0) := by
    apply monotoneOn_of_deriv_nonneg (convex_Ici 0)
      (Real.continuous_sinh.sub ((continuous_id.pow 2).div_const 2)).continuousOn
    · intro u hu
      exact ((Real.differentiableAt_sinh).sub
        ((differentiableAt_id.pow 2).div_const 2)).differentiableWithinAt
    · intro u hu
      rw [interior_Ici, mem_Ioi] at hu
      rw [((Real.hasDerivAt_sinh u).sub
        ((hasDerivAt_id u).pow 2 |>.div_const 2)).deriv]
      have h₁ := Real.self_le_sinh_iff.mpr hu.le
      have h₂ := Real.sinh_lt_cosh u
      simp only [id_eq, mul_one]
      linarith
  have h := hm (show (0 : ℝ) ∈ Ici 0 by simp) hx hx
  simpa using h
576
def sineDomain : Set ℂ := {z | 0 < z.re ∧ z.re < Real.pi ∧ 0 < z.im ∧ 0 < (csinc z).re}
577
def sineQuadrant : Set ℂ := {z | 0 < z.re ∧ z.im < 0}
578
def sineStrip : Set ℂ := {z | 0 ≤ z.re ∧ z.re ≤ Real.pi ∧ 0 ≤ z.im}
580
theorem isOpen_sineDomain : IsOpen sineDomain :=
proof · 4 lines
  (isOpen_lt continuous_const Complex.continuous_re).inter
    ((isOpen_lt Complex.continuous_re continuous_const).inter
      ((isOpen_lt continuous_const Complex.continuous_im).inter
        (isOpen_lt continuous_const (Complex.continuous_re.comp continuous_csinc))))
586
theorem isOpen_sineQuadrant : IsOpen sineQuadrant :=
proof · 2 lines
  (isOpen_lt continuous_const Complex.continuous_re).inter
    (isOpen_lt Complex.continuous_im continuous_const)
590
theorem isClosed_sineStrip : IsClosed sineStrip :=
proof · 3 lines
  (isClosed_le continuous_const Complex.continuous_re).inter
    ((isClosed_le Complex.continuous_re continuous_const).inter
      (isClosed_le continuous_const Complex.continuous_im))
595
theorem csinc_mapsTo : MapsTo csinc sineDomain sineQuadrant := by
proof · 4 lines
  intro z hz
  refine ⟨hz.2.2.2, ?_⟩
  rw [csinc_of_ne (by intro he; have := hz.1; simp [he] at this)]
  exact sineParameter_im_neg ⟨hz.1, hz.2.1⟩ hz.2.2.1
601
theorem csinc_strip_bound {z : ℂ} (hz : z ∈ sineStrip) {M : ℝ} (hM : ‖csinc z‖ ≤ M) :
    z.im ≤ Real.pi + 4 * M := by
proof · 24 lines
  have hM0 : 0 ≤ M := (norm_nonneg _).trans hM
  by_contra! hq
  have hz0 : z ≠ 0 := by
    intro he
    simp only [he, Complex.zero_im] at hq
    linarith [Real.pi_pos]
  have hn : Real.sinh z.im ≤ ‖Complex.sin z‖ := by
    have hnorm := Complex.normSq_eq_norm_sq (Complex.sin z)
    rw [normSq_sin] at hnorm
    nlinarith [norm_nonneg (Complex.sin z), Real.sinh_nonneg_iff.mpr hz.2.2,
      sq_nonneg (Real.sin z.re)]
  have hzbound : ‖z‖ ≤ Real.pi + z.im := by
    have he := Complex.norm_le_abs_re_add_abs_im z
    rw [abs_of_nonneg hz.1, abs_of_nonneg hz.2.2] at he
    linarith [hz.2.1]
  have he : ‖Complex.sin z‖ = ‖csinc z‖ * ‖z‖ := by
    rw [csinc_of_ne hz0, sineParameter, norm_div, div_mul_cancel₀ _ (norm_ne_zero_iff.mpr hz0)]
  have hsq := half_sq_le_sinh hz.2.2
  have hu : z.im ^ 2 / 2 ≤ M * (Real.pi + z.im) :=
    hsq.trans (hn.trans (he ▸ mul_le_mul hM hzbound (norm_nonneg _) hM0))
  have hqp : Real.pi < z.im := by linarith
  have hqm : 4 * M < z.im := by linarith [Real.pi_pos]
  have hpos : 0 < z.im := Real.pi_pos.trans hqp
  nlinarith [mul_nonneg hM0 (sub_nonneg.mpr hqp.le), mul_pos hpos (sub_pos.mpr hqm)]
628
theorem csinc_strip_quadrant {z : ℂ} (hz : z ∈ sineStrip)
    (ha : csinc z ∈ sineQuadrant) : z ∈ sineDomain := by
proof · 20 lines
  have hz0 : z ≠ 0 := by intro he; simp [he, csinc_zero, sineQuadrant] at ha
  have he := csinc_of_ne hz0
  have hi := ha.2
  have hr := ha.1
  rw [he, sineParameter_im] at hi
  rw [he, sineParameter_re] at hr
  refine ⟨?_, ?_, ?_, ha.1⟩
  · by_contra! h
    have hp : z.re = 0 := le_antisymm h hz.1
    simp [hp] at hi
  · by_contra! h
    have hp : z.re = Real.pi := le_antisymm hz.2.1 h
    simp [hp] at hr
    have : -(z.im * Real.sinh z.im) / (Real.pi ^ 2 + z.im ^ 2) ≤ 0 :=
      div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr
        (mul_nonneg hz.2.2 (Real.sinh_nonneg_iff.mpr hz.2.2))) (by positivity)
    linarith
  · by_contra! h
    have hq : z.im = 0 := le_antisymm h hz.2.2
    simp [hq] at hi
651
theorem isCompact_strip_preimage {K : Set ℂ} (hK : IsCompact K) :
    IsCompact (sineStrip ∩ csinc ⁻¹' K) := by
proof · 8 lines
  obtain ⟨M, hM⟩ := hK.isBounded.exists_norm_le
  apply Metric.isCompact_of_isClosed_isBounded (isClosed_sineStrip.inter (hK.isClosed.preimage continuous_csinc))
  apply isBounded_iff_forall_norm_le.mpr
  refine ⟨Real.pi + (Real.pi + 4 * M), ?_⟩
  intro z hz
  have he := Complex.norm_le_abs_re_add_abs_im z
  rw [abs_of_nonneg hz.1.1, abs_of_nonneg hz.1.2.2] at he
  linarith [hz.1.2.1, csinc_strip_bound hz.1 (hM _ hz.2)]
662
def sineMap : sineDomain → sineQuadrant := fun z => ⟨csinc z, csinc_mapsTo z.property⟩
664
theorem continuous_sineMap : Continuous sineMap :=
proof · 1 line
  (continuous_csinc.comp continuous_subtype_val).subtype_mk _
667
theorem proper_sineMap : IsProperMap sineMap := by
proof · 15 lines
  apply isProperMap_iff_isCompact_preimage.mpr
  refine ⟨continuous_sineMap, ?_⟩
  intro K hK
  have hc := isCompact_strip_preimage (hK.image continuous_subtype_val)
  have he : Subtype.val '' (sineMap ⁻¹' K) = sineStrip ∩ csinc ⁻¹' (Subtype.val '' K) := by
    ext z
    constructor
    · rintro ⟨u, hu, rfl⟩
      exact ⟨⟨u.property.1.le, u.property.2.1.le, u.property.2.2.1.le⟩, _, hu, rfl⟩
    · rintro ⟨hz, w, hw, he⟩
      have ha : csinc z ∈ sineQuadrant := he ▸ w.property
      refine ⟨⟨z, csinc_strip_quadrant hz ha⟩, ?_, rfl⟩
      have hw' : sineMap ⟨z, csinc_strip_quadrant hz ha⟩ = w := Subtype.ext he.symm
      simpa [hw'] using hw
  exact (Topology.IsEmbedding.subtypeVal.isCompact_iff).mpr (he ▸ hc)
684
theorem deriv_csinc_ne_zero {z : ℂ} (hz : z ∈ sineDomain) : deriv csinc z ≠ 0 := by
proof · 6 lines
  have hn : z ≠ 0 := by intro he; have := hz.1; simp [he] at this
  have he : csinc =ᶠ[𝓝 z] sineParameter := by
    filter_upwards [eventually_ne_nhds hn] with w hw
    exact csinc_of_ne hw
  rw [he.deriv_eq]
  exact deriv_sineParameter_ne_zero hz.1 hz.2.2.1
692
theorem localHomeomorphOn_csinc : IsLocalHomeomorphOn csinc sineDomain := by
proof · 5 lines
  intro z hz
  let hd := (analyticAt_csinc z).hasStrictDerivAt.hasStrictFDerivAt_equiv
    (deriv_csinc_ne_zero hz)
  exact ⟨hd.toOpenPartialHomeomorph csinc, hd.mem_toOpenPartialHomeomorph_source,
    hd.toOpenPartialHomeomorph_coe.symm⟩
699
theorem localHomeomorph_sineMap : IsLocalHomeomorph sineMap := by
proof · 7 lines
  have hi := isOpen_sineDomain.isOpenEmbedding_subtypeVal.isLocalHomeomorph
  have ho := isOpen_sineQuadrant.isOpenEmbedding_subtypeVal.isLocalHomeomorph
  have hc : IsLocalHomeomorph (csinc ∘ (Subtype.val : sineDomain → ℂ)) := by
    apply isLocalHomeomorph_iff_isLocalHomeomorphOn_univ.mpr
    exact localHomeomorphOn_csinc.comp hi.isLocalHomeomorphOn (fun x _ => x.property)
  change IsLocalHomeomorph ((Subtype.val : sineQuadrant → ℂ) ∘ sineMap) at hc
  exact hc.of_comp ho continuous_sineMap
708
theorem covering_sineMap : IsCoveringMap sineMap := by
proof · 8 lines
  apply isCoveringMap_iff_isCoveringMapOn_univ.mpr
  apply proper_sineMap.isClosedMap.isCoveringMapOn_of_isLocalHomeomorphOn
  · intro x _
    apply (proper_sineMap.isCompact_preimage isCompact_singleton).finite
    apply (show IsLocalHomeomorphOn sineMap (sineMap ⁻¹' {x}) from
      fun z _ => localHomeomorph_sineMap z).isDiscrete_of_image
    exact ((Set.finite_singleton x).subset (Set.image_preimage_subset _ _)).isDiscrete
  · exact localHomeomorph_sineMap.isLocalHomeomorphOn
718
theorem strictAnti_boundaryRatio :
    StrictAntiOn (fun p : ℝ => p * Real.sin p / (-Real.cos p))
      (Ioo (Real.pi / 2) Real.pi) := by
proof · 23 lines
  have hc : ∀ p ∈ Ioo (Real.pi / 2) Real.pi, Real.cos p < 0 := by
    intro p hp
    exact Real.cos_neg_of_pi_div_two_lt_of_lt hp.1 (by linarith [hp.2, Real.pi_pos])
  apply strictAntiOn_of_deriv_neg (convex_Ioo _ _)
  · apply ContinuousOn.div
    · exact (continuous_id.mul Real.continuous_sin).continuousOn
    · exact Real.continuous_cos.neg.continuousOn
    · intro p hp
      exact neg_ne_zero.mpr (ne_of_lt (hc p hp))
  · intro p hp
    rw [interior_Ioo] at hp
    have hn : -Real.cos p ≠ 0 := neg_ne_zero.mpr (ne_of_lt (hc p hp))
    have hd := ((hasDerivAt_id p).mul (Real.hasDerivAt_sin p)).div
      (Real.hasDerivAt_cos p).neg hn
    simp only [Pi.mul_apply, Pi.neg_apply, id_eq] at hd
    change deriv (id * Real.sin / -Real.cos) p < 0
    rw [hd.deriv]
    apply div_neg_of_neg_of_pos _ (sq_pos_of_ne_zero hn)
    simp only [one_mul, neg_neg]
    have hs := Real.sin_sq_add_cos_sq p
    have hq := sq_nonneg (Real.sin p + Real.cos p)
    have hp1 : 1 < p := by linarith [hp.1, Real.pi_gt_three]
    nlinarith
745
theorem csinc_re_pos_of_small_re {z : ℂ} (hp : 0 < z.re)
    (hp' : z.re ≤ Real.pi / 2) (hq : 0 < z.im) : 0 < (csinc z).re := by
proof · 7 lines
  rw [csinc_of_ne (by intro h; simp [h] at hp), sineParameter_re]
  apply div_pos _ (add_pos_of_pos_of_nonneg (sq_pos_of_pos hp) (sq_nonneg _))
  have hsin := Real.sin_pos_of_pos_of_lt_pi hp (by linarith [Real.pi_pos])
  have hcos := Real.cos_nonneg_of_mem_Icc (show z.re ∈ Icc (-(Real.pi / 2)) (Real.pi / 2)
    from ⟨by linarith [Real.pi_pos], hp'⟩)
  exact add_pos_of_pos_of_nonneg (mul_pos (mul_pos hp hsin) (Real.cosh_pos _))
    (mul_nonneg (mul_nonneg hq.le hcos) (Real.sinh_nonneg_iff.mpr hq.le))
755
theorem csinc_re_pos_iff_of_large_re {z : ℂ} (hp : Real.pi / 2 < z.re)
    (hp' : z.re < Real.pi) (_hq : 0 < z.im) :
    0 < (csinc z).re ↔ z.im * Real.sinh z.im / Real.cosh z.im <
      z.re * Real.sin z.re / (-Real.cos z.re) := by
proof · 7 lines
  have hp0 : 0 < z.re := by linarith [Real.pi_pos]
  have hcos := Real.cos_neg_of_pi_div_two_lt_of_lt hp (show z.re < Real.pi + Real.pi / 2 by
    linarith [Real.pi_pos])
  rw [csinc_of_ne (by intro h; simp [h] at hp0), sineParameter_re,
    div_pos_iff_of_pos_right (add_pos_of_pos_of_nonneg (sq_pos_of_pos hp0) (sq_nonneg _)),
    div_lt_div_iff₀ (Real.cosh_pos _) (neg_pos.mpr hcos)]
  constructor <;> intro h <;> nlinarith
767
theorem sineDomain_horizontal {z w : ℂ} (hz : z ∈ sineDomain)
    (hi : w.im = z.im) (hp : 0 < w.re)
    (hl : w.re ≤ max (Real.pi / 2) z.re) : w ∈ sineDomain := by
proof · 16 lines
  have hpi : w.re < Real.pi := lt_of_le_of_lt hl
    (max_lt (by linarith [Real.pi_pos]) hz.2.1)
  refine ⟨hp, hpi, hi ▸ hz.2.2.1, ?_⟩
  by_cases hs : w.re ≤ Real.pi / 2
  · exact csinc_re_pos_of_small_re hp hs (hi ▸ hz.2.2.1)
  · have hs' : Real.pi / 2 < w.re := lt_of_not_ge hs
    have hz' : Real.pi / 2 < z.re := by
      by_contra! hn
      rw [max_eq_left hn] at hl
      exact hs hl
    rw [csinc_re_pos_iff_of_large_re hs' hpi (hi ▸ hz.2.2.1)]
    have hzr := (csinc_re_pos_iff_of_large_re hz' hz.2.1 hz.2.2.1).mp hz.2.2.2
    rw [hi]
    apply lt_of_lt_of_le hzr
    apply strictAnti_boundaryRatio.antitoneOn ⟨hs', hpi⟩ ⟨hz', hz.2.1⟩
    simpa [max_eq_right hz'.le] using hl
787
def sineMidPoint (q : ℝ) : ℂ := ⟨Real.pi / 2, q⟩
789
theorem sineMidPoint_mem {q : ℝ} (hq : 0 < q) : sineMidPoint q ∈ sineDomain := by
proof · 3 lines
  have hp : 0 < Real.pi / 2 := by positivity
  refine ⟨hp, by dsimp [sineMidPoint]; linarith [Real.pi_pos], hq, ?_⟩
  exact csinc_re_pos_of_small_re hp le_rfl hq
794
theorem joined_horizontal {z : ℂ} (hz : z ∈ sineDomain) :
    JoinedIn sineDomain z (sineMidPoint z.im) := by
proof · 11 lines
  apply JoinedIn.of_segment_subset
  intro w hw
  have hp : 0 < w.re := (convex_halfSpace_re_gt 0).segment_subset
    hz.1 (show 0 < (sineMidPoint z.im).re by dsimp [sineMidPoint]; positivity) hw
  have hl : w.re ≤ max (Real.pi / 2) z.re :=
    (convex_halfSpace_re_le (max (Real.pi / 2) z.re)).segment_subset
      (show z.re ≤ max (Real.pi / 2) z.re from le_max_right _ _) (show (sineMidPoint z.im).re ≤ max (Real.pi / 2) z.re from le_max_left _ _) hw
  apply sineDomain_horizontal hz _ hp hl
  rcases hw with ⟨a, b, ha, hb, hab, rfl⟩
  simp only [Complex.add_im, Complex.smul_im, sineMidPoint, smul_eq_mul]
  rw [← add_mul, hab, one_mul]
808
theorem joined_sineMidPoints {q r : ℝ} (hq : 0 < q) (hr : 0 < r) :
    JoinedIn sineDomain (sineMidPoint q) (sineMidPoint r) := by
proof · 11 lines
  apply JoinedIn.of_segment_subset
  intro w hw
  have hi : 0 < w.im := (convex_halfSpace_im_gt 0).segment_subset hq hr hw
  have he : w = sineMidPoint w.im := by
    apply Complex.ext
    · rcases hw with ⟨a, b, ha, hb, hab, rfl⟩
      simp only [Complex.add_re, Complex.smul_re, sineMidPoint, smul_eq_mul]
      rw [← add_mul, hab, one_mul]
    · rfl
  rw [he]
  exact sineMidPoint_mem hi
822
theorem isPathConnected_sineDomain : IsPathConnected sineDomain := by
proof · 3 lines
  refine ⟨sineMidPoint 1, sineMidPoint_mem zero_lt_one, ?_⟩
  intro z hz
  exact (joined_sineMidPoints zero_lt_one hz.2.2.1).trans (joined_horizontal hz).symm
827
theorem convex_sineQuadrant : Convex ℝ sineQuadrant :=
proof · 1 line
  (convex_halfSpace_re_gt 0).inter (convex_halfSpace_im_lt 0)
830
theorem bijective_sineMap : Function.Bijective sineMap := by
proof · 6 lines
  let : PathConnectedSpace sineDomain :=
    isPathConnected_iff_pathConnectedSpace.mp isPathConnected_sineDomain
  let : ContractibleSpace sineQuadrant := convex_sineQuadrant.contractibleSpace
    ⟨⟨1, -1⟩, by constructor <;> norm_num⟩
  let : LocallyPathConnectedSpace sineQuadrant := convex_sineQuadrant.locallyPathConnectedSpace
  exact covering_bijective_of_simplyConnected covering_sineMap
838
def sineInverse (w : ℂ) : ℂ := by
body · 4 lines
  classical
  exact if hw : w ∈ sineQuadrant then
    ((Equiv.ofBijective sineMap bijective_sineMap).symm ⟨w, hw⟩).val
  else 0
844
theorem sineInverse_mem {w : ℂ} (hw : w ∈ sineQuadrant) :
    sineInverse w ∈ sineDomain := by
proof · 2 lines
  simpa only [sineInverse, dite_eq_left hw] using
    ((Equiv.ofBijective sineMap bijective_sineMap).symm ⟨w, hw⟩).property
849
theorem csinc_sineInverse {w : ℂ} (hw : w ∈ sineQuadrant) :
    csinc (sineInverse w) = w := by
proof · 3 lines
  have he := congrArg Subtype.val
    ((Equiv.ofBijective sineMap bijective_sineMap).apply_symm_apply ⟨w, hw⟩)
  simpa only [sineInverse, dite_eq_left hw, Equiv.ofBijective_apply, sineMap] using he
855
theorem sineInverse_csinc {z : ℂ} (hz : z ∈ sineDomain) :
    sineInverse (csinc z) = z := by
proof · 4 lines
  have he := congrArg Subtype.val
    ((Equiv.ofBijective sineMap bijective_sineMap).symm_apply_apply ⟨z, hz⟩)
  simpa only [sineInverse, dite_eq_left (csinc_mapsTo hz), Equiv.ofBijective_apply,
    sineMap] using he
862
theorem analyticAt_sineInverse {w : ℂ} (hw : w ∈ sineQuadrant) :
    AnalyticAt ℂ sineInverse w := by
proof · 9 lines
  let z := sineInverse w
  have hz : z ∈ sineDomain := sineInverse_mem hw
  have he : sineInverse ∘ csinc =ᶠ[𝓝 z] id := by
    filter_upwards [isOpen_sineDomain.mem_nhds hz] with u hu
    exact sineInverse_csinc hu
  have ha : AnalyticAt ℂ (sineInverse ∘ csinc) z := analyticAt_id.congr he.symm
  have := (analyticAt_comp_iff_of_deriv_ne_zero (analyticAt_csinc z)
    (deriv_csinc_ne_zero hz)).mp ha
  simpa only [z, csinc_sineInverse hw] using this
874
theorem inv_sqrt_mem_sineQuadrant {s : ℂ} (hs : 0 < s.im) :
    (Complex.sqrt s)⁻¹ ∈ sineQuadrant := by
proof · 17 lines
  have hn : |s.re| < ‖s‖ := Complex.abs_re_lt_norm.mpr hs.ne'
  have hr : 0 < (Complex.sqrt s).re := by
    change 0 < (s ^ (2⁻¹ : ℂ)).re
    rw [Complex.cpow_inv_two_re]
    apply Real.sqrt_pos.mpr
    have := (abs_lt.mp hn).1
    linarith
  have hi : 0 < (Complex.sqrt s).im := by
    change 0 < (s ^ (2⁻¹ : ℂ)).im
    rw [Complex.cpow_inv_two_im_eq_sqrt hs.le]
    exact Real.sqrt_pos.mpr (by linarith [(abs_lt.mp hn).2])
  have hz : Complex.sqrt s ≠ 0 := by intro he; simp [he] at hr
  constructor
  · rw [Complex.inv_re]
    exact div_pos hr (Complex.normSq_pos.mpr hz)
  · rw [Complex.inv_im]
    exact div_neg_of_neg_of_pos (neg_neg_of_pos hi) (Complex.normSq_pos.mpr hz)
894
def upperB (s : ℂ) : ℂ := cotParameter (sineInverse (Complex.sqrt s)⁻¹)
896
theorem analyticAt_upperB {s : ℂ} (hs : 0 < s.im) : AnalyticAt ℂ upperB s := by
proof · 16 lines
  have hm := sineInverse_mem (inv_sqrt_mem_sineQuadrant hs)
  have hsqrt : AnalyticAt ℂ Complex.sqrt s :=
    Complex.differentiableOn_sqrt.analyticOnNhd Complex.isOpen_slitPlane s (Or.inr hs.ne')
  have hn : Complex.sqrt s ≠ 0 := by
    have hi := (inv_sqrt_mem_sineQuadrant hs).1
    intro he
    simp [he] at hi
  have ha := (analyticAt_sineInverse (inv_sqrt_mem_sineQuadrant hs)).comp
    (f := fun w : ℂ => (Complex.sqrt w)⁻¹) (hsqrt.inv hn)
  have hsin : Complex.sin (sineInverse (Complex.sqrt s)⁻¹) ≠ 0 := by
    intro he
    have he' := Complex.normSq_eq_zero.mpr he
    rw [normSq_sin] at he'
    have hsh := Real.sinh_pos_iff.mpr hm.2.2.1
    nlinarith [sq_nonneg (Real.sin (sineInverse (Complex.sqrt s)⁻¹).re)]
  exact (ha.mul (Complex.analyticAt_cos.comp ha)).div (Complex.analyticAt_sin.comp ha) hsin
914
theorem upperB_im_neg {s : ℂ} (hs : 0 < s.im) : (upperB s).im < 0 := by
proof · 2 lines
  have hm := sineInverse_mem (inv_sqrt_mem_sineQuadrant hs)
  exact cotParameter_im_neg hm.1 hm.2.2.1
918
def sinhc : ℝ → ℝ := dslope Real.sinh 0
920
@[simp] theorem sinhc_zero : sinhc 0 = 1 := by
proof · 1 line
  simp [sinhc, dslope_same, (Real.hasDerivAt_sinh 0).deriv]
923
theorem sinhc_of_ne {q : ℝ} (hq : q ≠ 0) : sinhc q = Real.sinh q / q := by
proof · 1 line
  simp [sinhc, dslope_of_ne _ hq, slope, div_eq_mul_inv, mul_comm]
926
theorem continuous_sinhc : Continuous sinhc := by
proof · 5 lines
  apply continuous_iff_continuousAt.mpr
  intro q
  rcases eq_or_ne q 0 with rfl | hq
  · exact continuousAt_dslope_same.mpr Real.differentiableAt_sinh
  · exact (continuousAt_dslope_of_ne hq).mpr Real.continuous_sinh.continuousAt
933
theorem strictMonoOn_sinhc : StrictMonoOn sinhc (Ici 0) := by
proof · 11 lines
  apply strictMonoOn_of_deriv_pos (convex_Ici 0) continuous_sinhc.continuousOn
  intro q hq
  rw [interior_Ici, mem_Ioi] at hq
  have he : sinhc =ᶠ[𝓝 q] fun x => Real.sinh x / x := by
    filter_upwards [eventually_ne_nhds hq.ne'] with x hx
    exact sinhc_of_ne hx
  rw [he.deriv_eq]
  change 0 < deriv (Real.sinh / id) q
  rw [((Real.hasDerivAt_sinh q).div (hasDerivAt_id q) hq.ne').deriv]
  simpa only [one_mul, mul_one, mul_comm, id_eq] using
    div_pos (sub_pos.mpr (sinh_lt_mul_cosh hq)) (sq_pos_of_pos hq)
946
theorem strictAntiOn_sinc : StrictAntiOn Real.sinc (Icc 0 Real.pi) := by
proof · 13 lines
  apply strictAntiOn_of_deriv_neg (convex_Icc 0 Real.pi) Real.continuous_sinc.continuousOn
  intro p hp
  rw [interior_Icc, mem_Ioo] at hp
  have he : Real.sinc =ᶠ[𝓝 p] fun x => Real.sin x / x := by
    filter_upwards [eventually_ne_nhds hp.1.ne'] with x hx
    exact Real.sinc_of_ne_zero hx
  rw [he.deriv_eq]
  change deriv (Real.sin / id) p < 0
  rw [((Real.hasDerivAt_sin p).div (hasDerivAt_id p) hp.1.ne').deriv]
  apply div_neg_of_neg_of_pos _ (sq_pos_of_pos hp.1)
  have := sin_sub_mul_cos_pos hp
  simp only [mul_one, id_eq]
  nlinarith
961
@[simp] theorem csinc_ofReal (p : ℝ) : csinc (p : ℂ) = (Real.sinc p : ℂ) := by
proof · 4 lines
  rcases eq_or_ne p 0 with rfl | hp
  · simp [csinc_zero]
  · rw [csinc_of_ne (Complex.ofReal_ne_zero.mpr hp), sineParameter,
      Real.sinc_of_ne_zero hp, ← Complex.ofReal_sin, Complex.ofReal_div]
967
@[simp] theorem csinc_mul_I (q : ℝ) : csinc ((q : ℂ) * I) = (sinhc q : ℂ) := by
proof · 6 lines
  rcases eq_or_ne q 0 with rfl | hq
  · simp [csinc_zero]
  · rw [csinc_of_ne (mul_ne_zero (Complex.ofReal_ne_zero.mpr hq) Complex.I_ne_zero),
      sineParameter, Complex.sin_mul_I, ← Complex.ofReal_sinh, sinhc_of_ne hq,
      Complex.ofReal_div]
    field_simp
975
def closedSineQuadrant : Set ℂ := {w | 0 < w.re ∧ w.im ≤ 0}
976
def closedSineDomain : Set ℂ := sineStrip ∩ csinc ⁻¹' closedSineQuadrant
978
theorem csinc_strip_re_lt_pi {z : ℂ} (hz : z ∈ sineStrip) (ha : 0 < (csinc z).re) :
    z.re < Real.pi := by
proof · 10 lines
  by_contra! hn
  have hp : z.re = Real.pi := le_antisymm hz.2.1 hn
  have hz0 : z ≠ 0 := by intro he; simp [he] at hp; linarith [Real.pi_pos]
  rw [csinc_of_ne hz0, sineParameter_re, hp] at ha
  simp only [Real.sin_pi, Real.cos_pi, mul_zero, zero_mul, mul_neg_one, zero_add] at ha
  have : -(z.im * Real.sinh z.im) / (Real.pi ^ 2 + z.im ^ 2) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr
      (mul_nonneg hz.2.2 (Real.sinh_nonneg_iff.mpr hz.2.2))) (by positivity)
  rw [neg_mul] at ha
  linarith
991
theorem csinc_boundary_axes {z : ℂ} (hz : z ∈ closedSineDomain)
    (hi : (csinc z).im = 0) : z.re = 0 ∨ z.im = 0 := by
proof · 6 lines
  by_contra! hn
  have hp : 0 < z.re := lt_of_le_of_ne hz.1.1 hn.1.symm
  have hq : 0 < z.im := lt_of_le_of_ne hz.1.2.2 hn.2.symm
  have he := sineParameter_im_neg ⟨hp, csinc_strip_re_lt_pi hz.1 hz.2.1⟩ hq
  rw [← csinc_of_ne (show z ≠ 0 by intro he; simp [he] at hp)] at he
  linarith
1000
theorem sinc_eq_sinhc_only_zero {p q : ℝ} (hp : p ∈ Icc 0 Real.pi) (hq : 0 ≤ q)
    (he : Real.sinc p = sinhc q) : p = 0 ∧ q = 0 := by
proof · 15 lines
  have hlow : 1 ≤ sinhc q := by
    simpa using strictMonoOn_sinhc.monotoneOn (show (0 : ℝ) ∈ Ici 0 by simp) hq hq
  have hp0 : p = 0 := by
    by_contra hn
    have hlt := strictAntiOn_sinc ⟨le_rfl, Real.pi_pos.le⟩ hp (lt_of_le_of_ne hp.1 (Ne.symm hn))
    simp only [Real.sinc_zero] at hlt
    linarith
  have hq0 : q = 0 := by
    by_contra hn
    have hlt := strictMonoOn_sinhc (show (0 : ℝ) ∈ Ici 0 by simp) hq
      (lt_of_le_of_ne hq (Ne.symm hn))
    simp only [sinhc_zero] at hlt
    simp [hp0] at he
    linarith
  exact ⟨hp0, hq0⟩
1018
theorem eq_of_im_zero {z : ℂ} (hz : z.im = 0) : z = (z.re : ℂ) := by
proof · 1 line
  apply Complex.ext <;> simp [hz]
1021
theorem eq_mul_I_of_re_zero {z : ℂ} (hz : z.re = 0) : z = (z.im : ℂ) * I := by
proof · 1 line
  apply Complex.ext <;> simp [hz]
1024
theorem csinc_eq_sinhc_of_re_zero {z : ℂ} (hz : z.re = 0) :
    csinc z = (sinhc z.im : ℂ) :=
proof · 1 line
  (congrArg csinc (eq_mul_I_of_re_zero hz)).trans (csinc_mul_I z.im)
1028
theorem csinc_eq_sinc_of_im_zero {z : ℂ} (hz : z.im = 0) :
    csinc z = (Real.sinc z.re : ℂ) :=
proof · 1 line
  (congrArg csinc (eq_of_im_zero hz)).trans (csinc_ofReal z.re)
1032
theorem csinc_injOn_closedSineDomain : InjOn csinc closedSineDomain := by
proof · 32 lines
  intro z hz w hw he
  by_cases hi : (csinc z).im < 0
  · have hz' : z ∈ sineDomain := csinc_strip_quadrant hz.1 ⟨hz.2.1, hi⟩
    have hw' : w ∈ sineDomain := csinc_strip_quadrant hw.1 ⟨hw.2.1, he ▸ hi⟩
    exact congrArg Subtype.val (bijective_sineMap.1 (a₁ := ⟨z, hz'⟩) (a₂ := ⟨w, hw'⟩)
      (Subtype.ext he))
  · have hi0 : (csinc z).im = 0 := le_antisymm hz.2.2 (le_of_not_gt hi)
    have hiw : (csinc w).im = 0 := he ▸ hi0
    rcases csinc_boundary_axes hz hi0 with hzr | hzi <;>
      rcases csinc_boundary_axes hw hiw with hwr | hwi
    · have he' : sinhc z.im = sinhc w.im := by
        apply Complex.ofReal_injective
        simpa only [csinc_eq_sinhc_of_re_zero hzr, csinc_eq_sinhc_of_re_zero hwr] using he
      have heq := strictMonoOn_sinhc.injOn hz.1.2.2 hw.1.2.2 he'
      exact Complex.ext (hzr.trans hwr.symm) heq
    · have he' : Real.sinc w.re = sinhc z.im := by
        apply Complex.ofReal_injective
        simpa only [csinc_eq_sinhc_of_re_zero hzr, csinc_eq_sinc_of_im_zero hwi]
          using he.symm
      obtain ⟨hwr0, hzi0⟩ := sinc_eq_sinhc_only_zero ⟨hw.1.1, hw.1.2.1⟩ hz.1.2.2 he'
      exact Complex.ext (hzr.trans hwr0.symm) (hzi0.trans hwi.symm)
    · have he' : Real.sinc z.re = sinhc w.im := by
        apply Complex.ofReal_injective
        simpa only [csinc_eq_sinc_of_im_zero hzi, csinc_eq_sinhc_of_re_zero hwr]
          using he
      obtain ⟨hzr0, hwi0⟩ := sinc_eq_sinhc_only_zero ⟨hz.1.1, hz.1.2.1⟩ hw.1.2.2 he'
      exact Complex.ext (hzr0.trans hwr.symm) (hzi.trans hwi0.symm)
    · have he' : Real.sinc z.re = Real.sinc w.re := by
        apply Complex.ofReal_injective
        simpa only [csinc_eq_sinc_of_im_zero hzi, csinc_eq_sinc_of_im_zero hwi] using he
      have heq := strictAntiOn_sinc.injOn ⟨hz.1.1, hz.1.2.1⟩ ⟨hw.1.1, hw.1.2.1⟩ he'
      exact Complex.ext heq (hzi.trans hwi.symm)
1066
def closedSineMap : closedSineDomain → closedSineQuadrant := fun z => ⟨csinc z, z.property.2⟩
1068
theorem continuous_closedSineMap : Continuous closedSineMap :=
proof · 1 line
  (continuous_csinc.comp continuous_subtype_val).subtype_mk _
1071
theorem proper_closedSineMap : IsProperMap closedSineMap := by
proof · 15 lines
  apply isProperMap_iff_isCompact_preimage.mpr
  refine ⟨continuous_closedSineMap, ?_⟩
  intro K hK
  have hc := isCompact_strip_preimage (hK.image continuous_subtype_val)
  have he : Subtype.val '' (closedSineMap ⁻¹' K) = sineStrip ∩ csinc ⁻¹' (Subtype.val '' K) := by
    ext z
    constructor
    · rintro ⟨u, hu, rfl⟩
      exact ⟨u.property.1, _, hu, rfl⟩
    · rintro ⟨hz, w, hw, he⟩
      have ha : csinc z ∈ closedSineQuadrant := he ▸ w.property
      refine ⟨⟨z, hz, ha⟩, ?_, rfl⟩
      have hw' : closedSineMap ⟨z, hz, ha⟩ = w := Subtype.ext he.symm
      simpa [hw'] using hw
  exact (Topology.IsEmbedding.subtypeVal.isCompact_iff).mpr (he ▸ hc)
1088
theorem closedSineMap_injective : Function.Injective closedSineMap := by
proof · 3 lines
  intro z w he
  apply Subtype.ext
  exact csinc_injOn_closedSineDomain z.property w.property (congrArg Subtype.val he)
1093
theorem range_closedSineMap_of_im_neg {w : closedSineQuadrant} (hw : w.val.im < 0) :
    w ∈ range closedSineMap := by
proof · 6 lines
  obtain ⟨z, hz⟩ := bijective_sineMap.2 ⟨w, w.property.1, hw⟩
  have hm : z.val ∈ closedSineDomain :=
    ⟨⟨z.property.1.le, z.property.2.1.le, z.property.2.2.1.le⟩,
       z.property.2.2.2, (csinc_mapsTo z.property).2.le⟩
  have he : csinc z.val = w.val := congrArg (fun u : sineQuadrant => u.val) hz
  exact ⟨⟨z, hm⟩, Subtype.ext he⟩
1102
theorem closedSineMap_surjective : Function.Surjective closedSineMap := by
proof · 25 lines
  intro w
  let v : ℕ → closedSineQuadrant := fun n =>
    ⟨⟨w.val.re, w.val.im - 1 / ((n : ℝ) + 1)⟩, w.property.1,
      sub_nonpos.mpr (w.property.2.trans (by positivity))⟩
  have hv (n : ℕ) : (v n).val.im < 0 := by
    dsimp [v]
    have hp : 0 < 1 / ((n : ℝ) + 1) := by positivity
    linarith [w.property.2]
  have ht : Tendsto v atTop (𝓝 w) := by
    apply tendsto_subtype_rng.mpr
    have hzero : Tendsto (fun n : ℕ => 1 / ((n : ℝ) + 1)) atTop (𝓝 0) := by
      simpa only [Function.comp_def, Nat.cast_add, Nat.cast_one] using
        (tendsto_const_div_atTop_nhds_zero_nat (1 : ℝ)).comp (tendsto_add_atTop_nat 1)
    have h := (tendsto_const_nhds (x := w.val)).sub
      ((Complex.continuous_ofReal.continuousAt.tendsto.comp hzero).mul_const I)
    simp only [Complex.ofReal_zero, zero_mul, sub_zero] at h
    convert h using 1
    funext n
    apply Complex.ext <;>
      simp only [v, Function.comp_apply, Complex.sub_re, Complex.sub_im,
        Complex.mul_re, Complex.mul_im, Complex.ofReal_re, Complex.ofReal_im,
        Complex.I_re, Complex.I_im, mul_zero, mul_one, sub_zero, add_zero]

  exact proper_closedSineMap.isClosed_range.mem_of_tendsto ht
    (Eventually.of_forall (fun n => range_closedSineMap_of_im_neg (hv n)))
1129
def closedSineHomeomorph : closedSineDomain ≃ₜ closedSineQuadrant :=
body · 1 line
  (Equiv.ofBijective closedSineMap ⟨closedSineMap_injective, closedSineMap_surjective⟩).toHomeomorphOfContinuousClosed continuous_closedSineMap proper_closedSineMap.isClosedMap
1132
def closedSineInverse (w : ℂ) : ℂ := by
body · 2 lines
  classical
  exact if hw : w ∈ closedSineQuadrant then (closedSineHomeomorph.symm ⟨w, hw⟩).val else 0
1136
theorem closedSineInverse_mem {w : ℂ} (hw : w ∈ closedSineQuadrant) :
    closedSineInverse w ∈ closedSineDomain := by
proof · 2 lines
  simpa only [closedSineInverse, dite_eq_left hw] using
    (closedSineHomeomorph.symm ⟨w, hw⟩).property
1141
theorem csinc_closedSineInverse {w : ℂ} (hw : w ∈ closedSineQuadrant) :
    csinc (closedSineInverse w) = w := by
proof · 3 lines
  have he := congrArg Subtype.val (closedSineHomeomorph.apply_symm_apply ⟨w, hw⟩)
  change csinc (closedSineHomeomorph.symm ⟨w, hw⟩).val = w at he
  simpa only [closedSineInverse, dite_eq_left hw] using he
1147
theorem continuousOn_closedSineInverse : ContinuousOn closedSineInverse closedSineQuadrant := by
proof · 7 lines
  rw [continuousOn_iff_continuous_domRestrict]
  have he : closedSineQuadrant.domRestrict closedSineInverse =
      fun w : closedSineQuadrant => (closedSineHomeomorph.symm w).val := by
    funext w
    simp only [domRestrict_apply, closedSineInverse, dite_eq_left w.property]
  rw [he]
  exact continuous_subtype_val.comp closedSineHomeomorph.symm.continuous
1156
theorem closedSineInverse_eq_sineInverse {w : ℂ} (hw : w ∈ sineQuadrant) :
    closedSineInverse w = sineInverse w := by
proof · 5 lines
  have hw' : w ∈ closedSineQuadrant := ⟨hw.1, hw.2.le⟩
  have hz := sineInverse_mem hw
  apply csinc_injOn_closedSineDomain (closedSineInverse_mem hw')
    ⟨⟨hz.1.le, hz.2.1.le, hz.2.2.1.le⟩, hz.2.2.2, (csinc_mapsTo hz).2.le⟩
  exact (csinc_closedSineInverse hw').trans (csinc_sineInverse hw).symm
1164
def ccot (z : ℂ) : ℂ := Complex.cos z / csinc z
1166
@[simp] theorem ccot_zero : ccot 0 = 1 := by simp [ccot, csinc_zero]
1168
theorem ccot_eq_cotParameter {z : ℂ} (hz : z ≠ 0) : ccot z = cotParameter z := by
proof · 2 lines
  rw [ccot, csinc_of_ne hz, sineParameter, cotParameter]
  rw [div_div_eq_mul_div, mul_comm]
1172
theorem continuousAt_ccot {z : ℂ} (hz : csinc z ≠ 0) : ContinuousAt ccot z :=
proof · 1 line
  Complex.continuous_cos.continuousAt.div continuous_csinc.continuousAt hz
1175
theorem ccot_boundary_im {w : ℂ} (hw : w ∈ closedSineQuadrant) (hi : w.im = 0) :
    (ccot (closedSineInverse w)).im = 0 := by
proof · 18 lines
  let z := closedSineInverse w
  have hz : z ∈ closedSineDomain := closedSineInverse_mem hw
  have he : csinc z = w := csinc_closedSineInverse hw
  rcases csinc_boundary_axes hz (by rw [he, hi]) with hr | hi'
  · have hcos : Complex.cos z = (Real.cosh z.im : ℂ) := by
      calc
        Complex.cos z = Complex.cos ((z.im : ℂ) * I) := congrArg _ (eq_mul_I_of_re_zero hr)
        _ = (Real.cosh z.im : ℂ) := by rw [Complex.cos_mul_I, Complex.ofReal_cosh]
    change (ccot z).im = 0
    rw [ccot, hcos, csinc_eq_sinhc_of_re_zero hr, ← Complex.ofReal_div]
    exact Complex.ofReal_im _
  · have hcos : Complex.cos z = (Real.cos z.re : ℂ) := by
      calc
        Complex.cos z = Complex.cos (z.re : ℂ) := congrArg _ (eq_of_im_zero hi')
        _ = (Real.cos z.re : ℂ) := (Complex.ofReal_cos _).symm
    change (ccot z).im = 0
    rw [ccot, hcos, csinc_eq_sinc_of_im_zero hi', ← Complex.ofReal_div]
    exact Complex.ofReal_im _
1196
def upperReflect (s : ℂ) : ℂ := ⟨s.re, |s.im|⟩
1198
theorem continuous_upperReflect : Continuous upperReflect := by
proof · 5 lines
  have he : upperReflect = fun s : ℂ => (s.re : ℂ) + ((|s.im| : ℝ) : ℂ) * I := by
    funext s
    apply Complex.ext <;> simp [upperReflect]
  rw [he]
  fun_prop
1205
theorem upperReflect_eq {s : ℂ} (hs : 0 ≤ s.im) : upperReflect s = s := by
proof · 1 line
  apply Complex.ext <;> simp [upperReflect, abs_of_nonneg hs]
1208
theorem inv_sqrt_mem_closedSineQuadrant {s : ℂ} (hr : 0 < s.re) (hi : 0 ≤ s.im) :
    (Complex.sqrt s)⁻¹ ∈ closedSineQuadrant := by
proof · 12 lines
  rcases eq_or_lt_of_le hi with he | hpos
  · have hs : s = (s.re : ℂ) := eq_of_im_zero he.symm
    have hsq : Complex.sqrt s = (Real.sqrt s.re : ℂ) := by
      rw [hs]
      change (s.re : ℂ) ^ (2⁻¹ : ℂ) = (Real.sqrt s.re : ℂ)
      rw [Real.sqrt_eq_rpow, Complex.ofReal_cpow hr.le]
      congr 1
      norm_num
    rw [hsq, ← Complex.ofReal_inv]
    exact ⟨inv_pos.mpr (Real.sqrt_pos.mpr hr), by simp⟩
  · have hm := inv_sqrt_mem_sineQuadrant hpos
    exact ⟨hm.1, hm.2.le⟩
1223
def boundaryB (s : ℂ) : ℂ := ccot (closedSineInverse (Complex.sqrt (upperReflect s))⁻¹)
1225
theorem boundaryB_eq_upperB {s : ℂ} (hs : 0 < s.im) : boundaryB s = upperB s := by
proof · 4 lines
  rw [boundaryB, upperReflect_eq hs.le,
    closedSineInverse_eq_sineInverse (inv_sqrt_mem_sineQuadrant hs)]
  have hz := sineInverse_mem (inv_sqrt_mem_sineQuadrant hs)
  exact ccot_eq_cotParameter (by intro he; have hr := hz.1; simp [he] at hr)
1231
theorem analyticAt_boundaryB {s : ℂ} (hs : 0 < s.im) : AnalyticAt ℂ boundaryB s := by
proof · 3 lines
  apply (analyticAt_upperB hs).congr
  filter_upwards [(isOpen_lt continuous_const Complex.continuous_im).mem_nhds hs] with z hz
  exact (boundaryB_eq_upperB hz).symm
1236
theorem boundaryB_im_neg {s : ℂ} (hs : 0 < s.im) : (boundaryB s).im < 0 := by
proof · 2 lines
  rw [boundaryB_eq_upperB hs]
  exact upperB_im_neg hs
1240
theorem continuousAt_reflectedRoot {s : ℂ} (hs : 0 < s.re) :
    ContinuousAt (fun z => (Complex.sqrt (upperReflect z))⁻¹) s := by
proof · 9 lines
  have hm : (Complex.sqrt (upperReflect s))⁻¹ ∈ closedSineQuadrant :=
    inv_sqrt_mem_closedSineQuadrant hs (abs_nonneg _)
  have hn : Complex.sqrt (upperReflect s) ≠ 0 := by
    intro he
    have hp := hm.1
    simp only [he, inv_zero, Complex.zero_re, lt_self_iff_false] at hp
  have hc : ContinuousAt Complex.sqrt (upperReflect s) :=
    Complex.continuousAt_sqrt (Or.inl hs.le)
  exact (hc.comp continuous_upperReflect.continuousAt).inv₀ hn
1252
theorem continuousAt_boundaryB {x : ℝ} (hx : 0 < x) : ContinuousAt boundaryB (x : ℂ) := by
proof · 15 lines
  let U : Set ℂ := {s | 0 < s.re}
  let r : ℂ → ℂ := fun s => (Complex.sqrt (upperReflect s))⁻¹
  have hmaps : MapsTo r U closedSineQuadrant := fun s hs =>
    inv_sqrt_mem_closedSineQuadrant hs (abs_nonneg _)
  have hr : ContinuousOn r U := fun s hs => (continuousAt_reflectedRoot hs).continuousWithinAt
  have ht : ContinuousAt (closedSineInverse ∘ r) (x : ℂ) :=
    (continuousOn_closedSineInverse.comp hr hmaps).continuousAt
      ((isOpen_lt continuous_const Complex.continuous_re).mem_nhds hx)
  have hm : r (x : ℂ) ∈ closedSineQuadrant := hmaps hx
  have hn : csinc (closedSineInverse (r (x : ℂ))) ≠ 0 := by
    rw [csinc_closedSineInverse hm]
    intro he
    have hp := hm.1
    simp only [he, Complex.zero_re, lt_self_iff_false] at hp
  exact (continuousAt_ccot hn).comp (f := closedSineInverse ∘ r) ht
1269
theorem boundaryB_real {x : ℝ} (hx : 0 < x) : (boundaryB (x : ℂ)).im = 0 := by
proof · 9 lines
  have hr : (Complex.sqrt (x : ℂ))⁻¹ ∈ closedSineQuadrant :=
    inv_sqrt_mem_closedSineQuadrant hx (by simp)
  have hi : ((Complex.sqrt (x : ℂ))⁻¹).im = 0 := by
    have hs : Complex.sqrt (x : ℂ) = (Real.sqrt x : ℂ) := by
      exact Complex.sqrt_of_nonneg (by exact_mod_cast hx.le)
    rw [hs, ← Complex.ofReal_inv]
    exact Complex.ofReal_im _
  rw [boundaryB, upperReflect_eq (by simp : (0 : ℝ) ≤ (x : ℂ).im)]
  exact ccot_boundary_im hr hi
1280
@[simp] theorem closedSineInverse_one : closedSineInverse 1 = 0 := by
proof · 7 lines
  have hw : (1 : ℂ) ∈ closedSineQuadrant := by constructor <;> norm_num
  have hz : (0 : ℂ) ∈ closedSineDomain := by
    refine ⟨⟨le_rfl, Real.pi_pos.le, le_rfl⟩, ?_⟩
    change csinc 0 ∈ closedSineQuadrant
    simpa only [csinc_zero] using hw
  exact csinc_injOn_closedSineDomain (closedSineInverse_mem hw) hz
    ((csinc_closedSineInverse hw).trans csinc_zero.symm)
1289
@[simp] theorem boundaryB_one : boundaryB 1 = 1 := by
proof · 2 lines
  rw [boundaryB, upperReflect_eq (by norm_num), Complex.sqrt_one, inv_one,
    closedSineInverse_one, ccot_zero]

Xet Storage Details

Size:
57.4 kB
·
Xet hash:
3a3adb91cadb374387913dc8f2007722caf1b8e4d4a705a6c3154e9bbf809a52

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.