perfect_matching_replace_finite_paired_vertices
Given a perfect matching P and a subgraph M of it, if a finite injective list of vertices is paired internally by P, avoids M, and admits a new graph-edge pairing represented by an involution, replacing the old list pairs by the new ones yields a perfect matching still containing M.
Statement
theorem perfect_matching_replace_finite_paired_vertices {V : Type*} (G : SimpleGraph V) (P M : G.Subgraph) (hP : P.IsPerfectMatching) (hMP : M ≤ P) (m : ℕ) (f : Fin m → V) (hf : Function.Injective f) (τ σ : Fin m → Fin m) (hτ : ∀ i, P.Adj (f i) (f (τ i))) (hσ : ∀ i, σ (σ i) = i) (hnew : ∀ i, G.Adj (f i) (f (σ i))) (hdisj : ∀ i, f i ∉ M.verts) : ∃ Q : G.Subgraph, Q.IsPerfectMatching ∧ M ≤ Q ∧ ∀ i, Q.Adj (f i) (f (σ i))
- Source
- OP-1957: reusable kernel-checked construction for four- and six-vertex alternating switches; adapt the finite-pairing construction in minimally_k_extendable_order_two_mul_add_six_min_degree_le.
- Verified
- 20 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 3
- minimally_k_extendable_high_degree_zero_codegree_complement_four_cycleIn a minimally k-extendable graph of minimum degree at least 2k+2, the complement neighborhoods of the endpoints of every zero-codegree…
- perfect_matching_false_twins_switch_partnerIf distinct vertices have identical open neighborhoods and a perfect matching contains an edge incident to one of them, another perfect…
- forced_matching_edge_blocks_four_and_six_switchesA forced matching edge blocks the specified four- and six-vertex switches.
The proof, explained
We construct a new subgraph Q on the full vertex set V by replacing the edges of P on the finite subset S = {f(0), ..., f(m-1)} with the new edges {f(i), f(σ(i))}, while retaining all edges of P that avoid S. Because P is a perfect matching that pairs S internally, no edge of P connects S to V \ S, so the remaining edges of P continue to perfectly match V \ S. The involution σ pairs the vertices of S among themselves along edges of G, making Q a perfect matching on all of V. Finally, since S is disjoint from the vertices of M ≤ P, all edges of M are preserved in Q, ensuring M ≤ Q.
Any vertex adjacent in P to an element of the image of f must also belong to the image of f.
From the definition of a perfect matching (via SimpleGraph.Subgraph.isPerfectMatching_iff.mp), every vertex in V has a unique neighbor in P, so no vertex can have two distinct mates. Since each f(i) is paired with f(τ(i)) in P, any P-neighbor of f(i) must be f(τ(i)), which shows that the image of f is closed under the matching edges of P.
uses
SimpleGraph.Subgraph.isPerfectMatching_iff.mpclassical have hP' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP have hmate : ∀ {a b c : V}, P.Adj a b → P.Adj a c → b = c := fun {a b c} h1 h2 => (hP' a).unique h1 h2 have hTclos : ∀ i (w : V), P.Adj (f i) w → w ∈ Set.range f := fun i w h => ⟨τ i, hmate (hτ i) h⟩
The candidate graph Q is a well-defined symmetric subgraph of G on all vertices, retaining the edges of P avoiding the image of f and adding the new pairs {f(i), f(σ(i))}.
We define Q with vertex set V (using Set.univ) and an edge relation specifying that an edge is either a P-edge with neither endpoint in the range of f, or a pair of the form {f(i), f(σ(i))}. We check the subgraph conditions: edges of the first kind are in G because P ≤ G, while edges of the second kind are in G by the hypothesis hnew. The endpoint condition is trivial since the vertex set is all of V (Set.mem_univ), and symmetry follows from the symmetry of P (using Or.inl) and the fact that σ is an involution (using Or.inr).
uses
Set.mem_univ,Or.inl,Or.inrrefine ⟨⟨Set.univ, fun x y => (P.Adj x y ∧ x ∉ Set.range f ∧ y ∉ Set.range f) ∨ ∃ i, x = f i ∧ y = f (σ i), ?_, ?_, ?_⟩, ?_, ?_, ?_⟩ · rintro x y (⟨h, -, -⟩ | ⟨i, rfl, rfl⟩) · exact P.adj_sub h · exact hnew i · intro x y _ exact Set.mem_univ x · refine ⟨fun x y hxy => ?_⟩ rcases hxy with ⟨h,hx,hy⟩ | ⟨i,rfl,rfl⟩ · exact Or.inl ⟨h.symm,hy,hx⟩ · exact Or.inr ⟨σ i,rfl,by rw [hσ i]⟩
Every vertex x in the image of f has a unique neighbor in Q, namely f(σ(i)) where x = f(i).
To show that Q is a perfect matching, SimpleGraph.Subgraph.isPerfectMatching_iff requires showing that every vertex has a unique mate in Q. For x = f(i), the pair (f(i), f(σ(i))) is an edge of Q by construction (Or.inr). Any neighbor w of f(i) in Q cannot come from the first clause of Q's edge definition because f(i) lies in the range of f. Thus w must arise from the second clause as f(σ(j)) with f(j) = f(i); by injectivity of f, j = i, which forces w = f(σ(i)).
uses
SimpleGraph.Subgraph.isPerfectMatching_iff,Or.inr· rw [SimpleGraph.Subgraph.isPerfectMatching_iff] intro x by_cases hx : x ∈ Set.range f · obtain ⟨i,rfl⟩ := hx refine ⟨f (σ i), Or.inr ⟨i,rfl,rfl⟩, ?_⟩ rintro w (⟨-,hx,-⟩ | ⟨j,hj,rfl⟩) · exact absurd ⟨i,rfl⟩ hx · rw [hf hj]
Every vertex x outside the image of f has a unique neighbor in Q, namely its mate in P, which completes the proof that Q is a perfect matching.
When x is not in the range of f, it has a unique neighbor w in P. This mate w cannot lie in the range of f, because if w = f(i), then x would be a P-neighbor of f(i) and therefore in the range of f by the closure property established earlier, a contradiction. Hence w is adjacent to x in Q via the first clause (Or.inl). Furthermore, any neighbor w' of x in Q cannot satisfy the second clause (as x is not in the range of f), so w' must be a P-neighbor of x, and by uniqueness of mates in P, w' = w.
uses
Or.inl· obtain ⟨w,hw,huniq⟩ := hP' x have hwT : w ∉ Set.range f := by rintro ⟨i,rfl⟩ exact hx (hTclos i x hw.symm) refine ⟨w, Or.inl ⟨hw,hx,hwT⟩, ?_⟩ rintro w' (⟨h',-,-⟩ | ⟨j,hj,-⟩) · exact huniq w' h' · exact absurd ⟨j,hj.symm⟩ hx
M is a subgraph of Q.
The vertex set of Q contains all vertices of M (Set.mem_univ). Any edge of M is also an edge of P since M ≤ P. Furthermore, neither endpoint of an edge of M can lie in the image of f, because the vertices of M are assumed disjoint from the image of f (hdisj). Thus, every edge of M satisfies the first clause of Q's adjacency relation (Or.inl), showing M ≤ Q.
uses
Set.mem_univ,Or.inl· refine ⟨fun x _ => Set.mem_univ x, fun x y h => Or.inl ⟨hMP.2 h, ?_, ?_⟩⟩ · rintro ⟨i,rfl⟩ exact hdisj i (M.edge_vert h) · rintro ⟨i,rfl⟩ exact hdisj i (M.edge_vert h.symm)
For each index i, the pair (f(i), f(σ(i))) is an edge of Q.
This holds immediately by taking i as the witness in the second clause of the definition of adjacency in Q (Or.inr).
uses
Or.inr· intro i exact Or.inr ⟨i,rfl,rfl⟩
SimpleGraph.Subgraph.isPerfectMatching_iff- A subgraph is a perfect matching if and only if every vertex of the ambient graph has a unique neighbor in that subgraph.
SimpleGraph.Subgraph.isPerfectMatching_iff.mp- If a subgraph is a perfect matching, then every vertex of the ambient graph has a unique neighbor in that subgraph.
Set.mem_univ- Every element of a type belongs to the universal set of that type.
Or.inl- A disjunction holds if its left disjunct holds.
Or.inr- A disjunction holds if its right disjunct holds.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
set_option maxHeartbeats 1000000set_option maxRecDepth 8192theorem perfect_matching_replace_finite_paired_vertices {V : Type*} (G : SimpleGraph V) (P M : G.Subgraph) (hP : P.IsPerfectMatching) (hMP : M ≤ P) (m : ℕ) (f : Fin m → V) (hf : Function.Injective f) (τ σ : Fin m → Fin m) (hτ : ∀ i, P.Adj (f i) (f (τ i))) (hσ : ∀ i, σ (σ i) = i) (hnew : ∀ i, G.Adj (f i) (f (σ i))) (hdisj : ∀ i, f i ∉ M.verts) : ∃ Q : G.Subgraph, Q.IsPerfectMatching ∧ M ≤ Q ∧ ∀ i, Q.Adj (f i) (f (σ i)) := by classical have hP' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP have hmate : ∀ {a b c : V}, P.Adj a b → P.Adj a c → b = c := fun {a b c} h1 h2 => (hP' a).unique h1 h2 have hTclos : ∀ i (w : V), P.Adj (f i) w → w ∈ Set.range f := fun i w h => ⟨τ i, hmate (hτ i) h⟩ refine ⟨⟨Set.univ, fun x y => (P.Adj x y ∧ x ∉ Set.range f ∧ y ∉ Set.range f) ∨ ∃ i, x = f i ∧ y = f (σ i), ?_, ?_, ?_⟩, ?_, ?_, ?_⟩ · rintro x y (⟨h, -, -⟩ | ⟨i, rfl, rfl⟩) · exact P.adj_sub h · exact hnew i · intro x y _ exact Set.mem_univ x · refine ⟨fun x y hxy => ?_⟩ rcases hxy with ⟨h,hx,hy⟩ | ⟨i,rfl,rfl⟩ · exact Or.inl ⟨h.symm,hy,hx⟩ · exact Or.inr ⟨σ i,rfl,by rw [hσ i]⟩ · rw [SimpleGraph.Subgraph.isPerfectMatching_iff] intro x by_cases hx : x ∈ Set.range f · obtain ⟨i,rfl⟩ := hx refine ⟨f (σ i), Or.inr ⟨i,rfl,rfl⟩, ?_⟩ rintro w (⟨-,hx,-⟩ | ⟨j,hj,rfl⟩) · exact absurd ⟨i,rfl⟩ hx · rw [hf hj] · obtain ⟨w,hw,huniq⟩ := hP' x have hwT : w ∉ Set.range f := by rintro ⟨i,rfl⟩ exact hx (hTclos i x hw.symm) refine ⟨w, Or.inl ⟨hw,hx,hwT⟩, ?_⟩ rintro w' (⟨h',-,-⟩ | ⟨j,hj,-⟩) · exact huniq w' h' · exact absurd ⟨j,hj.symm⟩ hx · refine ⟨fun x _ => Set.mem_univ x, fun x y h => Or.inl ⟨hMP.2 h, ?_, ?_⟩⟩ · rintro ⟨i,rfl⟩ exact hdisj i (M.edge_vert h) · rintro ⟨i,rfl⟩ exact hdisj i (M.edge_vert h.symm) · intro i exact Or.inr ⟨i,rfl,rfl⟩