Lemmas about loghead from the logops-lemmas book.
Theorem:
(defthm loghead-identity (implies (unsigned-byte-p size i) (equal (loghead size i) i)))
Theorem:
(defthm loghead-loghead (implies (and (>= size1 0) (integerp size1) (loghead-guard size i)) (equal (loghead size1 (loghead size i)) (if (< size1 size) (loghead size1 i) (loghead size i)))))
Theorem:
(defthm loghead-0-i (implies (integerp i) (equal (loghead 0 i) 0)))
Theorem:
(defthm loghead-size-0 (implies (and (integerp size) (>= size 0)) (equal (loghead size 0) 0)))
Theorem:
(defthm loghead-leq (implies (and (>= i 0) (loghead-guard size i)) (<= (loghead size i) i)) :rule-classes ((:linear :trigger-terms ((loghead size i)))))
Theorem:
(defthm loghead-logapp (implies (and (<= size1 size) (force (>= size1 0)) (force (integerp size1)) (logapp-guard size i j)) (equal (loghead size1 (logapp size i j)) (loghead size1 i))))
Theorem:
(defthm loghead-logrpl (implies (and (logrpl-guard size1 i j) (force (integerp size)) (force (>= size 0))) (equal (loghead size (logrpl size1 i j)) (if (< size1 size) (logrpl size1 i (loghead size j)) (loghead size i)))))
Theorem:
(defthm bitp-loghead-1 (bitp (loghead 1 i)) :rule-classes :type-prescription)
Theorem:
(defthm loghead-+-cancel-0 (implies (and (force (integerp j)) (loghead-guard size i)) (equal (equal (loghead size (+ i j)) (loghead size i)) (equal (loghead size j) 0))))
Theorem:
(defthm loghead-+-cancel (implies (and (force (integerp size)) (>= size 0) (force (integerp i)) (force (integerp j)) (force (integerp k))) (equal (equal (loghead size (+ i j)) (loghead size (+ i k))) (equal (loghead size j) (loghead size k)))))
Theorem:
(defthm loghead-+-loghead (implies (and (force (integerp size)) (>= size 0) (force (integerp i)) (force (integerp j))) (equal (loghead size (+ i (loghead size j))) (loghead size (+ i j)))))