Theory Free_Rotations_SO3
theory Free_Rotations_SO3
imports
"Banach_Tarski.F2_Paradox"
"Banach_Tarski.Free_Action_Paradox"
"HOL-Computational_Algebra.Primes"
"Free-Groups.PingPongLemma"
begin
section ‹Rotations of three-space›
text ‹
A rotation is an orthogonal transformation of determinant 1.
›
definition rotation :: "(real^3 ⇒ real^3) ⇒ bool" where
"rotation f ⟷ orthogonal_transformation f ∧ det (matrix f) = 1"
definition SO3 :: "(real^3 ⇒ real^3) set" where
"SO3 = {f. rotation f}"
text ‹SO(3) contains the identity and is closed under composition.›
lemma id_in_SO3: "id ∈ SO3"
proof -
have "orthogonal_transformation (id::real^3 ⇒ real^3)"
using orthogonal_transformation_id by (simp add: id_def)
moreover have "det (matrix (id::real^3 ⇒ real^3)) = 1"
by simp
ultimately show ?thesis
unfolding SO3_def rotation_def by simp
qed
lemma SO3_closed_compose:
assumes "f ∈ SO3" and "g ∈ SO3"
shows "f ∘ g ∈ SO3"
proof -
from assms have f_orth: "orthogonal_transformation f"
and g_orth: "orthogonal_transformation g"
and f_det: "det (matrix f) = 1"
and g_det: "det (matrix g) = 1"
unfolding SO3_def rotation_def by auto
have f_lin: "linear f" using f_orth by (rule orthogonal_transformation_linear)
have g_lin: "linear g" using g_orth by (rule orthogonal_transformation_linear)
have orth_comp: "orthogonal_transformation (f ∘ g)"
using f_orth g_orth by (rule orthogonal_transformation_compose)
have "matrix (f ∘ g) = matrix f ** matrix g"
using g_lin f_lin by (rule matrix_compose)
hence "det (matrix (f ∘ g)) = det (matrix f) * det (matrix g)"
by (simp add: det_mul)
also have "… = 1" using f_det g_det by simp
finally have "det (matrix (f ∘ g)) = 1" .
with orth_comp show ?thesis
unfolding SO3_def rotation_def by simp
qed
text ‹SO(3) elements preserve the unit sphere.›
lemma rotation_preserves_sphere2:
assumes "f ∈ SO3" and "x ∈ sphere2"
shows "f x ∈ sphere2"
proof -
from assms(1) have "orthogonal_transformation f"
unfolding SO3_def rotation_def by auto
hence "norm (f x) = norm x"
by (rule orthogonal_transformation_norm)
with assms(2) show ?thesis
by (simp add: sphere2_def)
qed
lemma SO3_bij:
assumes "f ∈ SO3"
shows "bij f"
using assms orthogonal_transformation_bij
unfolding SO3_def rotation_def by auto
section ‹Two distinguished rotations›
text ‹
We use the rotations ‹R⇩x› (about the x-axis) and
‹R⇩z› (about the z-axis) by the same angle ‹θ›
with ‹cos θ = 1/3›. The exact-form witnesses are unimportant
for the paradoxical decomposition; what matters is the abstract
conclusion that these generate a free ‹F⇩2› inside SO(3).
›
definition rot_c :: real where
"rot_c = 1 / 3"
definition rot_s :: real where
"rot_s = sqrt 8 / 3"
lemma rot_c_sq_plus_rot_s_sq: "rot_c⇧2 + rot_s⇧2 = 1"
unfolding rot_c_def rot_s_def
by (simp add: power_divide)
lemma rot_c_mul_plus_rot_s_mul [simp]: "rot_c * rot_c + rot_s * rot_s = 1"
using rot_c_sq_plus_rot_s_sq by (simp add: power2_eq_square)
definition Rx_mat :: "real^3^3" where
"Rx_mat = vector [
vector [1, 0, 0],
vector [0, rot_c, - rot_s],
vector [0, rot_s, rot_c]]"
definition Rz_mat :: "real^3^3" where
"Rz_mat = vector [
vector [rot_c, - rot_s, 0],
vector [rot_s, rot_c, 0],
vector [0, 0, 1]]"
definition Rx_inv_mat :: "real^3^3" where
"Rx_inv_mat = vector [
vector [1, 0, 0],
vector [0, rot_c, rot_s],
vector [0, - rot_s, rot_c]]"
definition Rz_inv_mat :: "real^3^3" where
"Rz_inv_mat = vector [
vector [rot_c, rot_s, 0],
vector [- rot_s, rot_c, 0],
vector [0, 0, 1]]"
definition Rx :: "real^3 ⇒ real^3" where
"Rx v = Rx_mat *v v"
definition Rz :: "real^3 ⇒ real^3" where
"Rz v = Rz_mat *v v"
definition Rx_inv :: "real^3 ⇒ real^3" where
"Rx_inv v = Rx_inv_mat *v v"
definition Rz_inv :: "real^3 ⇒ real^3" where
"Rz_inv v = Rz_inv_mat *v v"
lemma Rx_mat_orthogonal: "orthogonal_matrix Rx_mat"
unfolding orthogonal_matrix Rx_mat_def
by (simp add: matrix_matrix_mult_def transpose_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma Rz_mat_orthogonal: "orthogonal_matrix Rz_mat"
unfolding orthogonal_matrix Rz_mat_def
by (simp add: matrix_matrix_mult_def transpose_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma Rx_inv_mat_orthogonal: "orthogonal_matrix Rx_inv_mat"
unfolding orthogonal_matrix Rx_inv_mat_def
by (simp add: matrix_matrix_mult_def transpose_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma Rz_inv_mat_orthogonal: "orthogonal_matrix Rz_inv_mat"
unfolding orthogonal_matrix Rz_inv_mat_def
by (simp add: matrix_matrix_mult_def transpose_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma det_Rx_mat [simp]: "det Rx_mat = 1"
unfolding Rx_mat_def
by (simp add: det_3 vector_def rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma det_Rz_mat [simp]: "det Rz_mat = 1"
unfolding Rz_mat_def
by (simp add: det_3 vector_def rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma det_Rx_inv_mat [simp]: "det Rx_inv_mat = 1"
unfolding Rx_inv_mat_def
by (simp add: det_3 vector_def rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma det_Rz_inv_mat [simp]: "det Rz_inv_mat = 1"
unfolding Rz_inv_mat_def
by (simp add: det_3 vector_def rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma Rx_mat_inverse_left: "Rx_inv_mat ** Rx_mat = mat 1"
unfolding Rx_inv_mat_def Rx_mat_def
by (simp add: matrix_matrix_mult_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma Rx_mat_inverse_right: "Rx_mat ** Rx_inv_mat = mat 1"
unfolding Rx_inv_mat_def Rx_mat_def
by (simp add: matrix_matrix_mult_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma Rz_mat_inverse_left: "Rz_inv_mat ** Rz_mat = mat 1"
unfolding Rz_inv_mat_def Rz_mat_def
by (simp add: matrix_matrix_mult_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
lemma Rz_mat_inverse_right: "Rz_mat ** Rz_inv_mat = mat 1"
unfolding Rz_inv_mat_def Rz_mat_def
by (simp add: matrix_matrix_mult_def mat_def vec_eq_iff vector_def sum_3 forall_3
rot_c_sq_plus_rot_s_sq power2_eq_square algebra_simps)
text ‹The concrete generators and their inverses lie in ‹SO(3)›.›
lemma Rx_in_SO3: "Rx ∈ SO3"
unfolding SO3_def rotation_def Rx_def
by (simp add: orthogonal_transformation_matrix Rx_mat_orthogonal matrix_vector_mul_linear)
lemma Rz_in_SO3: "Rz ∈ SO3"
unfolding SO3_def rotation_def Rz_def
by (simp add: orthogonal_transformation_matrix Rz_mat_orthogonal matrix_vector_mul_linear)
lemma Rx_inv_in_SO3: "Rx_inv ∈ SO3"
unfolding SO3_def rotation_def Rx_inv_def
by (simp add: orthogonal_transformation_matrix Rx_inv_mat_orthogonal matrix_vector_mul_linear)
lemma Rz_inv_in_SO3: "Rz_inv ∈ SO3"
unfolding SO3_def rotation_def Rz_inv_def
by (simp add: orthogonal_transformation_matrix Rz_inv_mat_orthogonal matrix_vector_mul_linear)
text ‹The named inverse rotations are two-sided inverses of the generators.›
lemma Rx_inv_left: "Rx_inv ∘ Rx = id"
by (rule ext) (simp add: Rx_inv_def Rx_def matrix_vector_mul_assoc Rx_mat_inverse_left)
lemma Rz_inv_left: "Rz_inv ∘ Rz = id"
by (rule ext) (simp add: Rz_inv_def Rz_def matrix_vector_mul_assoc Rz_mat_inverse_left)
lemma Rx_inv_right: "Rx ∘ Rx_inv = id"
by (rule ext) (simp add: Rx_inv_def Rx_def matrix_vector_mul_assoc Rx_mat_inverse_right)
lemma Rz_inv_right: "Rz ∘ Rz_inv = id"
by (rule ext) (simp add: Rz_inv_def Rz_def matrix_vector_mul_assoc Rz_mat_inverse_right)
section ‹The rotations as bijections of the sphere›
definition sphere_perm :: "(real^3 ⇒ real^3) ⇒ (real^3 ⇒ real^3)" where
"sphere_perm f = restrict f sphere2"
lemma SO3_bij_betw_sphere2:
assumes "f ∈ SO3"
shows "bij_betw f sphere2 sphere2"
proof -
have "f ` sphere2 ⊆ sphere2"
using rotation_preserves_sphere2[OF assms] by auto
moreover have "sphere2 ⊆ f ` sphere2"
proof
fix y assume y: "y ∈ sphere2"
from SO3_bij[OF assms] obtain x where x: "y = f x"
by (meson bij_pointE)
have "x ∈ sphere2"
proof -
from assms have orth: "orthogonal_transformation f"
unfolding SO3_def rotation_def by auto
from x y have "norm (f x) = 1"
by (simp add: sphere2_def)
moreover from orth have "norm (f x) = norm x"
by (rule orthogonal_transformation_norm)
ultimately show ?thesis
by (simp add: sphere2_def)
qed
with x show "y ∈ f ` sphere2"
by blast
qed
moreover have "inj_on f sphere2"
proof -
have "inj f"
using SO3_bij[OF assms] by (rule bij_is_inj)
thus ?thesis
by (rule inj_on_subset) simp
qed
ultimately show ?thesis
unfolding bij_betw_def by auto
qed
lemma sphere_perm_in_Bij:
assumes "f ∈ SO3"
shows "sphere_perm f ∈ Bij sphere2"
using SO3_bij_betw_sphere2[OF assms]
by (simp add: sphere_perm_def Bij_def)
lemma sphere_perm_mult:
assumes "sphere_perm f ∈ Bij sphere2" "sphere_perm g ∈ Bij sphere2"
shows "sphere_perm f ⊗⇘BijGroup sphere2⇙ sphere_perm g = sphere_perm (f ∘ g)"
proof (rule ext)
fix x
show "(sphere_perm f ⊗⇘BijGroup sphere2⇙ sphere_perm g) x = sphere_perm (f ∘ g) x"
proof (cases "x ∈ sphere2")
case True
from assms True have "sphere_perm g x ∈ sphere2"
by (auto simp: Bij_def bij_betw_def)
with assms True show ?thesis
by (simp add: sphere_perm_def BijGroup_def compose_def restrict_def)
next
case False
with assms show ?thesis
by (simp add: sphere_perm_def BijGroup_def compose_def restrict_def)
qed
qed
lemma sphere_perm_id: "sphere_perm id = 𝟭⇘BijGroup sphere2⇙"
by (simp add: sphere_perm_def BijGroup_def id_def)
lemma sphere_perm_Rx [simp]: "sphere_perm Rx ∈ Bij sphere2"
by (rule sphere_perm_in_Bij) (rule Rx_in_SO3)
lemma sphere_perm_Rx_inv [simp]: "sphere_perm Rx_inv ∈ Bij sphere2"
by (rule sphere_perm_in_Bij) (rule Rx_inv_in_SO3)
lemma sphere_perm_Rz [simp]: "sphere_perm Rz ∈ Bij sphere2"
by (rule sphere_perm_in_Bij) (rule Rz_in_SO3)
lemma sphere_perm_Rz_inv [simp]: "sphere_perm Rz_inv ∈ Bij sphere2"
by (rule sphere_perm_in_Bij) (rule Rz_inv_in_SO3)
lemma sphere_perm_Rx_inv_left:
"sphere_perm Rx_inv ⊗⇘BijGroup sphere2⇙ sphere_perm Rx = 𝟭⇘BijGroup sphere2⇙"
by (simp add: sphere_perm_mult Rx_inv_left sphere_perm_id)
lemma sphere_perm_Rx_inv_right:
"sphere_perm Rx ⊗⇘BijGroup sphere2⇙ sphere_perm Rx_inv = 𝟭⇘BijGroup sphere2⇙"
by (simp add: sphere_perm_mult Rx_inv_right sphere_perm_id)
lemma sphere_perm_Rz_inv_left:
"sphere_perm Rz_inv ⊗⇘BijGroup sphere2⇙ sphere_perm Rz = 𝟭⇘BijGroup sphere2⇙"
by (simp add: sphere_perm_mult Rz_inv_left sphere_perm_id)
lemma sphere_perm_Rz_inv_right:
"sphere_perm Rz ⊗⇘BijGroup sphere2⇙ sphere_perm Rz_inv = 𝟭⇘BijGroup sphere2⇙"
by (simp add: sphere_perm_mult Rz_inv_right sphere_perm_id)
lemma inv_sphere_perm_Rx:
"inv⇘BijGroup sphere2⇙ (sphere_perm Rx) = sphere_perm Rx_inv"
proof -
interpret B: group "BijGroup sphere2"
by (rule group_BijGroup)
show ?thesis
proof (rule B.inv_equality)
show "sphere_perm Rx_inv ⊗⇘BijGroup sphere2⇙ sphere_perm Rx = 𝟭⇘BijGroup sphere2⇙"
by (rule sphere_perm_Rx_inv_left)
show "sphere_perm Rx ∈ carrier (BijGroup sphere2)"
by (simp add: BijGroup_def)
show "sphere_perm Rx_inv ∈ carrier (BijGroup sphere2)"
by (simp add: BijGroup_def)
qed
qed
lemma inv_sphere_perm_Rz:
"inv⇘BijGroup sphere2⇙ (sphere_perm Rz) = sphere_perm Rz_inv"
proof -
interpret B: group "BijGroup sphere2"
by (rule group_BijGroup)
show ?thesis
proof (rule B.inv_equality)
show "sphere_perm Rz_inv ⊗⇘BijGroup sphere2⇙ sphere_perm Rz = 𝟭⇘BijGroup sphere2⇙"
by (rule sphere_perm_Rz_inv_left)
show "sphere_perm Rz ∈ carrier (BijGroup sphere2)"
by (simp add: BijGroup_def)
show "sphere_perm Rz_inv ∈ carrier (BijGroup sphere2)"
by (simp add: BijGroup_def)
qed
qed