AFTD Auto-Formalizing Theoretical Domains

perfect_matching_twins_switch_partner

theoremverified

Any matching edge incident to one of two distinct vertices with identical neighbors outside the pair can be avoided by another perfect matching, provided the edge does not join the pair.

Statement

theorem perfect_matching_twins_switch_partner {V : Type*} (G : SimpleGraph V)
    (P : G.Subgraph) (hP : P.IsPerfectMatching) (x y z : V)
    (hxy : x ≠ y) (hzy : z ≠ y)
    (htwin : ∀ a, a ≠ x → a ≠ y → (G.Adj x a ↔ G.Adj y a))
    (hxz : P.Adj x z) :
    ∃ Q : G.Subgraph, Q.IsPerfectMatching ∧ ¬ Q.Adj x z
Source
OP-1957: extension of the false-twin bridge route to adjacent and nonadjacent twins.
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 1

The proof, explained

The proof proceeds by contradiction. If no perfect matching avoids the edge xz, then xz must belong to every perfect matching of G (it is forced). Since x and y are twins outside {x, y}, the matching edges xz and yw together with graph edges zy and xw form an alternating 4-cycle x - z - y - w - x. However, switching edges along an alternating 4-cycle yields a valid perfect matching that avoids xz, contradicting the fact that xz is forced.

  1. The edge xz must belong to every perfect matching of G.

    We proceed by contradiction: suppose there is no perfect matching avoiding xz. Then any perfect matching Q must contain the edge xz, since otherwise Q would provide an immediate counterexample.

    lines 7–12

      classical
      by_contra hno
      have hforced : ∀ Q : G.Subgraph, Q.IsPerfectMatching → Q.Adj x z := by
        intro Q hQ
        by_contra hn
        exact hno ⟨Q,hQ,hn⟩
  2. There is a vertex w matched to y in P, with z ≠ x and w ≠ y.

    Because P is a perfect matching, every vertex has a unique matched neighbor in P; let w be the partner of y. Since xz and yw are edges in G, their endpoints are distinct, giving z ≠ x and w ≠ y.

    lines 13–17

    uses SimpleGraph.Subgraph.isPerfectMatching_iff.mp

      obtain ⟨w, hyw, _⟩ := (SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP) y
      have hxzG : G.Adj x z := P.adj_sub hxz
      have hywG : G.Adj y w := P.adj_sub hyw
      have hzx : z ≠ x := hxzG.ne.symm
      have hwy : w ≠ y := hywG.ne.symm
  3. w is distinct from x and from z.

    If w = x, then x would be matched in P to both z and y. Because a matching gives each vertex at most one partner, this would imply z = y, contradicting the assumption z ≠ y. Likewise, if w = z, then z would be matched to both x and y, implying x = y and contradicting x ≠ y.

    lines 18–27

      have hwx : w ≠ x := by
        intro h
        subst w
        have he : z = y := hP.1.eq_of_adj_left hxz hyw.symm
        exact hzy he
      have hwz : w ≠ z := by
        intro h
        subst w
        have he : x = y := hP.1.eq_of_adj_left hxz.symm hyw.symm
        exact hxy he
  4. The four vertices x, z, y, and w are pairwise distinct.

    Having established all six pairwise inequalities among x, z, y, and w, the map sending indices in {0, 1, 2, 3} to the vertices x, z, y, w is injective. In the proof, this is checked by exhausting all sixteen pairs of indices.

    lines 28–30

      have hinj : Function.Injective (![x,z,y,w] : Fin 4 → V) := by
        intro i j hij
        fin_cases i <;> fin_cases j <;> simp_all
  5. y is adjacent to z, and x is adjacent to w in G.

    By the twin hypothesis, x and y have identical neighbors outside {x, y}. Since z is distinct from both x and y, the edge xz in G implies that yz is an edge in G. Similarly, since w is distinct from both x and y, the edge yw in G implies that xw is an edge in G.

    lines 31–32

      have hyz : G.Adj y z := (htwin z hzx hzy).mp hxzG
      have hxw : G.Adj x w := (htwin w hwx hwy).mpr hywG
  6. Contradiction: the forced edge xz cannot belong to an alternating 4-cycle.

    The matching edges xz, yw in P and graph edges zy, xw in G form an alternating 4-cycle on the four distinct vertices x, z, y, w. By forced_matching_edge_blocks_four_and_six_switches, a forced matching edge cannot lie on an alternating 4-cycle, as swapping edges along the cycle would produce a perfect matching avoiding xz.

    lines 33–34

    uses forced_matching_edge_blocks_four_and_six_switches

      exact (forced_matching_edge_blocks_four_and_six_switches G P hP x z hxz hforced).1
        ⟨y,w,hinj,hyw,hyz.symm,hxw⟩
SimpleGraph.Subgraph.isPerfectMatching_iff.mp
A subgraph is a perfect matching if and only if every vertex has a unique neighbor in the subgraph; the forward implication provides a unique matched partner for any given vertex.
forced_matching_edge_blocks_four_and_six_switches
If an edge of a perfect matching is forced (it belongs to every perfect matching of the graph), then it cannot belong to an alternating cycle of length 4 or 6.

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_twins_switch_partner {V : Type*} (G : SimpleGraph V)    (P : G.Subgraph) (hP : P.IsPerfectMatching) (x y z : V)    (hxy : x ≠ y) (hzy : z ≠ y)    (htwin : ∀ a, a ≠ x → a ≠ y → (G.Adj x a ↔ G.Adj y a))    (hxz : P.Adj x z) :    ∃ Q : G.Subgraph, Q.IsPerfectMatching ∧ ¬ Q.Adj x z := by  classical  by_contra hno  have hforced : ∀ Q : G.Subgraph, Q.IsPerfectMatching → Q.Adj x z := by    intro Q hQ    by_contra hn    exact hno ⟨Q,hQ,hn⟩  obtain ⟨w, hyw, _⟩ := (SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP) y  have hxzG : G.Adj x z := P.adj_sub hxz  have hywG : G.Adj y w := P.adj_sub hyw  have hzx : z ≠ x := hxzG.ne.symm  have hwy : w ≠ y := hywG.ne.symm  have hwx : w ≠ x := by    intro h    subst w    have he : z = y := hP.1.eq_of_adj_left hxz hyw.symm    exact hzy he  have hwz : w ≠ z := by    intro h    subst w    have he : x = y := hP.1.eq_of_adj_left hxz.symm hyw.symm    exact hxy he  have hinj : Function.Injective (![x,z,y,w] : Fin 4 → V) := by    intro i j hij    fin_cases i <;> fin_cases j <;> simp_all  have hyz : G.Adj y z := (htwin z hzx hzy).mp hxzG  have hxw : G.Adj x w := (htwin w hwx hwy).mpr hywG  exact (forced_matching_edge_blocks_four_and_six_switches G P hP x z hxz hforced).1    ⟨y,w,hinj,hyw,hyz.symm,hxw⟩
See it in the graphDiscuss this resultChallenge it