AFTD Auto-Formalizing Theoretical Domains

graph_iso_odd_components_card

theoremverified

A finite graph isomorphism preserves the number of odd connected components.

Statement

theorem graph_iso_odd_components_card
    {V W : Type*} [Fintype V] [Fintype W]
    (G : SimpleGraph V) (H : SimpleGraph W) (e : G ≃g H) :
    G.oddComponents.ncard = H.oddComponents.ncard
Source
Balanced-cut k=7 reduction for OP-1957; https://arxiv.org/abs/2611.22690.
Verified
26 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • is_k_extendableFor a finite vertex type V (with [Fintype V]), a simple graph G : SimpleGraph V and k : ℕ, is_k_extendable G k is the Prop that is the…
Used by 4

The proof, explained

The graph isomorphism induces a bijection between the connected components of G and those of H. Because the isomorphism restricts to a bijection between the vertex sets of corresponding components, each component has the same number of vertices as its image, preserving oddness. Thus, the bijection maps the odd components of G onto the odd components of H, showing that both graphs have the same number of odd components.

  1. Let f be the bijection between the connected components of G and the connected components of H induced by the isomorphism e.

    The graph isomorphism e induces an equivalence f between the connected components of G and those of H (e.connectedComponentEquiv).

    lines 5–7

      set_option maxHeartbeats 4000000 in
        classical
        let f := e.connectedComponentEquiv
  2. A connected component c of G has an odd number of vertices if and only if f(c) has an odd number of vertices in H.

    For any component c of G, the isomorphism e restricts to a bijection between the vertex sets of c and f(c) (SimpleGraph.ConnectedComponent.isoEquivSupp). By Nat.card_congr (and using Nat.card_coe_set_eq to relate subtype and set cardinalities), their vertex sets have equal cardinality. Since being an odd component means that this cardinality is odd, c is odd in G if and only if f(c) is odd in H.

    lines 8–14

    uses Nat.card_coe_set_eq, Nat.card_congr, SimpleGraph.ConnectedComponent.isoEquivSupp

        have hf : ∀ c : G.ConnectedComponent, c ∈ G.oddComponents ↔ f c ∈ H.oddComponents := by
          intro c
          have hc : c.supp.ncard = (f c).supp.ncard := by
            rw [← Nat.card_coe_set_eq,← Nat.card_coe_set_eq]
            exact Nat.card_congr (SimpleGraph.ConnectedComponent.isoEquivSupp e c)
          change Odd c.supp.ncard ↔ Odd (f c).supp.ncard
          rw [hc]
  3. The image under f of the set of odd components of G is precisely the set of odd components of H.

    We check both set inclusions. If a component of H has the form f(x) for an odd component x of G, it is odd by the forward direction of the equivalence proved in the previous step. Conversely, if c is an odd component of H, its preimage f⁻¹(c) is an odd component of G by the reverse direction, and f(f⁻¹(c)) = c.

    lines 15–23

        have himage : f '' G.oddComponents = H.oddComponents := by
          ext c
          constructor
          · rintro ⟨x,hx,rfl⟩
            exact (hf x).mp hx
          · intro hc
            refine ⟨f.symm c,?_,by simp⟩
            apply (hf (f.symm c)).mpr
            simpa using hc
  4. The number of odd components of G equals the number of odd components of H.

    Since H.oddComponents is the image f '' G.oddComponents and f is injective (being an equivalence), the set cardinalities coincide by Set.ncard_image_of_injective.

    line 24

    uses Set.ncard_image_of_injective

        rw [← himage,Set.ncard_image_of_injective _ f.injective]
Nat.card_coe_set_eq
The cardinality of a set s viewed as a subtype equals the set cardinality s.ncard.
Nat.card_congr
A bijection between two types implies that their cardinalities are equal.
SimpleGraph.ConnectedComponent.isoEquivSupp
A graph isomorphism restricts to a bijection between the vertex support of any connected component and the vertex support of its image component.
Set.ncard_image_of_injective
An injective map preserves the cardinality of any set under its forward image.

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

theorem graph_iso_odd_components_card    {V W : Type*} [Fintype V] [Fintype W]    (G : SimpleGraph V) (H : SimpleGraph W) (e : G ≃g H) :    G.oddComponents.ncard = H.oddComponents.ncard := by  set_option maxHeartbeats 4000000 in    classical    let f := e.connectedComponentEquiv    have hf : ∀ c : G.ConnectedComponent, c ∈ G.oddComponents ↔ f c ∈ H.oddComponents := by      intro c      have hc : c.supp.ncard = (f c).supp.ncard := by        rw [← Nat.card_coe_set_eq,← Nat.card_coe_set_eq]        exact Nat.card_congr (SimpleGraph.ConnectedComponent.isoEquivSupp e c)      change Odd c.supp.ncard ↔ Odd (f c).supp.ncard      rw [hc]    have himage : f '' G.oddComponents = H.oddComponents := by      ext c      constructor      · rintro ⟨x,hx,rfl⟩        exact (hf x).mp hx      · intro hc        refine ⟨f.symm c,?_,by simp⟩        apply (hf (f.symm c)).mpr        simpa using hc    rw [← himage,Set.ncard_image_of_injective _ f.injective]
See it in the graphDiscuss this resultChallenge it