Dev/MonadicDependence/ComparabilityGrid/Contract.lean
1import Mathlib.Combinatorics.SimpleGraph.Basic
2
3namespace Dev.MonadicDependence.ComparabilityGrid
4
5/-- The comparability grid of order `n` (Mählmann, p. 15) is the graph on
6vertex set `Fin n × Fin n` in which two distinct vertices `(i, j)` and
7`(i', j')` are adjacent iff at least one of: `i = i'` (same row),
8`j = j'` (same column), or `i < i' ↔ j < j'` (comparable — ordered the
9same way in both coordinates).
10
11Built with `SimpleGraph.fromRel`, which adds the `p ≠ q` guard and
12symmetrizes by disjunction. The extra disjunct from symmetrization,
13`j' < j ↔ i' < i`, coincides with `i < i' ↔ j < j'` whenever the two
14pairs differ in both coordinates (by trichotomy on `Fin n`), so the
15adjacency of `comparabilityGrid n` matches the source verbatim — see
16`review.tex`. -/
17def comparabilityGrid (n : ℕ) : SimpleGraph (Fin n × Fin n) :=
18 SimpleGraph.fromRel fun p q =>
19 p.1 = q.1 ∨ p.2 = q.2 ∨ (p.1 < q.1 ↔ p.2 < q.2)
20
21end Dev.MonadicDependence.ComparabilityGrid
22