import Mathlib import OAI.Probability.BinarySweep.Trajectories.PathSign namespace OAI noncomputable section open scoped BigOperators Classical namespace BinaryCoordinateSweeps attribute [local instance] Classical.propDecidable variable {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) lemma exists_untouched_line (j : Fin b) (hh : h Nat.one_le_iff_ne_zero.mpr (hn y)) simp only [Finset.sum_const,Finset.card_univ,smul_eq_mul,mul_one,sum_lineHoles] at he omega lemma signed_path_weight_zero_sparse (z : ℝ) (j : Fin b) (hj : 0 huv (Subtype.ext he)),u.property,v.property⟩ lemma exists_line_two_free (j : Fin b) (hh : h+Fintype.card (GridOutside bits j) Slot (bits i))) change Fintype.card (GridSlot bits)=Fintype.card (Slot (bits j) × GridOutside bits j) at he have hs : Fintype.card (Slot (bits j))=2^bits j := by simp [Slot] have hg : Fintype.card (GridSlot bits)=gridSize bits := by simp [GridSlot,gridSize,Slot] simpa only [Fintype.card_prod,hs,hg,mul_comm] using he.symm have he : ∃y : GridOutside bits j, lineHoles H j y+1<2^bits j := by by_contra hn push Not at hn have hf := Finset.sum_le_sum (s:=Finset.univ) (fun y _ => hn y) simp only [Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,smul_eq_mul, mul_one,sum_lineHoles,hfull] at hf omega obtain ⟨y,hy⟩ := he refine ⟨y,?_⟩ apply two_outside_embedding (lineOutput H j y) have hc : Fintype.card (LinePaths H j y)=lineHoles H j y := by unfold LinePaths lineHoles congr 1 rw [hc] simpa [Slot] using hy lemma signed_path_weight_zero_few (j : Fin b) (hh : h+Fintype.card (GridOutside bits j)