Extract the topological order from successful applications of toposort-aux.
(extract-topological-order seen acc) → nodelist
Function:
(defun extract-topological-order (seen acc) (declare (xargs :guard (cons-listp seen))) (let ((__function__ 'extract-topological-order)) (declare (ignorable __function__)) (cond ((atom seen) acc) ((eq (cdar seen) :finished) (extract-topological-order (cdr seen) (cons (caar seen) acc))) (t (extract-topological-order (cdr seen) acc)))))
Theorem:
(defthm true-listp-of-extract-topological-order (implies (true-listp acc) (true-listp (extract-topological-order seen acc))))
Theorem:
(defthm subsetp-equal-of-extract-topological-order (subsetp-equal (extract-topological-order seen acc) (append (alist-keys seen) acc)))
Now we prove a completeness theorem that shows extract-topological-order will get us at least everything that was in the queue.
Theorem:
(defthm extract-topological-order-includes-queue (implies (and (mv-nth 0 (toposort-aux queue seen graph)) (subsetp-equal queue (alist-keys graph))) (subsetp-equal queue (extract-topological-order (mv-nth 1 (toposort-aux queue seen graph)) nil))))
And a uniqueness theorem that shows the extracted elements are at least duplicate-free.
Theorem:
(defthm no-duplicatesp-equal-of-extract-topological-order (implies (no-duplicatesp-equal (extract-topological-order seen nil)) (no-duplicatesp-equal (extract-topological-order (mv-nth 1 (toposort-aux queue seen graph)) nil))))