import Mathlib import OAI.Analysis.HardSphere.Paths.AcceptedIntegrand namespace OAI section noncomputable section open MeasureTheory ProbabilityTheory open scoped ENNReal BigOperators namespace HardSphere.DyadicSkeleton open HardSphere.Lattice attribute [local instance] Classical.propDecidable def currentAdmissiblePair {K : ℕ} [NeZero K] (x y : DiscreteTorus K) : Prop := ∃ n : ℕ, K≤10*n ∧ 8*n≤K ∧ ∃ d : Fin 2 → ℤ, (∀ j, |d j|≤n) ∧ y=x+![(n:ZMod K),(d 0:ZMod K),(d 1:ZMod K)] def currentAdmissiblePairs (K : ℕ) [NeZero K] : Finset (DiscreteTorus K × DiscreteTorus K) := Finset.univ.filter (fun z ↦ currentAdmissiblePair z.1 z.2) lemma current_admissible_lift {K : ℕ} [NeZero K] {x y : DiscreteTorus K} (h : currentAdmissiblePair x y) : ∃ n : ℕ, 0 simp [torusProjection,v] lemma current_admissible_card {K : ℕ} [NeZero K] (hK : 400≤K) : K^6≤2000*(currentAdmissiblePairs K).card := by let m := K/10 let I := Finset.Icc (K/10+1) (K/8) let J := Finset.range (2*m+1) let S : Finset (DiscreteTorus K × ℕ × ℕ × ℕ) := Finset.univ ×ˢ (I ×ˢ (J ×ˢ J)) let f : DiscreteTorus K × ℕ × ℕ × ℕ → DiscreteTorus K × DiscreteTorus K := fun z ↦ (z.1,z.1+![(z.2.1:ZMod K),((z.2.2.1:ℤ)-m:ZMod K),((z.2.2.2:ℤ)-m:ZMod K)]) have hI (n : ℕ) (hn : n∈I) : K≤10*n ∧ 8*n≤K ∧ n omega have hsub : S.image f⊆currentAdmissiblePairs K := by intro z hz obtain ⟨⟨x,n,b,c⟩,hu,rfl⟩ := Finset.mem_image.mp hz simp only [S,Finset.mem_product] at hu obtain ⟨_,hn,hb,hc⟩ := hu have hin := hI n hn apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _,n,hin.1,hin.2.1,![(b:ℤ)-m,(c:ℤ)-m],?_,?_⟩ · intro j fin_cases j · exact (hJ b hb).2.trans (by exact_mod_cast hin.2.2.2.le) · exact (hJ c hc).2.trans (by exact_mod_cast hin.2.2.2.le) · simp [f] have hinj : Set.InjOn f (↑S : Set _) := by rintro ⟨x,n,b,c⟩ hx ⟨x',n',b',c'⟩ hx' he have he₁ : x=x' := congrArg Prod.fst he subst x' have he₂ : ![(n:ZMod K),((b:ℤ)-m:ZMod K),((c:ℤ)-m:ZMod K)]= ![(n':ZMod K),((b':ℤ)-m:ZMod K),((c':ℤ)-m:ZMod K)] := add_left_cancel (congrArg Prod.snd he) change (x,n,b,c)∈S at hx change (x,n',b',c')∈S at hx' simp only [S,Finset.mem_product] at hx hx' obtain ⟨_,hn,hb,hc⟩ := hx obtain ⟨_,hn',hb',hc'⟩ := hx' have hnval := congrArg (fun z : Fin 3 → ZMod K ↦ (z 0).val) he₂ simp only [Matrix.cons_val_zero,ZMod.val_natCast_of_lt (hI n hn).2.2.1, ZMod.val_natCast_of_lt (hI n' hn').2.2.1] at hnval have hbeq : (b:ZMod K)=(b':ZMod K) := by have h := congrFun he₂ 1 simpa using h have hceq : (c:ZMod K)=(c':ZMod K) := by have h := congrFun he₂ 2 simpa using h have hbval := congrArg ZMod.val hbeq have hcval := congrArg ZMod.val hceq simp only [ZMod.val_natCast_of_lt (hJ b hb).1,ZMod.val_natCast_of_lt (hJ b' hb').1] at hbval simp only [ZMod.val_natCast_of_lt (hJ c hc).1,ZMod.val_natCast_of_lt (hJ c' hc').1] at hcval simp only [Prod.mk.injEq] exact ⟨trivial,hnval,hbval,hcval⟩ have hcard : S.card≤(currentAdmissiblePairs K).card := (Finset.card_image_iff.mpr hinj).symm.trans_le (Finset.card_le_card hsub) have hcardS : S.card=K^3*I.card*J.card^2 := by dsimp only [S] rw [Finset.card_product,Finset.card_product,Finset.card_product] simp [DiscreteTorus,mul_assoc,pow_two] have hcardI : K≤50*I.card := by dsimp [I] rw [Nat.card_Icc] omega have hcardJ : K≤6*J.card := by simp only [J,Finset.card_range,m] omega rw [hcardS] at hcard calc K^6=K^3*K*K^2 := by ring _ ≤ K^3*(50*I.card)*(6*J.card)^2 := Nat.mul_le_mul (Nat.mul_le_mul_left _ hcardI) (Nat.pow_le_pow_left hcardJ 2) _ = 1800*(K^3*I.card*J.card^2) := by ring _ ≤ 1800*(currentAdmissiblePairs K).card := Nat.mul_le_mul_left _ hcard _ ≤ _ := Nat.mul_le_mul_right _ (by decide) end HardSphere.DyadicSkeleton end end section noncomputable section open MeasureTheory ProbabilityTheory open scoped ENNReal BigOperators namespace HardSphere.DyadicSkeleton open HardSphere.Lattice theorem current_good_paths (R : ℕ) : ∃ p₀ κ : ℝ, 0