Retrieve, from a set of certificates, a certificate with a given author and round.
(certificate-with-author+round author round certs) → cert?
If there is no certificate with the given author and round,
If there is a certificate with the given author and round, the first one found is returned, according to the total ordering of the set. However, when a certificate set is unequivocal, i.e. it has unique author-round combinations, the first certificate found is the only one.
Function:
(defun certificate-with-author+round (author round certs) (declare (xargs :guard (and (addressp author) (posp round) (certificate-setp certs)))) (let ((__function__ 'certificate-with-author+round)) (declare (ignorable __function__)) (b* (((when (emptyp certs)) nil) ((certificate cert) (head certs)) ((when (and (equal author cert.author) (equal round cert.round))) (certificate-fix cert))) (certificate-with-author+round author round (tail certs)))))
Theorem:
(defthm certificate-optionp-of-certificate-with-author+round (b* ((cert? (certificate-with-author+round author round certs))) (certificate-optionp cert?)) :rule-classes :rewrite)
Theorem:
(defthm certificate->author-of-certificate-with-author+round (b* ((?cert? (certificate-with-author+round author round certs))) (implies cert? (equal (certificate->author cert?) (address-fix author)))))
Theorem:
(defthm certificate->round-of-certificate-with-author+round (b* ((?cert? (certificate-with-author+round author round certs))) (implies cert? (equal (certificate->round cert?) (pos-fix round)))))
Theorem:
(defthm certificate-with-author+round-element (implies (and (certificate-setp certs) (certificate-with-author+round author round certs)) (in (certificate-with-author+round author round certs) certs)))
Theorem:
(defthm certificate-with-author+round-when-element (implies (and (in cert certs) (equal (certificate->author cert) author) (equal (certificate->round cert) round)) (certificate-with-author+round author round certs)))
Theorem:
(defthm certificate-with-author+round-when-subset (implies (and (certificate-with-author+round author round certs0) (subset certs0 certs)) (certificate-with-author+round author round certs)))
Theorem:
(defthm certificate-with-author+round-of-insert-iff (iff (certificate-with-author+round author round (insert cert certs)) (or (and (equal (certificate->author cert) author) (equal (certificate->round cert) round)) (certificate-with-author+round author round certs))))
Theorem:
(defthm certificate-with-author+round-of-union-iff (implies (certificate-setp certs2) (iff (certificate-with-author+round author round (union certs1 certs2)) (or (certificate-with-author+round author round certs1) (certificate-with-author+round author round certs2)))))
Theorem:
(defthm certificate-with-author+round-when-delete (implies (certificate-with-author+round author round (delete cert certs)) (certificate-with-author+round author round certs)))
Theorem:
(defthm certificate-with-author+round-of-delete (implies (and (certificate-with-author+round author round certs) (or (not (equal (certificate->author cert) author)) (not (equal (certificate->round cert) round)))) (certificate-with-author+round author round (delete cert certs))))