Function:
(defun find-max-level (n max-idx curr-max levels) (declare (xargs :stobjs (levels))) (declare (xargs :guard (and (natp n) (natp max-idx) (natp curr-max)))) (declare (xargs :guard (and (<= max-idx (u32-length levels)) (<= n max-idx)))) (let ((__function__ 'find-max-level)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp (- (nfix max-idx) (nfix n))) :exec (eql max-idx n))) (lnfix curr-max)) (next-max (max (lnfix curr-max) (get-u32 n levels)))) (find-max-level (1+ (lnfix n)) max-idx next-max levels))))
Theorem:
(defthm natp-of-find-max-level (b* ((max (find-max-level n max-idx curr-max levels))) (natp max)) :rule-classes :type-prescription)
Theorem:
(defthm find-max-level-of-nfix-n (equal (find-max-level (nfix n) max-idx curr-max levels) (find-max-level n max-idx curr-max levels)))
Theorem:
(defthm find-max-level-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (find-max-level n max-idx curr-max levels) (find-max-level n-equiv max-idx curr-max levels))) :rule-classes :congruence)
Theorem:
(defthm find-max-level-of-nfix-max-idx (equal (find-max-level n (nfix max-idx) curr-max levels) (find-max-level n max-idx curr-max levels)))
Theorem:
(defthm find-max-level-nat-equiv-congruence-on-max-idx (implies (nat-equiv max-idx max-idx-equiv) (equal (find-max-level n max-idx curr-max levels) (find-max-level n max-idx-equiv curr-max levels))) :rule-classes :congruence)
Theorem:
(defthm find-max-level-of-nfix-curr-max (equal (find-max-level n max-idx (nfix curr-max) levels) (find-max-level n max-idx curr-max levels)))
Theorem:
(defthm find-max-level-nat-equiv-congruence-on-curr-max (implies (nat-equiv curr-max curr-max-equiv) (equal (find-max-level n max-idx curr-max levels) (find-max-level n max-idx curr-max-equiv levels))) :rule-classes :congruence)