thurston-lean / Thurston /Core /Counterexamples.lean
system's picture
system HF Staff
Sync Lean + ledger from GitHub (6d6513147f03fcdca5249ee06cbaf74ba025e4b0)
55a3af4 verified
Raw History Blame Contribute Delete
33.6 kB

The radial twist H(z) = z · exp(i · ‖z‖ / (1 - ‖z‖)) on ℂ.

33
noncomputable def radialTwist (z : ℂ) : ℂ :=
body · 1 line
  z * Complex.exp (Complex.I * ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ))

The inverse radial twist H⁻¹(z) = z · exp(-i · ‖z‖ / (1 - ‖z‖)) on ℂ.

37
noncomputable def radialTwistInv (z : ℂ) : ℂ :=
body · 1 line
  z * Complex.exp (-Complex.I * ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ))

radialTwist preserves the Euclidean norm on ℂ.

41
theorem norm_radialTwist (z : ℂ) : ‖radialTwist z‖ = ‖z‖ := by
proof · 2 lines
  unfold radialTwist
  rw [norm_mul, mul_comm Complex.I, Complex.norm_exp_ofReal_mul_I, mul_one]

radialTwistInv preserves the Euclidean norm on ℂ.

46
theorem norm_radialTwistInv (z : ℂ) : ‖radialTwistInv z‖ = ‖z‖ := by
proof · 6 lines
  unfold radialTwistInv
  have h : -Complex.I * ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ) =
      ((-(‖z‖ / (1 - ‖z‖)) : ℝ) : ℂ) * Complex.I := by
    push_cast
    ring
  rw [norm_mul, h, Complex.norm_exp_ofReal_mul_I, mul_one]

radialTwistInv is a left inverse to radialTwist on all of ℂ.

55
theorem radialTwist_left_inv (z : ℂ) : radialTwistInv (radialTwist z) = z := by
proof · 7 lines
  unfold radialTwistInv radialTwist
  rw [norm_mul, mul_comm Complex.I, Complex.norm_exp_ofReal_mul_I, mul_one, mul_assoc,
    ← Complex.exp_add]
  have hzero : ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ) * Complex.I +
      -Complex.I * ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ) = 0 := by
    ring
  rw [hzero, Complex.exp_zero, mul_one]

radialTwistInv is a right inverse to radialTwist on all of ℂ.

65
theorem radialTwist_right_inv (z : ℂ) : radialTwist (radialTwistInv z) = z := by
proof · 8 lines
  unfold radialTwist radialTwistInv
  have hnorm : ‖z * Complex.exp (-Complex.I * ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ))‖ = ‖z‖ :=
    norm_radialTwistInv z
  rw [hnorm, mul_assoc, ← Complex.exp_add]
  have hzero : -Complex.I * ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ) +
      Complex.I * ((‖z‖ / (1 - ‖z‖) : ℝ) : ℂ) = 0 := by
    ring
  rw [hzero, Complex.exp_zero, mul_one]
75
private lemma continuous_radialAngle_on_ball :
    Continuous fun z : Metric.ball (0 : ℂ) 1 => (‖z.1‖ / (1 - ‖z.1‖) : ℝ) := by
proof · 5 lines
  refine (continuous_norm.comp continuous_subtype_val).div
    (continuous_const.sub (continuous_norm.comp continuous_subtype_val)) ?_
  intro z
  have hz : ‖z.1‖ < 1 := mem_ball_zero_iff.mp z.2
  linarith

Remark 12.4 (`rem:ep-twist`): radialTwist restricts to a self-homeomorphism of the open unit disk Metric.ball (0 : ℂ) 1, with inverse radialTwistInv.

85
noncomputable def radialTwistHomeomorph :
    Homeomorph (Metric.ball (0 : ℂ) 1) (Metric.ball (0 : ℂ) 1) where
body · 20 lines
  toFun z := ⟨radialTwist z.1, mem_ball_zero_iff.mpr <| by
    rw [norm_radialTwist]
    exact mem_ball_zero_iff.mp z.2⟩
  invFun z := ⟨radialTwistInv z.1, mem_ball_zero_iff.mpr <| by
    rw [norm_radialTwistInv]
    exact mem_ball_zero_iff.mp z.2⟩
  left_inv z := Subtype.ext (radialTwist_left_inv z.1)
  right_inv z := Subtype.ext (radialTwist_right_inv z.1)
  continuous_toFun := by
    refine Continuous.subtype_mk ?_ _
    unfold radialTwist
    exact continuous_subtype_val.mul <|
      Complex.continuous_exp.comp <|
        continuous_const.mul (Complex.continuous_ofReal.comp continuous_radialAngle_on_ball)
  continuous_invFun := by
    refine Continuous.subtype_mk ?_ _
    unfold radialTwistInv
    exact continuous_subtype_val.mul <|
      Complex.continuous_exp.comp <|
        continuous_const.mul (Complex.continuous_ofReal.comp continuous_radialAngle_on_ball)

Positive-limit radial sequence r_n = 2π n / (1 + 2π n) along [0, 1).

109
noncomputable def twistSeqPos (n : ℕ) : ℝ :=
body · 1 line
  2 * Real.pi * n / (1 + 2 * Real.pi * n)

Negative-limit radial sequence s_n = (2n + 1)π / (1 + (2n + 1)π) along (0, 1).

113
noncomputable def twistSeqNeg (n : ℕ) : ℝ :=
body · 1 line
  (2 * n + 1) * Real.pi / (1 + (2 * n + 1) * Real.pi)

Every r_n = twistSeqPos n lies in [0, 1).

117
theorem twistSeqPos_mem_Ico (n : ℕ) : twistSeqPos n ∈ Set.Ico 0 1 := by
proof · 3 lines
  unfold twistSeqPos
  have hx : 0 ≤ 2 * Real.pi * (n : ℝ) := by positivity
  exact ⟨by positivity, (div_lt_one (by linarith)).2 (by linarith)⟩

Every s_n = twistSeqNeg n lies in (0, 1).

123
theorem twistSeqNeg_mem_Ioo (n : ℕ) : twistSeqNeg n ∈ Set.Ioo 0 1 := by
proof · 3 lines
  unfold twistSeqNeg
  have hx : 0 < (2 * (n : ℝ) + 1) * Real.pi := by positivity
  exact ⟨by positivity, (div_lt_one (by linarith)).2 (by linarith)⟩
128
private lemma tendsto_div_one_add_atTop {u : ℕ → ℝ} (hu : Tendsto u atTop atTop) :
    Tendsto (fun n => u n / (1 + u n)) atTop (𝓝 1) := by
proof · 10 lines
  have h1 : Tendsto (fun n => 1 + u n) atTop atTop :=
    tendsto_atTop_add_const_left atTop 1 hu
  have hsub : Tendsto (fun n => 1 - (1 + u n)⁻¹) atTop (𝓝 (1 - 0)) :=
    tendsto_const_nhds.sub (tendsto_inv_atTop_zero.comp h1)
  rw [sub_zero] at hsub
  refine hsub.congr' ?_
  filter_upwards [h1.eventually_gt_atTop 0] with n hn
  have hne : 1 + u n ≠ 0 := hn.ne'
  field_simp [hne]
  ring

twistSeqPos n → 1 in ℂ.

142
theorem tendsto_twistSeqPos : Tendsto (fun n => (twistSeqPos n : ℂ)) atTop (𝓝 1) := by
proof · 5 lines
  have hu : Tendsto (fun n : ℕ => 2 * Real.pi * (n : ℝ)) atTop atTop :=
    Tendsto.const_mul_atTop (by positivity) tendsto_natCast_atTop_atTop
  have hr : Tendsto twistSeqPos atTop (𝓝 1) := tendsto_div_one_add_atTop hu
  have h := (Complex.continuous_ofReal.tendsto (1 : ℝ)).comp hr
  simpa only [Function.comp_def, Complex.ofReal_one] using h

twistSeqNeg n → 1 in ℂ.

150
theorem tendsto_twistSeqNeg : Tendsto (fun n => (twistSeqNeg n : ℂ)) atTop (𝓝 1) := by
proof · 8 lines
  have h2n : Tendsto (fun n : ℕ => 2 * (n : ℝ) + 1) atTop atTop :=
    tendsto_atTop_add_const_right atTop 1 <|
      Tendsto.const_mul_atTop (by norm_num) tendsto_natCast_atTop_atTop
  have hu : Tendsto (fun n : ℕ => (2 * (n : ℝ) + 1) * Real.pi) atTop atTop :=
    Tendsto.atTop_mul_const Real.pi_pos h2n
  have hr : Tendsto twistSeqNeg atTop (𝓝 1) := tendsto_div_one_add_atTop hu
  have h := (Complex.continuous_ofReal.tendsto (1 : ℝ)).comp hr
  simpa only [Function.comp_def, Complex.ofReal_one] using h

radialTwist fixes every r_n = twistSeqPos n because r_n / (1 - r_n) = 2π n.

161
theorem radialTwist_twistSeqPos (n : ℕ) :
    radialTwist (twistSeqPos n : ℂ) = (twistSeqPos n : ℂ) := by
proof · 15 lines
  unfold radialTwist
  have hmem := twistSeqPos_mem_Ico n
  have hnorm : ‖(twistSeqPos n : ℂ)‖ = twistSeqPos n := by
    rw [Complex.norm_real, Real.norm_of_nonneg hmem.1]
  have hangle : twistSeqPos n / (1 - twistSeqPos n) = 2 * Real.pi * (n : ℝ) := by
    unfold twistSeqPos
    have hpos : 0 < 1 + 2 * Real.pi * (n : ℝ) := by positivity
    field_simp [hpos.ne']
    ring
  rw [hnorm, hangle]
  have harg : Complex.I * ((2 * Real.pi * (n : ℝ) : ℝ) : ℂ) =
      (n : ℂ) * (2 * Real.pi * Complex.I) := by
    push_cast
    ring
  rw [harg, Complex.exp_nat_mul, Complex.exp_two_pi_mul_I, one_pow, mul_one]

radialTwist negates every s_n = twistSeqNeg n because s_n / (1 - s_n) = (2n + 1)π.

180
theorem radialTwist_twistSeqNeg (n : ℕ) :
    radialTwist (twistSeqNeg n : ℂ) = -(twistSeqNeg n : ℂ) := by
proof · 16 lines
  unfold radialTwist
  have hmem := twistSeqNeg_mem_Ioo n
  have hnorm : ‖(twistSeqNeg n : ℂ)‖ = twistSeqNeg n := by
    rw [Complex.norm_real, Real.norm_of_nonneg hmem.1.le]
  have hangle : twistSeqNeg n / (1 - twistSeqNeg n) = (2 * (n : ℝ) + 1) * Real.pi := by
    unfold twistSeqNeg
    have hpos : 0 < 1 + (2 * (n : ℝ) + 1) * Real.pi := by positivity
    field_simp [hpos.ne']
    ring
  rw [hnorm, hangle]
  have harg : Complex.I * (((2 * (n : ℝ) + 1) * Real.pi : ℝ) : ℂ) =
      (n : ℂ) * (2 * Real.pi * Complex.I) + Real.pi * Complex.I := by
    push_cast
    ring
  rw [harg, Complex.exp_add, Complex.exp_nat_mul, Complex.exp_two_pi_mul_I, one_pow, one_mul,
    Complex.exp_pi_mul_I, mul_neg_one]

radialTwist (twistSeqPos n) → 1.

200
theorem tendsto_radialTwist_twistSeqPos :
    Tendsto (fun n => radialTwist (twistSeqPos n : ℂ)) atTop (𝓝 1) := by
proof · 1 line
  simpa [radialTwist_twistSeqPos] using tendsto_twistSeqPos

radialTwist (twistSeqNeg n) → -1.

205
theorem tendsto_radialTwist_twistSeqNeg :
    Tendsto (fun n => radialTwist (twistSeqNeg n : ℂ)) atTop (𝓝 (-1)) := by
proof · 1 line
  simpa [radialTwist_twistSeqNeg] using tendsto_twistSeqNeg.neg

Remark 12.4 (`rem:ep-twist`): radialTwist admits no continuous extension from the open unit disk to the closed unit disk Metric.closedBall (0 : ℂ) 1.

211
theorem radialTwist_no_continuous_extension :
    ¬ ∃ F : Metric.closedBall (0 : ℂ) 1 → ℂ,
      Continuous F ∧ ∀ z : ℂ, (hz : ‖z‖ < 1) → F ⟨z, by simp [hz.le]⟩ = radialTwist z := by
proof · 28 lines
  rintro ⟨F, hFcont, hFeq⟩
  let a : ℕ → Metric.closedBall (0 : ℂ) 1 := fun n =>
    ⟨(twistSeqPos n : ℂ), by
      have hm := twistSeqPos_mem_Ico n
      simp [Metric.mem_closedBall, dist_zero_right, Real.norm_of_nonneg hm.1, hm.2.le]⟩
  let b : ℕ → Metric.closedBall (0 : ℂ) 1 := fun n =>
    ⟨(twistSeqNeg n : ℂ), by
      have hm := twistSeqNeg_mem_Ioo n
      simp [Metric.mem_closedBall, dist_zero_right, Real.norm_of_nonneg hm.1.le, hm.2.le]⟩
  let p1 : Metric.closedBall (0 : ℂ) 1 := ⟨1, by simp⟩
  have hFa : Tendsto (fun n => F (a n)) atTop (𝓝 (F p1)) :=
    (hFcont.continuousAt.tendsto).comp (tendsto_subtype_rng.2 tendsto_twistSeqPos)
  have hFb : Tendsto (fun n => F (b n)) atTop (𝓝 (F p1)) :=
    (hFcont.continuousAt.tendsto).comp (tendsto_subtype_rng.2 tendsto_twistSeqNeg)
  have hFa_eq : (fun n => F (a n)) = fun n => radialTwist (twistSeqPos n : ℂ) := by
    ext n
    have hm := twistSeqPos_mem_Ico n
    exact hFeq (twistSeqPos n : ℂ) (by simpa [Real.norm_of_nonneg hm.1] using hm.2)
  have hFb_eq : (fun n => F (b n)) = fun n => radialTwist (twistSeqNeg n : ℂ) := by
    ext n
    have hm := twistSeqNeg_mem_Ioo n
    exact hFeq (twistSeqNeg n : ℂ) (by simpa [Real.norm_of_nonneg hm.1.le] using hm.2)
  rw [hFa_eq] at hFa
  rw [hFb_eq] at hFb
  have h1 : F p1 = 1 := tendsto_nhds_unique hFa tendsto_radialTwist_twistSeqPos
  have h2 : F p1 = -1 := tendsto_nhds_unique hFb tendsto_radialTwist_twistSeqNeg
  have hcontra : (1 : ℂ) = -1 := h1.symm.trans h2
  norm_num at hcontra

The quadratic polynomial f(z) = z² + i of Remark 9.3.

246
def polyMap (z : ℂ) : ℂ := z ^ 2 + Complex.I

The second iterate f²(z) = (z² + i)² + i.

249
def polyMap2 (z : ℂ) : ℂ := polyMap (polyMap z)

Explicit square root of 1 - 2i: √((√5 + 1)/2) - i √((√5 - 1)/2).

252
noncomputable def polyRoot : ℂ :=
body · 1 line
  ⟨Real.sqrt ((Real.sqrt 5 + 1) / 2), -Real.sqrt ((Real.sqrt 5 - 1) / 2)⟩

polyRoot satisfies polyRoot² = 1 - 2i.

256
theorem polyRoot_sq : polyRoot ^ 2 = 1 - 2 * Complex.I := by
proof · 18 lines
  have h5 : (1 : ℝ) ≤ Real.sqrt 5 := by
    rw [← Real.sqrt_one]
    exact Real.sqrt_le_sqrt (by norm_num)
  have hpos1 : 0 ≤ (Real.sqrt 5 + 1) / 2 := by linarith
  have hpos2 : 0 ≤ (Real.sqrt 5 - 1) / 2 := by linarith
  have hprod : Real.sqrt ((Real.sqrt 5 + 1) / 2) * Real.sqrt ((Real.sqrt 5 - 1) / 2) = 1 := by
    rw [← Real.sqrt_mul hpos1]
    have hsq5 : Real.sqrt 5 ^ 2 = 5 := Real.sq_sqrt (by norm_num)
    have hmul : (Real.sqrt 5 + 1) / 2 * ((Real.sqrt 5 - 1) / 2) = 1 := by nlinarith
    rw [hmul, Real.sqrt_one]
  apply Complex.ext
  · simp only [sq, polyRoot, Complex.mul_re, Complex.sub_re, Complex.one_re, Complex.I_re,
      Complex.I_im, Complex.re_ofNat, Complex.im_ofNat, mul_neg, neg_mul, neg_neg]
    rw [← sq, ← sq, Real.sq_sqrt hpos1, Real.sq_sqrt hpos2]
    ring
  · simp only [sq, polyRoot, Complex.mul_im, Complex.sub_im, Complex.one_im, Complex.I_re,
      Complex.I_im, Complex.re_ofNat, Complex.im_ofNat, mul_neg, neg_mul]
    linarith

The 7-element forward-invariant finite marking A = {0, i, -i, -1 + i, 1 - i, √(1 - 2i), -√(1 - 2i)}.

278
noncomputable def polyMarks : Finset ℂ :=
body · 1 line
  {0, Complex.I, -Complex.I, -1 + Complex.I, 1 - Complex.I, polyRoot, -polyRoot}
281
private lemma ne_of_sq_ne {a b : ℂ} (h : a ^ 2 ≠ b ^ 2) : a ≠ b := fun hab => h (by rw [hab])
283
private lemma complex_ne_of_re {a b : ℂ} (h : a.re ≠ b.re) : a ≠ b :=
proof · 1 line
  fun hab => h (congrArg Complex.re hab)
286
private lemma complex_ne_of_im {a b : ℂ} (h : a.im ≠ b.im) : a ≠ b :=
proof · 1 line
  fun hab => h (congrArg Complex.im hab)
289
private lemma polyRoot_ne_zero : polyRoot ≠ 0 :=
proof · 1 line
  ne_of_sq_ne (by rw [polyRoot_sq, zero_pow (by norm_num)]; exact complex_ne_of_re (by norm_num))
292
private lemma polyRoot_ne_neg : polyRoot ≠ -polyRoot := fun h =>
proof · 1 line
  polyRoot_ne_zero (by linear_combination (1 / 2 : ℂ) * h)

Remark 9.3 (`r:poly`): the finite marking polyMarks has cardinality s = 7.

296
theorem polyMarks_card : polyMarks.card = 7 := by
proof · 35 lines
  have hI : (Complex.I : ℂ) ^ 2 = -1 := Complex.I_sq
  have hmI : (-Complex.I : ℂ) ^ 2 = -1 := by rw [neg_sq, Complex.I_sq]
  have hm1I : (-1 + Complex.I : ℂ) ^ 2 = -2 * Complex.I := by linear_combination Complex.I_sq
  have h1mI : (1 - Complex.I : ℂ) ^ 2 = -2 * Complex.I := by linear_combination Complex.I_sq
  have hpr : polyRoot ^ 2 = 1 - 2 * Complex.I := polyRoot_sq
  have hmpr : (-polyRoot) ^ 2 = 1 - 2 * Complex.I := by rw [neg_sq, polyRoot_sq]
  unfold polyMarks
  rw [card_insert_of_notMem, card_insert_of_notMem, card_insert_of_notMem, card_insert_of_notMem,
    card_insert_of_notMem, card_insert_of_notMem, card_singleton]
  · simp [polyRoot_ne_neg]
  · simp only [mem_insert, mem_singleton, not_or]
    exact ⟨ne_of_sq_ne (by rw [h1mI, hpr]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [h1mI, hmpr]; exact complex_ne_of_re (by norm_num))⟩
  · simp only [mem_insert, mem_singleton, not_or]
    exact ⟨complex_ne_of_re (by norm_num),
      ne_of_sq_ne (by rw [hm1I, hpr]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [hm1I, hmpr]; exact complex_ne_of_re (by norm_num))⟩
  · simp only [mem_insert, mem_singleton, not_or]
    exact ⟨ne_of_sq_ne (by rw [hmI, hm1I]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [hmI, h1mI]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [hmI, hpr]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [hmI, hmpr]; exact complex_ne_of_re (by norm_num))⟩
  · simp only [mem_insert, mem_singleton, not_or]
    exact ⟨complex_ne_of_im (by norm_num),
      ne_of_sq_ne (by rw [hI, hm1I]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [hI, h1mI]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [hI, hpr]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [hI, hmpr]; exact complex_ne_of_re (by norm_num))⟩
  · simp only [mem_insert, mem_singleton, not_or]
    exact ⟨ne_of_sq_ne (by rw [zero_pow (by norm_num), hI]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [zero_pow (by norm_num), hmI]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [zero_pow (by norm_num), hm1I]; exact complex_ne_of_im (by norm_num)),
      ne_of_sq_ne (by rw [zero_pow (by norm_num), h1mI]; exact complex_ne_of_im (by norm_num)),
      ne_of_sq_ne (by rw [zero_pow (by norm_num), hpr]; exact complex_ne_of_re (by norm_num)),
      ne_of_sq_ne (by rw [zero_pow (by norm_num), hmpr]; exact complex_ne_of_re (by norm_num))⟩

Critical orbit of f(z) = z² + i: 0 ↦ i ↦ -1 + i ↦ -i ↦ -1 + i.

334
theorem polyMap_critical_orbit :
    polyMap 0 = Complex.I ∧
      polyMap Complex.I = -1 + Complex.I ∧
      polyMap (-1 + Complex.I) = -Complex.I ∧
      polyMap (-Complex.I) = -1 + Complex.I := by
proof · 4 lines
  refine ⟨by unfold polyMap; ring,
    by unfold polyMap; linear_combination Complex.I_sq,
    by unfold polyMap; linear_combination Complex.I_sq,
    by unfold polyMap; linear_combination Complex.I_sq⟩

Remark 9.3 (`r:poly`): polyMarks is forward-invariant under f(z) = z² + i.

345
theorem polyMarks_forward_invariant : ∀ a ∈ polyMarks, polyMap a ∈ polyMarks := by
proof · 12 lines
  intro a ha
  simp only [polyMarks, mem_insert, mem_singleton] at ha ⊢
  rcases ha with rfl | rfl | rfl | rfl | rfl | rfl | rfl
  · exact Or.inr (Or.inl (by unfold polyMap; ring))
  · exact Or.inr (Or.inr (Or.inr (Or.inl (by unfold polyMap; linear_combination Complex.I_sq))))
  · exact Or.inr (Or.inr (Or.inr (Or.inl (by unfold polyMap; linear_combination Complex.I_sq))))
  · exact Or.inr (Or.inr (Or.inl (by unfold polyMap; linear_combination Complex.I_sq)))
  · exact Or.inr (Or.inr (Or.inl (by unfold polyMap; linear_combination Complex.I_sq)))
  · exact Or.inr (Or.inr (Or.inr (Or.inr (Or.inl (by
      unfold polyMap; rw [polyRoot_sq]; ring)))))
  · exact Or.inr (Or.inr (Or.inr (Or.inr (Or.inl (by
      unfold polyMap; rw [neg_sq, polyRoot_sq]; ring)))))

First derivative of f²(z) = (z² + i)² + i: (f²)'(z) = 4 z (z² + i).

360
theorem deriv_polyMap2 (z : ℂ) : deriv polyMap2 z = 4 * z * (z ^ 2 + Complex.I) := by
proof · 9 lines
  have hfn : polyMap2 = fun w : ℂ => (w ^ 2 + Complex.I) ^ 2 + Complex.I := rfl
  rw [hfn]
  have h1 : HasDerivAt (fun w : ℂ => w ^ 2 + Complex.I) (2 * z) z := by
    simpa using (hasDerivAt_pow 2 z).add_const Complex.I
  have h2 : HasDerivAt (fun w : ℂ => (w ^ 2 + Complex.I) ^ 2 + Complex.I)
      (2 * (z ^ 2 + Complex.I) ^ (2 - 1) * (2 * z)) z := by
    simpa using (h1.pow 2).add_const Complex.I
  rw [h2.deriv]
  ring

Second derivative of f²: (f²)''(z) = 4 (3 z² + i).

372
theorem deriv_deriv_polyMap2 (z : ℂ) :
    deriv (deriv polyMap2) z = 4 * (3 * z ^ 2 + Complex.I) := by
proof · 10 lines
  have hfn : deriv polyMap2 = fun w : ℂ => 4 * w ^ 3 + 4 * Complex.I * w := by
    ext w
    rw [deriv_polyMap2]
    ring
  rw [hfn]
  have h1 : HasDerivAt (fun w : ℂ => 4 * w ^ 3) (4 * (3 * z ^ 2)) z := by
    simpa using (hasDerivAt_pow 3 z).const_mul (4 : ℂ)
  have h2 : HasDerivAt (fun w : ℂ => 4 * Complex.I * w) (4 * Complex.I * 1) z := by
    simpa using (hasDerivAt_id z).const_mul (4 * Complex.I)
  exact (h1.add h2).deriv.trans (by ring)
385
private lemma deriv_polyMap2_ne_zero {z : ℂ} (hz0 : z ^ 2 ≠ 0) (hzI : z ^ 2 ≠ -Complex.I) :
    deriv polyMap2 z ≠ 0 := by
proof · 3 lines
  rw [deriv_polyMap2]
  exact mul_ne_zero (mul_ne_zero (by norm_num) (fun h => hz0 (by rw [h]; ring)))
    (fun h => hzI (by linear_combination h))

Remark 9.3 (`r:poly`): exact fibers and ramification of f² over the three finite poles i, -i, and -1 + i of p = dz² / ((z - i)(z + i)(z + 1 - i)).

393
theorem polyMap2_fibers :
    (∀ z : ℂ, polyMap2 z = Complex.I ↔ z ^ 2 = -Complex.I) ∧
      (∀ z : ℂ, z ^ 2 = -Complex.I →
        deriv polyMap2 z = 0 ∧ deriv (deriv polyMap2) z ≠ 0) ∧
      (∀ z : ℂ, polyMap2 z = -Complex.I ↔
        z ∈ ({Complex.I, -Complex.I, polyRoot, -polyRoot} : Finset ℂ)) ∧
      (∀ z ∈ ({Complex.I, -Complex.I, polyRoot, -polyRoot} : Finset ℂ),
        deriv polyMap2 z ≠ 0 ∧ z ∈ polyMarks) ∧
      (∀ z : ℂ, polyMap2 z = -1 + Complex.I ↔
        z = 0 ∨ z = 1 - Complex.I ∨ z = -1 + Complex.I) ∧
      (deriv polyMap2 0 = 0 ∧ deriv (deriv polyMap2) 0 ≠ 0) ∧
      (∀ z ∈ ({1 - Complex.I, -1 + Complex.I} : Finset ℂ),
        deriv polyMap2 z ≠ 0 ∧ z ∈ polyMarks) := by
proof · 87 lines
  refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩
  · intro z
    unfold polyMap2 polyMap
    constructor
    · intro h
      have hlin : z ^ 2 + Complex.I = 0 := sq_eq_zero_iff.mp (by linear_combination h)
      linear_combination hlin
    · intro h
      rw [h]
      ring
  · intro z hz
    rw [deriv_polyMap2, deriv_deriv_polyMap2, hz]
    refine ⟨by ring, ?_⟩
    have hval : 4 * (3 * -Complex.I + Complex.I) = -8 * Complex.I := by ring
    rw [hval]
    exact mul_ne_zero (by norm_num) Complex.I_ne_zero
  · intro z
    unfold polyMap2 polyMap
    simp only [mem_insert, mem_singleton]
    constructor
    · intro h
      have hsq : (z ^ 2 + Complex.I) ^ 2 = (1 - Complex.I) ^ 2 := by
        linear_combination h - Complex.I_sq
      rcases sq_eq_sq_iff_eq_or_eq_neg.mp hsq with h1 | h1
      · have hz2 : z ^ 2 = polyRoot ^ 2 := by rw [polyRoot_sq]; linear_combination h1
        rcases sq_eq_sq_iff_eq_or_eq_neg.mp hz2 with rfl | rfl
        · exact Or.inr (Or.inr (Or.inl rfl))
        · exact Or.inr (Or.inr (Or.inr rfl))
      · have hz2 : z ^ 2 = Complex.I ^ 2 := by rw [Complex.I_sq]; linear_combination h1
        rcases sq_eq_sq_iff_eq_or_eq_neg.mp hz2 with rfl | rfl
        · exact Or.inl rfl
        · exact Or.inr (Or.inl rfl)
    · rintro (rfl | rfl | rfl | rfl)
      · rw [Complex.I_sq]; ring_nf; rw [Complex.I_sq]; ring
      · rw [neg_sq, Complex.I_sq]; ring_nf; rw [Complex.I_sq]; ring
      · rw [polyRoot_sq]; ring_nf; rw [Complex.I_sq]; ring
      · rw [neg_sq, polyRoot_sq]; ring_nf; rw [Complex.I_sq]; ring
  · intro z hz
    simp only [mem_insert, mem_singleton] at hz
    rcases hz with rfl | rfl | rfl | rfl
    · exact ⟨deriv_polyMap2_ne_zero
        (by rw [Complex.I_sq]; exact complex_ne_of_re (by norm_num))
        (by rw [Complex.I_sq]; exact complex_ne_of_re (by norm_num)), by simp [polyMarks]⟩
    · exact ⟨deriv_polyMap2_ne_zero
        (by rw [neg_sq, Complex.I_sq]; exact complex_ne_of_re (by norm_num))
        (by rw [neg_sq, Complex.I_sq]; exact complex_ne_of_re (by norm_num)), by simp [polyMarks]⟩
    · exact ⟨deriv_polyMap2_ne_zero
        (by rw [polyRoot_sq]; exact complex_ne_of_re (by norm_num))
        (by rw [polyRoot_sq]; exact complex_ne_of_re (by norm_num)), by simp [polyMarks]⟩
    · exact ⟨deriv_polyMap2_ne_zero
        (by rw [neg_sq, polyRoot_sq]; exact complex_ne_of_re (by norm_num))
        (by rw [neg_sq, polyRoot_sq]; exact complex_ne_of_re (by norm_num)), by simp [polyMarks]⟩
  · intro z
    unfold polyMap2 polyMap
    constructor
    · intro h
      have hsq : (z ^ 2 + Complex.I) ^ 2 = Complex.I ^ 2 := by
        rw [Complex.I_sq]
        linear_combination h
      rcases sq_eq_sq_iff_eq_or_eq_neg.mp hsq with h1 | h1
      · exact Or.inl (sq_eq_zero_iff.mp (by linear_combination h1))
      · have hz2 : z ^ 2 = (1 - Complex.I) ^ 2 := by linear_combination h1 - Complex.I_sq
        rcases sq_eq_sq_iff_eq_or_eq_neg.mp hz2 with h2 | h2
        · exact Or.inr (Or.inl h2)
        · exact Or.inr (Or.inr (by linear_combination h2))
    · rintro (rfl | rfl | rfl)
      · ring_nf; rw [Complex.I_sq]; ring
      · have hsq : (1 - Complex.I) ^ 2 = -2 * Complex.I := by linear_combination Complex.I_sq
        rw [hsq]; ring_nf; rw [Complex.I_sq]; ring
      · have hsq : (-1 + Complex.I) ^ 2 = -2 * Complex.I := by linear_combination Complex.I_sq
        rw [hsq]; ring_nf; rw [Complex.I_sq]; ring
  · rw [deriv_polyMap2, deriv_deriv_polyMap2]
    refine ⟨by ring, ?_⟩
    have hval : 4 * (3 * (0 : ℂ) ^ 2 + Complex.I) = 4 * Complex.I := by ring
    rw [hval]
    exact mul_ne_zero (by norm_num) Complex.I_ne_zero
  · intro z hz
    simp only [mem_insert, mem_singleton] at hz
    rcases hz with rfl | rfl
    · have hsq : (1 - Complex.I) ^ 2 = -2 * Complex.I := by linear_combination Complex.I_sq
      exact ⟨deriv_polyMap2_ne_zero
        (by rw [hsq]; exact complex_ne_of_im (by norm_num))
        (by rw [hsq]; exact complex_ne_of_im (by norm_num)), by simp [polyMarks]⟩
    · have hsq : (-1 + Complex.I) ^ 2 = -2 * Complex.I := by linear_combination Complex.I_sq
      exact ⟨deriv_polyMap2_ne_zero
        (by rw [hsq]; exact complex_ne_of_im (by norm_num))
        (by rw [hsq]; exact complex_ne_of_im (by norm_num)), by simp [polyMarks]⟩

Coefficient of p = dz² / ((z - i)(z + i)(z + 1 - i)).

495
noncomputable def polyPCoeff (z : ℂ) : ℂ :=
body · 1 line
  1 / ((z - Complex.I) * (z + Complex.I) * (z + 1 - Complex.I))

Coefficient of the scaled pullback q = (f²)⋆ p / 4: q(z) = (1/4) · p(f²(z)) · ((f²)'(z))².

500
noncomputable def polyQCoeff (z : ℂ) : ℂ :=
body · 1 line
  (1 / 4 : ℂ) * polyPCoeff (polyMap2 z) * (deriv polyMap2 z) ^ 2

Remark 9.3 (`r:poly`): exact rational cancellation of q = (f²)⋆ p / 4. Away from the finite ramified points (z = 0 and z² = -i), the factor z² (z² + i)² cancels identically, leaving a rational function whose denominator vanishes only at the six unramified poles in A.

506
theorem polyPullback_exact_cancellation (z : ℂ) (hz0 : z ≠ 0) (hzI : z ^ 2 ≠ -Complex.I) :
    polyQCoeff z =
      4 / ((z ^ 2 + 1) * (z ^ 2 + 2 * Complex.I) * (z ^ 2 - (1 - 2 * Complex.I))) := by
proof · 24 lines
  unfold polyQCoeff polyPCoeff
  rw [deriv_polyMap2]
  set D := (z ^ 2 + 1) * (z ^ 2 + 2 * Complex.I) * (z ^ 2 - (1 - 2 * Complex.I))
  have hden :
      (polyMap2 z - Complex.I) * (polyMap2 z + Complex.I) * (polyMap2 z + 1 - Complex.I) =
        z ^ 2 * (z ^ 2 + Complex.I) ^ 2 * D := by
    unfold polyMap2 polyMap
    dsimp [D]
    have h1 : (z ^ 2 + Complex.I) ^ 2 + 2 * Complex.I =
        (z ^ 2 + 1) * (z ^ 2 - (1 - 2 * Complex.I)) := by linear_combination Complex.I_sq
    have h2 : (z ^ 2 + Complex.I) ^ 2 + 1 = z ^ 2 * (z ^ 2 + 2 * Complex.I) := by
      linear_combination Complex.I_sq
    have h3 : (z ^ 2 + Complex.I) ^ 2 + Complex.I - Complex.I = (z ^ 2 + Complex.I) ^ 2 := by ring
    have h4 : (z ^ 2 + Complex.I) ^ 2 + Complex.I + Complex.I =
        (z ^ 2 + Complex.I) ^ 2 + 2 * Complex.I := by ring
    have h5 : (z ^ 2 + Complex.I) ^ 2 + Complex.I + 1 - Complex.I =
        (z ^ 2 + Complex.I) ^ 2 + 1 := by ring
    rw [h3, h4, h5, h1, h2]
    ring
  rw [hden]
  by_cases hD : D = 0
  · simp [hD]
  · have hzi : z ^ 2 + Complex.I ≠ 0 := fun h => hzI (by linear_combination h)
    field_simp [hz0, hzi, hD]

The reduced denominator of q = (f²)⋆ p / 4 vanishes precisely at the six points {i, -i, 1 - i, -1 + i, √(1 - 2i), -√(1 - 2i)} ⊆ polyMarks.

536
theorem polyPullback_poles_in_marks :
    (∀ z : ℂ,
      (z ^ 2 + 1) * (z ^ 2 + 2 * Complex.I) * (z ^ 2 - (1 - 2 * Complex.I)) = 0 ↔
        z ∈ ({Complex.I, -Complex.I, 1 - Complex.I, -1 + Complex.I,
          polyRoot, -polyRoot} : Finset ℂ)) ∧
      ({Complex.I, -Complex.I, 1 - Complex.I, -1 + Complex.I,
        polyRoot, -polyRoot} : Finset ℂ) ⊆ polyMarks := by
proof · 30 lines
  refine ⟨?_, ?_⟩
  · intro z
    simp only [mul_eq_zero, mem_insert, mem_singleton]
    have h1 : z ^ 2 + 1 = 0 ↔ z = Complex.I ∨ z = -Complex.I := by
      have : z ^ 2 + 1 = 0 ↔ z ^ 2 = Complex.I ^ 2 := by
        rw [Complex.I_sq]
        constructor <;> intro h <;> linear_combination h
      rw [this, sq_eq_sq_iff_eq_or_eq_neg]
    have h2 : z ^ 2 + 2 * Complex.I = 0 ↔ z = 1 - Complex.I ∨ z = -1 + Complex.I := by
      have : z ^ 2 + 2 * Complex.I = 0 ↔ z ^ 2 = (1 - Complex.I) ^ 2 := by
        constructor <;> intro h
        · linear_combination h - Complex.I_sq
        · linear_combination h + Complex.I_sq
      rw [this, sq_eq_sq_iff_eq_or_eq_neg]
      constructor
      · rintro (h | h)
        · exact Or.inl h
        · exact Or.inr (by linear_combination h)
      · rintro (h | h)
        · exact Or.inl h
        · exact Or.inr (by linear_combination h)
    have h3 : z ^ 2 - (1 - 2 * Complex.I) = 0 ↔ z = polyRoot ∨ z = -polyRoot := by
      have : z ^ 2 - (1 - 2 * Complex.I) = 0 ↔ z ^ 2 = polyRoot ^ 2 := by
        rw [polyRoot_sq, sub_eq_zero]
      rw [this, sq_eq_sq_iff_eq_or_eq_neg]
    rw [h1, h2, h3]
    tauto
  · intro z hz
    simp only [polyMarks, mem_insert, mem_singleton] at hz ⊢
    rcases hz with rfl | rfl | rfl | rfl | rfl | rfl <;> simp

Every non-critical value w ∉ {i, -1 + i} of f² has 4 distinct unramified preimages.

575
theorem polyMap2_regular_fiber (w : ℂ) (hw1 : w ≠ Complex.I) (hw2 : w ≠ -1 + Complex.I) :
    ∃ z : Fin 4 → ℂ, Function.Injective z ∧
      ∀ i : Fin 4, polyMap2 (z i) = w ∧ deriv polyMap2 (z i) ≠ 0 := by
proof · 54 lines
  obtain ⟨u, hu⟩ := IsAlgClosed.exists_pow_nat_eq (w - Complex.I) (by norm_num : 0 < 2)
  have hu0 : u ≠ 0 := fun h0 =>
    hw1 (by rw [h0, zero_pow (by norm_num)] at hu; linear_combination hu.symm)
  have huI : u - Complex.I ≠ 0 := fun h =>
    hw2 (by
      have heq : u = Complex.I := by linear_combination h
      rw [heq, Complex.I_sq] at hu
      linear_combination hu.symm)
  have humI : -u - Complex.I ≠ 0 := fun h =>
    hw2 (by
      have heq : u = -Complex.I := by linear_combination -h
      rw [heq, neg_sq, Complex.I_sq] at hu
      linear_combination hu.symm)
  obtain ⟨z0, hz0⟩ := IsAlgClosed.exists_pow_nat_eq (u - Complex.I) (by norm_num : 0 < 2)
  obtain ⟨z2, hz2⟩ := IsAlgClosed.exists_pow_nat_eq (-u - Complex.I) (by norm_num : 0 < 2)
  have hz0_ne : z0 ≠ 0 := fun h => huI (by rw [← hz0, h]; ring)
  have hz2_ne : z2 ≠ 0 := fun h => humI (by rw [← hz2, h]; ring)
  have hsq_ne : z0 ^ 2 ≠ z2 ^ 2 := by
    rw [hz0, hz2]
    intro h
    exact hu0 (by linear_combination (1 / 2 : ℂ) * h)
  let z : Fin 4 → ℂ := ![z0, -z0, z2, -z2]
  refine ⟨z, ?_, ?_⟩
  · intro i j hij
    fin_cases i <;> fin_cases j <;> dsimp [z] at hij
    · rfl
    · exact absurd (by linear_combination (1 / 2 : ℂ) * hij : z0 = 0) hz0_ne
    · exact absurd (congrArg (· ^ 2) hij) hsq_ne
    · exact absurd (by rw [← neg_sq z2, ← hij]) hsq_ne
    · exact absurd (by linear_combination (-1 / 2 : ℂ) * hij : z0 = 0) hz0_ne
    · rfl
    · exact absurd (by rw [← neg_sq z0, hij]) hsq_ne
    · exact absurd (by rw [← neg_sq z0, hij, neg_sq]) hsq_ne
    · exact absurd (congrArg (· ^ 2) hij.symm) hsq_ne
    · exact absurd (by rw [← neg_sq z0, ← hij]) hsq_ne
    · rfl
    · exact absurd (by linear_combination (1 / 2 : ℂ) * hij : z2 = 0) hz2_ne
    · exact absurd (by rw [← neg_sq z2, hij]) hsq_ne
    · exact absurd (by rw [← neg_sq z0, ← neg_sq z2, hij]) hsq_ne
    · exact absurd (by linear_combination (-1 / 2 : ℂ) * hij : z2 = 0) hz2_ne
    · rfl
  · intro i
    fin_cases i <;> dsimp [z] <;> rw [deriv_polyMap2] <;> unfold polyMap2 polyMap
    · exact ⟨by rw [hz0]; linear_combination hu,
        mul_ne_zero (mul_ne_zero (by norm_num) hz0_ne) (by rw [hz0]; simpa using hu0)⟩
    · exact ⟨by rw [neg_sq, hz0]; linear_combination hu,
        mul_ne_zero (mul_ne_zero (by norm_num) (neg_ne_zero.mpr hz0_ne))
          (by rw [neg_sq, hz0]; simpa using hu0)⟩
    · exact ⟨by rw [hz2]; linear_combination hu,
        mul_ne_zero (mul_ne_zero (by norm_num) hz2_ne)
          (by rw [hz2]; simpa using neg_ne_zero.mpr hu0)⟩
    · exact ⟨by rw [neg_sq, hz2]; linear_combination hu,
        mul_ne_zero (mul_ne_zero (by norm_num) (neg_ne_zero.mpr hz2_ne))
          (by rw [neg_sq, hz2]; simpa using neg_ne_zero.mpr hu0)⟩

Remark 9.3 (`r:poly`): over any 4 unramified preimages z₀, z₁, z₂, z₃ of w under f², the pushforward of q = (f²)⋆ p / 4 equals p(w) with zero cancellation: ∑ i, q(zᵢ) / ((f²)'(zᵢ))² = p(w) and ∑ i, ‖q(zᵢ) / ((f²)'(zᵢ))²‖ = ‖p(w)‖.

636
theorem polyPushforward_zero_cancellation (w : ℂ) (z : Fin 4 → ℂ)
    (hpre : ∀ i : Fin 4, polyMap2 (z i) = w)
    (hunram : ∀ i : Fin 4, deriv polyMap2 (z i) ≠ 0) :
    (∑ i : Fin 4, polyQCoeff (z i) / (deriv polyMap2 (z i)) ^ 2 = polyPCoeff w) ∧
      (∑ i : Fin 4, ‖polyQCoeff (z i) / (deriv polyMap2 (z i)) ^ 2‖ = ‖polyPCoeff w‖) := by
proof · 14 lines
  have hterm : ∀ i : Fin 4,
      polyQCoeff (z i) / (deriv polyMap2 (z i)) ^ 2 = (1 / 4 : ℂ) * polyPCoeff w := by
    intro i
    unfold polyQCoeff
    rw [hpre i]
    exact mul_div_cancel_right₀ _ (pow_ne_zero 2 (hunram i))
  constructor
  · simp_rw [hterm]
    simp only [sum_const, card_univ, Fintype.card_fin, nsmul_eq_mul]
    ring
  · simp_rw [hterm, norm_mul]
    have hnorm : ‖(1 / 4 : ℂ)‖ = (1 / 4 : ℝ) := by norm_num
    simp only [hnorm, sum_const, card_univ, Fintype.card_fin, nsmul_eq_mul]
    ring