import Mathlib import OAI.Probability.CriticalPercolation.Gluing.ContourSites namespace OAI section section noncomputable section open Set Function open scoped Classical BigOperators namespace CriticalPercolation.Boundary def wordDir {n : ℕ} (w : Fin n → Dir) (i : ℕ) : Dir := if h : i (e j).2) i=e i := by let w : Fin n → Dir := fun j => (e j).2 have hd (i : ℕ) (hi : i exact wordEdge_zero _ _ | succ i ih => have hh : i (e j).2) := by have hr := wordEdge_reconstruct hn e hchain hclose refine ⟨?_,?_⟩ · rw [hr n le_rfl,hr 0 (Nat.zero_le n),hclose] · intro i hi j hj he rw [hr i hi.le,hr j hj.le] at he exact hinj hi hj he lemma outsideSites_congr {n : ℕ} {e f : ℕ → Edge} (h : ∀ i (e j).2),?_,?_⟩ · simpa only [hp] using wordValid_reconstruct hl e hchain he hinj · have hr := wordEdge_reconstruct hl e hchain he rw [hp] at hr rw [outsideSites_congr (fun i hi => hr i hi.le)] exact outsideSites_failed_children S e (n+1) hmem end CriticalPercolation.Boundary end end end end OAI