Theory Sphere_Surface

theory Sphere_Surface
  imports Surface_Examples Surface_Reparametrization
begin

section ‹The unit sphere in latitude coordinates›

definition sphere_patch :: "surface_parameter ⇒ surface_vector" where
  "sphere_patch p = (cos (p$1) * cos (p$2)) *R axis 1 1 +
    (sin (p$1) * cos (p$2)) *R axis 2 1 + sin (p$2) *R axis 3 1"

definition sphere_domain :: "surface_parameter set" where
  "sphere_domain = {p. -pi/2 < p$2 ∧ p$2 < pi/2}"

lemma sphere_domain_open: "open sphere_domain"
  unfolding sphere_domain_def
  by (intro open_Collect_conj open_Collect_less continuous_intros)

lemma sphere_c3: "3-smooth_on sphere_domain sphere_patch"
  unfolding sphere_patch_def
  by (intro smooth_on_add smooth_on_scaleR smooth_on_mult smooth_on_cos smooth_on_sin
    parameter_component_smooth smooth_on_const sphere_domain_open)

lemma sphere_has_derivative:
  "(sphere_patch has_derivative (λa.
    (-sin (p$1) * cos (p$2) * a$1 - cos (p$1) * sin (p$2) * a$2) *R axis 1 1 +
    (cos (p$1) * cos (p$2) * a$1 - sin (p$1) * sin (p$2) * a$2) *R axis 2 1 +
    (cos (p$2) * a$2) *R axis 3 1)) (at p)"
  unfolding sphere_patch_def
  by (auto intro!: derivative_eq_intros bounded_linear.has_derivative[OF bounded_linear_vec_nth]
    simp: algebra_simps)

lemma sphere_derivative:
  "patch_derivative sphere_patch p a =
    (-sin (p$1) * cos (p$2) * a$1 - cos (p$1) * sin (p$2) * a$2) *R axis 1 1 +
    (cos (p$1) * cos (p$2) * a$1 - sin (p$1) * sin (p$2) * a$2) *R axis 2 1 +
    (cos (p$2) * a$2) *R axis 3 1"
  unfolding patch_derivative_def
  using fun_cong[OF frechet_derivative_at[OF sphere_has_derivative[where p=p]], where x=a] by simp

lemma sphere_unit: "norm (sphere_patch p) = 1"
proof -
  have identity: "norm (sphere_patch p)^2 =
    (cos (p$1)^2 + sin (p$1)^2) * cos (p$2)^2 + sin (p$2)^2"
    unfolding power2_norm_eq_inner sphere_patch_def inner_vec_def
    by (simp del: sin_cos_squared_add sin_cos_squared_add2 sin_cos_squared_add3
      add: sum_3 axis_def power2_eq_square algebra_simps)
  have "norm (sphere_patch p)^2 = 1" using identity by simp
  thus ?thesis using norm_ge_zero[of "sphere_patch p"] by (auto simp: power2_eq_1_iff)
qed

lemma sphere_normal:
  "patch_normal sphere_patch p = cos (p$2) *R sphere_patch p"
proof -
  have trig: "cos (p$1) * cos (p$1) + sin (p$1) * sin (p$1) = 1"
    "cos (p$2) * cos (p$2) + sin (p$2) * sin (p$2) = 1" by simp_all
  show ?thesis
    unfolding patch_normal_def patch_u_def patch_v_def sphere_derivative sphere_patch_def
    using trig
    by (simp add: cross3_simps forall_3 axis_def algebra_simps; algebra)
qed

lemma sphere_cos_positive:
  "p ∈ sphere_domain ⟹ 0 < cos (p$2)"
  unfolding sphere_domain_def by (auto intro: cos_gt_zero_pi)

lemma sphere_normal_norm:
  "p ∈ sphere_domain ⟹ norm (patch_normal sphere_patch p) = cos (p$2)"
  by (simp add: sphere_normal norm_scaleR sphere_unit abs_of_pos sphere_cos_positive)

interpretation sphere_surface: regular_surface_patch sphere_domain sphere_patch
proof
  show "open sphere_domain" by (rule sphere_domain_open)
  show "3-smooth_on sphere_domain sphere_patch" by (rule sphere_c3)
  fix p assume p: "p ∈ sphere_domain"
  show "patch_normal sphere_patch p ≠ 0"
    using sphere_normal_norm[OF p] sphere_cos_positive[OF p] by auto
qed

lemma sphere_gauss_map:
  assumes p: "p ∈ sphere_domain"
  shows "gauss_map sphere_patch p = sphere_patch p"
proof -
  have nz: "cos (p$2) ≠ 0" using sphere_cos_positive[OF p] by auto
  show ?thesis unfolding gauss_map_def
    by (subst sphere_normal_norm[OF p], simp add: sphere_normal nz)
qed

lemma sphere_gauss_derivative:
  assumes p: "p ∈ sphere_domain"
  shows "frechet_derivative (gauss_map sphere_patch) (at p) = patch_derivative sphere_patch p"
  unfolding patch_derivative_def
  using frechet_derivative_transform_within_open p sphere_domain_open sphere_gauss_map by blast

lemma sphere_shape_operator:
  assumes p: "p ∈ sphere_domain" and w: "w ∈ tangent_plane sphere_patch p"
  shows "shape_operator sphere_patch p w = -w"
  by (simp add: shape_operator_def sphere_gauss_derivative[OF p]
    sphere_surface.derivative_tangent_coordinates[OF p w])

lemma sphere_second_form:
  assumes p: "p ∈ sphere_domain"
  shows "second_fundamental_form sphere_patch p a b = - first_fundamental_form sphere_patch p a b"
proof -
  have tangent: "patch_derivative sphere_patch p a ∈ tangent_plane sphere_patch p"
    unfolding tangent_plane_def by simp
  show ?thesis using sphere_surface.shape_operator_second_form[OF p, of a b]
    by (simp add: sphere_shape_operator[OF p tangent] first_fundamental_form_def)
qed

lemma sphere_curvature:
  assumes p: "p ∈ sphere_domain"
  shows "gaussian_curvature sphere_patch p = 1"
proof -
  have nz: "first_fundamental_form sphere_patch p (axis 1 1) (axis 1 1) *
    first_fundamental_form sphere_patch p (axis 2 1) (axis 2 1) -
    first_fundamental_form sphere_patch p (axis 1 1) (axis 2 1)^2 ≠ 0"
    using sphere_surface.metric_determinant_positive[OF p] by auto
  show ?thesis using nz
    by (simp add: gaussian_curvature_def sphere_second_form[OF p]
      first_fundamental_form_symmetric power2_eq_square[symmetric] nz)
qed

theorem no_sphere_chart_plane_local_isometry:
  assumes "open W" "W ⊆ sphere_domain" "W ≠ {}"
  shows "¬ surface_local_isometry W sphere_patch V plane_patch f"
proof
  assume iso: "surface_local_isometry W sphere_patch V plane_patch f"
  interpret iso: surface_local_isometry W sphere_patch V plane_patch f by (rule iso)
  obtain p where p: "p ∈ W" using assms by blast
  have sphere: "gaussian_curvature sphere_patch p = 1"
    by (rule sphere_curvature, use assms p in blast)
  show False using iso.theorema_egregium[OF p] sphere plane_curvature by simp
qed

end