AFTD Auto-Formalizing Theoretical Domains

retained_line_component_count_le_left_roots

theoremverified

For a simple graph on the first n linearly ordered vertices, the number of connected components is at most the number of vertices with no adjacent vertex to their left.

Statement

theorem retained_line_component_count_le_left_roots {n : ℕ} (G : SimpleGraph (Fin n)) :
    Nat.card G.ConnectedComponent ≤
      {v : Fin n | ∀ w : Fin n, w < v → ¬ G.Adj v w}.ncard
Source
OP-815: deterministic component-count bound needed for a uniform tail estimate.
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
Used by 1

The proof, explained

Every connected component of the graph has a minimum vertex under the standard linear order on Fin n. Because it is minimal in its component, this vertex cannot be adjacent to any strictly smaller vertex, so it belongs to the set S of left-roots. Mapping each left-root to its connected component yields a surjective function, which implies that the number of connected components is at most the number of left-roots.

  1. Let S be the set of vertices with no adjacent vertex to their left.

    We enable classical reasoning and define S ⊆ Fin n as the set of vertices v such that no strictly smaller vertex w < v is adjacent to v.

    lines 4–5

      classical
      let S := {v : Fin n | ∀ w : Fin n, w < v → ¬ G.Adj v w}
  2. For any connected component c, let v be the minimum vertex in c.

    To show that the map sending a vertex in S to its connected component is surjective, consider an arbitrary component c. Converting its support to a finset F, which is nonempty because every component is nonempty, we let v be the minimum element of F with respect to the linear order on Fin n; by definition v belongs to c.

    lines 6–13

      have surj : Function.Surjective (fun v : S => G.connectedComponentMk v.1) := by
        intro c
        let F := c.supp.toFinset
        have ne : F.Nonempty := by
          simpa [F] using c.nonempty_supp
        let v := F.min' ne
        have hv : v ∈ c.supp := by
          simpa [F, v] using F.min'_mem ne
  3. The minimum vertex v has no smaller neighbor, hence v ∈ S.

    Suppose for contradiction that some w < v is adjacent to v. Since adjacency preserves component membership, w also belongs to c and thus to F. But v is the minimum of F, so v ≤ w, which contradicts w < v by not_lt_of_ge.

    lines 14–19

    uses not_lt_of_ge

        have root : v ∈ S := by
          intro w hw hadj
          have hwc : w ∈ c.supp := (c.mem_supp_congr_adj hadj).mp hv
          have hwF : w ∈ F := by simpa [F] using hwc
          have hmin : v ≤ w := F.min'_le w hwF
          exact (not_lt_of_ge hmin) hw
  4. The canonical map sending each vertex in S to its connected component is surjective.

    The element v ∈ S belongs to the component c, which definitionally means that the component of v is c. Thus v serves as a preimage for c.

    line 20

        exact ⟨⟨v, root⟩, hv⟩
  5. The number of connected components is at most the cardinality of S.

    Applying Nat.card_le_card_of_surjective to the surjective component map shows that the number of connected components is at most the cardinality of S, which matches the definition of the set's counting measure.

    lines 21–23

    uses Nat.card_le_card_of_surjective

      have hcard := Nat.card_le_card_of_surjective (fun v : S => G.connectedComponentMk v.1) surj
      change Nat.card G.ConnectedComponent ≤ Nat.card S
      exact hcard
not_lt_of_ge
In a preorder, if a ≤ b then b is not strictly less than a.
Nat.card_le_card_of_surjective
If a function between types is surjective and the domain is finite, the cardinality of the codomain is at most the cardinality of the domain.

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 retained_line_component_count_le_left_roots {n : ℕ} (G : SimpleGraph (Fin n)) :    Nat.card G.ConnectedComponent ≤      {v : Fin n | ∀ w : Fin n, w < v → ¬ G.Adj v w}.ncard := by  classical  let S := {v : Fin n | ∀ w : Fin n, w < v → ¬ G.Adj v w}  have surj : Function.Surjective (fun v : S => G.connectedComponentMk v.1) := by    intro c    let F := c.supp.toFinset    have ne : F.Nonempty := by      simpa [F] using c.nonempty_supp    let v := F.min' ne    have hv : v ∈ c.supp := by      simpa [F, v] using F.min'_mem ne    have root : v ∈ S := by      intro w hw hadj      have hwc : w ∈ c.supp := (c.mem_supp_congr_adj hadj).mp hv      have hwF : w ∈ F := by simpa [F] using hwc      have hmin : v ≤ w := F.min'_le w hwF      exact (not_lt_of_ge hmin) hw    exact ⟨⟨v, root⟩, hv⟩  have hcard := Nat.card_le_card_of_surjective (fun v : S => G.connectedComponentMk v.1) surj  change Nat.card G.ConnectedComponent ≤ Nat.card S  exact hcard
See it in the graphDiscuss this resultChallenge it