disjoint_matchable_shores_have_matching_avoiding_cross_edge
If two disjoint vertex sets induce perfect matchings, then their union has a perfect matching avoiding every specified edge with one endpoint in each set.
Statement
theorem disjoint_matchable_shores_have_matching_avoiding_cross_edge {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (A B : Finset V) (hdisj : Disjoint A B) (u v : V) (hu : u ∈ A) (hv : v ∈ B) (hA : ∃ M : (G.induce {z | z ∈ A}).Subgraph, M.IsPerfectMatching) (hB : ∃ M : (G.induce {z | z ∈ B}).Subgraph, M.IsPerfectMatching) : ∃ M : (G.induce {z | z ∈ A ∪ B}).Subgraph, M.IsPerfectMatching ∧ ¬ M.Adj ⟨u, Finset.mem_union.mpr (Or.inl hu)⟩ ⟨v, Finset.mem_union.mpr (Or.inr hv)⟩
- Source
- Full-union disjoint-shore exclusion in the OP-1957 two-bridge campaign.
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext
The proof, explained
The proof constructs a candidate subgraph M on G[A ∪ B] as the disjoint union of the two given perfect matchings MA on G[A] and MB on G[B]. Because A and B are disjoint, every vertex in A ∪ B belongs to exactly one shore and therefore inherits a unique neighbor in M from MA or MB, with no possible edges crossing between A and B. Consequently, M is a perfect matching of G[A ∪ B]. Furthermore, since every edge in M has both endpoints strictly inside A or strictly inside B, M cannot contain any cross edge between A and B, in particular avoiding the specified edge between u ∈ A and v ∈ B.
Unpack the assumed perfect matchings MA on G[A] and MB on G[B].
By decomposing the existential hypotheses hA and hB, we obtain the subgraphs MA and MB along with the certificates that each is a matching and spans its respective induced subgraph.
rcases hA with ⟨MA, hMA_mat, hMA_sp⟩ rcases hB with ⟨MB, hMB_mat, hMB_sp⟩
Construct a subgraph M on G[A ∪ B] as the disjoint union of MA and MB.
We define M to contain all vertices of G[A ∪ B] and declare two vertices adjacent in M if they are both in A and adjacent in MA, or both in B and adjacent in MB. The obligations that M is a valid subgraph (its edges exist in G[A ∪ B], its edges connect valid vertices, and adjacency is symmetric) follow immediately from the corresponding properties of MA and MB.
uses
Set.mem_univ,Or.inl,Or.inrlet M : (G.induce {z | z ∈ A ∪ B}).Subgraph := { verts := Set.univ Adj := fun x y => (∃ (hx : x.1 ∈ A) (hy : y.1 ∈ A), MA.Adj ⟨x.1, hx⟩ ⟨y.1, hy⟩) ∨ (∃ (hx : x.1 ∈ B) (hy : y.1 ∈ B), MB.Adj ⟨x.1, hx⟩ ⟨y.1, hy⟩) adj_sub := by rintro x y (⟨hx, hy, h⟩ | ⟨hx, hy, h⟩) · exact MA.adj_sub h · exact MB.adj_sub h edge_vert := fun _ => Set.mem_univ _ symm := ⟨by rintro x y (⟨hx, hy, h⟩ | ⟨hx, hy, h⟩) · exact Or.inl ⟨hy, hx, MA.adj_symm h⟩ · exact Or.inr ⟨hy, hx, MB.adj_symm h⟩⟩ }
It suffices to show that M is a matching, is spanning, and avoids the cross edge between u and v.
We supply M as the existential witness and split the goal into the three components of the conjunction: M is a matching, M is spanning (together making it a perfect matching), and M does not contain the specified cross edge.
use M refine ⟨⟨?_, ?_⟩, ?_⟩
Every vertex x ∈ A has a unique neighbor in M.
Since MA is spanning on G[A], x is a vertex of MA, so it has a unique neighbor wA ∈ A in MA. Promoting wA to a vertex w ∈ A ∪ B, x and w are adjacent in M. Conversely, if y ∈ A ∪ B is adjacent to x in M, the edge cannot originate from MB because x ∈ A and A is disjoint from B; therefore the edge is in MA, and by uniqueness of neighbors in MA, y must equal w.
uses
Finset.mem_union.mp,Finset.mem_union_left,Subtype.ext,congrArg,Subtype.val,Finset.disjoint_left.mp,False.elim· intro x _ rcases Finset.mem_union.mp x.2 with hxA | hxB · have hx_sp : (⟨x.1, hxA⟩ : ↑{z | z ∈ A}) ∈ MA.verts := hMA_sp ⟨x.1, hxA⟩ rcases hMA_mat hx_sp with ⟨wA, hwA_adj, hwA_uniq⟩ have hw_mem : wA.1 ∈ A ∪ B := Finset.mem_union_left B wA.2 let w : ↑{z | z ∈ A ∪ B} := ⟨wA.1, hw_mem⟩ use w dsimp [ExistsUnique] refine ⟨?_, ?_⟩ · left refine ⟨hxA, wA.2, ?_⟩ have : (⟨w.1, wA.2⟩ : ↑{z | z ∈ A}) = wA := Subtype.ext rfl rw [this] exact hwA_adj · intro y hy rcases hy with ⟨hx', hy', hadj⟩ | ⟨hx', hy', hadj⟩ · have h_eq : (⟨x.1, hx'⟩ : ↑{z | z ∈ A}) = ⟨x.1, hxA⟩ := Subtype.ext rfl rw [h_eq] at hadj have hy_eq := hwA_uniq ⟨y.1, hy'⟩ hadj apply Subtype.ext change y.1 = w.1 have : (⟨y.1, hy'⟩ : ↑{z | z ∈ A}).1 = wA.1 := congrArg Subtype.val hy_eq exact this · have := Finset.disjoint_left.mp hdisj hxA exact False.elim (this hx')
Every vertex x ∈ B has a unique neighbor in M.
Symmetrically, since MB is spanning on G[B], x is a vertex of MB, giving a unique neighbor wB ∈ B in MB. Promoting wB to w ∈ A ∪ B, x and w are adjacent in M. If y ∈ A ∪ B is adjacent to x in M, the edge cannot come from MA because x ∈ B and A is disjoint from B; hence it comes from MB, and uniqueness in MB implies y = w.
uses
Finset.mem_union_right,Finset.disjoint_right.mp,False.elim,Subtype.ext,congrArg,Subtype.val· have hx_sp : (⟨x.1, hxB⟩ : ↑{z | z ∈ B}) ∈ MB.verts := hMB_sp ⟨x.1, hxB⟩ rcases hMB_mat hx_sp with ⟨wB, hwB_adj, hwB_uniq⟩ have hw_mem : wB.1 ∈ A ∪ B := Finset.mem_union_right A wB.2 let w : ↑{z | z ∈ A ∪ B} := ⟨wB.1, hw_mem⟩ use w dsimp [ExistsUnique] refine ⟨?_, ?_⟩ · right refine ⟨hxB, wB.2, ?_⟩ have : (⟨w.1, wB.2⟩ : ↑{z | z ∈ B}) = wB := Subtype.ext rfl rw [this] exact hwB_adj · intro y hy rcases hy with ⟨hx', hy', hadj⟩ | ⟨hx', hy', hadj⟩ · have := Finset.disjoint_right.mp hdisj hxB exact False.elim (this hx') · have h_eq : (⟨x.1, hx'⟩ : ↑{z | z ∈ B}) = ⟨x.1, hxB⟩ := Subtype.ext rfl rw [h_eq] at hadj have hy_eq := hwB_uniq ⟨y.1, hy'⟩ hadj apply Subtype.ext change y.1 = w.1 have : (⟨y.1, hy'⟩ : ↑{z | z ∈ B}).1 = wB.1 := congrArg Subtype.val hy_eq exact this
M is a spanning subgraph of G[A ∪ B].
By definition, the vertex set of M is Set.univ, meaning that every vertex of G[A ∪ B] belongs to M.
uses
Set.mem_univ· intro x exact Set.mem_univ x
M does not contain the edge between u and v.
Suppose for contradiction that u and v were adjacent in M. By definition of M, both endpoints would have to lie in A or both in B. But u ∈ A and v ∈ B, so both endpoints in A contradicts v ∉ A (since A and B are disjoint), while both in B contradicts u ∉ B.
uses
Finset.disjoint_left.mp,Finset.disjoint_right.mp· rintro (⟨hu', hv', hadj⟩ | ⟨hu', hv', hadj⟩) · have := Finset.disjoint_left.mp hdisj hv' exact this hv · have := Finset.disjoint_right.mp hdisj hu' exact this hu
Finset.mem_union_left- An element of a finite set also belongs to the union of that set with another finite set.
Finset.mem_union_right- An element of a finite set also belongs to the union of another finite set with that set.
Finset.mem_union.mp- If an element belongs to the union of two finite sets, it belongs to the first or to the second.
Finset.disjoint_left.mp- If two finite sets are disjoint, an element of the first set cannot belong to the second set.
Finset.disjoint_right.mp- If two finite sets are disjoint, an element of the second set cannot belong to the first set.
Set.mem_univ- Every element of a type belongs to the universal set Set.univ on that type.
Or.inl- From a proof of a proposition P, infer the disjunction P ∨ Q.
Or.inr- From a proof of a proposition Q, infer the disjunction P ∨ Q.
Subtype.ext- Two terms of a subtype are equal whenever their underlying values are equal.
Subtype.val- The projection extracting the underlying value from a subtype term.
congrArg- Functions yield equal outputs when evaluated on equal inputs.
False.elim- From a false premise or contradiction, any conclusion can be deduced (ex falso quodlibet).
- Because the induced subgraphs are formalized via subtypes, the proof repeatedly converts vertices between the union subtype {z // z ∈ A ∪ B} and the shore subtypes {z // z ∈ A} and {z // z ∈ B} using Subtype.ext and congrArg.
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.
theorem disjoint_matchable_shores_have_matching_avoiding_cross_edge {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (A B : Finset V) (hdisj : Disjoint A B) (u v : V) (hu : u ∈ A) (hv : v ∈ B) (hA : ∃ M : (G.induce {z | z ∈ A}).Subgraph, M.IsPerfectMatching) (hB : ∃ M : (G.induce {z | z ∈ B}).Subgraph, M.IsPerfectMatching) : ∃ M : (G.induce {z | z ∈ A ∪ B}).Subgraph, M.IsPerfectMatching ∧ ¬ M.Adj ⟨u, Finset.mem_union.mpr (Or.inl hu)⟩ ⟨v, Finset.mem_union.mpr (Or.inr hv)⟩ := by rcases hA with ⟨MA, hMA_mat, hMA_sp⟩ rcases hB with ⟨MB, hMB_mat, hMB_sp⟩ let M : (G.induce {z | z ∈ A ∪ B}).Subgraph := { verts := Set.univ Adj := fun x y => (∃ (hx : x.1 ∈ A) (hy : y.1 ∈ A), MA.Adj ⟨x.1, hx⟩ ⟨y.1, hy⟩) ∨ (∃ (hx : x.1 ∈ B) (hy : y.1 ∈ B), MB.Adj ⟨x.1, hx⟩ ⟨y.1, hy⟩) adj_sub := by rintro x y (⟨hx, hy, h⟩ | ⟨hx, hy, h⟩) · exact MA.adj_sub h · exact MB.adj_sub h edge_vert := fun _ => Set.mem_univ _ symm := ⟨by rintro x y (⟨hx, hy, h⟩ | ⟨hx, hy, h⟩) · exact Or.inl ⟨hy, hx, MA.adj_symm h⟩ · exact Or.inr ⟨hy, hx, MB.adj_symm h⟩⟩ } use M refine ⟨⟨?_, ?_⟩, ?_⟩ · intro x _ rcases Finset.mem_union.mp x.2 with hxA | hxB · have hx_sp : (⟨x.1, hxA⟩ : ↑{z | z ∈ A}) ∈ MA.verts := hMA_sp ⟨x.1, hxA⟩ rcases hMA_mat hx_sp with ⟨wA, hwA_adj, hwA_uniq⟩ have hw_mem : wA.1 ∈ A ∪ B := Finset.mem_union_left B wA.2 let w : ↑{z | z ∈ A ∪ B} := ⟨wA.1, hw_mem⟩ use w dsimp [ExistsUnique] refine ⟨?_, ?_⟩ · left refine ⟨hxA, wA.2, ?_⟩ have : (⟨w.1, wA.2⟩ : ↑{z | z ∈ A}) = wA := Subtype.ext rfl rw [this] exact hwA_adj · intro y hy rcases hy with ⟨hx', hy', hadj⟩ | ⟨hx', hy', hadj⟩ · have h_eq : (⟨x.1, hx'⟩ : ↑{z | z ∈ A}) = ⟨x.1, hxA⟩ := Subtype.ext rfl rw [h_eq] at hadj have hy_eq := hwA_uniq ⟨y.1, hy'⟩ hadj apply Subtype.ext change y.1 = w.1 have : (⟨y.1, hy'⟩ : ↑{z | z ∈ A}).1 = wA.1 := congrArg Subtype.val hy_eq exact this · have := Finset.disjoint_left.mp hdisj hxA exact False.elim (this hx') · have hx_sp : (⟨x.1, hxB⟩ : ↑{z | z ∈ B}) ∈ MB.verts := hMB_sp ⟨x.1, hxB⟩ rcases hMB_mat hx_sp with ⟨wB, hwB_adj, hwB_uniq⟩ have hw_mem : wB.1 ∈ A ∪ B := Finset.mem_union_right A wB.2 let w : ↑{z | z ∈ A ∪ B} := ⟨wB.1, hw_mem⟩ use w dsimp [ExistsUnique] refine ⟨?_, ?_⟩ · right refine ⟨hxB, wB.2, ?_⟩ have : (⟨w.1, wB.2⟩ : ↑{z | z ∈ B}) = wB := Subtype.ext rfl rw [this] exact hwB_adj · intro y hy rcases hy with ⟨hx', hy', hadj⟩ | ⟨hx', hy', hadj⟩ · have := Finset.disjoint_right.mp hdisj hxB exact False.elim (this hx') · have h_eq : (⟨x.1, hx'⟩ : ↑{z | z ∈ B}) = ⟨x.1, hxB⟩ := Subtype.ext rfl rw [h_eq] at hadj have hy_eq := hwB_uniq ⟨y.1, hy'⟩ hadj apply Subtype.ext change y.1 = w.1 have : (⟨y.1, hy'⟩ : ↑{z | z ∈ B}).1 = wB.1 := congrArg Subtype.val hy_eq exact this · intro x exact Set.mem_univ x · rintro (⟨hu', hv', hadj⟩ | ⟨hu', hv', hadj⟩) · have := Finset.disjoint_left.mp hdisj hv' exact this hv · have := Finset.disjoint_right.mp hdisj hu' exact this hu