Dev.MonadicDependence.ComparabilityGrid
Definition
For \(n \in \mathbb{N}\), the comparability grid of order \(n\) is the graph with vertex set \(\{a_{i, j} : i, j \in [n]\}\) in which two distinct vertices \(a_{i, j}\) and \(a_{i', j'}\) are adjacent if and only if at least one of the following holds:
- \(i = i'\) (“same row”), or
- \(j = j'\) (“same column”), or
- \(i < i' \Leftrightarrow j < j'\) (“comparable”: \((i, j)\) and \((i', j')\) are ordered the same way in both coordinates).
No other edges are present.
Review notes
No flipped variant. Mählmann explains (p. 15) why no flipped variant of the comparability grid is needed: “any huge flipped comparability grid contains a still large non-flipped comparability grid as an induced subgraph”. We mirror this in our definition, using only the unflipped version as one of the four forbidden patterns in Definition MonadicDependence’s clause (3).
Adjacency convention. The third adjacency condition “\(i < i' \Leftrightarrow j < j'\)” is well-defined precisely when \(i \neq i'\) and \(j \neq j'\); otherwise one of the first two conditions applies, so we never evaluate the third condition with \(i = i'\) or \(j = j'\). In particular, the graph has no self-loops (the condition is restricted to distinct vertices).
Standard name. The same graph is called the “\(n \times n\) comparability grid” in standard graph theory. It is a dense, highly symmetric graph of order \(n^2\); the number of edges is \(n^2(n^2 - 1)/2 \cdot \bigl(\text{adjacency density}\bigr)\), where the adjacency density approaches \(1/2\) as \(n \to \infty\).
Lean encoding. We use SimpleGraph.fromRel over
Fin n × Fin n with
\[R\ p\ q := (p.1 = q.1) \lor (p.2 = q.2) \lor (p.1 < q.1 \leftrightarrow p.2 < q.2).\]
fromRel automatically adds the \(p \neq q\) guard (so no
self-loops) and symmetrizes by disjunction. The symmetrization adds
\(R\ q\ p = (q.1 = p.1) \lor (q.2 = p.2) \lor (q.1 < p.1
\leftrightarrow q.2 < p.2)\); the first two disjuncts coincide with the
forward clauses, and the third disjunct \(q.1 < p.1 \leftrightarrow q.2
< p.2\) coincides with \(p.1 < q.1 \leftrightarrow p.2 < q.2\) whenever
both coordinates differ (by trichotomy on Fin n). Hence the
adjacency of comparabilityGrid n matches the source
verbatim.
Dev/MonadicDependence/ComparabilityGrid/Contract.lean (full)
| 1 | import Mathlib.Combinatorics.SimpleGraph.Basic |
| 2 | |
| 3 | namespace Dev.MonadicDependence.ComparabilityGrid |
| 4 | |
| 5 | /-- The comparability grid of order `n` (Mählmann, p. 15) is the graph on |
| 6 | vertex 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 |
| 9 | same way in both coordinates). |
| 10 | |
| 11 | Built with `SimpleGraph.fromRel`, which adds the `p ≠ q` guard and |
| 12 | symmetrizes by disjunction. The extra disjunct from symmetrization, |
| 13 | `j' < j ↔ i' < i`, coincides with `i < i' ↔ j < j'` whenever the two |
| 14 | pairs differ in both coordinates (by trichotomy on `Fin n`), so the |
| 15 | adjacency of `comparabilityGrid n` matches the source verbatim — see |
| 16 | `review.tex`. -/ |
| 17 | def 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 | |
| 21 | end Dev.MonadicDependence.ComparabilityGrid |
| 22 |