Bonded committee at a given round.
(bonded-committee-at-round round blocks all-vals) → commtt?
This is the committee that results from updating the genesis committee with all the transactions up to the latest block not after the round. The previous sentence is approximate, so we need to clarify it. First, the bonded committee at round 1 is certainly the genesis committee. If there is a block at round 2, with transactions that change the committee, we have two choices for the bonded committee at round 2: it could be still the genesis committee, or it could be the new committee after the block; this depends on whether we consider the new committee to be bonded at the beginning or at the end of round 2. The same kind of choice applies to any other even round with a block that changes the committee; on the other hand, it is always clear what the bonded committee at an odd round is, and also at even rounds without blocks or with blocks that do not change the committee.
There seems to be no real criterion to choose between the two options, and it should no matter to correctness, i.e. the protocol should be correct either way. We choose to change committee at the end of the even round. Thus, the bonded committee at round 2 is always the genesis committee, which may change in round 3.
This ACL2 function returns the committee bonded at a given round,
according to the choice explained above,
But note that not every round has a bonded committee:
after a certain round, the bonded committee is unknown,
because there are no blocks yet.
Suppose that the last block is at (even) round
The above also works if we take
So here is how this ACL2 function to calculate the bonded committee works.
First, we calculate the latest round
Since, as explained above, we regard the committe as
changing at the end of the even round of each block,
we need to find the latest block whose round is below
In a well-formed blockchain, the blocks all have even rounds,
and the rounds strictly decrease going from left to right in the list.
In this function we do not have this invariant,
but we do not need that in order to define this function.
Note that the loop terminates regardless of the round numbers.
But in order to understand this function, it is best to think of
the
The role of the
We show that the bonded committee, if calculable,
has members in
Function:
(defun bonded-committee-at-round-loop (round blocks all-vals) (declare (xargs :guard (and (posp round) (block-listp blocks) (address-setp all-vals)))) (let ((__function__ 'bonded-committee-at-round-loop)) (declare (ignorable __function__)) (b* (((when (endp blocks)) (genesis-committee)) ((when (> (pos-fix round) (block->round (car blocks)))) (committee-after-blocks blocks all-vals))) (bonded-committee-at-round-loop round (cdr blocks) all-vals))))
Theorem:
(defthm committeep-of-bonded-committee-at-round-loop (b* ((commtt (bonded-committee-at-round-loop round blocks all-vals))) (committeep commtt)) :rule-classes :rewrite)
Theorem:
(defthm bonded-committee-at-round-loop-when-no-blocks (implies (endp blocks) (equal (bonded-committee-at-round-loop round blocks all-vals) (genesis-committee))))
Theorem:
(defthm bonded-committee-at-round-loop-subset-all-vals (implies (and (address-setp all-vals) (subset (committee-members (genesis-committee)) all-vals)) (b* ((?commtt (bonded-committee-at-round-loop round blocks all-vals))) (subset (committee-members commtt) all-vals))))
Theorem:
(defthm bonded-committee-at-round-loop-of-round-leq-2 (implies (and (blocks-ordered-even-p blocks) (<= (pos-fix round) 2)) (equal (bonded-committee-at-round-loop round blocks all-vals) (genesis-committee))))
Theorem:
(defthm bonded-committee-at-round-loop-of-append-no-change (implies (and (blocks-ordered-even-p (append blocks1 blocks)) (or (endp blocks1) (<= (pos-fix round) (block->round (car (last blocks1)))))) (equal (bonded-committee-at-round-loop round (append blocks1 blocks) all-vals) (bonded-committee-at-round-loop round blocks all-vals))))
Theorem:
(defthm bonded-committee-at-round-loop-of-pos-fix-round (equal (bonded-committee-at-round-loop (pos-fix round) blocks all-vals) (bonded-committee-at-round-loop round blocks all-vals)))
Theorem:
(defthm bonded-committee-at-round-loop-pos-equiv-congruence-on-round (implies (acl2::pos-equiv round round-equiv) (equal (bonded-committee-at-round-loop round blocks all-vals) (bonded-committee-at-round-loop round-equiv blocks all-vals))) :rule-classes :congruence)
Theorem:
(defthm bonded-committee-at-round-loop-of-block-list-fix-blocks (equal (bonded-committee-at-round-loop round (block-list-fix blocks) all-vals) (bonded-committee-at-round-loop round blocks all-vals)))
Theorem:
(defthm bonded-committee-at-round-loop-block-list-equiv-congruence-on-blocks (implies (block-list-equiv blocks blocks-equiv) (equal (bonded-committee-at-round-loop round blocks all-vals) (bonded-committee-at-round-loop round blocks-equiv all-vals))) :rule-classes :congruence)
Theorem:
(defthm bonded-committee-at-round-loop-of-address-set-fix-all-vals (equal (bonded-committee-at-round-loop round blocks (address-set-fix all-vals)) (bonded-committee-at-round-loop round blocks all-vals)))
Theorem:
(defthm bonded-committee-at-round-loop-address-set-equiv-congruence-on-all-vals (implies (address-set-equiv all-vals all-vals-equiv) (equal (bonded-committee-at-round-loop round blocks all-vals) (bonded-committee-at-round-loop round blocks all-vals-equiv))) :rule-classes :congruence)
Function:
(defun bonded-committee-at-round (round blocks all-vals) (declare (xargs :guard (and (posp round) (block-listp blocks) (address-setp all-vals)))) (let ((__function__ 'bonded-committee-at-round)) (declare (ignorable __function__)) (b* (((when (> (pos-fix round) (+ 2 (blocks-last-round blocks)))) nil)) (bonded-committee-at-round-loop round blocks all-vals))))
Theorem:
(defthm committee-optionp-of-bonded-committee-at-round (b* ((commtt? (bonded-committee-at-round round blocks all-vals))) (committee-optionp commtt?)) :rule-classes :rewrite)
Theorem:
(defthm bonded-committee-at-earlier-round-when-at-later-round (implies (and (bonded-committee-at-round later blocks all-vals) (< (pos-fix earlier) (pos-fix later))) (bonded-committee-at-round earlier blocks all-vals)))
Theorem:
(defthm bonded-committee-at-round-when-no-blocks (implies (endp blocks) (b* ((commtt (bonded-committee-at-round round blocks all-vals))) (implies commtt (equal commtt (genesis-committee))))))
Theorem:
(defthm bonded-committee-at-round-subset-all-vals (implies (and (address-setp all-vals) (subset (committee-members (genesis-committee)) all-vals)) (b* ((?commtt? (bonded-committee-at-round round blocks all-vals))) (implies commtt? (subset (committee-members commtt?) all-vals)))))
Theorem:
(defthm bonded-committee-at-round-iff-round-upper-bound (iff (bonded-committee-at-round round blocks all-vals) (<= (pos-fix round) (+ 2 (blocks-last-round blocks)))))
Theorem:
(defthm bonded-committee-at-round-of-round-leq-2 (implies (and (blocks-ordered-even-p blocks) (<= (pos-fix round) 2)) (equal (bonded-committee-at-round round blocks all-vals) (genesis-committee))))
Theorem:
(defthm bonded-committee-at-round-of-append-no-change (implies (and (blocks-ordered-even-p (append blocks1 blocks)) (bonded-committee-at-round round blocks all-vals)) (equal (bonded-committee-at-round round (append blocks1 blocks) all-vals) (bonded-committee-at-round round blocks all-vals))))
Theorem:
(defthm bonded-committee-at-round-of-pos-fix-round (equal (bonded-committee-at-round (pos-fix round) blocks all-vals) (bonded-committee-at-round round blocks all-vals)))
Theorem:
(defthm bonded-committee-at-round-pos-equiv-congruence-on-round (implies (acl2::pos-equiv round round-equiv) (equal (bonded-committee-at-round round blocks all-vals) (bonded-committee-at-round round-equiv blocks all-vals))) :rule-classes :congruence)
Theorem:
(defthm bonded-committee-at-round-of-block-list-fix-blocks (equal (bonded-committee-at-round round (block-list-fix blocks) all-vals) (bonded-committee-at-round round blocks all-vals)))
Theorem:
(defthm bonded-committee-at-round-block-list-equiv-congruence-on-blocks (implies (block-list-equiv blocks blocks-equiv) (equal (bonded-committee-at-round round blocks all-vals) (bonded-committee-at-round round blocks-equiv all-vals))) :rule-classes :congruence)
Theorem:
(defthm bonded-committee-at-round-of-address-set-fix-all-vals (equal (bonded-committee-at-round round blocks (address-set-fix all-vals)) (bonded-committee-at-round round blocks all-vals)))
Theorem:
(defthm bonded-committee-at-round-address-set-equiv-congruence-on-all-vals (implies (address-set-equiv all-vals all-vals-equiv) (equal (bonded-committee-at-round round blocks all-vals) (bonded-committee-at-round round blocks all-vals-equiv))) :rule-classes :congruence)