roseking's picture
Add lean source and binary files (part 95)
b224933 verified
Raw History Blame Contribute Delete
8.12 kB
18
noncomputable def sphereChartScaleND (u : V) : ℝ := Real.sqrt (1-‖u‖^2/4)
19
noncomputable def sphereChartND (u : V) : WithLp 2 (V × ℝ) :=
body · 1 line
  WithLp.toLp 2 (sphereChartScaleND u • u, 1-‖u‖^2/2)
23
lemma sphereChartScaleND_pos {u : V} (hu : ‖u‖ < 2) :
    0 < sphereChartScaleND u := by
proof · 2 lines
  apply Real.sqrt_pos.mpr
  nlinarith [norm_nonneg u]
29
lemma sphereChartScaleND_sq {u : V} (hu : ‖u‖ ≤ 2) :
    sphereChartScaleND u ^ 2 = 1-‖u‖^2/4 := by
proof · 2 lines
  apply Real.sq_sqrt
  nlinarith [norm_nonneg u]
34
lemma sphereChartND_norm {u : V} (hu : ‖u‖ ≤ 2) :
    ‖sphereChartND u‖ = 1 := by
proof · 8 lines
  have hs : 0 ≤ sphereChartScaleND u := Real.sqrt_nonneg _
  have he : ‖sphereChartND u‖^2 = 1 := by
    rw [sphereChartND, WithLp.prod_norm_sq_eq_of_L2]
    change ‖sphereChartScaleND u • u‖^2 + ‖(1-‖u‖^2/2:ℝ)‖^2 = 1
    simp only [norm_smul, Real.norm_eq_abs, mul_pow, sq_abs]
    rw [sphereChartScaleND_sq hu]
    ring
  nlinarith [norm_nonneg (sphereChartND u)]
45
lemma sphereChartND_mem_sphere {u : V} (hu : ‖u‖ ≤ 2) :
    sphereChartND u ∈ sphere (0 : WithLp 2 (V × ℝ)) 1 := by
proof · 1 line
  simpa only [mem_sphere, dist_zero_right] using sphereChartND_norm hu
49
lemma sphereChartND_phase (u : V) :
    inner ℝ (sphereChartND u) (WithLp.toLp 2 (0, (1:ℝ))) = 1-‖u‖^2/2 := by
proof · 1 line
  simp [sphereChartND,WithLp.prod_inner_apply]
53
lemma sphereChartND_north : sphereChartND (0:V) = WithLp.toLp 2 (0,(1:ℝ)) := by
proof · 1 line
  simp [sphereChartND]
56
lemma sphereChartND_snd_gt_neg_one {u : V} (hu : ‖u‖ < 2) :
    -1 < (WithLp.ofLp (sphereChartND u)).2 := by
proof · 2 lines
  change -1 < 1-‖u‖^2/2
  nlinarith [norm_nonneg u]
61
noncomputable def sphereChartInvND (w : WithLp 2 (V × ℝ)) : V :=
body · 1 line
  (Real.sqrt ((1+(WithLp.ofLp w).2)/2))⁻¹ • (WithLp.ofLp w).1
64
lemma sphereChartND_left_inv {u : V} (hu : ‖u‖ < 2) :
    sphereChartInvND (sphereChartND u) = u := by
proof · 5 lines
  have hs : sphereChartScaleND u ≠ 0 := (sphereChartScaleND_pos hu).ne'
  have he : (1+(1-‖u‖^2/2))/2 = 1-‖u‖^2/4 := by ring
  simp only [sphereChartInvND, sphereChartND, WithLp.ofLp_toLp, he]
  change (sphereChartScaleND u)⁻¹ • (sphereChartScaleND u • u) = u
  rw [← mul_smul, inv_mul_cancel₀ hs, one_smul]
72
lemma sphereChartND_injOn : InjOn (sphereChartND : V → WithLp 2 (V × ℝ)) (ball 0 2) := by
proof · 5 lines
  intro u hu v hv he
  have hu' : ‖u‖ < 2 := by simpa using hu
  have hv' : ‖v‖ < 2 := by simpa using hv
  have := congrArg sphereChartInvND he
  simpa [sphereChartND_left_inv hu', sphereChartND_left_inv hv'] using this
79
lemma sphereChartInvND_norm_sq {w : WithLp 2 (V × ℝ)} (hw : ‖w‖ = 1)
    (ht : -1 < (WithLp.ofLp w).2) :
    ‖sphereChartInvND w‖^2 = 2*(1-(WithLp.ofLp w).2) := by
proof · 12 lines
  have hp : 0 < (1+(WithLp.ofLp w).2)/2 := by linarith
  have hs : Real.sqrt ((1+(WithLp.ofLp w).2)/2)^2 = (1+(WithLp.ofLp w).2)/2 :=
    Real.sq_sqrt hp.le
  have hn : ‖(WithLp.ofLp w).1‖^2 + ((WithLp.ofLp w).2)^2 = 1 := by
    have he := WithLp.prod_norm_sq_eq_of_L2 w
    rw [hw] at he
    simpa [Real.norm_eq_abs, sq_abs] using he.symm
  unfold sphereChartInvND
  rw [norm_smul, Real.norm_eq_abs, mul_pow, sq_abs, inv_pow, hs]
  field_simp [show 1+(WithLp.ofLp w).2 ≠ 0 by linarith]
  rw [div_eq_iff (show 1+(WithLp.ofLp w).2 ≠ 0 by linarith)]
  nlinarith [hn]
95
lemma sphereChartInvND_mem_ball {w : WithLp 2 (V × ℝ)} (hw : ‖w‖ = 1)
    (ht : -1 < (WithLp.ofLp w).2) : sphereChartInvND w ∈ ball (0:V) 2 := by
proof · 3 lines
  have he := sphereChartInvND_norm_sq hw ht
  rw [mem_ball, dist_zero_right]
  nlinarith [norm_nonneg (sphereChartInvND w)]
101
lemma sphereChartND_right_inv {w : WithLp 2 (V × ℝ)} (hw : ‖w‖ = 1)
    (ht : -1 < (WithLp.ofLp w).2) : sphereChartND (sphereChartInvND w) = w := by
proof · 16 lines
  have he := sphereChartInvND_norm_sq hw ht
  have hp : 0 < (1+(WithLp.ofLp w).2)/2 := by linarith
  have hs : Real.sqrt ((1+(WithLp.ofLp w).2)/2) ≠ 0 := (Real.sqrt_pos.mpr hp).ne'
  have hscale : sphereChartScaleND (sphereChartInvND w) =
      Real.sqrt ((1+(WithLp.ofLp w).2)/2) := by
    unfold sphereChartScaleND
    rw [he]
    congr 1
    ring
  apply WithLp.ofLp_injective 2
  apply Prod.ext
  · change sphereChartScaleND (sphereChartInvND w) • sphereChartInvND w = (WithLp.ofLp w).1
    rw [hscale, sphereChartInvND, ← mul_smul, mul_inv_cancel₀ hs, one_smul]
  · change 1-‖sphereChartInvND w‖^2/2 = (WithLp.ofLp w).2
    rw [he]
    ring
120
lemma sphereChartScaleND_contDiffOn :
    ContDiffOn ℝ ⊤ (sphereChartScaleND : V → ℝ) (ball 0 2) := by
proof · 6 lines
  apply ContDiffOn.sqrt
    ((contDiffOn_const.sub ((contDiff_norm_sq ℝ).contDiffOn.div_const 4)))
  intro u hu
  have hu' : ‖u‖ < 2 := by simpa using hu
  have : 0 < 1-‖u‖^2/4 := by nlinarith [norm_nonneg u]
  exact this.ne'
129
lemma sphereChartND_contDiffOn :
    ContDiffOn ℝ ⊤ (sphereChartND : V → WithLp 2 (V × ℝ)) (ball 0 2) := by
proof · 3 lines
  exact (WithLp.prodContinuousLinearEquiv 2 ℝ V ℝ).symm.contDiff.comp_contDiffOn
    ((sphereChartScaleND_contDiffOn.smul contDiffOn_id).prodMk
      (contDiffOn_const.sub ((contDiff_norm_sq ℝ).contDiffOn.div_const 2)))
135
lemma sphereChartScaleND_hasStrictFDerivAt {u : V} (hu : ‖u‖ < 2) :
    HasStrictFDerivAt sphereChartScaleND
      ((-1/(4*sphereChartScaleND u)) • innerSL ℝ u) u := by
proof · 15 lines
  have hp : 0 < 1-‖u‖^2/4 := by nlinarith [norm_nonneg u]
  have hq : HasStrictFDerivAt (fun x : V => 1-‖x‖^2/4)
      ((-(1/2:ℝ)) • innerSL ℝ u) u := by
    convert! ((hasStrictFDerivAt_norm_sq u).mul_const (1/4:ℝ)).const_sub 1 using 1
    · funext x
      ring
    · apply ContinuousLinearMap.ext
      intro v
      simp only [smul_apply, neg_apply, smul_eq_mul]
      ring
  convert! hq.sqrt hp.ne' using 1
  apply ContinuousLinearMap.ext
  intro v
  simp only [sphereChartScaleND, smul_apply, smul_eq_mul]
  ring
154
noncomputable def sphereConeND (p : V × ℝ) : V × ℝ :=
body · 1 line
  (p.2 • (sphereChartScaleND p.1 • p.1), p.2 * (1-‖p.1‖^2/2))
157
noncomputable def sphereConeDerivND (p : V × ℝ) : (V × ℝ) →L[ℝ] (V × ℝ) :=
body · 8 lines
  let u := p.1
  let r := p.2
  let s := sphereChartScaleND u
  let F := ContinuousLinearMap.fst ℝ V ℝ
  let T := ContinuousLinearMap.snd ℝ V ℝ
  let H := (innerSL ℝ u).comp F
  ((r*s) • F + (s • T - (r/(4*s)) • H).smulRight u).prod
    ((1-‖u‖^2/2) • T - r • H)
167
lemma sphereConeND_hasStrictFDerivAt {p : V × ℝ} (hp : ‖p.1‖ < 2) :
    HasStrictFDerivAt sphereConeND (sphereConeDerivND p) p := by
proof · 18 lines
  have hs := (sphereChartScaleND_hasStrictFDerivAt hp).comp p hasStrictFDerivAt_fst
  have h₁ := hasStrictFDerivAt_snd.smul (hs.smul hasStrictFDerivAt_fst)
  have hv : HasStrictFDerivAt (fun x : V => 1-‖x‖^2/2) (-(innerSL ℝ p.1)) p.1 := by
    convert! ((hasStrictFDerivAt_norm_sq p.1).mul_const (1/2:ℝ)).const_sub 1 using 1
    · funext x
      ring
    · apply ContinuousLinearMap.ext
      intro v
      simp only [smul_apply, neg_apply, smul_eq_mul]
      ring
  have h₂ := (hasStrictFDerivAt_snd (𝕜 := ℝ)).mul
    (hv.comp p hasStrictFDerivAt_fst)
  convert! h₁.prodMk h₂ using 1
  apply ContinuousLinearMap.ext
  intro z
  apply Prod.ext
  · simp [sphereConeDerivND, smul_add, sub_smul, smul_smul]; module
  · simp [sphereConeDerivND]; ring
188
lemma sphereConeDerivND_apply (p z : V × ℝ) :
    sphereConeDerivND p z =
      ((p.2*sphereChartScaleND p.1) • z.1 +
         (sphereChartScaleND p.1*z.2-p.2/(4*sphereChartScaleND p.1)*inner ℝ p.1 z.1) • p.1,
       (1-‖p.1‖^2/2)*z.2-p.2*inner ℝ p.1 z.1) := by
proof · 1 line
  simp [sphereConeDerivND]