Index of the last-place vote in
(last-place xs) → lp
Theorem:
(defthm posp-number-of-candidates (implies (and (irv-ballot-p xs) (consp xs)) (posp (number-of-candidates xs))))
Function:
(defun last-place (xs) (declare (xargs :guard (irv-ballot-p xs))) (let ((__function__ 'last-place)) (declare (ignorable __function__)) (if (and (irv-ballot-p xs) (consp xs)) (1- (number-of-candidates xs)) 0)))
Theorem:
(defthm natp-of-last-place (b* ((lp (last-place xs))) (natp lp)) :rule-classes :type-prescription)
Theorem:
(defthm last-place-after-eliminate-candidate (implies (and (irv-ballot-p xs) (< 1 (number-of-candidates xs))) (equal (last-place (eliminate-candidate id xs)) (if (member-equal id (candidate-ids xs)) (1- (last-place xs)) (last-place xs)))))
Theorem:
(defthm last-place-of-cdr-xs (implies (irv-ballot-p xs) (<= (last-place (cdr xs)) (last-place xs))) :rule-classes (:linear :rewrite))