even_graph_few_odd_components_has_perfect_matching
An even-order finite graph has a perfect matching if its odd-component count after deleting any vertex set is at most three, is at most two after deleting one vertex, and is zero after deleting no vertices.
Statement
theorem even_graph_few_odd_components_has_perfect_matching {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (heven : Even (Nat.card V)) (hzero : ∀ S : Set V, S.ncard = 0 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard = 0) (hone : ∀ S : Set V, S.ncard = 1 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 2) (hall : ∀ S : Set V, ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 3) : ∃ P : G.Subgraph, P.IsPerfectMatching
- Source
- OP-1957: odd-component parity helper for four-block matching obstructions.
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- forced_matching_edge_common_nonneighbors_below_min_degree_is_bridgeIn a finite graph of minimum degree at least r, a perfect-matching edge belonging to every perfect matching is a bridge whenever its…
- op_2037_subgraph_fintypeA graph on a finite decidable vertex type has only finitely many subgraphs.
The proof, explained
The theorem is proved by contradiction using Tutte's 1-factor theorem. If $G$ has no perfect matching, there exists a Tutte violator $S \subseteq V$, meaning the number of odd components $q(G \setminus S)$ strictly exceeds $|S|$. A standard parity argument shows that $q(G \setminus S) \equiv |V| - |S| \equiv |S| \pmod 2$, so $q(G \setminus S)$ and $|S|$ have the same parity. The proof then splits into cases on $|S|$: if $|S| = 0$, then $q(G \setminus S) = 0 \ngtr 0$; if $|S| = 1$, then $q(G \setminus S) \le 2$ must be odd and $> 1$, which is impossible; and if $|S| \ge 2$, then $2 \le |S| < q(G \setminus S) \le 3$ forces $|S| = 2$ and $q(G \setminus S) = 3$, violating the parity agreement. In all cases we reach a contradiction.
Assume for contradiction that $G$ has no perfect matching; then there is a vertex set $S \subseteq V$ such that $H = G \setminus S$ has strictly more than $|S|$ odd components.
We proceed by contradiction (`by_contra`). Since the order of $G$ is even (`heven`), Tutte's 1-factor theorem via `SimpleGraph.exists_isTutteViolator` provides a set $S \subseteq V$ violating Tutte's condition. Defining $W = V \setminus S$ and the induced subgraph $H = G[W]$, the violator condition gives $|S| < q(H)$, where $q(H)$ is the number of odd connected components of $H$.
uses
SimpleGraph.exists_isTutteViolatorclassical by_contra hn obtain ⟨S, hS⟩ := SimpleGraph.exists_isTutteViolator (G := G) (fun M hM => hn ⟨M, hM⟩) heven let W : Set V := ((⊤ : G.Subgraph).deleteVerts S).verts let H := ((⊤ : G.Subgraph).deleteVerts S).coe have hS' : S.ncard < H.oddComponents.ncard := hS
The number of odd components of $H$ has the same parity as $|S|$, formulated as $q(H) \pmod 2 = (|V| - |S|) \pmod 2$ with $|V|$ even and $|S| \le |V|$.
By `SimpleGraph.odd_ncard_oddComponents`, the number of odd components of $H$ has the same parity as its vertex count $|W|$. We compute $|W| = |V| - |S|$ by rewriting the subtype cardinality to set cardinality (`Nat.card_coe_set_eq`) and subtracting $|S|$ from $|V| = |\mathrm{univ}|$ (`Set.ncard_diff`, `Set.subset_univ`, `Set.ncard_univ`, `Nat.card_eq_fintype_card`). We also verify that $|S| \le |V|$ (`Set.ncard_le_ncard`, `Set.subset_univ`, `Nat.card_eq_fintype_card`) and that $|V| \pmod 2 = 0$ using `heven` (`Nat.even_iff.mp`, `Nat.card_eq_fintype_card`). Rewriting the parity equivalence in terms of remainders modulo 2 using `Nat.odd_iff` gives $q(H) \pmod 2 = (|V| - |S|) \pmod 2$, which implies that $q(H)$ and $|S|$ share the same parity.
uses
SimpleGraph.odd_ncard_oddComponents,Nat.card_coe_set_eq,Set.ncard_diff,Set.subset_univ,Set.ncard_univ,Nat.card_eq_fintype_card,Set.ncard_le_ncard,Nat.even_iff.mp,Nat.odd_iffhave hpar := SimpleGraph.odd_ncard_oddComponents H have hcardW : Nat.card W = Fintype.card V - S.ncard := by rw [Nat.card_coe_set_eq] change (Set.univ \ S).ncard = _ rw [Set.ncard_diff (Set.subset_univ S), Set.ncard_univ, Nat.card_eq_fintype_card] have hSle : S.ncard ≤ Fintype.card V := by rw [← Nat.card_eq_fintype_card, ← Set.ncard_univ] exact Set.ncard_le_ncard (Set.subset_univ S) have hev : Fintype.card V % 2 = 0 := by rw [← Nat.card_eq_fintype_card]; exact Nat.even_iff.mp heven rw [hcardW, Nat.odd_iff, Nat.odd_iff] at hpar
The number of odd components of $H$ is at most 3.
Applying the global hypothesis `hall` to the Tutte violator set $S$ directly yields $q(H) \le 3$.
have hb : H.oddComponents.ncard ≤ 3 := hall SThe case $|S| = 0$ is impossible.
We split into cases on whether $|S| = 0$ (`by_cases`). If $|S| = 0$, hypothesis `hzero` implies that $H$ has 0 odd components. But the violator inequality gives $0 = |S| < q(H) = 0$, an immediate linear arithmetic contradiction closed by `omega`.
by_cases hs0 : S.ncard = 0 · have hh : H.oddComponents.ncard = 0 := hzero S hs0 omega
The case $|S| = 1$ is impossible.
In the remaining branch, we split on whether $|S| = 1$ (`by_cases`). If $|S| = 1$, hypothesis `hone` implies $q(H) \le 2$. But $|S| < q(H)$ requires $q(H) \ge 2$, forcing $q(H) = 2$. However, $q(H)$ must have the same parity as $|S| = 1$ because $|V|$ is even, meaning $q(H)$ must be odd, which contradicts $q(H) = 2$. Integer linear and modular arithmetic (`omega`) closes this branch.
· by_cases hs1 : S.ncard = 1 · have hh : H.oddComponents.ncard ≤ 2 := hone S hs1 omega
The case $|S| \ge 2$ is impossible, completing the proof.
In the final branch, $|S| \ne 0$ and $|S| \ne 1$, so $|S| \ge 2$. Since $2 \le |S| < q(H) \le 3$, we must have $|S| = 2$ and $q(H) = 3$. But $q(H)$ and $|S|$ have the same parity, whereas 3 is odd and 2 is even. This contradiction is resolved by `omega`, concluding the proof.
· omega
SimpleGraph.exists_isTutteViolator- If a finite graph of even order has no perfect matching, then there exists a Tutte violator: a vertex subset $S$ whose deletion leaves strictly more than $|S|$ odd components.
SimpleGraph.odd_ncard_oddComponents- In any finite graph, the number of odd connected components has the same parity as the total number of vertices.
Nat.card_coe_set_eq- The cardinality of a set viewed as a subtype equals its set cardinality (`ncard`).
Set.ncard_diff- For a subset $s \subseteq t$ with $s$ finite, the cardinality of the difference $t \setminus s$ is $|t| - |s|$.
Set.subset_univ- Every set of elements of a type is a subset of the universal set.
Set.ncard_univ- The cardinality of the universal set of a type equals the cardinality of the type.
Nat.card_eq_fintype_card- For a finite type, its cardinality as a natural number (`Nat.card`) equals its `Fintype` cardinality.
Set.ncard_le_ncard- If $s \subseteq t$ and $t$ is finite, then $|s| \le |t|$.
Nat.even_iff.mp- If a natural number is even, then its remainder modulo 2 is 0.
Nat.odd_iff- A natural number is odd if and only if its remainder modulo 2 is 1.
- The arithmetic contradictions in the case analysis (steps 4, 5, and 6) are closed automatically by `omega`. In particular, for $|S| = 1$ and $|S| \ge 2$, `omega` combines the linear inequalities with the parity constraint $q(G - S) \pmod 2 = (|V| - |S|) \pmod 2$ and the evenness of $|V|$ to deduce the contradiction without manual case exhaustion.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem even_graph_few_odd_components_has_perfect_matching {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (heven : Even (Nat.card V)) (hzero : ∀ S : Set V, S.ncard = 0 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard = 0) (hone : ∀ S : Set V, S.ncard = 1 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 2) (hall : ∀ S : Set V, ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 3) : ∃ P : G.Subgraph, P.IsPerfectMatching := by classical by_contra hn obtain ⟨S, hS⟩ := SimpleGraph.exists_isTutteViolator (G := G) (fun M hM => hn ⟨M, hM⟩) heven let W : Set V := ((⊤ : G.Subgraph).deleteVerts S).verts let H := ((⊤ : G.Subgraph).deleteVerts S).coe have hS' : S.ncard < H.oddComponents.ncard := hS have hpar := SimpleGraph.odd_ncard_oddComponents H have hcardW : Nat.card W = Fintype.card V - S.ncard := by rw [Nat.card_coe_set_eq] change (Set.univ \ S).ncard = _ rw [Set.ncard_diff (Set.subset_univ S), Set.ncard_univ, Nat.card_eq_fintype_card] have hSle : S.ncard ≤ Fintype.card V := by rw [← Nat.card_eq_fintype_card, ← Set.ncard_univ] exact Set.ncard_le_ncard (Set.subset_univ S) have hev : Fintype.card V % 2 = 0 := by rw [← Nat.card_eq_fintype_card]; exact Nat.even_iff.mp heven rw [hcardW, Nat.odd_iff, Nat.odd_iff] at hpar have hb : H.oddComponents.ncard ≤ 3 := hall S by_cases hs0 : S.ncard = 0 · have hh : H.oddComponents.ncard = 0 := hzero S hs0 omega · by_cases hs1 : S.ncard = 1 · have hh : H.oddComponents.ncard ≤ 2 := hone S hs1 omega · omega