(* Title: Uniqueness of sampled torus lifts under a half-turn bound 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_Sample_Lifting imports Torus_Polygonal_Loopsbegin lemma circle_near_lift_unique: fixes x y a :: real assumes same: "circle_cover x = circle_cover y" and near_x: "abs (x - a) < 1/2" and near_y: "abs (y - a) < 1/2" shows "x = y"proof - obtain k :: int where k: "x = y + of_int k" using same circle_cover_fiber[of x y] by blast have bx: "-1/2 < x-a" "x-a < 1/2" using near_x by linarith+ have by0: "-1/2 < y-a" "y-a < 1/2" using near_y by linarith+ have lower: "(-1::real) < of_int k" using k bx by0 by linarith have upper: "(of_int k::real) < 1" using k bx by0 by linarith have "k = 0" using lower upper by linarith then show ?thesis using k by simpqed fun half_step_lift :: "real list \<Rightarrow> bool" where "half_step_lift [] = True"| "half_step_lift [x] = True"| "half_step_lift (x # y # xs) = (abs (y-x) < 1/2 \<and> half_step_lift (y # xs))" lemma circle_sample_lifts_unique_aux: assumes first: "a = b" and observed: "map circle_cover (a # xs) = map circle_cover (b # ys)" and bound_x: "half_step_lift (a # xs)" and bound_y: "half_step_lift (b # ys)" shows "a # xs = b # ys" using assmsproof (induction xs arbitrary: a b ys) case Nil then show ?case by (cases ys) simp_allnext case (Cons x xs) obtain y ys' where ys: "ys = y # ys'" using Cons.prems(2) by (cases ys) auto have projected: "circle_cover x = circle_cover y" using Cons.prems(2) ys by simp have near_x: "abs (x-a) < 1/2" using Cons.prems(3) by simp have near_y: "abs (y-a) < 1/2" using Cons.prems(1,4) ys by simp have xy: "x = y" by (rule circle_near_lift_unique[OF projected near_x near_y]) have tails: "x # xs = y # ys'" using Cons.IH[of x y ys'] Cons.prems ys xy by simp show ?case using Cons.prems(1) tails ys by simpqed theorem circle_sample_lifts_unique: assumes nonempty: "xs \<noteq> []" and observed: "map circle_cover xs = map circle_cover ys" and first: "hd xs = hd ys" and bound_x: "half_step_lift xs" and bound_y: "half_step_lift ys" shows "xs = ys"proof - obtain a as where xs: "xs = a # as" using nonempty by (cases xs) auto obtain b bs where ys: "ys = b # bs" using observed xs by (cases ys) auto show ?thesis using circle_sample_lifts_unique_aux[of a b as bs] observed first bound_x bound_y by (simp add: xs ys)qed lemma zip_vertex_coordinates: "zip (map fst vs) (map snd vs) = vs" by (induction vs) auto theorem torus_sample_lifts_unique: fixes vs ws :: "(real \<times> real) list" assumes nonempty: "vs \<noteq> []" and same_start: "hd vs = hd ws" and observed: "map project_vertex vs = map project_vertex ws" and xbound_v: "half_step_lift (map fst vs)" and ybound_v: "half_step_lift (map snd vs)" and xbound_w: "half_step_lift (map fst ws)" and ybound_w: "half_step_lift (map snd ws)" shows "vs = ws"proof - have xobs: "map circle_cover (map fst vs) = map circle_cover (map fst ws)" proof - have "map fst (map project_vertex vs) = map fst (map project_vertex ws)" using observed by simp then show ?thesis by (simp add: project_vertex_def o_def) qed have yobs: "map circle_cover (map snd vs) = map circle_cover (map snd ws)" proof - have "map snd (map project_vertex vs) = map snd (map project_vertex ws)" using observed by simp then show ?thesis by (simp add: project_vertex_def o_def) qed have xstart: "hd (map fst vs) = hd (map fst ws)" using nonempty same_start observed by (cases vs; cases ws) auto have ystart: "hd (map snd vs) = hd (map snd ws)" using nonempty same_start observed by (cases vs; cases ws) auto have xe: "map fst vs = map fst ws" by (rule circle_sample_lifts_unique[OF _ xobs xstart xbound_v xbound_w]) (use nonempty in simp) have ye: "map snd vs = map snd ws" by (rule circle_sample_lifts_unique[OF _ yobs ystart ybound_v ybound_w]) (use nonempty in simp) have zipped: "zip (map fst vs) (map snd vs) = zip (map fst ws) (map snd ws)" using xe ye by (simp only: xe ye) then show ?thesis by (simp only: zip_vertex_coordinates)qed theorem bounded_samples_fix_winding: fixes vs ws :: "(real \<times> real) list" assumes nonempty: "vs \<noteq> []" and first: "hd vs = (0,0)" and final: "last vs = (of_int m, of_int n)" and same_start: "hd vs = hd ws" and observed: "map project_vertex vs = map project_vertex ws" and xbound_v: "half_step_lift (map fst vs)" and ybound_v: "half_step_lift (map snd vs)" and xbound_w: "half_step_lift (map fst ws)" and ybound_w: "half_step_lift (map snd ws)" shows "torus_lift_endpoint (torus_vertex_path ws) = (m,n)"proof - have "vs = ws" by (rule torus_sample_lifts_unique[OF nonempty same_start observed xbound_v ybound_v xbound_w ybound_w]) then show ?thesis using torus_vertex_path_degree[OF nonempty first final] by simpqed theorem half_turn_bound_is_strict: "map circle_cover [0, 1/2] = map circle_cover [0, -1/2] \<and> [0, 1/2] \<noteq> ([0, -1/2]::real list)"proof - have cover: "circle_cover (1/2) = circle_cover (-1/2)" using circle_cover_periodic_int[of "-1/2" 1] by simp show ?thesis using cover by simpqed end