AFTD Auto-Formalizing Theoretical Domains

extendible_matchable_two_k_vertices_complement_matchable

theoremverified

In a finite k-extendible graph, the complement of any matchable set of exactly 2k vertices is matchable.

Statement

theorem extendible_matchable_two_k_vertices_complement_matchable
    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (k : ℕ)
    (hG : is_k_extendable G k) (S : Set V)
    (hsize : S.ncard = 2 * k)
    (hS : ∃ M : (G.induce S).Subgraph, M.IsPerfectMatching) :
    ∃ P : (G.induce Sᶜ).Subgraph, P.IsPerfectMatching
Source
Matching-restriction ingredient for OP-1957 connected triple-twin cut.
Verified
20 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 35

The proof, explained

To show that the complement Sᶜ of a matchable 2k-vertex set S is matchable in a k-extendable graph G, we take a perfect matching on the induced subgraph G[S], which has size k by an auxiliary lemma relating the vertex and edge counts of any matching. By k-extendability, this matching extends to a perfect matching Q of the entire graph G. Because Q already covers S using only edges within S, Q cannot match any vertex of Sᶜ to a vertex of S; therefore, Q restricts to a perfect matching on the induced subgraph G[Sᶜ].

  1. For any edge e in a matching M, exactly two vertices of M are mapped to e by toEdge, namely the two endpoints of e.

    Representing an edge e in M as an unordered pair s(a, b) of adjacent vertices, the fiber of the matching map toEdge over e consists precisely of the two endpoints a and b. Since G is a simple graph, adjacent vertices are distinct (a ≠ b), so the fiber has cardinality 2.

    lines 4–30

    uses Sym2.ind, Subtype.ext, Fintype.card_congr, Equiv.setCongr, Set.toFinset_card

      classical
      have key : ∀ e : M.edgeSet, Fintype.card {v : M.verts // h.toEdge v = e} = 2 := by
        rintro ⟨x, hx⟩
        revert hx
        induction x using Sym2.ind with
        | _ a b =>
          intro hx
          have hab : M.Adj a b := SimpleGraph.Subgraph.mem_edgeSet.mp hx
          have h1 : (⟨s(a, b), hx⟩ : M.edgeSet) =
              ⟨s(a, b), SimpleGraph.Subgraph.mem_edgeSet.mpr hab⟩ := Subtype.ext rfl
          have hEq : h.toEdge ⁻¹' {⟨s(a, b), hx⟩} = {⟨a, hab.fst_mem⟩, ⟨b, hab.snd_mem⟩} := by
            rw [h1]
            exact h.toEdge_preimage_singleton hab
          have hset2 : {v : M.verts | h.toEdge v = (⟨s(a, b), hx⟩ : M.edgeSet)}
              = ({⟨a, hab.fst_mem⟩, ⟨b, hab.snd_mem⟩} : Set M.verts) := by
            ext v
            have hmem := Set.ext_iff.mp hEq v
            simpa only [Set.mem_preimage, Set.mem_singleton_iff, Set.mem_ofPred_eq,
              Set.mem_insert_iff] using hmem
          calc Fintype.card {v : M.verts // h.toEdge v = (⟨s(a, b), hx⟩ : M.edgeSet)}
              = Fintype.card ↥({⟨a, hab.fst_mem⟩, ⟨b, hab.snd_mem⟩} : Set M.verts) :=
                Fintype.card_congr (Equiv.setCongr hset2)
            _ = 2 := by
                rw [← Set.toFinset_card]
                have hne : (⟨a, hab.fst_mem⟩ : M.verts) ≠ ⟨b, hab.snd_mem⟩ := by
                  simp [G.ne_of_adj (M.adj_sub hab)]
                simp [hne]
  2. The finite type cardinality of M.verts is twice the finite type cardinality of M.edgeSet.

    Decomposing the vertex type M.verts into the disjoint union of fibers over M.edgeSet via Equiv.sigmaFiberEquiv, the total number of vertices is the sum of the fiber cardinalities. Since each of the |M.edgeSet| fibers has size 2, the sum evaluates to 2 * |M.edgeSet|.

    lines 31–37

    uses Fintype.card_sigma, Equiv.sigmaFiberEquiv, Nat.mul_comm

      have hsum : Fintype.card M.verts =
          ∑ e : M.edgeSet, Fintype.card {v : M.verts // h.toEdge v = e} := by
        rw [← Fintype.card_sigma]
        exact Fintype.card_congr (Equiv.sigmaFiberEquiv h.toEdge).symm
      have h1 : Fintype.card M.verts = 2 * Fintype.card M.edgeSet := by
        rw [hsum]
        simp [key, Nat.mul_comm]
  3. For any matching M in a finite graph, 2 * |M.edgeSet| = |M.verts| in terms of set cardinalities (ncard).

    Because the vertex and edge sets are finite, their set cardinalities (ncard) coincide with their Fintype cardinalities via Set.ncard_eq_toFinset_card and Set.toFinite_toFinset. Substituting these into the relation from the previous step yields 2 * M.edgeSet.ncard = M.verts.ncard.

    lines 38–44

    uses Set.ncard_eq_toFinset_card, Set.toFinite_toFinset, Set.toFinset_card

      have hv : M.verts.ncard = Fintype.card M.verts := by
        rw [Set.ncard_eq_toFinset_card M.verts, Set.toFinite_toFinset]
        exact Set.toFinset_card M.verts
      have he : M.edgeSet.ncard = Fintype.card M.edgeSet := by
        rw [Set.ncard_eq_toFinset_card M.edgeSet, Set.toFinite_toFinset]
        exact Set.toFinset_card M.edgeSet
      rw [hv, he, h1]
  4. We obtain a perfect matching on the induced subgraph G[S], and push it forward via the inclusion map into G to obtain a matching M on G whose vertex set is S.

    From the hypothesis hS, let P be a perfect matching on the induced subgraph G[S]. Pushing P forward along the canonical inclusion f : G[S] →g G yields a subgraph M = P.map f of G. Since f is injective, M is a matching in G. Furthermore, because P spans G[S], the vertex set of M is precisely S.

    lines 52–64

    uses Subtype.val_injective, SimpleGraph.Subgraph.map_verts

      classical
      obtain ⟨P, hP⟩ := hS
      let f : (G.induce S) →g G :=
        { toFun := Subtype.val, map_rel' := by intro a b h; simpa using h }
      let M : G.Subgraph := P.map f
      have hf : Function.Injective f := fun a b h => Subtype.val_injective h
      have hMmatch : M.IsMatching := hP.1.map f hf
      have hMverts : M.verts = S := by
        rw [SimpleGraph.Subgraph.map_verts]
        ext v
        constructor
        · rintro ⟨x, -, rfl⟩; exact x.property
        · intro hv; exact ⟨⟨v, hv⟩, hP.2 ⟨v, hv⟩, rfl⟩
  5. The matching M has exactly k edges. automation

    Applying the helper lemma in1076_matching_twice_card to M gives 2 * |M.edgeSet| = |M.verts|. Substituting M.verts = S and |S| = 2k gives 2 * |M.edgeSet| = 2k, from which linear arithmetic closes the goal |M.edgeSet| = k.

    lines 65–68

    uses in1076_matching_twice_card

      have hMcard : M.edgeSet.ncard = k := by
        have h := in1076_matching_twice_card hMmatch
        rw [hMverts, hsize] at h
        omega
  6. The matching M extends to a perfect matching Q on G, and any vertex in Sᶜ is matched by Q to another vertex in Sᶜ.

    Because G is k-extendable and M is a matching of size k, M extends to a perfect matching Q of G. If some vertex a ∈ Sᶜ were matched by Q to a vertex b ∈ S, then since M spans S, b would already be matched in M to some vertex c ∈ S. Since M ≤ Q and Q is a matching, the incident edge to b in Q is unique, forcing c = a. But this contradicts c ∈ S and a ∈ Sᶜ. Thus, every neighbor of a in Q also belongs to Sᶜ.

    lines 69–76

      obtain ⟨Q, hQ, hle⟩ := hG.2.2 M hMmatch hMcard
      have hmate {a b : V} (ha : a ∈ Sᶜ) (hab : Q.Adj a b) : b ∈ Sᶜ := by
        intro hb
        obtain ⟨c, hbc, -⟩ := hMmatch (v := b) (by rw [hMverts]; exact hb)
        have hQbc : Q.Adj b c := hle.2 hbc
        have hca : c = a := (hQ.1 (hQ.2 b)).unique hQbc hab.symm
        have hcS : c ∈ S := hMverts ▸ M.edge_vert hbc.symm
        exact ha (hca ▸ hcS)
  7. The pullback subgraph R of Q along the inclusion of G[Sᶜ] into G is a perfect matching of G[Sᶜ].

    We define R to be the pullback of Q under the inclusion g : G[Sᶜ] →g G. Since Q is a perfect matching of G and Q-edges incident to Sᶜ have both endpoints in Sᶜ, each vertex of G[Sᶜ] has a unique incident edge in R. Moreover, R spans G[Sᶜ] because Q spans G. Therefore, R is a perfect matching on G[Sᶜ].

    lines 77–91

    uses Subtype.ext

      let g : (G.induce Sᶜ) →g G :=
        { toFun := Subtype.val, map_rel' := by intro a b h; simpa using h }
      let R : (G.induce Sᶜ).Subgraph := Q.comap g
      refine ⟨R, ?_⟩
      constructor
      · intro a ha
        obtain ⟨b, hab, huniq⟩ := hQ.1 (hQ.2 a.val)
        let b' : {v : V // v ∈ Sᶜ} := ⟨b, hmate a.property hab⟩
        refine ⟨b', ?_, ?_⟩
        · exact ⟨Q.adj_sub hab, hab⟩
        · intro c hc
          apply Subtype.ext
          exact huniq c.val hc.2
      · intro a
        exact hQ.2 a.val
Sym2.ind
An induction principle for unordered pairs: any property that holds for all pairs s(x, y) holds for every element of Sym2.
Subtype.ext
Two elements of a subtype are equal if their underlying values are equal.
Fintype.card_congr
Equivalent types have the same finite cardinality.
Equiv.setCongr
Equal sets have canonically equivalent subtype types.
Set.toFinset_card
The cardinality of a set converted to a finset equals the finite type cardinality of the set as a subtype.
Fintype.card_sigma
The cardinality of a sigma type (disjoint union) is the sum of the cardinalities of the individual fibers.
Equiv.sigmaFiberEquiv
A domain type is canonically equivalent to the sigma type of its fibers over all elements of the codomain.
Nat.mul_comm
Multiplication of natural numbers is commutative.
Set.ncard_eq_toFinset_card
The set cardinality (ncard) of a finite set equals the cardinality of its finset representation.
Set.toFinite_toFinset
Connects the canonical finiteness proof of a set with a Fintype instance to its finset conversion.
Subtype.val_injective
The subtype embedding from a subtype to the ambient type is injective.
SimpleGraph.Subgraph.map_verts
The vertex set of the image subgraph under a graph homomorphism is the image of the original vertex set.
in1076_matching_twice_card
For any matching M in a subgraph of a finite graph, twice the number of edges of M equals the number of vertices of M.

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

lemma in1076_matching_twice_card    {V : Type*} [Fintype V] {G : SimpleGraph V} {M : G.Subgraph}    (h : M.IsMatching) : 2 * M.edgeSet.ncard = M.verts.ncard := by  classical  have key : ∀ e : M.edgeSet, Fintype.card {v : M.verts // h.toEdge v = e} = 2 := by    rintro ⟨x, hx⟩    revert hx    induction x using Sym2.ind with    | _ a b =>      intro hx      have hab : M.Adj a b := SimpleGraph.Subgraph.mem_edgeSet.mp hx      have h1 : (⟨s(a, b), hx⟩ : M.edgeSet) =          ⟨s(a, b), SimpleGraph.Subgraph.mem_edgeSet.mpr hab⟩ := Subtype.ext rfl      have hEq : h.toEdge ⁻¹' {⟨s(a, b), hx⟩} = {⟨a, hab.fst_mem⟩, ⟨b, hab.snd_mem⟩} := by        rw [h1]        exact h.toEdge_preimage_singleton hab      have hset2 : {v : M.verts | h.toEdge v = (⟨s(a, b), hx⟩ : M.edgeSet)}          = ({⟨a, hab.fst_mem⟩, ⟨b, hab.snd_mem⟩} : Set M.verts) := by        ext v        have hmem := Set.ext_iff.mp hEq v        simpa only [Set.mem_preimage, Set.mem_singleton_iff, Set.mem_ofPred_eq,          Set.mem_insert_iff] using hmem      calc Fintype.card {v : M.verts // h.toEdge v = (⟨s(a, b), hx⟩ : M.edgeSet)}          = Fintype.card ↥({⟨a, hab.fst_mem⟩, ⟨b, hab.snd_mem⟩} : Set M.verts) :=            Fintype.card_congr (Equiv.setCongr hset2)        _ = 2 := by            rw [← Set.toFinset_card]            have hne : (⟨a, hab.fst_mem⟩ : M.verts) ≠ ⟨b, hab.snd_mem⟩ := by              simp [G.ne_of_adj (M.adj_sub hab)]            simp [hne]  have hsum : Fintype.card M.verts =      ∑ e : M.edgeSet, Fintype.card {v : M.verts // h.toEdge v = e} := by    rw [← Fintype.card_sigma]    exact Fintype.card_congr (Equiv.sigmaFiberEquiv h.toEdge).symm  have h1 : Fintype.card M.verts = 2 * Fintype.card M.edgeSet := by    rw [hsum]    simp [key, Nat.mul_comm]  have hv : M.verts.ncard = Fintype.card M.verts := by    rw [Set.ncard_eq_toFinset_card M.verts, Set.toFinite_toFinset]    exact Set.toFinset_card M.verts  have he : M.edgeSet.ncard = Fintype.card M.edgeSet := by    rw [Set.ncard_eq_toFinset_card M.edgeSet, Set.toFinite_toFinset]    exact Set.toFinset_card M.edgeSet  rw [hv, he, h1]theorem extendible_matchable_two_k_vertices_complement_matchable    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (k : ℕ)    (hG : is_k_extendable G k) (S : Set V)    (hsize : S.ncard = 2 * k)    (hS : ∃ M : (G.induce S).Subgraph, M.IsPerfectMatching) :    ∃ P : (G.induce Sᶜ).Subgraph, P.IsPerfectMatching := by  classical  obtain ⟨P, hP⟩ := hS  let f : (G.induce S) →g G :=    { toFun := Subtype.val, map_rel' := by intro a b h; simpa using h }  let M : G.Subgraph := P.map f  have hf : Function.Injective f := fun a b h => Subtype.val_injective h  have hMmatch : M.IsMatching := hP.1.map f hf  have hMverts : M.verts = S := by    rw [SimpleGraph.Subgraph.map_verts]    ext v    constructor    · rintro ⟨x, -, rfl⟩; exact x.property    · intro hv; exact ⟨⟨v, hv⟩, hP.2 ⟨v, hv⟩, rfl⟩  have hMcard : M.edgeSet.ncard = k := by    have h := in1076_matching_twice_card hMmatch    rw [hMverts, hsize] at h    omega  obtain ⟨Q, hQ, hle⟩ := hG.2.2 M hMmatch hMcard  have hmate {a b : V} (ha : a ∈ Sᶜ) (hab : Q.Adj a b) : b ∈ Sᶜ := by    intro hb    obtain ⟨c, hbc, -⟩ := hMmatch (v := b) (by rw [hMverts]; exact hb)    have hQbc : Q.Adj b c := hle.2 hbc    have hca : c = a := (hQ.1 (hQ.2 b)).unique hQbc hab.symm    have hcS : c ∈ S := hMverts ▸ M.edge_vert hbc.symm    exact ha (hca ▸ hcS)  let g : (G.induce Sᶜ) →g G :=    { toFun := Subtype.val, map_rel' := by intro a b h; simpa using h }  let R : (G.induce Sᶜ).Subgraph := Q.comap g  refine ⟨R, ?_⟩  constructor  · intro a ha    obtain ⟨b, hab, huniq⟩ := hQ.1 (hQ.2 a.val)    let b' : {v : V // v ∈ Sᶜ} := ⟨b, hmate a.property hab⟩    refine ⟨b', ?_, ?_⟩    · exact ⟨Q.adj_sub hab, hab⟩    · intro c hc      apply Subtype.ext      exact huniq c.val hc.2  · intro a    exact hQ.2 a.val
See it in the graphDiscuss this resultChallenge it