even_graph_four_odd_component_bounds_has_perfect_matching
An even-order finite graph has a perfect matching if, after removing zero vertices, it has no odd component, after removing one or two vertices it has at most two odd components, after removing three it has at most three, and after any vertex deletion it has at most four.
Statement
theorem even_graph_four_odd_component_bounds_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) (htwo : ∀ S : Set V, S.ncard=2 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 2) (hthree : ∀ S : Set V, S.ncard=3 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 3) (hall : ∀ S : Set V, ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 4) : ∃ P : G.Subgraph, P.IsPerfectMatching
- Source
- OP-1957: matching-criterion assembly for the (5,7) example.
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- op_2037_subgraph_fintypeA graph on a finite decidable vertex type has only finitely many subgraphs.
The proof, explained
The proof proceeds by contradiction using Tutte's 1-factor theorem. If $G$ has no perfect matching, then since its order is even, there exists a Tutte violator—a vertex subset $S$ whose deletion leaves strictly more odd components than $|S|$. Because $|V|$ is even, the number of odd components $q(G - S)$ and $|S|$ share the same parity, which forces $q(G - S) \ge |S| + 2$. Case analysis on $|S| \in \{0, 1, 2, 3\}$ and $|S| \ge 4$ then contradicts the given upper bounds in every case.
Assuming $G$ has no perfect matching, there exists a Tutte violator $S \subseteq V$.
We argue by contradiction, supposing that $G$ has no perfect matching (`hn`). Because $V$ has even cardinality (`heven`), Tutte's theorem (`SimpleGraph.exists_isTutteViolator`) yields a subset $S \subseteq V$ violating Tutte's condition.
uses
SimpleGraph.exists_isTutteViolatorclassical by_contra hn obtain ⟨S, hS⟩ := SimpleGraph.exists_isTutteViolator (G := G) (fun M hM => hn ⟨M, hM⟩) heven
In the deleted subgraph $H = G - S$, the number of odd components strictly exceeds $|S|$ and has the same parity as the number of vertices in $H$.
Let $W = V \setminus S$ be the remaining vertex set and $H$ the induced subgraph $G - S$. By definition of a Tutte violator, the number of odd components of $H$ is strictly greater than $|S|$ (`hS'`). By `SimpleGraph.odd_ncard_oddComponents`, the number of odd components of $H$ has the same parity as the vertex count $|W|$.
uses
SimpleGraph.odd_ncard_oddComponentslet 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
The vertex count of $H$ is $|V| - |S|$, and the number of odd components of $H$ has the same parity as $|V| - |S|$.
We express $W$ as the set difference $V \setminus S$, showing $|W| = |V| - |S|$ (`hcardW`) and $|S| \le |V|$ (`hSle`) using set difference and universal set cardinality lemmas (`Nat.card_coe_set_eq`, `Set.ncard_diff`, `Set.subset_univ`, `Set.ncard_univ`, `Nat.card_eq_fintype_card`, `Set.ncard_le_ncard`). Since $|V|$ is even (`heven`), $|V| \pmod 2 = 0$ (`hev`) via `Nat.even_iff.mp`. Rewriting the parity condition with `Nat.odd_iff` and `hcardW` expresses parity as a modulo 2 relation between the number of odd components and $|V| - |S|$.
uses
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 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 case $|S| = 0$ is impossible.
If $|S| = 0$, hypothesis `hzero` states that $H$ has 0 odd components, contradicting the requirement $|S| < q(H)$ (which would demand $0 < 0$). Linear arithmetic (`omega`) closes this case.
by_cases hs0 : S.ncard=0 · have hh : H.oddComponents.ncard=0 := hzero S hs0 omega
The case $|S| = 1$ is impossible.
If $|S| = 1$, hypothesis `hone` bounds the number of odd components by at most 2. However, since $|V|$ is even, $|V| - 1$ is odd, so $H$ must have an odd number of odd components. Coupled with $q(H) > 1$, this requires $q(H) \ge 3$, contradicting $q(H) \le 2$. Linear arithmetic (`omega`) closes this case.
· by_cases hs1 : S.ncard=1 · have hh : H.oddComponents.ncard ≤ 2 := hone S hs1 omega
The case $|S| = 2$ is impossible.
If $|S| = 2$, hypothesis `htwo` bounds the number of odd components by at most 2. But $|V| - 2$ is even, so $q(H)$ must be even. Coupled with $q(H) > 2$, this requires $q(H) \ge 4$, contradicting $q(H) \le 2$. Linear arithmetic (`omega`) closes this case.
· by_cases hs2 : S.ncard=2 · have hh : H.oddComponents.ncard ≤ 2 := htwo S hs2 omega
The case $|S| = 3$ is impossible.
If $|S| = 3$, hypothesis `hthree` bounds the number of odd components by at most 3. But $|V| - 3$ is odd, so $q(H)$ must be odd. Coupled with $q(H) > 3$, this requires $q(H) \ge 5$, contradicting $q(H) \le 3$. Linear arithmetic (`omega`) closes this case.
· by_cases hs3 : S.ncard=3 · have hh : H.oddComponents.ncard ≤ 3 := hthree S hs3 omega
The case $|S| \ge 4$ is impossible, completing the contradiction.
If $|S| \notin \{0, 1, 2, 3\}$, then $|S| \ge 4$. Hypothesis `hall` bounds the number of odd components by at most 4 for any deleted set. But $q(H) > |S| \ge 4$ requires $q(H) \ge 5$, contradicting $q(H) \le 4$. Linear arithmetic (`omega`) closes this final case.
· have hh : H.oddComponents.ncard ≤ 4 := hall S omega
SimpleGraph.exists_isTutteViolator- In a finite graph of even order with no perfect matching, there exists a Tutte violator: a vertex subset whose deletion leaves strictly more odd connected components than vertices removed.
SimpleGraph.odd_ncard_oddComponents- The number of odd connected components of a finite graph has the same parity as the total number of its 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 finite subset $s \subseteq t$, 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 of that type.
Set.ncard_univ- The set cardinality of the universal set of a type equals the cardinality of the type.
Nat.card_eq_fintype_card- For a finite type, the general cardinality `Nat.card` equals the `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, 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 parity condition that the number of odd components $q(G - S)$ has the same parity as $|S|$ when $|V|$ is even implies $q(G - S) \ge |S| + 2$. The proof does not state this general inequality explicitly as an intermediate lemma; instead, the tactic `omega` deduces the arithmetic contradiction in each case directly from $|S| < q(G - S)$, the parity congruence, and the case bound.
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_four_odd_component_bounds_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) (htwo : ∀ S : Set V, S.ncard=2 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 2) (hthree : ∀ S : Set V, S.ncard=3 → ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 3) (hall : ∀ S : Set V, ((⊤ : G.Subgraph).deleteVerts S).coe.oddComponents.ncard ≤ 4) : ∃ 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 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 · by_cases hs2 : S.ncard=2 · have hh : H.oddComponents.ncard ≤ 2 := htwo S hs2 omega · by_cases hs3 : S.ncard=3 · have hh : H.oddComponents.ncard ≤ 3 := hthree S hs3 omega · have hh : H.oddComponents.ncard ≤ 4 := hall S omega