Finite ordered DFS executions satisfy the local forest invariants
ProvedCLRS.DFS.local_certificate_of_executionLet be a finite directed multigraph with vertices, allowing parallel adjacency occurrences and self-loops. Let be a permutation of its vertices, and suppose the supplied sequence agrees with on its first entries. Start recursive ordered DFS with white colors, zero timestamps and counters, and parent, finish-order and tree-label entries.
For every finite execution of the complete outer loop ending in state , the parent array , discovery times , finish times , finish-order sequence , and tree labels satisfy
The certificate asserts positive distinct timestamps within , distinct discovery and finish events, and disjoint or nested vertex intervals. A nonroot parent is adjacent to its child and is the nearest strict enclosing interval. Every edge target is discovered before its source finishes. Root discoveries respect the supplied input priority, and the finish-order prefix is a vertex permutation in strictly increasing finish time.
Labels lie in , every label occurs, parent links preserve labels, and labels order roots in discovery order. This is the invariant-preservation part of DFS correctness. It assumes a finite execution and makes no assertion that such an execution exists or that it meets an event budget; termination and accounting can be established independently.
import Definitions.Def_CLRS_DFS_PureExecution set_option autoImplicit false open Algo2LeanGenerated CLRS.GraphTraversal CLRS.DFS CLRS.DFS.Pure
theorem CLRS.DFS.local_certificate_of_execution (g : Graph) (input : Seq) (values : List Int)
(permutation : values.Perm ((List.range g.size).map Int.ofNat))
(observed : ∀ i : Nat, i < g.size → input i = values[i]!)
(a : Pure.State) (k : Nat) (execution : Eval g (.roots values) initial a k) :
LocalCertificate g input (a.arrays 1) (a.arrays 2) (a.arrays 3)
(a.arrays 4) (a.arrays 5) a.count.toNat := by sorry