In languages like C, this might be written as
By convention we define
Function:
(defun loghead$inline (size i) (declare (type unsigned-byte size)) (declare (xargs :guard (and (and (integerp size) (<= 0 size)) (integerp i)))) (declare (xargs :split-types t)) (let ((__function__ 'loghead)) (declare (ignorable __function__)) (mbe :logic (imod i (expt2 size)) :exec (the unsigned-byte (logand i (the unsigned-byte (1- (the unsigned-byte (ash 1 size)))))))))
Theorem:
(defthm loghead-type (b* ((nat (loghead$inline size i))) (natp nat)) :rule-classes :type-prescription)