AFTD Auto-Formalizing Theoretical Domains

perfect_matching_induced_edges_form_matching

theoremverified

The edges of a perfect matching internal to a given vertex set form a matching supported on that set.

Statement

theorem perfect_matching_induced_edges_form_matching
    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
    (P : G.Subgraph) (hP : P.IsPerfectMatching) (S : Finset V) :
    ∃ Q : G.Subgraph, Q.IsMatching ∧ Q.verts ⊆ (S : Set V) ∧
      Q ≤ P ∧ Q.edgeSet = (P.induce (S : Set V)).edgeSet
Source
Balanced-cut matching symmetry 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 2

The proof, explained

Since P is a perfect matching, every vertex v has a unique neighbor f(v) in P. The desired subgraph Q is explicitly constructed with edges being those of P having both endpoints in S, and vertex set consisting of those v ∈ S whose partner f(v) also belongs to S. Because each vertex in Q can only be adjacent to its unique partner in P, Q is a matching supported on S. By construction, the edges of Q are precisely the edges of P with both endpoints in S, matching the edge set of the induced subgraph P[S].

  1. Define the partner map f : V → V sending each vertex to its unique neighbor in P, and show that each v is adjacent to f(v) in P.

    Because P is a perfect matching, it is both spanning (every vertex v ∈ V is in P) and a matching (every vertex in P has a unique neighbor in P). By classical choice, we define f(v) to be this unique neighbor, which satisfies P.Adj v (f v) by construction.

    lines 6–11

      set_option maxHeartbeats 4000000 in
        classical
        let f : V → V := fun v => (hP.1 (hP.2 v)).choose
        have hf : ∀ v, P.Adj v (f v) := by
          intro v
          exact (hP.1 (hP.2 v)).choose_spec.1
  2. The matching function f is an involution: f(f(v)) = v for every vertex v.

    By symmetry of adjacency in P, the relation P.Adj v (f v) implies P.Adj (f v) v. Since f(v) has a unique neighbor in P, which is f(f(v)) by definition, it follows that f(f(v)) = v.

    lines 12–14

        have hinv : Function.Involutive f := by
          intro v
          exact (hP.1 (hP.2 (f v))).unique (hf (f v)) (hf v).symm
  3. Construct the candidate subgraph Q with vertices {v ∈ S | f(v) ∈ S} and edges P.Adj u v for u, v ∈ S, and verify that it forms a valid subgraph of G.

    We define Q by setting its vertex set to {v ∈ S | f(v) ∈ S} and its adjacency relation to P.Adj u v ∧ u ∈ S ∧ v ∈ S. To show Q is a well-defined subgraph of G, we verify: (1) any edge in Q is an edge in G because P is a subgraph of G; (2) if u and v are adjacent in Q, then u, v ∈ S and u is adjacent to v in P, so by uniqueness of neighbors in P we have f(u) = v ∈ S, meaning u ∈ Q.verts; and (3) adjacency in Q is symmetric.

    lines 15–23

        let Q : G.Subgraph := {
          verts := {v | v ∈ S ∧ f v ∈ S}
          Adj := fun u v => P.Adj u v ∧ u ∈ S ∧ v ∈ S
          adj_sub := by intro u v h; exact P.adj_sub h.1
          edge_vert := by
            intro u v h
            have hfv : f u = v := (hP.1 (hP.2 u)).unique (hf u) h.1
            exact ⟨h.2.1,hfv ▸ h.2.2⟩
          symm := ⟨by intro u v h; exact ⟨h.1.symm,h.2.2,h.2.1⟩⟩ }
  4. Q is a matching: every vertex in Q has a unique neighbor in Q.

    For any v ∈ Q.verts, both v ∈ S and f(v) ∈ S, so f(v) is a neighbor of v in Q, establishing existence. If w is any neighbor of v in Q, then w is also a neighbor of v in P, so w = f(v) by the uniqueness of the neighbor of v in P.

    lines 24–28

        have hQ : Q.IsMatching := by
          intro v hv
          refine ⟨f v,⟨hf v,hv.1,hv.2⟩,?_⟩
          intro w hw
          exact (hP.1 (hP.2 v)).unique hw.1 (hf v)
  5. The edge set of Q equals the edge set of the induced subgraph P[S]. automation

    By extensionality and induction on unordered pairs e = s(u, v), an edge belongs to Q if and only if P.Adj u v ∧ u ∈ S ∧ v ∈ S. By the definition of induced subgraphs, this is precisely the condition for s(u, v) to belong to the edge set of P.induce S. The simplification tactic closes the equivalence by rewriting the definitions of edgeSet membership and induced adjacency, and reordering the conjunctions.

    lines 29–34

    uses Sym2.inductionOn, SimpleGraph.Subgraph.mem_edgeSet, SimpleGraph.Subgraph.induce_adj, and_comm, and_left_comm, and_assoc

        have hedge : Q.edgeSet = (P.induce (S : Set V)).edgeSet := by
          ext e
          induction e using Sym2.inductionOn with
          | _ u v =>
            simp [Q,SimpleGraph.Subgraph.mem_edgeSet,SimpleGraph.Subgraph.induce_adj,
              and_comm,and_left_comm,and_assoc]
  6. The vertex set of Q is contained in S.

    By definition, every vertex v ∈ Q.verts satisfies v ∈ S ∧ f(v) ∈ S, so in particular v ∈ S.

    line 35

        have hsub : Q.verts ⊆ (S : Set V) := by intro v hv; exact hv.1
  7. Q is a subgraph of P (Q ≤ P).

    For vertices, every v ∈ Q.verts belongs to P.verts because P is spanning. For edges, any adjacent pair in Q is adjacent in P by definition of Q's adjacency.

    lines 36–41

        have hle : Q ≤ P := by
          constructor
          · intro v hv
            exact hP.2 v
          · intro u v h
            exact h.1
  8. There exists a matching Q ≤ P supported on S whose edge set is that of P[S].

    We assemble the witness Q together with the four verified properties: Q is a matching, its vertices are contained in S, Q ≤ P, and its edge set equals that of P.induce S.

    line 42

        exact ⟨Q,hQ,hsub,hle,hedge⟩
Sym2.inductionOn
To prove a property for all unordered pairs in Sym²(V), it suffices to prove it for all pairs of the form s(x, y).
SimpleGraph.Subgraph.mem_edgeSet
An unordered pair s(v, w) belongs to the edge set of a subgraph if and only if v and w are adjacent in that subgraph.
SimpleGraph.Subgraph.induce_adj
Two vertices u and v are adjacent in the induced subgraph G'[s] if and only if u ∈ s, v ∈ s, and u and v are adjacent in G'.
and_comm
Conjunction is commutative: a ∧ b ↔ b ∧ a.
and_left_comm
Conjunction is left-commutative: a ∧ (b ∧ c) ↔ b ∧ (a ∧ c).
and_assoc
Conjunction is associative: (a ∧ b) ∧ c ↔ a ∧ (b ∧ c).

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 perfect_matching_induced_edges_form_matching    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)    (P : G.Subgraph) (hP : P.IsPerfectMatching) (S : Finset V) :    ∃ Q : G.Subgraph, Q.IsMatching ∧ Q.verts ⊆ (S : Set V) ∧      Q ≤ P ∧ Q.edgeSet = (P.induce (S : Set V)).edgeSet := by  set_option maxHeartbeats 4000000 in    classical    let f : V → V := fun v => (hP.1 (hP.2 v)).choose    have hf : ∀ v, P.Adj v (f v) := by      intro v      exact (hP.1 (hP.2 v)).choose_spec.1    have hinv : Function.Involutive f := by      intro v      exact (hP.1 (hP.2 (f v))).unique (hf (f v)) (hf v).symm    let Q : G.Subgraph := {      verts := {v | v ∈ S ∧ f v ∈ S}      Adj := fun u v => P.Adj u v ∧ u ∈ S ∧ v ∈ S      adj_sub := by intro u v h; exact P.adj_sub h.1      edge_vert := by        intro u v h        have hfv : f u = v := (hP.1 (hP.2 u)).unique (hf u) h.1        exact ⟨h.2.1,hfv ▸ h.2.2⟩      symm := ⟨by intro u v h; exact ⟨h.1.symm,h.2.2,h.2.1⟩⟩ }    have hQ : Q.IsMatching := by      intro v hv      refine ⟨f v,⟨hf v,hv.1,hv.2⟩,?_⟩      intro w hw      exact (hP.1 (hP.2 v)).unique hw.1 (hf v)    have hedge : Q.edgeSet = (P.induce (S : Set V)).edgeSet := by      ext e      induction e using Sym2.inductionOn with      | _ u v =>        simp [Q,SimpleGraph.Subgraph.mem_edgeSet,SimpleGraph.Subgraph.induce_adj,          and_comm,and_left_comm,and_assoc]    have hsub : Q.verts ⊆ (S : Set V) := by intro v hv; exact hv.1    have hle : Q ≤ P := by      constructor      · intro v hv        exact hP.2 v      · intro u v h        exact h.1    exact ⟨Q,hQ,hsub,hle,hedge⟩
See it in the graphDiscuss this resultChallenge it