simple_graph_odd_components_card_le_vertices
A finite graph has at most as many odd connected components as vertices.
Statement
theorem simple_graph_odd_components_card_le_vertices {V : Type*} [Fintype V] (G : SimpleGraph V) : G.oddComponents.ncard ≤ Fintype.card V
- Source
- OP-1957: bound the barrier size by the cardinality of the extra component part.
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 2
- op1957_saturated_b_only_connected_shore_impossibleThe displayed disjoint connected endpoint shores and B-only odd reservoir cannot satisfy the four-block degree, separator and…
- boundary_five_blocks_forced_cross_edge_is_bridgeFor every k at least five, in a four-block boundary partition with the two displayed opposite blocks of size five and minimum degree at…
The proof, explained
The proof bounds the number of odd connected components by the total number of connected components, and then bounds the total number of connected components by the number of vertices. The first bound holds because odd components form a subset of all connected components in a finite graph. The second bound holds because the projection sending each vertex to its connected component is surjective, and a surjective map from a finite set cannot increase cardinality. Transitivity of inequality completes the argument.
The canonical map sending each vertex to its connected component is surjective.
Classical reasoning is enabled. Given any connected component `c`, its support is nonempty, so there exists some vertex `v` belonging to `c`, which means the projection map `G.connectedComponentMk` maps `v` to `c`.
classical have hsurj : Function.Surjective G.connectedComponentMk := by intro c obtain ⟨v, hv⟩ := c.nonempty_supp exact ⟨v, hv⟩
The total number of connected components is at most the number of vertices.
Because `V` is finite and `G.connectedComponentMk : V → G.ConnectedComponent` is surjective, the cardinality of `G.ConnectedComponent` is at most the cardinality of `V` by `Nat.card_le_card_of_surjective`. Rewriting `Nat.card V` to `Fintype.card V` using `Nat.card_eq_fintype_card` gives the desired bound.
uses
Nat.card_eq_fintype_card,Nat.card_le_card_of_surjectivehave hcomp : Nat.card G.ConnectedComponent ≤ Fintype.card V := by simpa only [Nat.card_eq_fintype_card] using (Nat.card_le_card_of_surjective G.connectedComponentMk hsurj)
The number of odd connected components is at most the total number of connected components.
The odd components form a subset of all connected components by `Set.subset_univ`. Since the universal set of components is finite (`Set.toFinite`), `Set.ncard_le_ncard` bounds the cardinality of this subset by the cardinality of the universal set, which equals the total number of connected components by `Set.ncard_univ`.
uses
Set.ncard_univ,Set.ncard_le_ncard,Set.subset_univ,Set.toFinitehave hodd : G.oddComponents.ncard ≤ Nat.card G.ConnectedComponent := by rw [← Set.ncard_univ] exact Set.ncard_le_ncard (Set.subset_univ _) (Set.toFinite _)
The number of odd connected components is at most the number of vertices in G.
Combining the bound on odd components in terms of all connected components (`hodd`) with the bound on connected components in terms of vertices (`hcomp`) by transitivity yields the theorem.
exact hodd.trans hcomp
Nat.card_eq_fintype_card- For any finite type α, its cardinality as a natural number (`Nat.card`) equals its finite-type cardinality (`Fintype.card`).
Nat.card_le_card_of_surjective- If a function from a finite type to another type is surjective, the cardinality of the target is at most the cardinality of the domain.
Set.ncard_univ- The set cardinality (`ncard`) of the universal set of a type α equals the cardinality of α (`Nat.card α`).
Set.ncard_le_ncard- If s ⊆ t and t is finite, then the cardinality of s is at most the cardinality of t.
Set.subset_univ- Every set of elements of α is a subset of the universal set of α.
Set.toFinite- A set whose coerced subtype is finite is finite as a set.
- The finiteness of the type of connected components `G.ConnectedComponent`, required to apply `Set.toFinite` on the universal set, is inferred automatically by typeclass synthesis because it is a quotient of the finite vertex type `V`.
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 simple_graph_odd_components_card_le_vertices {V : Type*} [Fintype V] (G : SimpleGraph V) : G.oddComponents.ncard ≤ Fintype.card V := by classical have hsurj : Function.Surjective G.connectedComponentMk := by intro c obtain ⟨v, hv⟩ := c.nonempty_supp exact ⟨v, hv⟩ have hcomp : Nat.card G.ConnectedComponent ≤ Fintype.card V := by simpa only [Nat.card_eq_fintype_card] using (Nat.card_le_card_of_surjective G.connectedComponentMk hsurj) have hodd : G.oddComponents.ncard ≤ Nat.card G.ConnectedComponent := by rw [← Set.ncard_univ] exact Set.ncard_le_ncard (Set.subset_univ _) (Set.toFinite _) exact hodd.trans hcomp