🏛️ Atlas✒️Isabelle.TorusLoopMachine.Torus_Word_Machine view on GitHub ↗7 theorems
(* Title: Certified evaluation of torus-loop words   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_Word_Machine  imports "Circle_Torus_Algebraic_Topology.Torus_Fundamental_Group"begin datatype loop_word = Horizontal | Vertical | Inverse loop_word                   | Join loop_word loop_word fun loop_path :: "loop_word \<Rightarrow> real \<Rightarrow> complex \<times> complex" where  "loop_path Horizontal = product_path (circlepath 0 1) (linepath 1 1)"| "loop_path Vertical = product_path (linepath 1 1) (circlepath 0 1)"| "loop_path (Inverse e) = reversepath (loop_path e)"| "loop_path (Join e f) = loop_path e +++ loop_path f" fun word_degree :: "loop_word \<Rightarrow> int \<times> int" where  "word_degree Horizontal = (1, 0)"| "word_degree Vertical = (0, 1)"| "word_degree (Inverse e) = - word_degree e"| "word_degree (Join e f) = word_degree e + word_degree f" lemma loop_path_valid: "torus_loop (loop_path e)"  by (induction e) (auto intro: torus_loop_product torus_loop_reverse    torus_loop_join is_loop_circlepath) theorem word_degree_correct:  "torus_lift_endpoint (loop_path e) = word_degree e"proof (induction e)  case Horizontal  then show ?case    by (simp add: torus_endpoint_product circle_lift_endpoint_circlepath      circle_lift_endpoint_linepath)next  case Vertical  then show ?case    by (simp add: torus_endpoint_product circle_lift_endpoint_circlepath      circle_lift_endpoint_linepath)next  case (Inverse e)  then show ?case    by (simp add: torus_lift_endpoint_reverse loop_path_valid)next  case (Join e f)  then show ?case    by (simp add: torus_lift_endpoint_join loop_path_valid)qed definition sample_word :: loop_word where  "sample_word = Join (Join (Join (Join Horizontal Vertical)    (Inverse Horizontal)) Vertical) Horizontal" theorem sample_word_degree:  "torus_lift_endpoint (loop_path sample_word) = (1, 2)"proof -  have "torus_lift_endpoint (loop_path sample_word) = word_degree sample_word"    by (rule word_degree_correct)  then show ?thesis by (simp add: sample_word_def)qed theorem sample_wrong_degree:  "torus_lift_endpoint (loop_path sample_word) \<noteq> (1, 1)"  using sample_word_degree by simp theorem word_homotopy_classification:  "homotopic_paths (circle \<times> circle) (loop_path e) (loop_path f)    \<longleftrightarrow> word_degree e = word_degree f"  by (simp add: torus_loop_homotopic_iff loop_path_valid word_degree_correct) theorem generators_commute_up_to_homotopy:  "homotopic_paths (circle \<times> circle)    (loop_path (Join Horizontal Vertical))    (loop_path (Join Vertical Horizontal))"proof -  have "word_degree (Join Horizontal Vertical) =    word_degree (Join Vertical Horizontal)" by simp  then show ?thesis by (rule word_homotopy_classification[THEN iffD2])qed theorem generators_are_distinct:  "\<not> homotopic_paths (circle \<times> circle)    (loop_path Horizontal) (loop_path Vertical)"  using word_homotopy_classification[of Horizontal Vertical] by simp end