import Mathlib import OAI.Analysis.HardSphere.Geometry.Vertex namespace OAI noncomputable section open MeasureTheory Filter Set open scoped ENNReal Topology BigOperators open scoped BigOperators Classical open scoped BigOperators Classical namespace HardSphere.Lattice abbrev DiscreteTorus (K : ℕ) := Fin 3 → ZMod K def torusProjection (K : ℕ) (x : Vertex) : DiscreteTorus K := fun i ↦ (x i : ZMod K) def rangeStep (a : ℕ) (x y : Vertex) : Prop := x≠y ∧ ∀ i, |x i-y i|≤a def torusRangeStep (K a : ℕ) (x y : DiscreteTorus K) : Prop := x≠y ∧ ∃ d : Vertex, (∀ i, |d i|≤a) ∧ ∀ i, y i=x i+(d i : ZMod K) lemma rangeStep_symm {a : ℕ} {x y : Vertex} (h : rangeStep a x y) : rangeStep a y x := ⟨h.1.symm,fun i ↦ by rw [abs_sub_comm]; exact h.2 i⟩ lemma torusRangeStep_symm {K a : ℕ} {x y : DiscreteTorus K} (h : torusRangeStep K a x y) : torusRangeStep K a y x := by obtain ⟨hne,d,hd,he⟩ := h refine ⟨hne.symm,-d,fun i ↦ by simpa using hd i,fun i ↦ ?_⟩ simp only [Pi.neg_apply,Int.cast_neg,he i] abel def forbiddenCuts {K : ℕ} (S : Finset (DiscreteTorus K)) (a : ℕ) (i : Fin 3) : Finset (ZMod K) := S.biUnion fun x ↦ (Finset.Icc 1 a).image fun j : ℕ ↦ x i+(j : ZMod K) lemma forbiddenCuts_card {K : ℕ} (S : Finset (DiscreteTorus K)) (a : ℕ) (i : Fin 3) : (forbiddenCuts S a i).card≤a*S.card := by calc _ ≤ ∑ x∈S, ((Finset.Icc 1 a).image fun j : ℕ ↦ x i+(j : ZMod K)).card := Finset.card_biUnion_le _ ≤ ∑ _x∈S, a := by apply Finset.sum_le_sum intro x _ simpa only [Nat.card_Icc,Nat.add_sub_cancel] using (Finset.card_image_le (s := Finset.Icc 1 a) (f := fun j : ℕ ↦ x i+(j : ZMod K))) _ = a*S.card := by simp [Nat.mul_comm] lemma exists_vacant_cut {K : ℕ} [NeZero K] (S : Finset (DiscreteTorus K)) (a : ℕ) (hsmall : a*S.card omega have heq := small_multiple_zero hzero hsmall rw [show cutLift cut x i-cutLift cut y i= -d i by omega,abs_neg] exact hd i theorem small_set_lift {K : ℕ} [NeZero K] (S : Finset (DiscreteTorus K)) (a : ℕ) (hsmall : a*S.card simp | @cons u v w huv p ih => calc |f u i-f w i| ≤ |f u i-f v i|+|f v i-f w i| := abs_sub_le _ _ _ _ ≤ (a:ℤ)+(a:ℤ)*p.length := add_le_add (hedge u v huv i) ih _ = (a:ℤ)*(SimpleGraph.Walk.cons huv p).length := by simp only [SimpleGraph.Walk.length_cons,Nat.cast_add,Nat.cast_one]; ring have hlen' : (q.val.length:ℤ) omega) dsimp only [Pi.sub_apply] omega lemma lift_offset_reach {K a : ℕ} (hK : 2*a rfl | @tail u v _ huv ih => exact (lift_offset_step hK S f hf hedge huv.1 huv.2.1 huv.2.2).trans ih lemma translated_projection {K : ℕ} (f : DiscreteTorus K → Vertex) (hf : ∀ x, torusProjection K (f x)=x) (r : Vertex) (x : DiscreteTorus K) : torusProjection K (f x+(r-f (torusProjection K r)))=x := by ext i have h₁ := congrFun (hf x) i have h₂ := congrFun (hf (torusProjection K r)) i change ((f x i:ℤ):ZMod K)=x i at h₁ change ((f (torusProjection K r) i:ℤ):ZMod K)=(r i:ZMod K) at h₂ simp only [torusProjection,Pi.add_apply,Pi.sub_apply,Int.cast_add,Int.cast_sub,h₁,h₂, sub_self,add_zero] lemma rangeStep_translate {a : ℕ} {x y : Vertex} (h : rangeStep a x y) (t : Vertex) : rangeStep a (x+t) (y+t) := by refine ⟨fun he ↦ h.1 (add_right_cancel he),fun i ↦ ?_⟩ simpa only [Pi.add_apply,add_sub_add_right_eq_sub] using h.2 i lemma translated_reach {K a : ℕ} (S : Finset (DiscreteTorus K)) (hS : ((torusRangeGraph K a).induce (↑S)).Preconnected) (f : DiscreteTorus K → Vertex) (hf : ∀ x, torusProjection K (f x)=x) (hedge : ∀ x∈S, ∀ y∈S, torusRangeStep K a x y → rangeStep a (f x) (f y)) (r : Vertex) (hr : torusProjection K r∈S) (x : DiscreteTorus K) (hx : x∈S) : f x+(r-f (torusProjection K r))∈periodicLift K a S r := by refine ⟨by simpa only [translated_projection f hf] using hx,?_⟩ have hp := (SimpleGraph.reachable_iff_reflTransGen _ _).mp (hS ⟨torusProjection K r,hr⟩ ⟨x,hx⟩) have hmap : ∀ {u v : ↑(↑S : Set (DiscreteTorus K))}, Relation.ReflTransGen ((torusRangeGraph K a).induce (↑S)).Adj u v → Relation.ReflTransGen (fun u v ↦ torusProjection K u∈S ∧ torusProjection K v∈S ∧ rangeStep a u v) (f u.val+(r-f (torusProjection K r))) (f v.val+(r-f (torusProjection K r))) := by intro u v huv induction huv using Relation.ReflTransGen.trans_induction_on with | refl => exact .refl | @single u v huv => apply Relation.ReflTransGen.single refine ⟨?_,?_,rangeStep_translate (hedge u.val u.property v.val v.property huv) _⟩ · simpa only [translated_projection f hf,Finset.mem_coe] using u.property · simpa only [translated_projection f hf,Finset.mem_coe] using v.property | trans _ _ ih₁ ih₂ => exact ih₁.trans ih₂ have h := hmap hp rw [show f (torusProjection K r)+(r-f (torusProjection K r))=r by abel] at h exact h theorem small_periodic_lifts {K a : ℕ} [NeZero K] (hK : 2*a