Collect all the anchor certificates to commit.
(collect-anchors current-anchor previous-round last-committed-round dag vals) → anchors
The starting point is an anchor,
Note that the last committed round is a natural number, not necessarily a positive one, because it is initially 0. Since the previous round eventually reaches the last committed round (at the end of the recursion), the previous round input of this ACL2 function is also a natural number, not necessarily positive.
Function:
(defun collect-anchors (current-anchor previous-round last-committed-round dag vals) (declare (xargs :guard (and (certificatep current-anchor) (natp previous-round) (natp last-committed-round) (certificate-setp dag) (address-setp vals)))) (declare (xargs :guard (and (evenp previous-round) (> (certificate->round current-anchor) previous-round) (not (emptyp vals))))) (let ((__function__ 'collect-anchors)) (declare (ignorable __function__)) (b* (((unless (and (mbt (and (natp previous-round) (evenp previous-round) (natp last-committed-round))) (> previous-round last-committed-round))) (list (certificate-fix current-anchor))) (previous-leader (leader-at-round previous-round vals)) (previous-anchor? (path-to-author+round current-anchor previous-leader previous-round dag))) (if previous-anchor? (cons (certificate-fix current-anchor) (collect-anchors previous-anchor? (- previous-round 2) last-committed-round dag vals)) (collect-anchors current-anchor (- previous-round 2) last-committed-round dag vals)))))
Theorem:
(defthm certificate-listp-of-collect-anchors (b* ((anchors (collect-anchors current-anchor previous-round last-committed-round dag vals))) (certificate-listp anchors)) :rule-classes :rewrite)
Theorem:
(defthm car-of-collect-anchors (equal (car (collect-anchors current-anchor previous-round last-committed-round dag vals)) (certificate-fix current-anchor)))