• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
          • Omaps
          • Std/alists
          • Fast-alists
          • Alistp
          • Misc/records
          • Remove-assocs
          • Assoc
          • Symbol-alistp
          • Rassoc
          • Remove-assoc
          • Remove1-assoc
          • Alist-map-vals
          • Depgraph
            • Toposort
            • Transdeps
            • Invert
            • Mergesort-alist-values
            • Alist-values-are-sets-p
            • Topologically-ordered-p
              • Topologically-ordered-p-aux
            • Dependency-chain-p
          • Alist-map-keys
          • Put-assoc
          • Strip-cars
          • Pairlis$
          • Strip-cdrs
          • Sublis
          • Acons
          • Eqlable-alistp
          • Assoc-string-equal
          • Alist-to-doublets
          • Character-alistp
          • String-alistp
          • Alist-keys-subsetp
          • R-symbol-alistp
          • R-eqlable-alistp
          • Pairlis
          • Pairlis-x2
          • Pairlis-x1
          • Delete-assoc
        • Set-register-invariant-risk
        • Strings
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Oracle-eval
        • Defmacro-untouchable
        • <<
        • Primitive
        • Revert-world
        • Unmemoize
        • Set-duplicate-keys-action
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Fake-oracle-eval
        • Defopen
        • Sleep
      • Operational-semantics
      • Real
      • Start-here
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Depgraph

Topologically-ordered-p

(topologically-ordered-p nodes graph) determines if a list of nodes is topologically ordered with respect to a graph.

Signature
(topologically-ordered-p nodes graph) → ordered-p
Arguments
nodes — List of nodes to check.
graph — Alist that binds nodes to their dependents.

We check that, for every node a in the list of nodes, the dependents of a come before a.

This is a weak check in a couple of ways: we don't require that the nodes are unique, and we don't check that every node in the graph is among the nodes.

We can determine if the nodes are topologically sorted in linear time, assuming constant-time hashing.

Definitions and Theorems

Function: topologically-ordered-p

(defun topologically-ordered-p (nodes graph)
  (declare (xargs :guard t))
  (let ((__function__ 'topologically-ordered-p))
    (declare (ignorable __function__))
    (b* ((seen (len nodes))
         ((mv ans seen)
          (topologically-ordered-p-aux nodes graph seen)))
      (fast-alist-free seen)
      ans)))

Subtopics

Topologically-ordered-p-aux