AFTD Auto-Formalizing Theoretical Domains

odd_components_split_for_positive_barrier

theoremverified

Let a finite graph have at least s odd connected components, where s is positive. Either s is one and the vertex count is odd, or the vertices split into two nonempty anticomplete sets with the second set containing at least s−1 vertices.

Statement

theorem odd_components_split_for_positive_barrier
    {V : Type*} [Fintype V] [DecidableEq V] (H : SimpleGraph V)
    (s : ℕ) (hs : 1 ≤ s) (hodd : s ≤ H.oddComponents.ncard) :
    (s=1 ∧ Odd (Fintype.card V)) ∨
      ∃ Z W : Finset V, Z.Nonempty ∧ W.Nonempty ∧ Disjoint Z W ∧
        Z ∪ W = Finset.univ ∧ s ≤ W.card+1 ∧
        (∀ z ∈ Z, ∀ w ∈ W, ¬ H.Adj z w)
Source
OP-1957: split the extra barrier vertices into one odd component and the remaining components.
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

The proof, explained

We split into cases based on whether $s = 1$ and the graph has an odd number of vertices; if so, the first alternative holds directly. Otherwise, parity conservation between odd components and vertices ensures that the graph has at least two odd components. We isolate one odd component $c$, taking $Z$ to be its vertices and $W$ to be the remaining vertices. Selecting a vertex from each of the other odd components defines an injective map into $W$, which implies that $|W| \ge s - 1$. Finally, $Z$ and $W$ partition the vertex set and are anticomplete because edges cannot cross between different connected components.

  1. If $s = 1$ and $|V|$ is odd, the theorem holds immediately.

    We branch on whether $s = 1$ and the vertex set $V$ has odd cardinality. In this case, the first alternative of the disjunction holds directly via `Or.inl`.

    lines 8–10

    uses Or.inl

      classical
      by_cases hfirst : s=1 ∧ Odd (Fintype.card V)
      · exact Or.inl hfirst
  2. In the remaining case, the graph $H$ has at least 2 odd connected components.

    Assuming the first case fails, we proceed with the second alternative. For contradiction, suppose $H$ has fewer than 2 odd components. Since $1 \le s \le |\mathrm{oddComponents}|$, the count of odd components must be exactly 1, which implies $s = 1$. Furthermore, the number of odd components of a finite graph has the same parity as its total number of vertices, so $|V|$ is odd. This yields $s = 1$ and $|V|$ is odd, contradicting our case assumption.

    lines 11–19

    uses Nat.card_eq_fintype_card

      · right
        have hcount : 2 ≤ H.oddComponents.ncard := by
          by_contra h
          have heq : H.oddComponents.ncard=1 := by omega
          have ho : Odd H.oddComponents.ncard := by rw [heq]; decide
          have hv : Odd (Fintype.card V) := by
            have := (H.odd_ncard_oddComponents.mp ho)
            simpa [Nat.card_eq_fintype_card] using this
          exact hfirst ⟨by omega, hv⟩
  3. There exists an odd component $c$, and the remaining odd components $A = \mathrm{oddComponents} \setminus \{c\}$ satisfy $|A| + 1 = |\mathrm{oddComponents}|$.

    Because $H$ has at least 2 odd components (hence strictly positive), the set of odd components is nonempty by `Set.ncard_pos` and `Set.toFinite`, so we choose an odd component $c$. Removing $\{c\}$ leaves the set $A = \mathrm{oddComponents} \setminus \{c\}$, whose cardinality satisfies $|A| + 1 = |\mathrm{oddComponents}|$ by `Set.ncard_sdiff_singleton_add_one`.

    lines 20–24

    uses Set.ncard_pos, Set.toFinite, Set.ncard_sdiff_singleton_add_one

        have hpos : 0 < H.oddComponents.ncard := by omega
        obtain ⟨c,hc⟩ := (Set.ncard_pos (Set.toFinite _)).mp hpos
        let A : Set H.ConnectedComponent := H.oddComponents \ {c}
        have hA : A.ncard+1 = H.oddComponents.ncard := by
          exact Set.ncard_sdiff_singleton_add_one hc
  4. We define $Z$ as the vertex set of $c$ and $W$ as its complement in $V$, where $Z$ is nonempty.

    We define $Z$ to be the support (vertex set) of component $c$, and $W = V \setminus Z$ to be its complement in the full vertex set. Since every connected component is nonempty, $Z$ is nonempty.

    lines 25–27

        let Z : Finset V := c.supp.toFinset
        let W : Finset V := Finset.univ \ Z
        have hZ : Z.Nonempty := by simpa [Z] using c.nonempty_supp
  5. For each remaining odd component $d \in A$, choosing a vertex $f(d)$ in its support yields a vertex in $W$.

    Each component $d \in A$ has a nonempty vertex set, so using `Classical.choose` we select a vertex $f(d) \in d$. If $f(d)$ were in $Z$, its connected component would be $c$ by `SimpleGraph.ConnectedComponent.mem_supp_iff`. But its connected component is $d$ by `Classical.choose_spec`, and $d \ne c$ since $d \in A$. This contradiction shows $f(d) \notin Z$, so $f(d) \in W$.

    lines 28–40

    uses Classical.choose, Classical.choose_spec, SimpleGraph.ConnectedComponent.mem_supp_iff

        let f (d : A) : V := Classical.choose d.val.nonempty_supp
        have hf (d : A) : f d ∈ d.val.supp := Classical.choose_spec d.val.nonempty_supp
        have hfW (d : A) : f d ∈ W := by
          simp only [W, Finset.mem_sdiff, Finset.mem_univ, true_and, Z, Set.mem_toFinset]
          intro hv
          have h1 : H.connectedComponentMk (f d) = c := by
            simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hv
          have h2 : H.connectedComponentMk (f d) = d.val := by
            simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hf d
          have hdc : d.val ≠ c := by
            have := d.property.2
            simpa using this
          exact hdc (h2.symm.trans h1)
  6. The assignment $f_W : A \to W$ mapping each component $d \in A$ to $f(d)$ is injective.

    Suppose $f_W(d) = f_W(e)$. Applying `congrArg` to the underlying vertices gives $f(d) = f(e)$. By `SimpleGraph.ConnectedComponent.mem_supp_iff`, taking the connected component of each side recovers $d$ and $e$, so $d = e$, and `Subtype.ext` establishes equality in $A$.

    lines 41–50

    uses congrArg, SimpleGraph.ConnectedComponent.mem_supp_iff, Subtype.ext

        let fW : A → {v : V // v ∈ W} := fun d => ⟨f d,hfW d⟩
        have hinj : Function.Injective fW := by
          intro d e hde
          have hval : f d = f e := congrArg Subtype.val hde
          have hd : H.connectedComponentMk (f d) = d.val := by
            simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hf d
          have he : H.connectedComponentMk (f e) = e.val := by
            simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hf e
          apply Subtype.ext
          exact hd.symm.trans ((congrArg H.connectedComponentMk hval).trans he)
  7. The set $W$ has cardinality at least $|A|$ (so $|A| \le |W|$), and $W$ is nonempty.

    The injective function $f_W : A \to W$ yields $|A| \le |W|$ via `Nat.card_le_card_of_injective` and `Nat.card_coe_set_eq`. Since the number of odd components is at least 2, we have $|A| = |\mathrm{oddComponents}| - 1 \ge 1$, which forces $|W| \ge 1 > 0$, so $W$ is nonempty by `Finset.card_pos.mp`.

    lines 51–56

    uses Nat.card_le_card_of_injective, Nat.card_coe_set_eq, Finset.card_pos.mp

        have hle : A.ncard ≤ W.card := by
          have h := Nat.card_le_card_of_injective fW hinj
          simpa [Nat.card_coe_set_eq] using h
        have hW : W.Nonempty := by
          apply Finset.card_pos.mp
          omega
  8. The sets $Z$ and $W$ form the desired partition: they are disjoint, cover $V$, satisfy $s \le |W| + 1$, and are anticomplete.

    We check the four properties: disjointness of $Z$ and $W$ holds by `Finset.disjoint_left.mpr` and `Finset.mem_sdiff.mp` since $W = V \setminus Z$; their union is all of $V$ by definition; linear arithmetic gives $s \le |W| + 1$ from $s \le |\mathrm{oddComponents}| = |A| + 1 \le |W| + 1$; and no edge connects $z \in Z$ to $w \in W$ because adjacency preserves connected components, so $z \in c$ would force $w \in c$, contradicting $w \in W$.

    lines 57–66

    uses Finset.disjoint_left.mpr, Finset.mem_sdiff.mp

        refine ⟨Z,W,hZ,hW,?_,?_,?_,?_⟩
        · apply Finset.disjoint_left.mpr
          intro v hv hw
          exact (Finset.mem_sdiff.mp hw).2 hv
        · simp [W]
        · omega
        · intro z hz w hw hzw
          have hzc : z ∈ c.supp := by simpa [Z] using hz
          have hwc : w ∉ c.supp := by simpa [W,Z] using hw
          exact hwc ((c.mem_supp_congr_adj hzw).mp hzc)
Or.inl
From a proof of $A$, concludes $A \lor B$.
Nat.card_eq_fintype_card
For a finite type $\alpha$, the general cardinality `Nat.card α` equals `Fintype.card α`.
Set.ncard_pos
A finite set has strictly positive cardinality if and only if it is nonempty.
Set.toFinite
Any subset of a finite type is finite.
Set.ncard_sdiff_singleton_add_one
Removing an element from a finite set decreases its cardinality by 1: $|s \setminus \{a\}| + 1 = |s|$ when $a \in s$.
Classical.choose
Given an existential assertion $\exists x, P(x)$, returns a canonical witness $x$.
Classical.choose_spec
The witness chosen by `Classical.choose` satisfies the predicate $P$.
SimpleGraph.ConnectedComponent.mem_supp_iff
A vertex $v$ belongs to the vertex set of a component $C$ if and only if the component containing $v$ is $C$.
congrArg
If $x = y$, then $f(x) = f(y)$.
Subtype.ext
Two elements of a subtype are equal if their underlying values are equal.
Nat.card_le_card_of_injective
An injective map from a type into a finite type implies the domain has cardinality at most the codomain.
Nat.card_coe_set_eq
The cardinality of a coerced subtype `Nat.card ↑s` equals the set cardinality `s.ncard`.
Finset.card_pos.mp
If a finite set has cardinality strictly greater than 0, then it is nonempty.
Finset.disjoint_left.mpr
Two finite sets are disjoint if no element of the first belongs to the second.
Finset.mem_sdiff.mp
If an element belongs to the set difference $s \setminus t$, then it belongs to $s$ and not to $t$.

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 odd_components_split_for_positive_barrier    {V : Type*} [Fintype V] [DecidableEq V] (H : SimpleGraph V)    (s : ℕ) (hs : 1 ≤ s) (hodd : s ≤ H.oddComponents.ncard) :    (s=1 ∧ Odd (Fintype.card V)) ∨      ∃ Z W : Finset V, Z.Nonempty ∧ W.Nonempty ∧ Disjoint Z W ∧        Z ∪ W = Finset.univ ∧ s ≤ W.card+1 ∧        (∀ z ∈ Z, ∀ w ∈ W, ¬ H.Adj z w) := by  classical  by_cases hfirst : s=1 ∧ Odd (Fintype.card V)  · exact Or.inl hfirst  · right    have hcount : 2 ≤ H.oddComponents.ncard := by      by_contra h      have heq : H.oddComponents.ncard=1 := by omega      have ho : Odd H.oddComponents.ncard := by rw [heq]; decide      have hv : Odd (Fintype.card V) := by        have := (H.odd_ncard_oddComponents.mp ho)        simpa [Nat.card_eq_fintype_card] using this      exact hfirst ⟨by omega, hv⟩    have hpos : 0 < H.oddComponents.ncard := by omega    obtain ⟨c,hc⟩ := (Set.ncard_pos (Set.toFinite _)).mp hpos    let A : Set H.ConnectedComponent := H.oddComponents \ {c}    have hA : A.ncard+1 = H.oddComponents.ncard := by      exact Set.ncard_sdiff_singleton_add_one hc    let Z : Finset V := c.supp.toFinset    let W : Finset V := Finset.univ \ Z    have hZ : Z.Nonempty := by simpa [Z] using c.nonempty_supp    let f (d : A) : V := Classical.choose d.val.nonempty_supp    have hf (d : A) : f d ∈ d.val.supp := Classical.choose_spec d.val.nonempty_supp    have hfW (d : A) : f d ∈ W := by      simp only [W, Finset.mem_sdiff, Finset.mem_univ, true_and, Z, Set.mem_toFinset]      intro hv      have h1 : H.connectedComponentMk (f d) = c := by        simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hv      have h2 : H.connectedComponentMk (f d) = d.val := by        simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hf d      have hdc : d.val ≠ c := by        have := d.property.2        simpa using this      exact hdc (h2.symm.trans h1)    let fW : A → {v : V // v ∈ W} := fun d => ⟨f d,hfW d⟩    have hinj : Function.Injective fW := by      intro d e hde      have hval : f d = f e := congrArg Subtype.val hde      have hd : H.connectedComponentMk (f d) = d.val := by        simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hf d      have he : H.connectedComponentMk (f e) = e.val := by        simpa [SimpleGraph.ConnectedComponent.mem_supp_iff] using hf e      apply Subtype.ext      exact hd.symm.trans ((congrArg H.connectedComponentMk hval).trans he)    have hle : A.ncard ≤ W.card := by      have h := Nat.card_le_card_of_injective fW hinj      simpa [Nat.card_coe_set_eq] using h    have hW : W.Nonempty := by      apply Finset.card_pos.mp      omega    refine ⟨Z,W,hZ,hW,?_,?_,?_,?_⟩    · apply Finset.disjoint_left.mpr      intro v hv hw      exact (Finset.mem_sdiff.mp hw).2 hv    · simp [W]    · omega    · intro z hz w hw hzw      have hzc : z ∈ c.supp := by simpa [Z] using hz      have hwc : w ∉ c.supp := by simpa [W,Z] using hw      exact hwc ((c.mem_supp_congr_adj hzw).mp hzc)
See it in the graphDiscuss this resultChallenge it