Retrieve, from a set of certificates, a certificate with a given author and round.
(cert-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 cert-with-author+round (author round certs) (declare (xargs :guard (and (addressp author) (posp round) (certificate-setp certs)))) (let ((__function__ 'cert-with-author+round)) (declare (ignorable __function__)) (b* (((when (emptyp certs)) nil) ((certificate cert) (head certs)) ((when (and (equal (address-fix author) cert.author) (equal (pos-fix round) cert.round))) (certificate-fix cert))) (cert-with-author+round author round (tail certs)))))
Theorem:
(defthm certificate-optionp-of-cert-with-author+round (b* ((cert? (cert-with-author+round author round certs))) (certificate-optionp cert?)) :rule-classes :rewrite)
Theorem:
(defthm cert-with-author+round-of-address-fix-author (equal (cert-with-author+round (address-fix author) round certs) (cert-with-author+round author round certs)))
Theorem:
(defthm cert-with-author+round-address-equiv-congruence-on-author (implies (address-equiv author author-equiv) (equal (cert-with-author+round author round certs) (cert-with-author+round author-equiv round certs))) :rule-classes :congruence)
Theorem:
(defthm cert-with-author+round-of-pos-fix-round (equal (cert-with-author+round author (pos-fix round) certs) (cert-with-author+round author round certs)))
Theorem:
(defthm cert-with-author+round-pos-equiv-congruence-on-round (implies (acl2::pos-equiv round round-equiv) (equal (cert-with-author+round author round certs) (cert-with-author+round author round-equiv certs))) :rule-classes :congruence)
Theorem:
(defthm certificate->author-of-cert-with-author+round (b* ((?cert? (cert-with-author+round author round certs))) (implies cert? (equal (certificate->author cert?) (address-fix author)))))
Theorem:
(defthm certificate->round-of-cert-with-author+round (b* ((?cert? (cert-with-author+round author round certs))) (implies cert? (equal (certificate->round cert?) (pos-fix round)))))
Theorem:
(defthm cert-with-author+round-element (implies (and (certificate-setp certs) (cert-with-author+round author round certs)) (in (cert-with-author+round author round certs) certs)))
Theorem:
(defthm cert-with-author+round-when-element (implies (and (in cert certs) (equal (certificate->author cert) (address-fix author)) (equal (certificate->round cert) (pos-fix round))) (cert-with-author+round author round certs)))
Theorem:
(defthm cert-with-author+round-when-subset (implies (and (cert-with-author+round author round certs0) (subset certs0 certs)) (cert-with-author+round author round certs)))
Theorem:
(defthm cert-with-author+round-of-insert-iff (iff (cert-with-author+round author round (insert cert certs)) (or (and (equal (certificate->author cert) (address-fix author)) (equal (certificate->round cert) (pos-fix round))) (cert-with-author+round author round certs))))
Theorem:
(defthm cert-with-author+round-of-union-iff (implies (certificate-setp certs2) (iff (cert-with-author+round author round (union certs1 certs2)) (or (cert-with-author+round author round certs1) (cert-with-author+round author round certs2)))))
Theorem:
(defthm cert-with-author+round-when-delete (implies (cert-with-author+round author round (delete cert certs)) (cert-with-author+round author round certs)))
Theorem:
(defthm cert-with-author+round-of-delete (implies (and (cert-with-author+round author round certs) (or (not (equal (certificate->author cert) (address-fix author))) (not (equal (certificate->round cert) (pos-fix round))))) (cert-with-author+round author round (delete cert certs))))