Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Ordered DFS execution with local timestamp and label invariants

Proved
CLRS.DFS.ordered_local_certificate

by fizzyinc3 · Oct 17, 2026 · Mathlib 0df444a (Lean v4.33.1)

algo2leanalgorithmsclrsdfsgraph-theoryrunning-time

Let GGG be a represented finite directed multigraph, with nnn vertices and mmm adjacency occurrences, in an arbitrary initial heap. Let an allocated input sequence have a vertex permutation in its first nnn entries. The generated ordered recursive DFS has a completed call, valid under every suspended caller stack, returning a fresh result object and six distinct fresh arrays. All initial sequences, objects, and collections are preserved, allocation counters and the work clock do not decrease, and other clocks are unchanged. The completed call satisfies

T≤4+6n+2m.T\le4+6n+2m.T≤4+6n+2m.

Its returned colors are black, its event clock and finish count are 2n2n2n and nnn, and its tree count is at most nnn. Its parent, discovery, finish, increasing-finish order, and tree-label arrays satisfy the local certificate: distinct valid event times with nested or disjoint intervals; parent edges and strictly containing parent intervals; the nearest-enclosing-parent condition; discovery of every edge target before its source finishes; root priority; increasing permutation of finish times; dense bounded labels inherited across parent links; and label order agreeing with discovery order at roots.

The certificate contains no parent-path or white-path equivalence and no common-root characterization of equal labels. These global properties can be established separately from the local invariants. The empty graph, duplicated adjacency occurrences, self-loops, aliasing among input rows, and arbitrary initial clocks are included.

Preamble
import Definitions.Def_CLRS_DFS_LocalCertificate

set_option autoImplicit false
open Algo2LeanGenerated CLRS.GraphTraversal CLRS.DFS

Formal statement
theorem CLRS.DFS.ordered_local_certificate
    (before : Heap) (graph : ObjectRef) (g : Graph) (inputOrder : SeqRef)
    (represented : GraphRep before graph g)
    (orderAllocated : inputOrder < before.nextRef)
    (orderValid : VertexOrder g (before.read inputOrder)) :
    ∃ (after : Heap) (result : ObjectRef),
      Algo.dfs.dfs_ordered.Call before (graph, inputOrder) after result ∧
      LocalPost before after result g (before.read inputOrder) ∧
      work before after ≤ 4 + 6 * g.size + 2 * edgeCount g := by sorry
Source
CLRS, Introduction to Algorithms, fourth edition, Section 20.3, DFS and DFS-VISIT, Theorems 20.7 and 20.9; local operational sublemma for the existing ordered DFS milestone. Supporting exposition: Jessica Su, Stanford CS 161 Lecture 10, Sections 2.1–2.4, PDF pages 5–9, https://web.stanford.edu/class/archive/cs/cs161/cs161.1168/lecture10-draft.pdf . Generated transitions are Definitions.Def_CLRS_DFS_Program on Prove2Me.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me