(* Title: Polygonal torus loops from finite vertex lists Author: Carles Marín and OpenAI (AI-assisted proof engineering) License: BSD-2-Clause AFP dependency: Circle_Torus_Algebraic_Topology, by A. Freitas Ramos, D. Barros Hulak and R. J. G. B. de Queiroz. *) theory Torus_Polygonal_Loops imports Torus_Geometric_Loopsbegin fun vertex_path :: "real list \<Rightarrow> real \<Rightarrow> real" where "vertex_path [] = linepath 0 0"| "vertex_path [a] = linepath a a"| "vertex_path (a # b # xs) = linepath a b +++ vertex_path (b # xs)" lemma vertex_path_start: assumes "xs \<noteq> []" shows "pathstart (vertex_path xs) = hd xs" using assms by (induction xs rule: vertex_path.induct) simp_all lemma vertex_path_finish: assumes "xs \<noteq> []" shows "pathfinish (vertex_path xs) = last xs" using assms by (induction xs rule: vertex_path.induct) simp_all lemma vertex_path_at_ends: assumes "xs \<noteq> []" shows "vertex_path xs 0 = hd xs" "vertex_path xs 1 = last xs" using vertex_path_start[OF assms] vertex_path_finish[OF assms] by (simp_all add: pathstart_def pathfinish_def) lemma vertex_path_continuous: "path (vertex_path xs)"proof (induction xs rule: vertex_path.induct) case 1 then show ?case by (simp add: path_def)next case (2 a) then show ?case by (simp add: path_def)next case (3 a b xs) have connect: "pathfinish (linepath a b) = pathstart (vertex_path (b # xs))" by (simp add: vertex_path_start) show ?case using "3.IH" connect by simpqed definition torus_vertex_path :: "(real \<times> real) list \<Rightarrow> real \<Rightarrow> complex \<times> complex" where "torus_vertex_path vs = torus_from_lifts (vertex_path (map fst vs)) (vertex_path (map snd vs))" theorem torus_vertex_path_degree: assumes nonempty: "vs \<noteq> []" and first: "hd vs = (0, 0)" and final: "last vs = (of_int m, of_int n)" shows "torus_lift_endpoint (torus_vertex_path vs) = (m, n)"proof - have x0: "vertex_path (map fst vs) 0 = 0" using nonempty first by (cases vs) (simp_all add: vertex_path_at_ends) have x1: "vertex_path (map fst vs) 1 = of_int m" using nonempty final by (simp add: vertex_path_at_ends last_map) have y0: "vertex_path (map snd vs) 0 = 0" using nonempty first by (cases vs) (simp_all add: vertex_path_at_ends) have y1: "vertex_path (map snd vs) 1 = of_int n" using nonempty final by (simp add: vertex_path_at_ends last_map) show ?thesis unfolding torus_vertex_path_def by (rule torus_from_lifts_degree[OF vertex_path_continuous x0 x1 vertex_path_continuous y0 y1])qed theorem torus_vertex_path_word_classification: assumes nonempty: "vs \<noteq> []" and first: "hd vs = (0, 0)" and final: "last vs = (of_int m, of_int n)" shows "homotopic_paths (circle \<times> circle) (torus_vertex_path vs) (loop_path e) \<longleftrightarrow> (m, n) = word_degree e"proof - have x0: "vertex_path (map fst vs) 0 = 0" using nonempty first by (cases vs) (simp_all add: vertex_path_at_ends) have x1: "vertex_path (map fst vs) 1 = of_int m" using nonempty final by (simp add: vertex_path_at_ends last_map) have y0: "vertex_path (map snd vs) 0 = 0" using nonempty first by (cases vs) (simp_all add: vertex_path_at_ends) have y1: "vertex_path (map snd vs) 1 = of_int n" using nonempty final by (simp add: vertex_path_at_ends last_map) show ?thesis unfolding torus_vertex_path_def by (rule geometric_word_classification[OF vertex_path_continuous x0 x1 vertex_path_continuous y0 y1])qed definition example_vertices :: "(real \<times> real) list" where "example_vertices = [(0,0), (1/2,1/3), (3/2,-1/4), (2,-1)]" theorem example_polygonal_degree: "torus_lift_endpoint (torus_vertex_path example_vertices) = (2,-1)" by (rule torus_vertex_path_degree) (simp_all add: example_vertices_def) theorem example_polygonal_matches_word: "homotopic_paths (circle \<times> circle) (torus_vertex_path example_vertices) (loop_path (Join (Join Horizontal Horizontal) (Inverse Vertical)))" using torus_vertex_path_word_classification [of example_vertices 2 "-1" "Join (Join Horizontal Horizontal) (Inverse Vertical)"] by (simp add: example_vertices_def) definition project_vertex :: "real \<times> real \<Rightarrow> complex \<times> complex" where "project_vertex v = (circle_cover (fst v), circle_cover (snd v))" theorem projected_samples_do_not_determine_winding: "map project_vertex [(0,0), (0,0)] = map project_vertex [(0,0), (1,0)] \<and> torus_lift_endpoint (torus_vertex_path [(0,0), (0,0)]) \<noteq> torus_lift_endpoint (torus_vertex_path [(0,0), (1,0)])"proof - have cover_one: "circle_cover 1 = (1::complex)" using circle_cover_periodic_int[of 0 1] by simp have samples: "map project_vertex [(0,0), (0,0)] = map project_vertex [(0,0), (1,0)]" by (simp add: project_vertex_def cover_one) have zero: "torus_lift_endpoint (torus_vertex_path [(0,0), (0,0)]) = (0,0)" by (rule torus_vertex_path_degree) simp_all have one: "torus_lift_endpoint (torus_vertex_path [(0,0), (1,0)]) = (1,0)" by (rule torus_vertex_path_degree) simp_all show ?thesis using samples zero one by simpqed end