AFTD Auto-Formalizing Theoretical Domains

odd_anticomplete_union_has_no_perfect_matching

theoremverified

If two disjoint finite vertex sets are anticomplete and the first has odd size, the graph induced by their union has no perfect matching.

Statement

theorem odd_anticomplete_union_has_no_perfect_matching : ∀ {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (A B : Finset V),
    Disjoint A B → Odd A.card →
    (∀ a ∈ A, ∀ b ∈ B, ¬ G.Adj a b) →
    ¬ ∃ P : (G.induce {v | v ∈ A ∨ v ∈ B}).Subgraph, P.IsPerfectMatching
Source
Factor-critical crossing-cut parity ingredient in the OP-1957 campaign.
Verified
20 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

We argue by contradiction: suppose the induced subgraph on $A \cup B$ has a perfect matching $P$. Restricting $P$ to the vertices in $A$ gives a subgraph $R$, which is itself a matching because there are no edges between $A$ and $B$, forcing every vertex in $A$ to be matched to another vertex in $A$. Since every finite matching has an even number of vertices, $|A|$ must be even, contradicting the hypothesis that $|A|$ is odd.

  1. Assume for contradiction that the graph induced by $A \cup B$ has a perfect matching $P$.

    We introduce the graph and hypotheses into scope, then assume for contradiction that there exists a subgraph $P$ of the induced subgraph on $A \cup B$ such that $P$ is a perfect matching.

    lines 5–7

      intro V instF instD G A B hAB hodd hcross
      classical
      rintro ⟨P, hP⟩
  2. Define $R$ as the subgraph of $P$ induced by the vertices of $A$.

    We identify the subset $C$ of vertices in $A \cup B$ that belong to $A$, and define $R$ to be the induced subgraph of $P$ on $C$.

    lines 8–9

      let C : Set {v : V // v ∈ A ∨ v ∈ B} := {v | v.val ∈ A}
      let R := P.induce C
  3. The induced subgraph $R$ is a matching.

    To show that $R$ is a matching, we show that every vertex $a \in A$ has a unique neighbor in $R$. Since $P$ is a perfect matching, $a$ has a unique neighbor $b$ in $P$. The vertex $b$ belongs to $A \cup B$; if it were in $B$, the edge between $a$ and $b$ would contradict the hypothesis that $A$ and $B$ are anticomplete (`False.elim`). Hence $b \in A$, so $b$ is a neighbor of $a$ in $R$. Moreover, any neighbor of $a$ in $R$ is also a neighbor in $P$, so uniqueness of $b$ in $P$ ensures uniqueness in $R$.

    lines 10–20

    uses False.elim

      have hRmatch : R.IsMatching := by
        intro a ha
        have haA : a.val ∈ A := ha
        obtain ⟨b, hab, huniq⟩ := hP.1 (hP.2 a)
        have hbA : b.val ∈ A := by
          rcases b.property with hbA | hbB
          · exact hbA
          · exact False.elim (hcross a.val haA b.val hbB (P.adj_sub hab))
        refine ⟨b, ⟨haA, hbA, hab⟩, ?_⟩
        intro c hc
        exact huniq c hc.2.2
  4. There is a canonical bijection between the vertices of $R$ and the set $A$.

    We define an equivalence $e$ mapping a vertex of $R$ to its underlying vertex in $A$ and vice versa, using `Or.inl` to lift an element of $A$ into $A \cup B$. We verify that the maps are mutually inverse by extensionality on subtypes (`Subtype.ext`).

    lines 21–25

    uses Or.inl, Subtype.ext

      let e : R.verts ≃ {v : V // v ∈ A} := {
        toFun := fun ⟨⟨v, hv⟩, ha⟩ => ⟨v, ha⟩
        invFun := fun ⟨v, hv⟩ => ⟨⟨v, Or.inl hv⟩, hv⟩
        left_inv := by intro v; apply Subtype.ext; apply Subtype.ext; rfl
        right_inv := by intro v; apply Subtype.ext; rfl }
  5. The number of vertices in $R$ is equal to $|A|$. automation

    By `Set.toFinset_card`, the size of the vertex finset of $R$ equals the cardinality of its underlying subtype. The equivalence $e$ between the vertices of $R$ and $A$ implies by `Fintype.card_congr` that their cardinalities are equal, which `simpa` simplifies to $|V(R)| = |A|$.

    lines 26–29

    uses Set.toFinset_card, Fintype.card_congr

      have hcard : R.verts.toFinset.card = A.card := by
        rw [Set.toFinset_card]
        have he := Fintype.card_congr e
        simpa using he
  6. $|A|$ is both even and odd, which is a contradiction.

    Since $R$ is a matching, its vertex set has even cardinality. Because $|V(R)| = |A|$, $|A|$ is even. By `Nat.not_odd_iff_even.mpr`, an even number cannot be odd, contradicting the assumption that $|A|$ is odd.

    lines 30–32

    uses Nat.not_odd_iff_even.mpr

      have heven := hRmatch.even_card
      rw [hcard] at heven
      exact (Nat.not_odd_iff_even.mpr heven) hodd
False.elim
from a false hypothesis, any statement follows
Or.inl
if a proposition $p$ holds, then $p \lor q$ holds
Subtype.ext
two subtype elements are equal if their underlying values are equal
Set.toFinset_card
the cardinality of a set coerced to a finset equals the cardinality of the corresponding subtype
Fintype.card_congr
a bijection between two finite types implies they have the same cardinality
Nat.not_odd_iff_even.mpr
an even natural number is not odd

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 odd_anticomplete_union_has_no_perfect_matching : ∀ {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (A B : Finset V),    Disjoint A B → Odd A.card →    (∀ a ∈ A, ∀ b ∈ B, ¬ G.Adj a b) →    ¬ ∃ P : (G.induce {v | v ∈ A ∨ v ∈ B}).Subgraph, P.IsPerfectMatching := by  intro V instF instD G A B hAB hodd hcross  classical  rintro ⟨P, hP⟩  let C : Set {v : V // v ∈ A ∨ v ∈ B} := {v | v.val ∈ A}  let R := P.induce C  have hRmatch : R.IsMatching := by    intro a ha    have haA : a.val ∈ A := ha    obtain ⟨b, hab, huniq⟩ := hP.1 (hP.2 a)    have hbA : b.val ∈ A := by      rcases b.property with hbA | hbB      · exact hbA      · exact False.elim (hcross a.val haA b.val hbB (P.adj_sub hab))    refine ⟨b, ⟨haA, hbA, hab⟩, ?_⟩    intro c hc    exact huniq c hc.2.2  let e : R.verts ≃ {v : V // v ∈ A} := {    toFun := fun ⟨⟨v, hv⟩, ha⟩ => ⟨v, ha⟩    invFun := fun ⟨v, hv⟩ => ⟨⟨v, Or.inl hv⟩, hv⟩    left_inv := by intro v; apply Subtype.ext; apply Subtype.ext; rfl    right_inv := by intro v; apply Subtype.ext; rfl }  have hcard : R.verts.toFinset.card = A.card := by    rw [Set.toFinset_card]    have he := Fintype.card_congr e    simpa using he  have heven := hRmatch.even_card  rw [hcard] at heven  exact (Nat.not_odd_iff_even.mpr heven) hodd
See it in the graphDiscuss this resultChallenge it