AFTD Auto-Formalizing Theoretical Domains

connected_graph_delete_twin_with_common_neighbor_connected

theoremverified

If two distinct vertices have identical neighbors outside the pair and a common neighbor, deleting either one preserves connectedness of a connected graph.

Statement

theorem connected_graph_delete_twin_with_common_neighbor_connected {V : Type*} (G : SimpleGraph V)
    (hconn : G.Connected) (x y z : V) (hxy : x ≠ y)
    (hxz : G.Adj x z) (hyz : G.Adj y z)
    (htwin : ∀ a, a ≠ x → a ≠ y → (G.Adj x a ↔ G.Adj y a)) :
    (G.induce {a | a ≠ y}).Connected
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 2
Used by 1

The proof, explained

The proof splits into two cases based on whether x and y are adjacent. If they are not adjacent, they share all neighbors including their mutual non-adjacency, making them false twins whose deletion preserves connectedness by a helper lemma. If they are adjacent, deleting the edge between them yields a subgraph in which they remain connected via their common neighbor z, so the edge is not a bridge and the subgraph remains connected. In this subgraph x and y are false twins, so deleting y preserves connectedness; since the removed edge was incident to y, the resulting induced subgraph is identical to G \ {y}.

  1. We perform a case split on whether vertices x and y are adjacent in G.

    By classical excluded middle, either x and y are connected by an edge in G (the true-twin case) or they are not (the false-twin case).

    lines 6–7

      classical
      by_cases hxyadj : G.Adj x y
  2. In the graph F obtained by deleting the edge {x, y}, the vertices x and y remain reachable from each other via z.

    Let F = G \ {{x, y}}. Because G has no self-loops and z is adjacent to both x and y, z cannot equal x or y. Hence the edges {x, z} and {y, z} are distinct from {x, y} and remain present in F (by SimpleGraph.deleteEdges_adj.mpr, Set.mem_singleton_iff, and Sym2.eq_iff). Concatenating these two edges yields a path in F connecting x and y via z.

    lines 8–25

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

      · let F := G.deleteEdges {s(x,y)}
        have hz_x : z ≠ x := hxz.ne.symm
        have hz_y : z ≠ y := hyz.ne.symm
        have hxzF : F.Adj x z := by
          apply SimpleGraph.deleteEdges_adj.mpr
          refine ⟨hxz, ?_⟩
          simp only [Set.mem_singleton_iff, Sym2.eq_iff]
          rintro (⟨_, h⟩ | ⟨h, _⟩)
          · exact hz_y h
          · exact hxy h
        have hyzF : F.Adj y z := by
          apply SimpleGraph.deleteEdges_adj.mpr
          refine ⟨hyz, ?_⟩
          simp only [Set.mem_singleton_iff, Sym2.eq_iff]
          rintro (⟨h, _⟩ | ⟨_, h⟩)
          · exact hxy h.symm
          · exact hz_x h
        have hr : F.Reachable x y := hxzF.reachable.trans hyzF.symm.reachable
  3. The graph F is connected.

    Because x and y are reachable from each other in F = G \ {{x, y}}, the edge {x, y} is not a bridge of G (SimpleGraph.isBridge_iff, not_not.mpr). Deleting a non-bridge edge from a connected graph preserves connectedness, so F is connected.

    lines 26–28

    uses SimpleGraph.isBridge_iff, not_not.mpr

        have hfconn : F.Connected := by
          exact hconn.connected_delete_edge_of_not_isBridge (x := x) (y := y)
            (by rw [SimpleGraph.isBridge_iff]; exact not_not.mpr hr)
  4. In F, x and y have identical neighborhoods (NF(x) = NF(y)).

    For any vertex a, we check whether x ~_F a is equivalent to y ~_F a. If a = x or a = y, neither vertex is adjacent to a in F because simple graphs lack self-loops and the edge {x, y} was removed (SimpleGraph.deleteEdges_adj, Sym2.eq_iff). If a is outside {x, y}, edge deletion does not affect edges to a (Set.mem_singleton_iff), so adjacencies in F match those in G, which agree by the twin hypothesis htwin.

    lines 29–41

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

        have hFtwins : F.neighborSet x = F.neighborSet y := by
          ext a
          change F.Adj x a ↔ F.Adj y a
          by_cases hax : a = x
          · subst a
            simp [F, SimpleGraph.deleteEdges_adj, Sym2.eq_iff, hxy]
          · by_cases hay : a = y
            · subst a
              simp [F, SimpleGraph.deleteEdges_adj, Sym2.eq_iff, hxy]
            · simp only [F, SimpleGraph.deleteEdges_adj, Set.mem_singleton_iff, Sym2.eq_iff]
              have hxa : x ≠ a := fun h => hax h.symm
              have hya : y ≠ a := fun h => hay h.symm
              simp [hxy,hxy.symm,hax,hay,hxa,hya,htwin a hax hay]
  5. The induced subgraph F \ {y} is connected.

    Since F is connected and x and y are distinct vertices with identical neighborhoods in F, deleting y preserves connectedness by connected_graph_delete_false_twin_connected.

    line 42

    uses connected_graph_delete_false_twin_connected

        have hfdel := connected_graph_delete_false_twin_connected F hfconn x y hxy hFtwins
  6. The induced subgraph G \ {y} is connected.

    The induced subgraphs F \ {y} and G \ {y} are identical because the only edge removed from G to obtain F was {x, y}, which is incident to y and therefore absent from any subgraph induced on vertices other than y (verified using SimpleGraph.induce_adj, SimpleGraph.deleteEdges_adj, Set.mem_singleton_iff, Sym2.eq_iff, and And.left). Rewriting along this equality shows that G \ {y} is connected.

    lines 43–55

    uses SimpleGraph.induce_adj, SimpleGraph.deleteEdges_adj, Set.mem_singleton_iff, Sym2.eq_iff, And.left

        have heq : F.induce {a | a ≠ y} = G.induce {a | a ≠ y} := by
          ext a b
          simp only [F, SimpleGraph.induce_adj, SimpleGraph.deleteEdges_adj,
            Set.mem_singleton_iff, Sym2.eq_iff]
          constructor
          · exact And.left
          · intro hab
            refine ⟨hab, ?_⟩
            rintro (⟨_, hb⟩ | ⟨ha, _⟩)
            · exact b.property hb
            · exact a.property ha
        rw [heq] at hfdel
        exact hfdel
  7. When x and y are not adjacent in G, they have identical neighborhoods (NG(x) = NG(y)).

    If a = x, neither x nor y is adjacent to x in G (by looplessness and non-adjacency). Similarly, if a = y, neither is adjacent to y. For any other vertex a outside {x, y}, their adjacencies agree by hypothesis htwin. Thus NG(x) = NG(y).

    lines 56–66

      · have hyxadj : ¬ G.Adj y x := fun h => hxyadj h.symm
        have ht : G.neighborSet x = G.neighborSet y := by
          ext a
          change G.Adj x a ↔ G.Adj y a
          by_cases hax : a = x
          · subst a
            simp [hxyadj, hyxadj]
          · by_cases hay : a = y
            · subst a
              simp [hxyadj, hyxadj]
            · exact htwin a hax hay
  8. The induced subgraph G \ {y} is connected.

    Since G is connected and x and y are distinct false twins in G, deleting y preserves connectedness by connected_graph_delete_false_twin_connected.

    line 67

    uses connected_graph_delete_false_twin_connected

        exact connected_graph_delete_false_twin_connected G hconn x y hxy ht
SimpleGraph.deleteEdges_adj.mpr
An edge of G remains present after deleting a set of edges s if that edge is not in s.
Set.mem_singleton_iff
An element belongs to a singleton set {b} if and only if it equals b.
Sym2.eq_iff
Two unordered pairs s(x, y) and s(z, w) are equal if and only if (x = z and y = w) or (x = w and y = z).
SimpleGraph.isBridge_iff
An edge is a bridge if and only if its endpoints are not reachable from each other after deleting that edge.
not_not.mpr
A proposition implies its double negation.
SimpleGraph.deleteEdges_adj
Two vertices are adjacent in G \ s if and only if they are adjacent in G and the edge between them is not in s.
connected_graph_delete_false_twin_connected
Deleting one of two distinct false twins (vertices with identical neighborhoods) from a connected graph preserves connectedness.
SimpleGraph.induce_adj
Two vertices in an induced subgraph are adjacent if and only if they are adjacent in the ambient graph.
And.left
From a conjunction of two propositions, the left conjunct 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

theorem connected_graph_delete_twin_with_common_neighbor_connected {V : Type*} (G : SimpleGraph V)    (hconn : G.Connected) (x y z : V) (hxy : x ≠ y)    (hxz : G.Adj x z) (hyz : G.Adj y z)    (htwin : ∀ a, a ≠ x → a ≠ y → (G.Adj x a ↔ G.Adj y a)) :    (G.induce {a | a ≠ y}).Connected := by  classical  by_cases hxyadj : G.Adj x y  · let F := G.deleteEdges {s(x,y)}    have hz_x : z ≠ x := hxz.ne.symm    have hz_y : z ≠ y := hyz.ne.symm    have hxzF : F.Adj x z := by      apply SimpleGraph.deleteEdges_adj.mpr      refine ⟨hxz, ?_⟩      simp only [Set.mem_singleton_iff, Sym2.eq_iff]      rintro (⟨_, h⟩ | ⟨h, _⟩)      · exact hz_y h      · exact hxy h    have hyzF : F.Adj y z := by      apply SimpleGraph.deleteEdges_adj.mpr      refine ⟨hyz, ?_⟩      simp only [Set.mem_singleton_iff, Sym2.eq_iff]      rintro (⟨h, _⟩ | ⟨_, h⟩)      · exact hxy h.symm      · exact hz_x h    have hr : F.Reachable x y := hxzF.reachable.trans hyzF.symm.reachable    have hfconn : F.Connected := by      exact hconn.connected_delete_edge_of_not_isBridge (x := x) (y := y)        (by rw [SimpleGraph.isBridge_iff]; exact not_not.mpr hr)    have hFtwins : F.neighborSet x = F.neighborSet y := by      ext a      change F.Adj x a ↔ F.Adj y a      by_cases hax : a = x      · subst a        simp [F, SimpleGraph.deleteEdges_adj, Sym2.eq_iff, hxy]      · by_cases hay : a = y        · subst a          simp [F, SimpleGraph.deleteEdges_adj, Sym2.eq_iff, hxy]        · simp only [F, SimpleGraph.deleteEdges_adj, Set.mem_singleton_iff, Sym2.eq_iff]          have hxa : x ≠ a := fun h => hax h.symm          have hya : y ≠ a := fun h => hay h.symm          simp [hxy,hxy.symm,hax,hay,hxa,hya,htwin a hax hay]    have hfdel := connected_graph_delete_false_twin_connected F hfconn x y hxy hFtwins    have heq : F.induce {a | a ≠ y} = G.induce {a | a ≠ y} := by      ext a b      simp only [F, SimpleGraph.induce_adj, SimpleGraph.deleteEdges_adj,        Set.mem_singleton_iff, Sym2.eq_iff]      constructor      · exact And.left      · intro hab        refine ⟨hab, ?_⟩        rintro (⟨_, hb⟩ | ⟨ha, _⟩)        · exact b.property hb        · exact a.property ha    rw [heq] at hfdel    exact hfdel  · have hyxadj : ¬ G.Adj y x := fun h => hxyadj h.symm    have ht : G.neighborSet x = G.neighborSet y := by      ext a      change G.Adj x a ↔ G.Adj y a      by_cases hax : a = x      · subst a        simp [hxyadj, hyxadj]      · by_cases hay : a = y        · subst a          simp [hxyadj, hyxadj]        · exact htwin a hax hay    exact connected_graph_delete_false_twin_connected G hconn x y hxy ht
See it in the graphDiscuss this resultChallenge it