Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.topological-sort

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/topological_sort.clj1 definitions, 3 theorems

AHoF Topological Sort (Kahn's algorithm): order the vertices of a DAG so every edge points forward -- the canonical dependency/scheduling order. Kahn's method repeatedly emits a vertex whose in-degree has dropped to zero (all its prerequisites are done) and decrements its successors' in-degrees. A vertex is ready to be emitted exactly when its remaining in-degree is zero: ready? in-degree = decide (in-degree <= 0) over exact-rational in-degree counts (in-degree 0 <= 0 iff it is exactly 0). Proved native and axiom-free: the readiness test; that a vertex with no remaining prerequisites is ready; that a vertex with outstanding prerequisites is not ready; and the certificate that a ready vertex's in-degree is at most zero, hence exactly zero (native nnrat/at-most). The adjacency structure and the in-degree decrements are executable; what is proved is the readiness decision. Requires nnrat/at-most, audit/decide-nnrat-at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 3 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.topological-sort` prints this classification.

topological-sort/ready?

DefinitionSource, line 58

topological-sort/ready? :
  (x₁ : ℚ≥0)
  → data/Bool

ℚ≥0 = nnrat/NonnegativeRational

topological-sort/no-prerequisites-ready

TheoremWorked exampleNo axiomsSource, line 69

topological-sort/no-prerequisites-ready :
  → hungarian/tight? 0 = data/true

= = equality/Eq

topological-sort/has-prerequisites-not-ready

TheoremWorked exampleNo axiomsSource, line 76

topological-sort/has-prerequisites-not-ready :
  → hungarian/tight? 2 = data/false

= = equality/Eq

topological-sort/ready-in-degree-zero

TheoremWorked exampleNo axiomsSource, line 83

topological-sort/ready-in-degree-zero :
  → 0 ≤ 0

≤ = nnrat/at-most