AFTD Auto-Formalizing Theoretical Domains

minimally_k_extendable_degree_surplus_zero_codegree_complete_bipartite

theoremverified

In a minimally k-extendable graph of minimum degree at least 2k+r, r at least two, every graph edge whose endpoints have no common complement neighbor has a complete bipartite complement graph with r vertices in each endpoint neighborhood.

Statement

theorem minimally_k_extendable_degree_surplus_zero_codegree_complete_bipartite
    (k n r : ℕ) (hr : 2 ≤ r) (G : SimpleGraph (Fin n)) [DecidableRel G.Adj]
    (hmin : is_minimally_k_extendable G k) (hdegree : 2*k+r ≤ G.minDegree)
    (u v : Fin n) (huv : G.Adj u v)
    (hfar2 : ∀ x, ¬ ((Gᶜ).Adj u x ∧ (Gᶜ).Adj v x)) :
    ∃ A B : Finset (Fin n), A.card = r ∧ B.card = r ∧
      (∀ a ∈ A, (Gᶜ).Adj u a) ∧ (∀ b ∈ B, (Gᶜ).Adj v b) ∧
      ∀ a ∈ A, ∀ b ∈ B, (Gᶜ).Adj a b
Source
OP-1957: the general matching bridge obstruction supplies complete bipartite complement subgraphs; experiment 34644.
Verified
20 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 5
Used by 1

The proof, explained

Because $G$ is minimally $k$-extendable, deleting the edge $uv$ destroys $k$-extendability, so $G - uv$ contains a $k$-matching $M$ that cannot be extended to any perfect matching of $G - uv$. However, $M$ extends to a perfect matching $P$ of $G$, which must therefore use the edge $uv$, forcing both $u$ and $v$ to lie outside the vertex set of $M$. In the residual graph $G_r = G \setminus V(M)$, the edge $uv$ is in a perfect matching, but $G_r - uv$ has no perfect matching; since the minimum degree in $G_r$ is at least $r$ and $u, v$ have no common non-neighbors, a forced-matching bridge lemma implies that $u$ cannot reach $v$ in $G_r - uv$. Choosing $B$ as a set of $r$ vertices reachable from $u$ in $G_r - uv$ and $A$ as a set of $r$ vertices not reachable from $u$ yields a complete bipartite complement subgraph between $A$ and $B$, with $A \subseteq N_{G^c}(u)$ and $B \subseteq N_{G^c}(v)$.

  1. Any perfect matching in $G$ extending a subgraph $M$ of $G - uv$ that does not use $uv$ yields a perfect matching of $G - uv$ extending $M$.

    If a perfect matching $Q$ in $G$ does not contain the edge $uv$, then every edge of $Q$ avoids $uv$ and therefore remains an edge in the edge-deleted subgraph $G - uv$. Restricting $Q$ to $G - uv$ gives a valid perfect matching in $G - uv$ that still extends $M$.

    lines 6–16

    uses SimpleGraph.deleteEdges_adj, Set.mem_singleton_iff, Sym2.eq_iff

      have hsub : ∀ {x y : V}, Q.Adj x y → (G.deleteEdges {s(u,v)}).Adj x y := by
        intro x y h
        rw [SimpleGraph.deleteEdges_adj]
        refine ⟨Q.adj_sub h, ?_⟩
        intro he
        simp only [Set.mem_singleton_iff, Sym2.eq_iff] at he
        rcases he with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩
        · exact hno h
        · exact hno h.symm
      refine ⟨⟨Q.verts, Q.Adj, hsub, Q.edge_vert, Q.symm⟩, ⟨fun x hx => hQ.1 hx, fun x => hQ.2 x⟩, ?_⟩
      exact ⟨hMQv, fun {x y} h => hMQ x y h⟩
  2. The vertices of any $k$-edge matching $M$ are contained in a subset $S$ of vertices with $|S| \le 2k$.

    Let $S$ be the union of the endpoint pairs of all edges in $M$. Every vertex of $M$ is an endpoint of some edge and thus belongs to $S$. Since each edge has at most 2 endpoints, the cardinality of the union is bounded by $2 \times |E(M)| = 2k$.

    lines 22–36

    uses Finset.mem_biUnion, Finset.card_biUnion_le_card_mul, Sym2.card_toFinset, Set.ncard_eq_toFinset_card

      classical
      refine ⟨(M.edgeSet.toFinite.toFinset).biUnion (fun e => e.toFinset), ?_, ?_⟩
      · intro x hx
        obtain ⟨w, hw, -⟩ := hM hx
        rw [Finset.mem_biUnion]
        exact ⟨s(x, w), by simpa using hw, by simp⟩
      · have h1 : ((M.edgeSet.toFinite.toFinset).biUnion (fun e => e.toFinset)).card ≤
            (M.edgeSet.toFinite.toFinset).card * 2 := by
          apply Finset.card_biUnion_le_card_mul
          intro e _
          rw [Sym2.card_toFinset]
          split_ifs <;> omega
        have h2 : (M.edgeSet.toFinite.toFinset).card = k := by
          rw [← Set.ncard_eq_toFinset_card M.edgeSet M.edgeSet.toFinite, hMk]
        omega
  3. We unpack the definition of minimal $k$-extendability for $G$ and establish basic adjacency facts for $G - uv$.

    Minimal $k$-extendability provides that $|V(G)| \ge 2k+2$, that $G$ possesses a $k$-matching, that every $k$-matching extends to a perfect matching, and that deleting any edge from $G$ destroys $k$-extendability. Since $u$ and $v$ are adjacent, $u \ne v$. We also record the characterization of edges in $G - uv$.

    lines 46–54

    uses SimpleGraph.deleteEdges_adj, Sym2.eq_iff

      classical
      obtain ⟨⟨hcard, ⟨M0, hM0, hM0k⟩, hext⟩, hminimal⟩ := hmin
      have hG' : ∀ x y : Fin n, (G.deleteEdges {s(u, v)}).Adj x y ↔ G.Adj x y ∧ s(x, y) ≠ s(u, v) := by
        intro x y
        simp [SimpleGraph.deleteEdges_adj]
      have hsym : ∀ x y : Fin n, s(x, y) = s(u, v) → (x = u ∧ y = v) ∨ (x = v ∧ y = u) := by
        intro x y h
        simpa [Sym2.eq_iff] using h
      have huvne : u ≠ v := huv.ne
  4. Assuming a given $k$-matching $M_0$ of $G$ contains the edge $uv$, we construct a replacement subgraph $M_1$ that avoids $uv$.

    We split into cases on whether $M_0$ contains $uv$. If it does, $M_0$ extends to a perfect matching $P_0$ of $G$. The vertices of $M_0$ are contained in a set $S_0$ of size at most $2k$, so since the total number of vertices is at least $2k+2$, there is a vertex $w \notin S_0$. The vertex $w'$ matched to $w$ in $P_0$ must also lie outside $M_0$. We define $M_1$ by replacing the edge $uv$ in $M_0$ with the disjoint edge $ww'$ from $P_0$, ensuring all edges of $M_1$ avoid $uv$.

    lines 55–116

    uses SimpleGraph.Subgraph.isPerfectMatching_iff, in1068_verts_bound, Finset.eq_univ_iff_forall, Finset.card_univ, Sym2.eq_swap

      -- (b) a k-matching of G - uv
      have hb : ∃ M : (G.deleteEdges {s(u, v)}).Subgraph, M.IsMatching ∧ M.edgeSet.ncard = k := by
        have hM0u : ∀ {x y y' : Fin n}, M0.Adj x y → M0.Adj x y' → y = y' := by
          intro x y y' h h'
          exact (hM0 (M0.edge_vert h)).unique h h'
        by_cases hM0uv : M0.Adj u v
        · obtain ⟨P0, hP0, hM0P0⟩ := hext M0 hM0 hM0k
          have hP0' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP0
          obtain ⟨S0, hS0, hS0c⟩ := in1068_verts_bound M0 hM0 hM0k
          obtain ⟨w, hw⟩ : ∃ w : Fin n, w ∉ S0 := by
            by_contra hall
            simp only [not_exists, not_not] at hall
            have h1 : S0 = Finset.univ := Finset.eq_univ_iff_forall.mpr hall
            rw [h1, Finset.card_univ] at hS0c
            omega
          have hwM : w ∉ M0.verts := fun h => hw (hS0 w h)
          obtain ⟨w', hww', -⟩ := hP0' w
          have hw'M : w' ∉ M0.verts := by
            intro h
            obtain ⟨c, hc, -⟩ := hM0 h
            have : c = w := (hP0' w').unique (hM0P0.2 hc) hww'.symm
            exact hwM (this ▸ M0.edge_vert hc.symm)
          have hwne : w ≠ w' := (P0.adj_sub hww').ne
          have huM : u ∈ M0.verts := M0.edge_vert hM0uv
          have hvM : v ∈ M0.verts := M0.edge_vert hM0uv.symm
          have hwu : w ≠ u := fun h => hwM (h ▸ huM)
          have hwv : w ≠ v := fun h => hwM (h ▸ hvM)
          -- an M0-edge other than uv avoids u and v
          have hoff : ∀ {x y : Fin n}, M0.Adj x y → s(x, y) ≠ s(u, v) → x ≠ u ∧ x ≠ v := by
            intro x y hxy hne
            constructor
            · rintro rfl
              exact hne (by rw [hM0u hxy hM0uv])
            · rintro rfl
              exact hne (by rw [hM0u hxy hM0uv.symm]; exact Sym2.eq_swap)
          let M1 : (G.deleteEdges {s(u, v)}).Subgraph :=
            { verts := (M0.verts \ {u, v}) ∪ {w, w'}
              Adj := fun x y => (M0.Adj x y ∧ s(x, y) ≠ s(u, v)) ∨ (x = w ∧ y = w') ∨ (x = w' ∧ y = w)
              adj_sub := by
                rintro x y (⟨h, hne⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
                · exact (hG' x y).mpr ⟨M0.adj_sub h, hne⟩
                · refine (hG' _ _).mpr ⟨P0.adj_sub hww', fun he => ?_⟩
                  rcases hsym _ _ he with ⟨h1, -⟩ | ⟨h1, -⟩
                  · exact hwu h1
                  · exact hwv h1
                · refine (hG' _ _).mpr ⟨P0.adj_sub hww'.symm, fun he => ?_⟩
                  rcases hsym _ _ he with ⟨-, h1⟩ | ⟨-, h1⟩
                  · exact hwv h1
                  · exact hwu h1
              edge_vert := by
                rintro x y (⟨h, hne⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
                · obtain ⟨h1, h2⟩ := hoff h hne
                  exact Or.inl ⟨M0.edge_vert h, by simp [h1, h2]⟩
                · exact Or.inr (by simp)
                · exact Or.inr (by simp)
              symm := by
                refine ⟨?_⟩
                rintro x y (⟨h, hne⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
                · exact Or.inl ⟨h.symm, by rwa [Sym2.eq_swap]⟩
                · exact Or.inr (Or.inr ⟨rfl, rfl⟩)
                · exact Or.inr (Or.inl ⟨rfl, rfl⟩) }
          refine ⟨M1, ?_, ?_⟩
  5. $G - uv$ contains a matching of size $k$.

    We verify that $M_1$ from the previous step is a valid matching in $G - uv$ and has size $(k - 1) + 1 = k$ by disjoint union. In the remaining case where $M_0$ does not contain $uv$, $M_0$ itself is already a $k$-matching in $G - uv$.

    lines 117–167

    uses Sym2.ind, Set.disjoint_singleton_right, Set.ncard_union_eq, Set.ncard_sdiff_singleton_of_mem, Set.ncard_singleton, Set.ncard_pos, Eq.trans, congrArg, Iff.rfl

          · intro x hx
            rcases hx with ⟨hx0, hxuv⟩ | hxw
            · simp only [Set.mem_insert_iff, Set.mem_singleton_iff, not_or] at hxuv
              obtain ⟨y, hy, -⟩ := hM0 hx0
              have hne : s(x, y) ≠ s(u, v) := by
                intro he
                rcases hsym _ _ he with ⟨h1, -⟩ | ⟨h1, -⟩
                · exact hxuv.1 h1
                · exact hxuv.2 h1
              refine ⟨y, Or.inl ⟨hy, hne⟩, ?_⟩
              rintro y' (⟨h', -⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
              · exact hM0u h' hy
              · exact absurd hx0 hwM
              · exact absurd hx0 hw'M
            · simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxw
              rcases hxw with rfl | rfl
              · refine ⟨w', Or.inr (Or.inl ⟨rfl, rfl⟩), ?_⟩
                rintro y' (⟨h', -⟩ | ⟨-, rfl⟩ | ⟨h1, -⟩)
                · exact absurd (M0.edge_vert h') hwM
                · rfl
                · exact absurd h1 hwne
              · refine ⟨w, Or.inr (Or.inr ⟨rfl, rfl⟩), ?_⟩
                rintro y' (⟨h', -⟩ | ⟨h1, -⟩ | ⟨-, rfl⟩)
                · exact absurd (M0.edge_vert h') hw'M
                · exact absurd h1.symm hwne
                · rfl
          · have hE : M1.edgeSet = (M0.edgeSet \ {s(u, v)}) ∪ {s(w, w')} := by
              ext e
              induction e using Sym2.ind with
              | h x y =>
                simp only [SimpleGraph.Subgraph.mem_edgeSet, Set.mem_union, Set.mem_sdiff,
                  Set.mem_singleton_iff]
                show ((M0.Adj x y ∧ s(x, y) ≠ s(u, v)) ∨ (x = w ∧ y = w') ∨ (x = w' ∧ y = w)) ↔ _
                simp only [Sym2.eq_iff, ne_eq]
            have hdisj : Disjoint (M0.edgeSet \ {s(u, v)}) {s(w, w')} := by
              rw [Set.disjoint_singleton_right]
              rintro ⟨h, -⟩
              exact hwM (M0.edge_vert h)
            have hmem : s(u, v) ∈ M0.edgeSet := hM0uv
            rw [hE, Set.ncard_union_eq hdisj (Set.toFinite _) (Set.toFinite _),
              Set.ncard_sdiff_singleton_of_mem hmem, Set.ncard_singleton, hM0k]
            have hpos : 0 < M0.edgeSet.ncard := Set.ncard_pos (Set.toFinite _) |>.mpr ⟨_, hmem⟩
            omega
        · refine ⟨⟨M0.verts, M0.Adj, fun {x y} h => (hG' x y).mpr ⟨M0.adj_sub h, fun he => ?_⟩,
            M0.edge_vert, M0.symm⟩, fun x hx => hM0 hx, ?_⟩
          · rcases hsym _ _ he with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩
            · exact hM0uv h
            · exact hM0uv h.symm
          · refine Eq.trans (congrArg Set.ncard ?_) hM0k
            ext e; induction e using Sym2.ind; exact Iff.rfl
      -- a non-extendable k-matching of G - uv
  6. There exists a $k$-matching $M$ in $G - uv$ that does not extend to any perfect matching of $G - uv$.

    By the minimality of $G$, the edge-deleted subgraph $G - uv$ is not $k$-extendable. Because $G - uv$ has at least $2k+2$ vertices and has a $k$-matching, the failure of $k$-extendability means that some $k$-matching $M$ of $G - uv$ cannot be extended to any perfect matching of $G - uv$.

    lines 168–174

      have hnot := hminimal s(u, v) (by simpa using huv)
      obtain ⟨M, hM, hMk, hMno⟩ : ∃ M : (G.deleteEdges {s(u, v)}).Subgraph, M.IsMatching ∧
          M.edgeSet.ncard = k ∧ ¬ ∃ P : (G.deleteEdges {s(u, v)}).Subgraph, P.IsPerfectMatching ∧ M ≤ P := by
        by_contra hcon
        push Not at hcon
        exact hnot ⟨hcard, hb, fun M hM hk => hcon M hM hk⟩
      have hup : ∀ {x y : Fin n}, M.Adj x y → G.Adj x y := fun h => ((hG' _ _).mp (M.adj_sub h)).1
  7. Viewing $M$ as a $k$-matching in $G$, it extends to a perfect matching $P$ of $G$, and $P$ must contain the edge $uv$.

    Since $G$ is $k$-extendable, $M$ extends to a perfect matching $P$ in $G$. If $P$ did not use the edge $uv$, then by in1068_transport it would be a perfect matching of $G - uv$ extending $M$, which would contradict the non-extendability of $M$. Hence $uv$ must be an edge of $P$.

    lines 175–184

    uses Eq.trans, congrArg, Sym2.ind, Iff.rfl, SimpleGraph.Subgraph.isPerfectMatching_iff, in1068_transport

      let MG : G.Subgraph := ⟨M.verts, M.Adj, hup, M.edge_vert, M.symm⟩
      have hMG : MG.IsMatching := fun x hx => hM hx
      have hMGk : MG.edgeSet.ncard = k :=
        Eq.trans (congrArg Set.ncard (by ext e; induction e using Sym2.ind; exact Iff.rfl)) hMk
      obtain ⟨P, hP, hMP⟩ := hext MG hMG hMGk
      have hP' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP
      have hMPadj : ∀ {x y : Fin n}, M.Adj x y → P.Adj x y := fun h => hMP.2 h
      have hPuv : P.Adj u v := by
        by_contra h
        exact hMno (in1068_transport G u v M P hP hMP.1 (fun x y hxy => hMPadj hxy) h)
  8. Neither $u$ nor $v$ is a vertex of $M$, and every edge of $P$ with one endpoint outside $M$ has both endpoints outside $M$.

    If $u$ were in $M$, its incident edge in $M$ would also belong to $P$. But $u$ is matched to $v$ in $P$, so uniqueness of matching edges forces that incident edge to be $uv$, which cannot belong to $M$ as $M$ lives in $G - uv$. The same holds for $v$. Furthermore, if an edge of $P$ had one endpoint outside $M$ and one in $M$, matching uniqueness would force the outside endpoint into $M$, a contradiction.

    lines 185–202

    uses Sym2.eq_swap

      have hnotin : ∀ x, (x = u ∨ x = v) → x ∉ M.verts := by
        intro x hx hxM
        obtain ⟨y, hy, -⟩ := hM hxM
        have hPy := hMPadj hy
        rcases hx with rfl | rfl
        · have : y = v := (hP' x).unique hPy hPuv
          subst this
          exact ((hG' _ _).mp (M.adj_sub hy)).2 rfl
        · have : y = u := (hP' x).unique hPy hPuv.symm
          subst this
          exact ((hG' _ _).mp (M.adj_sub hy)).2 Sym2.eq_swap
      have huR : u ∉ M.verts := hnotin u (Or.inl rfl)
      have hvR : v ∉ M.verts := hnotin v (Or.inr rfl)
      have hcl : ∀ a b, P.Adj a b → a ∉ M.verts → b ∉ M.verts := by
        intro a b hab ha hbM
        obtain ⟨c, hc, -⟩ := hM hbM
        have : c = a := (hP' b).unique (hMPadj hc) hab.symm
        exact ha (this ▸ M.edge_vert hc.symm)
  9. Every vertex of $G$ has at least $r$ neighbors outside the vertex set of $M$.

    The vertices of $M$ are contained in a set $S_f$ of size at most $2k$ by in1068_verts_bound. Because the minimum degree of $G$ is at least $2k + r$, subtracting $S_f$ leaves at least $(2k + r) - 2k = r$ neighbors outside $S_f$, and hence outside $V(M)$.

    lines 203–212

    uses in1068_verts_bound, SimpleGraph.card_neighborFinset_eq_degree, le_trans, Finset.le_card_sdiff

      obtain ⟨Sf, hSf, hSfc⟩ := in1068_verts_bound MG hMG hMGk
      -- many neighbours outside M
      have hbig : ∀ x : Fin n, r ≤ (G.neighborFinset x \ Sf).card := by
        intro x
        have h1 : 2 * k + r ≤ (G.neighborFinset x).card := by
          rw [SimpleGraph.card_neighborFinset_eq_degree]
          exact le_trans hdegree (G.minDegree_le_degree x)
        have := Finset.le_card_sdiff Sf (G.neighborFinset x)
        omega
      have hout : ∀ y, y ∉ Sf → y ∉ M.verts := fun y hy hyM => hy (hSf y hyM)
  10. The residual graph $G_r = G \setminus V(M)$ has minimum degree at least $r$, and contains a perfect matching $P_r$ containing the edge $uv$.

    In the induced subgraph $G_r$ on vertices outside $M$, each vertex retains at least $r$ neighbors from $G \setminus S_f$. Restricting $P$ to $G_r$ yields a perfect matching $P_r$ because edges of $P$ outside $M$ have both endpoints outside $M$, and $P_r$ contains $uv$ since $u, v \notin V(M)$.

    lines 213–253

    uses SimpleGraph.deleteEdges_adj, Set.mem_singleton_iff, Sym2.eq_iff, SimpleGraph.card_neighborFinset_eq_degree, Finset.mem_sdiff, SimpleGraph.mem_neighborFinset, Finset.mem_map, le_trans, Finset.card_le_card, Finset.card_map, SimpleGraph.Subgraph.isPerfectMatching_iff, Subtype.ext

      -- the residual graph
      let s : Set (Fin n) := {x | x ∉ M.verts}
      let Gr : SimpleGraph s := G.induce s
      have hGr : ∀ x y : s, Gr.Adj x y ↔ G.Adj x.1 y.1 := fun x y => Iff.rfl
      let uW : s := ⟨u, huR⟩
      let vW : s := ⟨v, hvR⟩
      let Gd := Gr.deleteEdges {s(uW, vW)}
      have hGd : ∀ x y : s, G.Adj x.1 y.1 → ¬ ((x.1 = u ∧ y.1 = v) ∨ (x.1 = v ∧ y.1 = u)) → Gd.Adj x y := by
        intro x y hxy hne
        rw [SimpleGraph.deleteEdges_adj]
        refine ⟨hxy, ?_⟩
        intro he
        simp only [Set.mem_singleton_iff, Sym2.eq_iff] at he
        apply hne
        rcases he with ⟨h1, h2⟩ | ⟨h1, h2⟩
        · exact Or.inl ⟨congrArg Subtype.val h1, congrArg Subtype.val h2⟩
        · exact Or.inr ⟨congrArg Subtype.val h1, congrArg Subtype.val h2⟩
      have hGdsub : ∀ x y : s, Gd.Adj x y → G.Adj x.1 y.1 := fun x y h => (SimpleGraph.deleteEdges_adj.mp h).1
      -- hypotheses of the forced-edge lemma on Gr
      have hdegGr : ∀ x : s, r ≤ Gr.degree x := by
        intro x
        rw [← SimpleGraph.card_neighborFinset_eq_degree]
        have hsub : G.neighborFinset x.1 \ Sf ⊆ (Gr.neighborFinset x).map ⟨Subtype.val, Subtype.val_injective⟩ := by
          intro y hy
          rw [Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hy
          rw [Finset.mem_map]
          exact ⟨⟨y, hout y hy.2⟩, by rw [SimpleGraph.mem_neighborFinset]; exact hy.1, rfl⟩
        have := le_trans (hbig x.1) (Finset.card_le_card hsub)
        rwa [Finset.card_map] at this
      have hPGr : ∃ Pr : Gr.Subgraph, Pr.IsPerfectMatching ∧ Pr.Adj uW vW := by
        let Pr : Gr.Subgraph :=
          { verts := Set.univ
            Adj := fun x y => P.Adj x.1 y.1
            adj_sub := fun {x y} h => P.adj_sub h
            edge_vert := fun _ => Set.mem_univ _
            symm := ⟨fun x y h => h.symm⟩ }
        refine ⟨Pr, ?_, hPuv⟩
        rw [SimpleGraph.Subgraph.isPerfectMatching_iff]
        intro x
        obtain ⟨p, hp, hpu⟩ := hP' x.1
        refine ⟨⟨p, hcl x.1 p hp x.2⟩, hp, fun y hy => Subtype.ext (hpu y.1 hy)⟩
  11. The deleted residual graph $G_d = G_r - uv$ has no perfect matching.

    If $G_d$ had a perfect matching $Q$, the disjoint union of $Q$ and $M$ would be a perfect matching of $G - uv$ extending $M$, which is impossible.

    lines 254–290

    uses SimpleGraph.Subgraph.isPerfectMatching_iff, SimpleGraph.deleteEdges_adj, Set.mem_singleton_iff, Sym2.eq_iff, Subtype.ext

      have hforcedGr : ¬ ∃ Q : Gd.Subgraph, Q.IsPerfectMatching := by
        rintro ⟨Q, hQ⟩
        have hQ' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hQ
        apply hMno
        let Q' : (G.deleteEdges {s(u, v)}).Subgraph :=
          { verts := Set.univ
            Adj := fun x y => M.Adj x y ∨ ∃ hx : x ∉ M.verts, ∃ hy : y ∉ M.verts, Q.Adj ⟨x, hx⟩ ⟨y, hy⟩
            adj_sub := by
              rintro x y (h | ⟨hx, hy, h⟩)
              · exact M.adj_sub h
              · have h1 := Q.adj_sub h
                rw [SimpleGraph.deleteEdges_adj] at h1
                refine (hG' x y).mpr ⟨h1.1, fun he => h1.2 ?_⟩
                rw [Set.mem_singleton_iff, Sym2.eq_iff]
                rcases hsym _ _ he with ⟨h2, h3⟩ | ⟨h2, h3⟩
                · exact Or.inl ⟨Subtype.ext h2, Subtype.ext h3⟩
                · exact Or.inr ⟨Subtype.ext h2, Subtype.ext h3⟩
            edge_vert := fun _ => Set.mem_univ _
            symm := by
              refine ⟨?_⟩
              rintro x y (h | ⟨hx, hy, h⟩)
              · exact Or.inl h.symm
              · exact Or.inr ⟨hy, hx, h.symm⟩ }
        refine ⟨Q', ?_, ⟨fun _ _ => Set.mem_univ _, fun {x y} h => Or.inl h⟩⟩
        rw [SimpleGraph.Subgraph.isPerfectMatching_iff]
        intro x
        by_cases hxM : x ∈ M.verts
        · obtain ⟨y, hy, hyu⟩ := hM hxM
          refine ⟨y, Or.inl hy, ?_⟩
          rintro y' (h | ⟨hx, -, -⟩)
          · exact hyu y' h
          · exact absurd hxM hx
        · obtain ⟨y, hy, hyu⟩ := hQ' ⟨x, hxM⟩
          refine ⟨y.1, Or.inr ⟨hxM, y.2, hy⟩, ?_⟩
          rintro y' (h | ⟨hx', hy', h⟩)
          · exact absurd (M.edge_vert h) hxM
          · exact congrArg Subtype.val (hyu ⟨y', hy'⟩ h)
  12. In $G_d = G_r - uv$, $u$ cannot reach $v$.

    By assumption, $u$ and $v$ have no common non-neighbors in $G$, so their common non-neighbor count in $G_r$ is 0, which is strictly less than $r$. In $G_r$, the minimum degree is at least $r$, the edge $uv$ is in a perfect matching, and $G_r - uv$ has no perfect matching. Applying the forced-matching bridge lemma (forced_matching_edge_common_nonneighbors_below_min_degree_is_bridge) shows that $u$ cannot reach $v$ in $G_d$.

    lines 291–304

    uses Set.mem_setOf_eq, iff_false, SimpleGraph.compl_adj, Subtype.ext, Set.ncard_empty, forced_matching_edge_common_nonneighbors_below_min_degree_is_bridge

      have hcoGr : ({w | (Grᶜ).Adj uW w ∧ (Grᶜ).Adj vW w} : Set s).ncard < r := by
        have hempty : ({w | (Grᶜ).Adj uW w ∧ (Grᶜ).Adj vW w} : Set s) = ∅ := by
          ext w
          simp only [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false]
          rintro ⟨h1, h2⟩
          rw [SimpleGraph.compl_adj] at h1 h2
          apply hfar2 w.1
          refine ⟨(SimpleGraph.compl_adj G u w.1).2 ⟨fun h => h1.1 (Subtype.ext h), h1.2⟩,
            (SimpleGraph.compl_adj G v w.1).2 ⟨fun h => h2.1 (Subtype.ext h), h2.2⟩⟩
        rw [hempty, Set.ncard_empty]
        omega
      have key := forced_matching_edge_common_nonneighbors_below_min_degree_is_bridge Gr r hdegGr uW vW
        huv hPGr hforcedGr hcoGr
      -- the two sides
  13. We define $B_s$ as the vertices outside $M$ (other than $u$) reachable from $u$ in $G_d$, and $A_s$ as those (other than $v$) not reachable from $u$.

    Because $u$ cannot reach $v$ in $G_d$, any vertex reachable from $u$ cannot be $v$. Reachability is also preserved when stepping along edges of $G$ avoiding $uv$. We define $B_s = \{x \notin V(M) \mid x \ne u \text{ and } x \text{ is reachable from } u \text{ in } G_d\}$ and $A_s = \{x \notin V(M) \mid x \ne v \text{ and } x \text{ is not reachable from } u \text{ in } G_d\}$.

    lines 305–323

    uses Subtype.ext, SimpleGraph.Adj.reachable

      have hreachv : ∀ y : s, Gd.Reachable uW y → y.1 ≠ v := by
        intro y hy hyv
        apply key
        have : y = vW := Subtype.ext hyv
        rwa [this] at hy
      have hedge : ∀ x y : s, Gd.Reachable uW x → G.Adj x.1 y.1 → x.1 ≠ u ∨ y.1 ≠ v →
          x.1 ≠ v ∨ y.1 ≠ u → Gd.Reachable uW y := by
        intro x y hx hxy h1 h2
        refine hx.trans (SimpleGraph.Adj.reachable (hGd x y hxy ?_))
        rintro (⟨a, b⟩ | ⟨a, b⟩)
        · rcases h1 with h | h
          · exact h a
          · exact h b
        · rcases h2 with h | h
          · exact h a
          · exact h b
      let Bs : Finset (Fin n) := Finset.univ.filter (fun x => ∃ h : x ∉ M.verts, Gd.Reachable uW ⟨x, h⟩ ∧ x ≠ u)
      let As : Finset (Fin n) := Finset.univ.filter (fun x => ∃ h : x ∉ M.verts, ¬ Gd.Reachable uW ⟨x, h⟩ ∧ x ≠ v)
      -- properties
  14. No vertex in $B_s$ is adjacent to $v$, no vertex in $A_s$ is adjacent to $u$, and no vertex in $A_s$ is adjacent to any vertex in $B_s$.

    If $b \in B_s$ were adjacent to $v$, the edge $bv$ in $G_d$ would make $v$ reachable from $u$, a contradiction. If $a \in A_s$ were adjacent to $u$, the edge $ua$ in $G_d$ would make $a$ reachable from $u$, a contradiction. If $a \in A_s$ and $b \in B_s$ were adjacent, the edge $ba$ in $G_d$ would make $a$ reachable from $u$ via $b$, a contradiction. Hence $A_s$ and $B_s$ are mutually non-adjacent in $G$, and form non-adjacent neighborhoods to $u$ and $v$ respectively.

    lines 324–351

    uses SimpleGraph.compl_adj, SimpleGraph.Reachable.refl

      have hBprop : ∀ b ∈ Bs, (Gᶜ).Adj v b := by
        intro b hb
        simp only [Bs, Finset.mem_filter, Finset.mem_univ, true_and] at hb
        obtain ⟨hbM, hbr, hbu⟩ := hb
        have hbv := hreachv _ hbr
        refine (SimpleGraph.compl_adj G v b).2 ⟨fun h => hbv h.symm, fun hvb => ?_⟩
        apply key
        have := hedge ⟨b, hbM⟩ vW hbr hvb.symm (Or.inl hbu) (Or.inl hbv)
        exact this
      have hAprop : ∀ a ∈ As, (Gᶜ).Adj u a := by
        intro a ha
        simp only [As, Finset.mem_filter, Finset.mem_univ, true_and] at ha
        obtain ⟨haM, har, hav⟩ := ha
        have hau : a ≠ u := by
          rintro rfl
          exact har (SimpleGraph.Reachable.refl _)
        refine (SimpleGraph.compl_adj G u a).2 ⟨fun h => hau h.symm, fun hua => ?_⟩
        exact har (hedge uW ⟨a, haM⟩ (SimpleGraph.Reachable.refl _) hua (Or.inr hav) (Or.inr hau))
      have hABprop : ∀ a ∈ As, ∀ b ∈ Bs, (Gᶜ).Adj a b := by
        intro a ha b hb
        simp only [As, Bs, Finset.mem_filter, Finset.mem_univ, true_and] at ha hb
        obtain ⟨haM, har, hav⟩ := ha
        obtain ⟨hbM, hbr, hbu⟩ := hb
        have hab : a ≠ b := by
          rintro rfl
          exact har hbr
        refine (SimpleGraph.compl_adj G a b).2 ⟨hab, fun hadj => ?_⟩
        exact har (hedge ⟨b, hbM⟩ ⟨a, haM⟩ hbr hadj.symm (Or.inl hbu) (Or.inl (hreachv _ hbr)))
  15. $|B_s| \ge r$.

    Since $u$ has at least $r \ge 2$ neighbors outside $S_f$, there is a neighbor $y \ne v$ of $u$ outside $S_f$. The edge $uy$ makes $y$ reachable from $u$ in $G_d$, so $y \in B_s$. Moreover, every neighbor $z$ of $y$ outside $S_f$ (other than $u$) is also reachable from $u$ via $y$, so $\{y\} \cup (N(y) \setminus S_f \setminus \{u\}) \subseteq B_s$. Since $y$ has at least $r$ neighbors outside $S_f$, this set contains at least $r$ vertices.

    lines 352–385

    uses Finset.card_pos, Finset.card_erase_le, Finset.pred_card_le_card_erase, Finset.mem_erase, Finset.mem_sdiff, SimpleGraph.mem_neighborFinset, SimpleGraph.Reachable.refl, Finset.card_le_card, Finset.card_insert_of_notMem, Finset.card_insert_le

      -- sizes
      have hBcard : r ≤ Bs.card := by
        obtain ⟨y, hy⟩ : ∃ y, y ∈ (G.neighborFinset u \ Sf).erase v := by
          apply Finset.card_pos.mp
          have := hbig u
          have := Finset.card_erase_le (s := G.neighborFinset u \ Sf) (a := v)
          have h2 := Finset.pred_card_le_card_erase (s := G.neighborFinset u \ Sf) (a := v)
          omega
        rw [Finset.mem_erase, Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hy
        obtain ⟨hyv, huy, hyS⟩ := hy
        have hyM := hout y hyS
        have hyr : Gd.Reachable uW ⟨y, hyM⟩ :=
          hedge uW ⟨y, hyM⟩ (SimpleGraph.Reachable.refl _) huy (Or.inr hyv) (Or.inr (fun h => huy.ne h.symm))
        have hyu : y ≠ u := fun h => huy.ne h.symm
        have hsub : insert y (G.neighborFinset y \ Sf) ⊆ insert u Bs := by
          intro z hz
          rw [Finset.mem_insert] at hz ⊢
          rcases hz with rfl | hz
          · right
            simp only [Bs, Finset.mem_filter, Finset.mem_univ, true_and]
            exact ⟨hyM, hyr, hyu⟩
          · rw [Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hz
            by_cases hzu : z = u
            · exact Or.inl hzu
            · right
              simp only [Bs, Finset.mem_filter, Finset.mem_univ, true_and]
              have hzM := hout z hz.2
              refine ⟨hzM, hedge ⟨y, hyM⟩ ⟨z, hzM⟩ hyr hz.1 (Or.inl hyu) (Or.inr hzu), hzu⟩
        have h1 := Finset.card_le_card hsub
        have hyn : y ∉ G.neighborFinset y \ Sf := by simp
        rw [Finset.card_insert_of_notMem hyn] at h1
        have h2 := Finset.card_insert_le u Bs
        have := hbig y
        omega
  16. $|A_s| \ge r$.

    Symmetrically, $v$ has a neighbor $y \ne u$ outside $S_f$. Vertex $y$ cannot be reachable from $u$ in $G_d$ (otherwise $v$ would be reachable via $yv$), so $y \in A_s$. Furthermore, no neighbor $z$ of $y$ outside $S_f$ (other than $v$) can be reachable from $u$ (otherwise $y$ would be reachable via $zy$), so $\{y\} \cup (N(y) \setminus S_f \setminus \{v\}) \subseteq A_s$, giving $|A_s| \ge r$.

    lines 386–424

    uses Finset.card_pos, Finset.pred_card_le_card_erase, Finset.mem_erase, Finset.mem_sdiff, SimpleGraph.mem_neighborFinset, Finset.card_le_card, Finset.card_insert_of_notMem, Finset.card_insert_le

      have hAcard : r ≤ As.card := by
        obtain ⟨y, hy⟩ : ∃ y, y ∈ (G.neighborFinset v \ Sf).erase u := by
          apply Finset.card_pos.mp
          have := hbig v
          have h2 := Finset.pred_card_le_card_erase (s := G.neighborFinset v \ Sf) (a := u)
          omega
        rw [Finset.mem_erase, Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hy
        obtain ⟨hyu, hvy, hyS⟩ := hy
        have hyM := hout y hyS
        have hyv : y ≠ v := fun h => hvy.ne h.symm
        -- y is not reachable: otherwise v would be
        have hyr : ¬ Gd.Reachable uW ⟨y, hyM⟩ := by
          intro h
          apply key
          exact hedge ⟨y, hyM⟩ vW h hvy.symm (Or.inl hyu) (Or.inl hyv)
        have hsub : insert y (G.neighborFinset y \ Sf) ⊆ insert v As := by
          intro z hz
          rw [Finset.mem_insert] at hz ⊢
          rcases hz with rfl | hz
          · right
            simp only [As, Finset.mem_filter, Finset.mem_univ, true_and]
            exact ⟨hyM, hyr, hyv⟩
          · rw [Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hz
            by_cases hzv : z = v
            · exact Or.inl hzv
            · right
              simp only [As, Finset.mem_filter, Finset.mem_univ, true_and]
              have hzM := hout z hz.2
              refine ⟨hzM, fun hzr => hyr (hedge ⟨z, hzM⟩ ⟨y, hyM⟩ hzr hz.1.symm ?_ ?_), hzv⟩
              · by_cases hzu : z = u
                · exact Or.inr hyv
                · exact Or.inl hzu
              · exact Or.inl hzv
        have h1 := Finset.card_le_card hsub
        have hyn : y ∉ G.neighborFinset y \ Sf := by simp
        rw [Finset.card_insert_of_notMem hyn] at h1
        have h2 := Finset.card_insert_le v As
        have := hbig y
        omega
  17. There exist subsets $A \subseteq A_s$ and $B \subseteq B_s$ of size exactly $r$ satisfying the conclusion.

    Since $|A_s| \ge r$ and $|B_s| \ge r$, Finset.exists_subset_card_eq provides subsets $A \subseteq A_s$ and $B \subseteq B_s$ with $|A| = |B| = r$. The non-adjacency properties proven for $A_s$ and $B_s$ carry over to $A$ and $B$, establishing that $(A, B)$ induces a complete bipartite subgraph of $G^c$.

    lines 425–428

    uses Finset.exists_subset_card_eq

      obtain ⟨A0, hA0, hA0c⟩ := Finset.exists_subset_card_eq hAcard
      obtain ⟨B0, hB0, hB0c⟩ := Finset.exists_subset_card_eq hBcard
      exact ⟨A0, B0, hA0c, hB0c, fun a ha => hAprop a (hA0 ha), fun b hb => hBprop b (hB0 hb),
        fun a ha b hb => hABprop a (hA0 ha) b (hB0 hb)⟩
SimpleGraph.deleteEdges_adj
An edge $vw$ is in $G \setminus s$ if and only if $vw \in E(G)$ and the unordered pair $s(v, w)$ is not in $s$.
Set.mem_singleton_iff
An element $a$ belongs to the singleton $\{b\}$ if and only if $a = b$.
Sym2.eq_iff
Two unordered pairs $s(x, y)$ and $s(z, w)$ are equal if and only if either $x = z$ and $y = w$, or $x = w$ and $y = z$.
Finset.mem_biUnion
An element $b$ belongs to the indexed union $\bigcup_{a \in s} t(a)$ if and only if $b \in t(a)$ for some $a \in s$.
Finset.card_biUnion_le_card_mul
If every set in a family indexed by a finset $s$ has size at most $n$, the size of their union is at most $|s| \times n$.
Sym2.card_toFinset
An unordered pair has cardinality 1 if its endpoints coincide (diagonal) and 2 otherwise.
Set.ncard_eq_toFinset_card
The set cardinality (ncard) of a finite set equals the cardinality of its finset representation.
SimpleGraph.Subgraph.isPerfectMatching_iff
A subgraph is a perfect matching if and only if every vertex of the ambient graph has a unique incident edge in the subgraph.
in1068_verts_bound
The vertices of any $k$-edge matching in a graph on $n$ vertices are contained in a finite subset of vertices of cardinality at most $2k$.
Finset.eq_univ_iff_forall
A finset of a finite type equals the universal finset if and only if it contains every element of the type.
Finset.card_univ
The cardinality of the universal finset of a finite type equals the cardinality of the type.
Sym2.eq_swap
The unordered pair $s(a, b)$ equals $s(b, a)$.
Sym2.ind
To prove a property for all unordered pairs, it suffices to check pairs of the form $s(x, y)$.
Set.disjoint_singleton_right
A set $s$ is disjoint from a singleton $\{a\}$ if and only if $a \notin s$.
Set.ncard_union_eq
The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
Set.ncard_sdiff_singleton_of_mem
Removing an element from a finite set decreases its cardinality by 1.
Set.ncard_singleton
A singleton set has cardinality 1.
Set.ncard_pos
A finite set has strictly positive cardinality if and only if it is nonempty.
Eq.trans
Equality is transitive.
congrArg
Equal arguments to a function produce equal values.
Iff.rfl
Every proposition is equivalent to itself.
in1068_transport
A perfect matching in $G$ extending a subgraph $M$ of $G - uv$ that avoids $uv$ can be viewed as a perfect matching of $G - uv$ extending $M$.
SimpleGraph.card_neighborFinset_eq_degree
The cardinality of the neighbor set of a vertex represented as a finset equals the vertex degree.
le_trans
Inequality $\le$ is transitive.
Finset.le_card_sdiff
For finsets $s$ and $t$, $|t| - |s| \le |t \setminus s|$.
Finset.mem_sdiff
An element belongs to $s \setminus t$ if and only if it belongs to $s$ and not to $t$.
SimpleGraph.mem_neighborFinset
A vertex $w$ belongs to the neighbor finset of $v$ if and only if $v$ and $w$ are adjacent.
Finset.mem_map
An element belongs to the image of a finset under an embedding if and only if it is the image of some element.
Finset.card_le_card
If $s \subseteq t$ for finsets, then $|s| \le |t|$.
Finset.card_map
Applying an embedding to a finset preserves its cardinality.
Subtype.ext
Two elements of a subtype are equal if and only if their underlying values are equal.
Set.mem_setOf_eq
Membership in a set comprehension $\{x \mid p(x)\}$ is equivalent to $p(x)$.
iff_false
An equivalence between a proposition and False is equivalent to the negation of the proposition.
SimpleGraph.compl_adj
Two vertices are adjacent in the complement graph $G^c$ if and only if they are distinct and non-adjacent in $G$.
Set.ncard_empty
The empty set has cardinality 0.
forced_matching_edge_common_nonneighbors_below_min_degree_is_bridge
In a graph with minimum degree at least $r$, if an edge $uv$ is in a perfect matching, $G - uv$ has no perfect matching, and $u, v$ have fewer than $r$ common non-neighbors, then $u$ cannot reach $v$ in $G - uv$.
SimpleGraph.Adj.reachable
Adjacent vertices are reachable from each other.
SimpleGraph.Reachable.refl
Every vertex is reachable from itself.
Finset.card_pos
A finset has strictly positive cardinality if and only if it is nonempty.
Finset.card_erase_le
Removing an element from a finset gives a finset of cardinality at most the original.
Finset.pred_card_le_card_erase
Removing an element from a finset leaves a finset of cardinality at least $|s| - 1$.
Finset.card_insert_of_notMem
Inserting an element not in $s$ yields a finset of cardinality $|s| + 1$.
Finset.card_insert_le
Inserting an element into a finset increases its cardinality by at most 1.
Finset.exists_subset_card_eq
Any finset $s$ contains a subset of cardinality $n$ whenever $n \le |s|$.

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

open SimpleGraph intheorem in1068_transport {V : Type*} (G : SimpleGraph V) (u v : V)    (M : (G.deleteEdges {s(u,v)}).Subgraph) (Q : G.Subgraph) (hQ : Q.IsPerfectMatching)    (hMQv : M.verts ⊆ Q.verts) (hMQ : ∀ x y, M.Adj x y → Q.Adj x y) (hno : ¬ Q.Adj u v) :    ∃ P : (G.deleteEdges {s(u,v)}).Subgraph, P.IsPerfectMatching ∧ M ≤ P := by  have hsub : ∀ {x y : V}, Q.Adj x y → (G.deleteEdges {s(u,v)}).Adj x y := by    intro x y h    rw [SimpleGraph.deleteEdges_adj]    refine ⟨Q.adj_sub h, ?_⟩    intro he    simp only [Set.mem_singleton_iff, Sym2.eq_iff] at he    rcases he with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩    · exact hno h    · exact hno h.symm  refine ⟨⟨Q.verts, Q.Adj, hsub, Q.edge_vert, Q.symm⟩, ⟨fun x hx => hQ.1 hx, fun x => hQ.2 x⟩, ?_⟩  exact ⟨hMQv, fun {x y} h => hMQ x y h⟩open SimpleGraph intheorem in1068_verts_bound {n k : ℕ} {H : SimpleGraph (Fin n)} (M : H.Subgraph) (hM : M.IsMatching)    (hMk : M.edgeSet.ncard = k) :    ∃ S : Finset (Fin n), (∀ x, x ∈ M.verts → x ∈ S) ∧ S.card ≤ 2 * k := by  classical  refine ⟨(M.edgeSet.toFinite.toFinset).biUnion (fun e => e.toFinset), ?_, ?_⟩  · intro x hx    obtain ⟨w, hw, -⟩ := hM hx    rw [Finset.mem_biUnion]    exact ⟨s(x, w), by simpa using hw, by simp⟩  · have h1 : ((M.edgeSet.toFinite.toFinset).biUnion (fun e => e.toFinset)).card ≤        (M.edgeSet.toFinite.toFinset).card * 2 := by      apply Finset.card_biUnion_le_card_mul      intro e _      rw [Sym2.card_toFinset]      split_ifs <;> omega    have h2 : (M.edgeSet.toFinite.toFinset).card = k := by      rw [← Set.ncard_eq_toFinset_card M.edgeSet M.edgeSet.toFinite, hMk]    omegatheorem minimally_k_extendable_degree_surplus_zero_codegree_complete_bipartite    (k n r : ℕ) (hr : 2 ≤ r) (G : SimpleGraph (Fin n)) [DecidableRel G.Adj]    (hmin : is_minimally_k_extendable G k) (hdegree : 2*k+r ≤ G.minDegree)    (u v : Fin n) (huv : G.Adj u v)    (hfar2 : ∀ x, ¬ ((Gᶜ).Adj u x ∧ (Gᶜ).Adj v x)) :    ∃ A B : Finset (Fin n), A.card = r ∧ B.card = r ∧      (∀ a ∈ A, (Gᶜ).Adj u a) ∧ (∀ b ∈ B, (Gᶜ).Adj v b) ∧      ∀ a ∈ A, ∀ b ∈ B, (Gᶜ).Adj a b := open SimpleGraph in by  classical  obtain ⟨⟨hcard, ⟨M0, hM0, hM0k⟩, hext⟩, hminimal⟩ := hmin  have hG' : ∀ x y : Fin n, (G.deleteEdges {s(u, v)}).Adj x y ↔ G.Adj x y ∧ s(x, y) ≠ s(u, v) := by    intro x y    simp [SimpleGraph.deleteEdges_adj]  have hsym : ∀ x y : Fin n, s(x, y) = s(u, v) → (x = u ∧ y = v) ∨ (x = v ∧ y = u) := by    intro x y h    simpa [Sym2.eq_iff] using h  have huvne : u ≠ v := huv.ne  -- (b) a k-matching of G - uv  have hb : ∃ M : (G.deleteEdges {s(u, v)}).Subgraph, M.IsMatching ∧ M.edgeSet.ncard = k := by    have hM0u : ∀ {x y y' : Fin n}, M0.Adj x y → M0.Adj x y' → y = y' := by      intro x y y' h h'      exact (hM0 (M0.edge_vert h)).unique h h'    by_cases hM0uv : M0.Adj u v    · obtain ⟨P0, hP0, hM0P0⟩ := hext M0 hM0 hM0k      have hP0' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP0      obtain ⟨S0, hS0, hS0c⟩ := in1068_verts_bound M0 hM0 hM0k      obtain ⟨w, hw⟩ : ∃ w : Fin n, w ∉ S0 := by        by_contra hall        simp only [not_exists, not_not] at hall        have h1 : S0 = Finset.univ := Finset.eq_univ_iff_forall.mpr hall        rw [h1, Finset.card_univ] at hS0c        omega      have hwM : w ∉ M0.verts := fun h => hw (hS0 w h)      obtain ⟨w', hww', -⟩ := hP0' w      have hw'M : w' ∉ M0.verts := by        intro h        obtain ⟨c, hc, -⟩ := hM0 h        have : c = w := (hP0' w').unique (hM0P0.2 hc) hww'.symm        exact hwM (this ▸ M0.edge_vert hc.symm)      have hwne : w ≠ w' := (P0.adj_sub hww').ne      have huM : u ∈ M0.verts := M0.edge_vert hM0uv      have hvM : v ∈ M0.verts := M0.edge_vert hM0uv.symm      have hwu : w ≠ u := fun h => hwM (h ▸ huM)      have hwv : w ≠ v := fun h => hwM (h ▸ hvM)      -- an M0-edge other than uv avoids u and v      have hoff : ∀ {x y : Fin n}, M0.Adj x y → s(x, y) ≠ s(u, v) → x ≠ u ∧ x ≠ v := by        intro x y hxy hne        constructor        · rintro rfl          exact hne (by rw [hM0u hxy hM0uv])        · rintro rfl          exact hne (by rw [hM0u hxy hM0uv.symm]; exact Sym2.eq_swap)      let M1 : (G.deleteEdges {s(u, v)}).Subgraph :=        { verts := (M0.verts \ {u, v}) ∪ {w, w'}          Adj := fun x y => (M0.Adj x y ∧ s(x, y) ≠ s(u, v)) ∨ (x = w ∧ y = w') ∨ (x = w' ∧ y = w)          adj_sub := by            rintro x y (⟨h, hne⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)            · exact (hG' x y).mpr ⟨M0.adj_sub h, hne⟩            · refine (hG' _ _).mpr ⟨P0.adj_sub hww', fun he => ?_⟩              rcases hsym _ _ he with ⟨h1, -⟩ | ⟨h1, -⟩              · exact hwu h1              · exact hwv h1            · refine (hG' _ _).mpr ⟨P0.adj_sub hww'.symm, fun he => ?_⟩              rcases hsym _ _ he with ⟨-, h1⟩ | ⟨-, h1⟩              · exact hwv h1              · exact hwu h1          edge_vert := by            rintro x y (⟨h, hne⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)            · obtain ⟨h1, h2⟩ := hoff h hne              exact Or.inl ⟨M0.edge_vert h, by simp [h1, h2]⟩            · exact Or.inr (by simp)            · exact Or.inr (by simp)          symm := by            refine ⟨?_⟩            rintro x y (⟨h, hne⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)            · exact Or.inl ⟨h.symm, by rwa [Sym2.eq_swap]⟩            · exact Or.inr (Or.inr ⟨rfl, rfl⟩)            · exact Or.inr (Or.inl ⟨rfl, rfl⟩) }      refine ⟨M1, ?_, ?_⟩      · intro x hx        rcases hx with ⟨hx0, hxuv⟩ | hxw        · simp only [Set.mem_insert_iff, Set.mem_singleton_iff, not_or] at hxuv          obtain ⟨y, hy, -⟩ := hM0 hx0          have hne : s(x, y) ≠ s(u, v) := by            intro he            rcases hsym _ _ he with ⟨h1, -⟩ | ⟨h1, -⟩            · exact hxuv.1 h1            · exact hxuv.2 h1          refine ⟨y, Or.inl ⟨hy, hne⟩, ?_⟩          rintro y' (⟨h', -⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)          · exact hM0u h' hy          · exact absurd hx0 hwM          · exact absurd hx0 hw'M        · simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxw          rcases hxw with rfl | rfl          · refine ⟨w', Or.inr (Or.inl ⟨rfl, rfl⟩), ?_⟩            rintro y' (⟨h', -⟩ | ⟨-, rfl⟩ | ⟨h1, -⟩)            · exact absurd (M0.edge_vert h') hwM            · rfl            · exact absurd h1 hwne          · refine ⟨w, Or.inr (Or.inr ⟨rfl, rfl⟩), ?_⟩            rintro y' (⟨h', -⟩ | ⟨h1, -⟩ | ⟨-, rfl⟩)            · exact absurd (M0.edge_vert h') hw'M            · exact absurd h1.symm hwne            · rfl      · have hE : M1.edgeSet = (M0.edgeSet \ {s(u, v)}) ∪ {s(w, w')} := by          ext e          induction e using Sym2.ind with          | h x y =>            simp only [SimpleGraph.Subgraph.mem_edgeSet, Set.mem_union, Set.mem_sdiff,              Set.mem_singleton_iff]            show ((M0.Adj x y ∧ s(x, y) ≠ s(u, v)) ∨ (x = w ∧ y = w') ∨ (x = w' ∧ y = w)) ↔ _            simp only [Sym2.eq_iff, ne_eq]        have hdisj : Disjoint (M0.edgeSet \ {s(u, v)}) {s(w, w')} := by          rw [Set.disjoint_singleton_right]          rintro ⟨h, -⟩          exact hwM (M0.edge_vert h)        have hmem : s(u, v) ∈ M0.edgeSet := hM0uv        rw [hE, Set.ncard_union_eq hdisj (Set.toFinite _) (Set.toFinite _),          Set.ncard_sdiff_singleton_of_mem hmem, Set.ncard_singleton, hM0k]        have hpos : 0 < M0.edgeSet.ncard := Set.ncard_pos (Set.toFinite _) |>.mpr ⟨_, hmem⟩        omega    · refine ⟨⟨M0.verts, M0.Adj, fun {x y} h => (hG' x y).mpr ⟨M0.adj_sub h, fun he => ?_⟩,        M0.edge_vert, M0.symm⟩, fun x hx => hM0 hx, ?_⟩      · rcases hsym _ _ he with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩        · exact hM0uv h        · exact hM0uv h.symm      · refine Eq.trans (congrArg Set.ncard ?_) hM0k        ext e; induction e using Sym2.ind; exact Iff.rfl  -- a non-extendable k-matching of G - uv  have hnot := hminimal s(u, v) (by simpa using huv)  obtain ⟨M, hM, hMk, hMno⟩ : ∃ M : (G.deleteEdges {s(u, v)}).Subgraph, M.IsMatching ∧      M.edgeSet.ncard = k ∧ ¬ ∃ P : (G.deleteEdges {s(u, v)}).Subgraph, P.IsPerfectMatching ∧ M ≤ P := by    by_contra hcon    push Not at hcon    exact hnot ⟨hcard, hb, fun M hM hk => hcon M hM hk⟩  have hup : ∀ {x y : Fin n}, M.Adj x y → G.Adj x y := fun h => ((hG' _ _).mp (M.adj_sub h)).1  let MG : G.Subgraph := ⟨M.verts, M.Adj, hup, M.edge_vert, M.symm⟩  have hMG : MG.IsMatching := fun x hx => hM hx  have hMGk : MG.edgeSet.ncard = k :=    Eq.trans (congrArg Set.ncard (by ext e; induction e using Sym2.ind; exact Iff.rfl)) hMk  obtain ⟨P, hP, hMP⟩ := hext MG hMG hMGk  have hP' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hP  have hMPadj : ∀ {x y : Fin n}, M.Adj x y → P.Adj x y := fun h => hMP.2 h  have hPuv : P.Adj u v := by    by_contra h    exact hMno (in1068_transport G u v M P hP hMP.1 (fun x y hxy => hMPadj hxy) h)  have hnotin : ∀ x, (x = u ∨ x = v) → x ∉ M.verts := by    intro x hx hxM    obtain ⟨y, hy, -⟩ := hM hxM    have hPy := hMPadj hy    rcases hx with rfl | rfl    · have : y = v := (hP' x).unique hPy hPuv      subst this      exact ((hG' _ _).mp (M.adj_sub hy)).2 rfl    · have : y = u := (hP' x).unique hPy hPuv.symm      subst this      exact ((hG' _ _).mp (M.adj_sub hy)).2 Sym2.eq_swap  have huR : u ∉ M.verts := hnotin u (Or.inl rfl)  have hvR : v ∉ M.verts := hnotin v (Or.inr rfl)  have hcl : ∀ a b, P.Adj a b → a ∉ M.verts → b ∉ M.verts := by    intro a b hab ha hbM    obtain ⟨c, hc, -⟩ := hM hbM    have : c = a := (hP' b).unique (hMPadj hc) hab.symm    exact ha (this ▸ M.edge_vert hc.symm)  obtain ⟨Sf, hSf, hSfc⟩ := in1068_verts_bound MG hMG hMGk  -- many neighbours outside M  have hbig : ∀ x : Fin n, r ≤ (G.neighborFinset x \ Sf).card := by    intro x    have h1 : 2 * k + r ≤ (G.neighborFinset x).card := by      rw [SimpleGraph.card_neighborFinset_eq_degree]      exact le_trans hdegree (G.minDegree_le_degree x)    have := Finset.le_card_sdiff Sf (G.neighborFinset x)    omega  have hout : ∀ y, y ∉ Sf → y ∉ M.verts := fun y hy hyM => hy (hSf y hyM)  -- the residual graph  let s : Set (Fin n) := {x | x ∉ M.verts}  let Gr : SimpleGraph s := G.induce s  have hGr : ∀ x y : s, Gr.Adj x y ↔ G.Adj x.1 y.1 := fun x y => Iff.rfl  let uW : s := ⟨u, huR⟩  let vW : s := ⟨v, hvR⟩  let Gd := Gr.deleteEdges {s(uW, vW)}  have hGd : ∀ x y : s, G.Adj x.1 y.1 → ¬ ((x.1 = u ∧ y.1 = v) ∨ (x.1 = v ∧ y.1 = u)) → Gd.Adj x y := by    intro x y hxy hne    rw [SimpleGraph.deleteEdges_adj]    refine ⟨hxy, ?_⟩    intro he    simp only [Set.mem_singleton_iff, Sym2.eq_iff] at he    apply hne    rcases he with ⟨h1, h2⟩ | ⟨h1, h2⟩    · exact Or.inl ⟨congrArg Subtype.val h1, congrArg Subtype.val h2⟩    · exact Or.inr ⟨congrArg Subtype.val h1, congrArg Subtype.val h2⟩  have hGdsub : ∀ x y : s, Gd.Adj x y → G.Adj x.1 y.1 := fun x y h => (SimpleGraph.deleteEdges_adj.mp h).1  -- hypotheses of the forced-edge lemma on Gr  have hdegGr : ∀ x : s, r ≤ Gr.degree x := by    intro x    rw [← SimpleGraph.card_neighborFinset_eq_degree]    have hsub : G.neighborFinset x.1 \ Sf ⊆ (Gr.neighborFinset x).map ⟨Subtype.val, Subtype.val_injective⟩ := by      intro y hy      rw [Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hy      rw [Finset.mem_map]      exact ⟨⟨y, hout y hy.2⟩, by rw [SimpleGraph.mem_neighborFinset]; exact hy.1, rfl⟩    have := le_trans (hbig x.1) (Finset.card_le_card hsub)    rwa [Finset.card_map] at this  have hPGr : ∃ Pr : Gr.Subgraph, Pr.IsPerfectMatching ∧ Pr.Adj uW vW := by    let Pr : Gr.Subgraph :=      { verts := Set.univ        Adj := fun x y => P.Adj x.1 y.1        adj_sub := fun {x y} h => P.adj_sub h        edge_vert := fun _ => Set.mem_univ _        symm := ⟨fun x y h => h.symm⟩ }    refine ⟨Pr, ?_, hPuv⟩    rw [SimpleGraph.Subgraph.isPerfectMatching_iff]    intro x    obtain ⟨p, hp, hpu⟩ := hP' x.1    refine ⟨⟨p, hcl x.1 p hp x.2⟩, hp, fun y hy => Subtype.ext (hpu y.1 hy)⟩  have hforcedGr : ¬ ∃ Q : Gd.Subgraph, Q.IsPerfectMatching := by    rintro ⟨Q, hQ⟩    have hQ' := SimpleGraph.Subgraph.isPerfectMatching_iff.mp hQ    apply hMno    let Q' : (G.deleteEdges {s(u, v)}).Subgraph :=      { verts := Set.univ        Adj := fun x y => M.Adj x y ∨ ∃ hx : x ∉ M.verts, ∃ hy : y ∉ M.verts, Q.Adj ⟨x, hx⟩ ⟨y, hy⟩        adj_sub := by          rintro x y (h | ⟨hx, hy, h⟩)          · exact M.adj_sub h          · have h1 := Q.adj_sub h            rw [SimpleGraph.deleteEdges_adj] at h1            refine (hG' x y).mpr ⟨h1.1, fun he => h1.2 ?_⟩            rw [Set.mem_singleton_iff, Sym2.eq_iff]            rcases hsym _ _ he with ⟨h2, h3⟩ | ⟨h2, h3⟩            · exact Or.inl ⟨Subtype.ext h2, Subtype.ext h3⟩            · exact Or.inr ⟨Subtype.ext h2, Subtype.ext h3⟩        edge_vert := fun _ => Set.mem_univ _        symm := by          refine ⟨?_⟩          rintro x y (h | ⟨hx, hy, h⟩)          · exact Or.inl h.symm          · exact Or.inr ⟨hy, hx, h.symm⟩ }    refine ⟨Q', ?_, ⟨fun _ _ => Set.mem_univ _, fun {x y} h => Or.inl h⟩⟩    rw [SimpleGraph.Subgraph.isPerfectMatching_iff]    intro x    by_cases hxM : x ∈ M.verts    · obtain ⟨y, hy, hyu⟩ := hM hxM      refine ⟨y, Or.inl hy, ?_⟩      rintro y' (h | ⟨hx, -, -⟩)      · exact hyu y' h      · exact absurd hxM hx    · obtain ⟨y, hy, hyu⟩ := hQ' ⟨x, hxM⟩      refine ⟨y.1, Or.inr ⟨hxM, y.2, hy⟩, ?_⟩      rintro y' (h | ⟨hx', hy', h⟩)      · exact absurd (M.edge_vert h) hxM      · exact congrArg Subtype.val (hyu ⟨y', hy'⟩ h)  have hcoGr : ({w | (Grᶜ).Adj uW w ∧ (Grᶜ).Adj vW w} : Set s).ncard < r := by    have hempty : ({w | (Grᶜ).Adj uW w ∧ (Grᶜ).Adj vW w} : Set s) = ∅ := by      ext w      simp only [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false]      rintro ⟨h1, h2⟩      rw [SimpleGraph.compl_adj] at h1 h2      apply hfar2 w.1      refine ⟨(SimpleGraph.compl_adj G u w.1).2 ⟨fun h => h1.1 (Subtype.ext h), h1.2⟩,        (SimpleGraph.compl_adj G v w.1).2 ⟨fun h => h2.1 (Subtype.ext h), h2.2⟩⟩    rw [hempty, Set.ncard_empty]    omega  have key := forced_matching_edge_common_nonneighbors_below_min_degree_is_bridge Gr r hdegGr uW vW    huv hPGr hforcedGr hcoGr  -- the two sides  have hreachv : ∀ y : s, Gd.Reachable uW y → y.1 ≠ v := by    intro y hy hyv    apply key    have : y = vW := Subtype.ext hyv    rwa [this] at hy  have hedge : ∀ x y : s, Gd.Reachable uW x → G.Adj x.1 y.1 → x.1 ≠ u ∨ y.1 ≠ v →      x.1 ≠ v ∨ y.1 ≠ u → Gd.Reachable uW y := by    intro x y hx hxy h1 h2    refine hx.trans (SimpleGraph.Adj.reachable (hGd x y hxy ?_))    rintro (⟨a, b⟩ | ⟨a, b⟩)    · rcases h1 with h | h      · exact h a      · exact h b    · rcases h2 with h | h      · exact h a      · exact h b  let Bs : Finset (Fin n) := Finset.univ.filter (fun x => ∃ h : x ∉ M.verts, Gd.Reachable uW ⟨x, h⟩ ∧ x ≠ u)  let As : Finset (Fin n) := Finset.univ.filter (fun x => ∃ h : x ∉ M.verts, ¬ Gd.Reachable uW ⟨x, h⟩ ∧ x ≠ v)  -- properties  have hBprop : ∀ b ∈ Bs, (Gᶜ).Adj v b := by    intro b hb    simp only [Bs, Finset.mem_filter, Finset.mem_univ, true_and] at hb    obtain ⟨hbM, hbr, hbu⟩ := hb    have hbv := hreachv _ hbr    refine (SimpleGraph.compl_adj G v b).2 ⟨fun h => hbv h.symm, fun hvb => ?_⟩    apply key    have := hedge ⟨b, hbM⟩ vW hbr hvb.symm (Or.inl hbu) (Or.inl hbv)    exact this  have hAprop : ∀ a ∈ As, (Gᶜ).Adj u a := by    intro a ha    simp only [As, Finset.mem_filter, Finset.mem_univ, true_and] at ha    obtain ⟨haM, har, hav⟩ := ha    have hau : a ≠ u := by      rintro rfl      exact har (SimpleGraph.Reachable.refl _)    refine (SimpleGraph.compl_adj G u a).2 ⟨fun h => hau h.symm, fun hua => ?_⟩    exact har (hedge uW ⟨a, haM⟩ (SimpleGraph.Reachable.refl _) hua (Or.inr hav) (Or.inr hau))  have hABprop : ∀ a ∈ As, ∀ b ∈ Bs, (Gᶜ).Adj a b := by    intro a ha b hb    simp only [As, Bs, Finset.mem_filter, Finset.mem_univ, true_and] at ha hb    obtain ⟨haM, har, hav⟩ := ha    obtain ⟨hbM, hbr, hbu⟩ := hb    have hab : a ≠ b := by      rintro rfl      exact har hbr    refine (SimpleGraph.compl_adj G a b).2 ⟨hab, fun hadj => ?_⟩    exact har (hedge ⟨b, hbM⟩ ⟨a, haM⟩ hbr hadj.symm (Or.inl hbu) (Or.inl (hreachv _ hbr)))  -- sizes  have hBcard : r ≤ Bs.card := by    obtain ⟨y, hy⟩ : ∃ y, y ∈ (G.neighborFinset u \ Sf).erase v := by      apply Finset.card_pos.mp      have := hbig u      have := Finset.card_erase_le (s := G.neighborFinset u \ Sf) (a := v)      have h2 := Finset.pred_card_le_card_erase (s := G.neighborFinset u \ Sf) (a := v)      omega    rw [Finset.mem_erase, Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hy    obtain ⟨hyv, huy, hyS⟩ := hy    have hyM := hout y hyS    have hyr : Gd.Reachable uW ⟨y, hyM⟩ :=      hedge uW ⟨y, hyM⟩ (SimpleGraph.Reachable.refl _) huy (Or.inr hyv) (Or.inr (fun h => huy.ne h.symm))    have hyu : y ≠ u := fun h => huy.ne h.symm    have hsub : insert y (G.neighborFinset y \ Sf) ⊆ insert u Bs := by      intro z hz      rw [Finset.mem_insert] at hz ⊢      rcases hz with rfl | hz      · right        simp only [Bs, Finset.mem_filter, Finset.mem_univ, true_and]        exact ⟨hyM, hyr, hyu⟩      · rw [Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hz        by_cases hzu : z = u        · exact Or.inl hzu        · right          simp only [Bs, Finset.mem_filter, Finset.mem_univ, true_and]          have hzM := hout z hz.2          refine ⟨hzM, hedge ⟨y, hyM⟩ ⟨z, hzM⟩ hyr hz.1 (Or.inl hyu) (Or.inr hzu), hzu⟩    have h1 := Finset.card_le_card hsub    have hyn : y ∉ G.neighborFinset y \ Sf := by simp    rw [Finset.card_insert_of_notMem hyn] at h1    have h2 := Finset.card_insert_le u Bs    have := hbig y    omega  have hAcard : r ≤ As.card := by    obtain ⟨y, hy⟩ : ∃ y, y ∈ (G.neighborFinset v \ Sf).erase u := by      apply Finset.card_pos.mp      have := hbig v      have h2 := Finset.pred_card_le_card_erase (s := G.neighborFinset v \ Sf) (a := u)      omega    rw [Finset.mem_erase, Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hy    obtain ⟨hyu, hvy, hyS⟩ := hy    have hyM := hout y hyS    have hyv : y ≠ v := fun h => hvy.ne h.symm    -- y is not reachable: otherwise v would be    have hyr : ¬ Gd.Reachable uW ⟨y, hyM⟩ := by      intro h      apply key      exact hedge ⟨y, hyM⟩ vW h hvy.symm (Or.inl hyu) (Or.inl hyv)    have hsub : insert y (G.neighborFinset y \ Sf) ⊆ insert v As := by      intro z hz      rw [Finset.mem_insert] at hz ⊢      rcases hz with rfl | hz      · right        simp only [As, Finset.mem_filter, Finset.mem_univ, true_and]        exact ⟨hyM, hyr, hyv⟩      · rw [Finset.mem_sdiff, SimpleGraph.mem_neighborFinset] at hz        by_cases hzv : z = v        · exact Or.inl hzv        · right          simp only [As, Finset.mem_filter, Finset.mem_univ, true_and]          have hzM := hout z hz.2          refine ⟨hzM, fun hzr => hyr (hedge ⟨z, hzM⟩ ⟨y, hyM⟩ hzr hz.1.symm ?_ ?_), hzv⟩          · by_cases hzu : z = u            · exact Or.inr hyv            · exact Or.inl hzu          · exact Or.inl hzv    have h1 := Finset.card_le_card hsub    have hyn : y ∉ G.neighborFinset y \ Sf := by simp    rw [Finset.card_insert_of_notMem hyn] at h1    have h2 := Finset.card_insert_le v As    have := hbig y    omega  obtain ⟨A0, hA0, hA0c⟩ := Finset.exists_subset_card_eq hAcard  obtain ⟨B0, hB0, hB0c⟩ := Finset.exists_subset_card_eq hBcard  exact ⟨A0, B0, hA0c, hB0c, fun a ha => hAprop a (hA0 ha), fun b hb => hBprop b (hB0 hb),    fun a ha b hb => hABprop a (hA0 ha) b (hB0 hb)⟩
See it in the graphDiscuss this resultChallenge it