Pick a correct validator address, if present, from a set of addresses.
(pick-correct-validator vals systate) → val?
Correct validators are identified via the system state, so we pass a system state to this function. The correct validators are the keys of the map from addresses to validator states, in the system state.
We go through all the addresses in the set,
returning the first one we find that is of a correct validator.
We return
We show that if this function returns an address,
the address is in the input set,
and it is the address of a correct validator.
We show that if this function returns
From the latter fact,
we prove that this function will return an address
if the following conditions are satisfied:
the input set is a subset of a fault-tolerant committee,
and the total stake of validators is more than
A related fact, which we also prove,
is that, if the committee is fault-tolerant and not-empty,
and the validators' total stake is at least the quorum,
then the function will pick a correct validator.
This is a simple consequence of the previous theorem,
given that
Function:
(defun pick-correct-validator (vals systate) (declare (xargs :guard (and (address-setp vals) (system-statep systate)))) (let ((__function__ 'pick-correct-validator)) (declare (ignorable __function__)) (b* (((when (emptyp vals)) nil) (val (head vals)) ((when (in val (correct-addresses systate))) (address-fix val))) (pick-correct-validator (tail vals) systate))))
Theorem:
(defthm address-optionp-of-pick-correct-validator (b* ((val? (pick-correct-validator vals systate))) (address-optionp val?)) :rule-classes :rewrite)
Theorem:
(defthm pick-correct-validator-of-system-state-fix-systate (equal (pick-correct-validator vals (system-state-fix systate)) (pick-correct-validator vals systate)))
Theorem:
(defthm pick-correct-validator-system-state-equiv-congruence-on-systate (implies (system-state-equiv systate systate-equiv) (equal (pick-correct-validator vals systate) (pick-correct-validator vals systate-equiv))) :rule-classes :congruence)
Theorem:
(defthm pick-correct-validator-in-set (implies (pick-correct-validator vals systate) (in (pick-correct-validator vals systate) vals)))
Theorem:
(defthm pick-correct-validator-is-correct (implies (pick-correct-validator vals systate) (in (pick-correct-validator vals systate) (correct-addresses systate))))
Theorem:
(defthm all-faulty-when-not-pick-correct-validator (implies (not (pick-correct-validator vals systate)) (emptyp (intersect vals (correct-addresses systate)))))
Theorem:
(defthm pick-correct-validator-when-fault-tolerant-and-gt-max-faulty (implies (and (address-setp vals) (subset vals (committee-members commtt)) (committee-fault-tolerant-p commtt systate) (> (committee-members-stake vals commtt) (committee-max-faulty-stake commtt))) (pick-correct-validator vals systate)))
Theorem:
(defthm pick-correct-validator-when-fault-tolerant-and-geq-quorum (implies (and (address-setp vals) (subset vals (committee-members commtt)) (committee-fault-tolerant-p commtt systate) (committee-nonemptyp commtt) (>= (committee-members-stake vals commtt) (committee-quorum-stake commtt))) (pick-correct-validator vals systate)))