GridRayCrossingIndexAdjacentCell #
Adapted from Wesley Pegden’s Apache-2.0 Trellis formalization of Levine–Pegden–Smart. Changes: pool module paths, public exports, project namespace and current Mathlib compatibility.
theorem
ApollonianSuperharmonic.GridRayCrossingIndexAdjacentCell
(p : List GaussianInt)
(x y : GaussianInt)
(hhead : p.head? = some x)
(hlast : p.getLast? = some y)
(hnodup : p.Nodup)
(hlen : 3 ≤ p.length)
(hadj : ∀ (a b : GaussianInt), (a, b) ∈ p.zip p.tail → FourNeighborAdjacent a b)
(hclose : FourNeighborAdjacent y x)
:
have cyclicEdges := p.zip p.tail ++ [(y, x)];
∀ (q : LatticeCell),
((q + 1, q + 1 + { re := 0, im := 1 }) ∉ cyclicEdges ∧ (q + 1 + { re := 0, im := 1 }, q + 1) ∉ cyclicEdges →
GridRayCrossingIndex (q + 1) p = GridRayCrossingIndex q p) ∧ ((q + 1, q + 1 + { re := 0, im := 1 }) ∈ cyclicEdges ∨ (q + 1 + { re := 0, im := 1 }, q + 1) ∈ cyclicEdges →
(GridRayCrossingIndex (q + 1) p - GridRayCrossingIndex q p).natAbs = 1) ∧ ((q + 1 + { re := 0, im := 1 }, q + { re := 0, im := 1 }) ∉ cyclicEdges ∧ (q + { re := 0, im := 1 }, q + 1 + { re := 0, im := 1 }) ∉ cyclicEdges →
GridRayCrossingIndex (q + { re := 0, im := 1 }) p = GridRayCrossingIndex q p) ∧ ((q + 1 + { re := 0, im := 1 }, q + { re := 0, im := 1 }) ∈ cyclicEdges ∨ (q + { re := 0, im := 1 }, q + 1 + { re := 0, im := 1 }) ∈ cyclicEdges →
(GridRayCrossingIndex (q + { re := 0, im := 1 }) p - GridRayCrossingIndex q p).natAbs = 1)