Documentation

CslibFrontier.Algorithms.Matching.Tutte

The Tutte matrix and the randomized perfect-matching test for general graphs #

A finite simple graph G on a linearly ordered vertex type V has the Tutte matrix Cslib.Algorithms.Matching.tutteMatrix G: its entry (i, j) is X s(i, j) when ij is an edge and i < j, -X s(i, j) when ij is an edge and j < i, and 0 otherwise, with one indeterminate per unordered pair. It is skew-symmetric. Tutte's matrix theorem: its determinant is a nonzero polynomial exactly when G has a perfect matching (Cslib.Algorithms.Matching.det_tutteMatrix_ne_zero_iff) [Tut47] Motwani and Raghavan, Section 7.3. The sources state it over a field; the statement here holds over every nontrivial commutative ring, a generality of this formalization that the same proof gives. It is distinct from Tutte's combinatorial criterion in terms of odd components, which Mathlib has as SimpleGraph.tutte.

In the Leibniz expansion of a skew-symmetric determinant the permutations with an odd cycle cancel (Matrix.det_eq_sum_even_cycleType_of_transpose_eq_neg). A surviving nonzero term is a permutation along the edges of G with only even cycles, which gives a perfect matching (SimpleGraph.exists_isPerfectMatching_of_perm). Conversely, at the indicator of the edges of a perfect matching M the Tutte matrix is the signed permutation matrix of the involution M, of determinant ±1.

The randomized test of Lovász [Lov79a] substitutes values r : Sym2 V → R for the indeterminates (Cslib.Algorithms.Matching.tutteEval G r) and checks whether the determinant is nonzero. Its error is one-sided. Without a perfect matching the determinant is always 0 (Cslib.Algorithms.Matching.det_tutteEval_eq_zero). With one, over an integral domain and with the values drawn independently and uniformly from a finite set S, the determinant vanishes with probability at most |V| / |S| (Cslib.Algorithms.Matching.card_det_tutteEval_eq_zero_div_le), by the Schwartz–Zippel lemma.

Main definitions #

Main results #

References #

def Cslib.Algorithms.Matching.tutteEval {V : Type u_1} [LinearOrder V] {R : Type u_2} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (r : Sym2 V → R) :
Matrix V V R

The Tutte matrix of G at the values r : Sym2 V → R: r s(i, j) at each edge with i < j, -r s(i, j) at each edge with j < i, and 0 elsewhere.

theorem Cslib.Algorithms.Matching.tutteEval_apply {V : Type u_1} [LinearOrder V] {R : Type u_2} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (r : Sym2 V → R) (i j : V) :
tutteEval G r i j = if G.Adj i j then if i < j then r s(i, j) else -r s(i, j) else 0

An entry of the Tutte matrix at values.

noncomputable def Cslib.Algorithms.Matching.tutteMatrix {V : Type u_1} [LinearOrder V] {R : Type u_2} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] :

The Tutte matrix of a simple graph G: X s(i, j) at each edge with i < j, -X s(i, j) at each edge with j < i, and 0 elsewhere.

The Tutte matrix at values is skew-symmetric.

Substituting values for the indeterminates of the Tutte matrix.

An entry of the Tutte matrix has total degree at most 1.

The determinant of the Tutte matrix at values is the determinant polynomial evaluated at them.

A nonzero determinant of the Tutte matrix at some values gives a perfect matching: in the Leibniz expansion the permutations with an odd cycle cancel, and a surviving nonzero term is a permutation along the edges of G with only even cycles.

theorem Cslib.Algorithms.Matching.det_tutteEval_eq_zero {V : Type u_1} [LinearOrder V] {R : Type u_2} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] (hG : ¬∃ (M : G.Subgraph), M.IsPerfectMatching) (r : Sym2 V → R) :
(tutteEval G r).det = 0

No false positives: without a perfect matching, the Tutte matrix has determinant 0 at all values.

Without a perfect matching, the determinant of the Tutte matrix is the zero polynomial.

With a perfect matching M, the determinant of the Tutte matrix is a nonzero polynomial: at the indicator of the edges of M the Tutte matrix is the signed permutation matrix of the involution M, of determinant ±1.

Tutte's matrix theorem [Tut47]: the determinant of the Tutte matrix of a simple graph is a nonzero polynomial exactly when the graph has a perfect matching. The sources state it over a field; this formalization proves it over every nontrivial commutative ring. For Tutte's combinatorial criterion (odd components) see Mathlib's SimpleGraph.tutte.

The determinant of the Tutte matrix has total degree at most |V|.

theorem Cslib.Algorithms.Matching.card_det_tutteEval_eq_zero_div_le {V : Type u_1} [LinearOrder V] {R : Type u_2} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [IsDomain R] [DecidableEq R] {M : G.Subgraph} (hM : M.IsPerfectMatching) (S : Finset R) :
↑{r ∈ Fintype.piFinset fun (x : Sym2 V) => S | (tutteEval G r).det = 0}.card / ↑S.card ^ Fintype.card (Sym2 V) ≤ ↑(Fintype.card V) / ↑S.card

The randomized perfect-matching test: for a simple graph with a perfect matching, over an integral domain, the Tutte matrix at values drawn independently and uniformly from a finite set S is singular with probability at most |V| / |S|.

theorem Cslib.Algorithms.Matching.exists_det_tutteEval_ne_zero {V : Type u_1} [LinearOrder V] {R : Type u_2} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [IsDomain R] {M : G.Subgraph} (hM : M.IsPerfectMatching) {S : Finset R} (hS : Fintype.card V < S.card) :
∃ (r : Sym2 V → R), (∀ (e : Sym2 V), r e ∈ S) ∧ (tutteEval G r).det ≠ 0

Values from any set of more than |V| elements of an integral domain detect a perfect matching: some choice of them makes the Tutte matrix nonsingular.