Theory Surface_Examples

theory Surface_Examples
  imports Regular_Surface_Patch
begin

section ‹The plane›

definition plane_patch :: "surface_parameter ⇒ surface_vector" where
  "plane_patch p = vector [p$1, p$2, 0]"

lemma plane_linear: "linear plane_patch"
  by (unfold_locales; simp add: plane_patch_def vec_eq_iff forall_3 vector_def algebra_simps)

lemma plane_bounded_linear: "bounded_linear plane_patch"
  using plane_linear by (simp add: linear_conv_bounded_linear)

lemma plane_derivative:
  "patch_derivative plane_patch p = plane_patch"
  unfolding patch_derivative_def
  by (rule sym, rule frechet_derivative_at,
      rule bounded_linear.has_derivative[OF plane_bounded_linear], simp)

lemma plane_c3: "3-smooth_on U plane_patch"
  unfolding smooth_on_def
  using bounded_linear.higher_differentiable_on[OF plane_bounded_linear] by blast

lemma plane_normal: "patch_normal plane_patch p = axis 3 1"
  by (simp add: patch_normal_def patch_u_def patch_v_def plane_derivative
    plane_patch_def cross3_simps forall_3 axis_def)

interpretation plane: regular_surface_patch UNIV plane_patch
  by (unfold_locales; simp add: plane_c3 plane_normal axis_eq_0_iff)

lemma plane_metric:
  "first_fundamental_form plane_patch p a b = inner a b"
  by (simp add: first_fundamental_form_def plane_derivative plane_patch_def
    inner_vec_def sum_3 sum_2 vector_def)

lemma plane_second_derivative:
  "patch_second_derivative plane_patch p a b = 0"
  by (simp add: patch_second_derivative_def plane_derivative frechet_derivative_const)

lemma plane_second_form:
  "second_fundamental_form plane_patch p a b = 0"
  by (simp add: second_fundamental_form_def plane_derivative frechet_derivative_const)

lemma plane_curvature: "gaussian_curvature plane_patch p = 0"
  by (simp add: gaussian_curvature_def plane_second_form)

lemma plane_gauss_map: "gauss_map plane_patch p = axis 3 1"
  by (simp add: gauss_map_def plane_normal norm_axis_1)

lemma plane_shape_operator: "shape_operator plane_patch p w = 0"
proof -
  have "gauss_map plane_patch = (λp. axis 3 1)"
    by (rule ext, rule plane_gauss_map)
  thus ?thesis by (simp add: shape_operator_def frechet_derivative_const)
qed

section ‹The unit cylinder›

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

lemma parameter_component_smooth:
  "k-smooth_on U (λp::surface_parameter. p$i)"
  unfolding smooth_on_def
  using bounded_linear.higher_differentiable_on[OF bounded_linear_vec_nth] by blast

lemma cylinder_c3: "3-smooth_on UNIV cylinder_patch"
  unfolding cylinder_patch_def
  by (intro smooth_on_add smooth_on_scaleR smooth_on_cos smooth_on_sin
      parameter_component_smooth smooth_on_const open_UNIV)

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

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

lemma cylinder_normal:
  "patch_normal cylinder_patch p = cos (p$1) *R axis 1 1 + sin (p$1) *R axis 2 1"
  by (simp add: patch_normal_def patch_u_def patch_v_def cylinder_derivative
    cross3_simps axis_def forall_3)

lemma cylinder_normal_norm: "norm (patch_normal cylinder_patch p) = 1"
proof -
  have "norm (patch_normal cylinder_patch p) ^ 2 = 1"
    unfolding power2_norm_eq_inner cylinder_normal inner_vec_def
    by (simp add: sum_3 axis_def power2_eq_square[symmetric])
  thus ?thesis using norm_ge_zero[of "patch_normal cylinder_patch p"]
    by (auto simp: power2_eq_1_iff)
qed

interpretation cylinder: regular_surface_patch UNIV cylinder_patch
proof
  show "open (UNIV :: surface_parameter set)" by simp
  show "3-smooth_on UNIV cylinder_patch" by (rule cylinder_c3)
  fix p assume "p ∈ (UNIV :: surface_parameter set)"
  show "patch_normal cylinder_patch p ≠ 0"
    using cylinder_normal_norm[of p] by auto
qed

lemma cylinder_metric:
  "first_fundamental_form cylinder_patch p a b = inner a b"
proof -
  have "first_fundamental_form cylinder_patch p a b =
    a$1 * b$1 * (sin (p$1)^2 + cos (p$1)^2) + a$2 * b$2"
    by (simp del: sin_cos_squared_add sin_cos_squared_add2 sin_cos_squared_add3
      add: first_fundamental_form_def cylinder_derivative inner_vec_def
      sum_3 axis_def power2_eq_square algebra_simps)
  thus ?thesis by (simp add: inner_vec_def sum_2)
qed

lemma plane_cylinder_equal_metrics:
  "first_fundamental_form plane_patch p a b = first_fundamental_form cylinder_patch p a b"
  by (simp add: plane_metric cylinder_metric)

lemma cylinder_second_derivative:
  "patch_second_derivative cylinder_patch p a b =
    (-cos (p$1) * a$1 * b$1) *R axis 1 1 +
    (-sin (p$1) * a$1 * b$1) *R axis 2 1"
proof -
  have hd: "((λq. patch_derivative cylinder_patch q b) has_derivative
    (λa. (-cos (p$1) * a$1 * b$1) *R axis 1 1 +
    (-sin (p$1) * a$1 * b$1) *R axis 2 1)) (at p)"
    unfolding cylinder_derivative
    by (auto intro!: derivative_eq_intros bounded_linear.has_derivative[OF bounded_linear_vec_nth]
      simp: algebra_simps)
  show ?thesis unfolding patch_second_derivative_def
    using fun_cong[OF frechet_derivative_at[OF hd], where x=a] by simp
qed

lemma cylinder_gauss_map:
  "gauss_map cylinder_patch p = cos (p$1) *R axis 1 1 + sin (p$1) *R axis 2 1"
  unfolding gauss_map_def
  by (subst cylinder_normal_norm, simp add: cylinder_normal)

lemma cylinder_second_form:
  "second_fundamental_form cylinder_patch p a b = - (a$1 * b$1)"
proof -
  have "second_fundamental_form cylinder_patch p a b =
    - (a$1 * b$1) * (sin (p$1)^2 + cos (p$1)^2)"
    unfolding second_fundamental_form_def patch_second_derivative_def[symmetric]
    by (simp del: sin_cos_squared_add sin_cos_squared_add2 sin_cos_squared_add3
      add: cylinder_second_derivative cylinder_gauss_map inner_vec_def sum_3
      axis_def power2_eq_square algebra_simps)
  thus ?thesis by simp
qed

lemma cylinder_curvature: "gaussian_curvature cylinder_patch p = 0"
  by (simp add: gaussian_curvature_def cylinder_second_form axis_def)

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

definition cylinder_chart_inverse :: "surface_vector ⇒ surface_parameter" where
  "cylinder_chart_inverse w = vector [arcsin (w$2), w$3]"

definition plane_chart_inverse :: "surface_vector ⇒ surface_parameter" where
  "plane_chart_inverse w = vector [w$1, w$2]"

lemma plane_chart_left_inverse:
  "plane_chart_inverse (plane_patch p) = p"
  by (simp add: plane_chart_inverse_def plane_patch_def vector_def vec_eq_iff forall_2)

lemma plane_injective: "inj plane_patch"
  by (metis inj_on_inverseI plane_chart_left_inverse)

lemma cylinder_chart_left_inverse:
  assumes "p ∈ cylinder_strip"
  shows "cylinder_chart_inverse (cylinder_patch p) = p"
proof -
  have "arcsin (sin (p$1)) = p$1"
    using assms unfolding cylinder_strip_def by (intro arcsin_sin; auto)
  thus ?thesis
    by (simp add: cylinder_chart_inverse_def cylinder_patch_def axis_def
      vector_def vec_eq_iff forall_2)
qed

lemma cylinder_strip_injective: "inj_on cylinder_patch cylinder_strip"
  by (rule inj_on_inverseI, rule cylinder_chart_left_inverse)

lemma cylinder_strip_open: "open cylinder_strip"
  unfolding cylinder_strip_def
  by (intro open_Collect_conj open_Collect_less continuous_intros)

lemma cylinder_strip_nonempty: "0 ∈ cylinder_strip"
  by (simp add: cylinder_strip_def)

definition roll_plane :: "surface_vector ⇒ surface_vector" where
  "roll_plane = cylinder_patch ∘ plane_chart_inverse"

definition unroll_cylinder :: "surface_vector ⇒ surface_vector" where
  "unroll_cylinder = plane_patch ∘ cylinder_chart_inverse"

lemma roll_plane_parameter:
  "roll_plane (plane_patch p) = cylinder_patch p"
  by (simp add: roll_plane_def plane_chart_left_inverse)

lemma unroll_cylinder_parameter:
  "p ∈ cylinder_strip ⟹ unroll_cylinder (cylinder_patch p) = plane_patch p"
  by (simp add: unroll_cylinder_def cylinder_chart_left_inverse)

lemma roll_unroll_inverse:
  "w ∈ plane_patch ` cylinder_strip ⟹ unroll_cylinder (roll_plane w) = w"
  "w ∈ cylinder_patch ` cylinder_strip ⟹ roll_plane (unroll_cylinder w) = w"
  by (auto simp: roll_plane_parameter unroll_cylinder_parameter)

lemma plane_chart_inverse_continuous:
  "continuous_on S plane_chart_inverse"
proof -
  have representation: "plane_chart_inverse = (λw. w$1 *R axis 1 1 + w$2 *R axis 2 1)"
    by (rule ext, simp add: plane_chart_inverse_def vec_eq_iff forall_2 vector_def axis_def)
  show ?thesis unfolding representation by (intro continuous_intros)
qed

lemma cylinder_chart_inverse_continuous:
  "continuous_on (cylinder_patch ` cylinder_strip) cylinder_chart_inverse"
proof -
  have representation: "cylinder_chart_inverse =
    (λw. arcsin (w$2) *R axis 1 1 + w$3 *R axis 2 1)"
    by (rule ext, simp add: cylinder_chart_inverse_def vec_eq_iff forall_2 vector_def axis_def)
  show ?thesis unfolding representation
    by (auto intro!: continuous_intros simp: cylinder_patch_def axis_def)
qed

lemma plane_chart_homeomorphism:
  "homeomorphism cylinder_strip (plane_patch ` cylinder_strip) plane_patch plane_chart_inverse"
proof -
  have cont: "continuous_on cylinder_strip plane_patch"
    by (rule smooth_on_imp_continuous_on[OF plane_c3])
  show ?thesis unfolding homeomorphism_def
    using cont plane_chart_inverse_continuous[of "plane_patch ` cylinder_strip"]
    by (auto simp: plane_chart_left_inverse; metis plane_chart_left_inverse imageI)
qed

lemma cylinder_chart_homeomorphism:
  "homeomorphism cylinder_strip (cylinder_patch ` cylinder_strip) cylinder_patch cylinder_chart_inverse"
proof -
  have cont: "continuous_on cylinder_strip cylinder_patch"
    unfolding cylinder_patch_def by (intro continuous_intros)
  show ?thesis unfolding homeomorphism_def
    using cont cylinder_chart_inverse_continuous
    by (auto simp: cylinder_chart_left_inverse; metis cylinder_chart_left_inverse imageI)
qed

lemma rolling_homeomorphism:
  "homeomorphism (plane_patch ` cylinder_strip) (cylinder_patch ` cylinder_strip)
    roll_plane unroll_cylinder"
  unfolding roll_plane_def unroll_cylinder_def
  by (rule homeomorphism_compose[OF homeomorphism_symD[OF plane_chart_homeomorphism]
      cylinder_chart_homeomorphism])

lemma rolling_chart_expression:
  "p ∈ cylinder_strip ⟹
    cylinder_chart_inverse (roll_plane (plane_patch p)) = p"
  by (simp add: roll_plane_parameter cylinder_chart_left_inverse)

lemma rolling_preserves_metric:
  "inner (frechet_derivative (roll_plane ∘ plane_patch) (at p) a)
     (frechet_derivative (roll_plane ∘ plane_patch) (at p) b) =
    first_fundamental_form plane_patch p a b"
proof -
  have eq: "roll_plane ∘ plane_patch = cylinder_patch"
    by (rule ext, simp add: roll_plane_parameter)
  show ?thesis unfolding eq
    using plane_cylinder_equal_metrics[of p a b]
    by (simp add: first_fundamental_form_def patch_derivative_def)
qed

text ‹The rolling map is a homeomorphism between the two chart images.
Its expression in these regular charts is the identity, hence is smooth with
smooth inverse, and its pullback preserves the first fundamental form.›

end