AFTD Auto-Formalizing Theoretical Domains

anticomplete_neighbor_defect_bound

theoremverified

A vertex anticomplete to a specified block misses at most r of its allowed neighbors when its degree is within r of their total number.

Statement

theorem anticomplete_neighbor_defect_bound
    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) [DecidableRel G.Adj]
    (B : Finset V) (x : V) (hx : x ∉ B)
    (hanti : ∀ b ∈ B, ¬ G.Adj x b) (d r : ℕ)
    (hsize : Fintype.card V = B.card + d + 1)
    (hdegree : d ≤ (G.neighborFinset x).card + r) :
    (((Finset.univ \ B).erase x) \ G.neighborFinset x).card ≤ r
Source
OP-1957: degree and incidence bounds for the size-five block route.
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 23

The proof, explained

Because vertex x has no neighbors in B and cannot be adjacent to itself, all of its neighbors must lie in the candidate set (V \ B) \ {x}. The total number of vertices is |B| + d + 1, so after excluding the |B| vertices of B and x itself, exactly d candidates remain. The number of allowed neighbors missed by x is therefore d - deg(x), which is at most r thanks to the degree bound d ≤ deg(x) + r.

  1. Every neighbor of x belongs to the candidate set (V \ B) \ {x}.

    Let y be any neighbor of x, so x and y are adjacent by G.mem_neighborFinset. Because the graph G is simple, adjacency is irreflexive, meaning y ≠ x. Furthermore, since x is anticomplete to B, y cannot belong to B, as that would contradict the non-adjacency of x to every vertex of B. Rewriting the membership condition for (univ \ B).erase x using Finset.mem_erase, Finset.mem_sdiff, Finset.mem_univ, and true_and reduces the goal to showing y ≠ x and y ∉ B, which both hold.

    lines 8–13

    uses G.mem_neighborFinset, Finset.mem_erase, Finset.mem_sdiff, Finset.mem_univ, true_and

      classical
      have hsub : G.neighborFinset x ⊆ (Finset.univ \ B).erase x := by
        intro y hy
        have hxy : G.Adj x y := (G.mem_neighborFinset x y).mp hy
        simp only [Finset.mem_erase, Finset.mem_sdiff, Finset.mem_univ, true_and]
        exact ⟨hxy.ne.symm, fun hyB => hanti y hyB hxy⟩
  2. The set (V \ B) \ {x} of allowed non-B neighbors has cardinality d.

    Since x ∉ B, x belongs to the complement V \ B (line 14). Since B is a subset of V (Finset.subset_univ), the cardinality of V \ B is |V| - |B| by Finset.card_sdiff_of_subset and Finset.card_univ; given that |V| = |B| + d + 1, linear arithmetic gives |V \ B| = d + 1 (lines 15–17). Finally, removing x from V \ B decreases its size by 1 (Finset.card_erase_of_mem), leaving exactly (d + 1) - 1 = d elements (lines 18–20).

    lines 14–20

    uses Finset.card_sdiff_of_subset, Finset.subset_univ, Finset.card_univ, Finset.card_erase_of_mem

      have hxmem : x ∈ (Finset.univ : Finset V) \ B := by simp [hx]
      have hbase : ((Finset.univ : Finset V) \ B).card = d+1 := by
        rw [Finset.card_sdiff_of_subset (Finset.subset_univ B), Finset.card_univ]
        omega
      have hcard : ((Finset.univ \ B).erase x).card = d := by
        rw [Finset.card_erase_of_mem hxmem, hbase]
        omega
  3. The number of allowed neighbors not connected to x is at most r.

    Because the neighborhood of x is a subset of (V \ B) \ {x}, the cardinality of their set difference is |(V \ B) \ {x}| - |N(x)| by Finset.card_sdiff_of_subset. Substituting |(V \ B) \ {x}| = d, this defect is d - |N(x)|. By the assumption that d ≤ |N(x)| + r, linear arithmetic (omega) concludes that d - |N(x)| ≤ r.

    lines 21–22

    uses Finset.card_sdiff_of_subset

      rw [Finset.card_sdiff_of_subset hsub, hcard]
      omega
G.mem_neighborFinset
A vertex belongs to the neighborhood finset of a vertex v if and only if they are adjacent in the graph.
Finset.mem_erase
An element belongs to s.erase b if and only if it is distinct from b and belongs to s.
Finset.mem_sdiff
An element belongs to the set difference s \ t if and only if it belongs to s and not to t.
Finset.mem_univ
Every element of a finite type belongs to the universal finset.
true_and
The conjunction of True and p simplifies to p.
Finset.card_sdiff_of_subset
If s ⊆ t, then the cardinality of t \ s equals the cardinality of t minus the cardinality of s.
Finset.subset_univ
Every finset of elements of a finite type is a subset of the universal finset.
Finset.card_univ
The cardinality of the universal finset of a type equals the cardinality of the type.
Finset.card_erase_of_mem
Removing an element from a finset that contains it decreases its cardinality by 1.

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 anticomplete_neighbor_defect_bound    {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) [DecidableRel G.Adj]    (B : Finset V) (x : V) (hx : x ∉ B)    (hanti : ∀ b ∈ B, ¬ G.Adj x b) (d r : ℕ)    (hsize : Fintype.card V = B.card + d + 1)    (hdegree : d ≤ (G.neighborFinset x).card + r) :    (((Finset.univ \ B).erase x) \ G.neighborFinset x).card ≤ r := by  classical  have hsub : G.neighborFinset x ⊆ (Finset.univ \ B).erase x := by    intro y hy    have hxy : G.Adj x y := (G.mem_neighborFinset x y).mp hy    simp only [Finset.mem_erase, Finset.mem_sdiff, Finset.mem_univ, true_and]    exact ⟨hxy.ne.symm, fun hyB => hanti y hyB hxy⟩  have hxmem : x ∈ (Finset.univ : Finset V) \ B := by simp [hx]  have hbase : ((Finset.univ : Finset V) \ B).card = d+1 := by    rw [Finset.card_sdiff_of_subset (Finset.subset_univ B), Finset.card_univ]    omega  have hcard : ((Finset.univ \ B).erase x).card = d := by    rw [Finset.card_erase_of_mem hxmem, hbase]    omega  rw [Finset.card_sdiff_of_subset hsub, hcard]  omega
See it in the graphDiscuss this resultChallenge it