Convert a natural number to its big-endian list of bits, seen as digits in base 2, of specified length.
Function:
(defun nat=>bebits (width nat) (declare (xargs :guard (and (natp width) (natp nat)))) (declare (xargs :guard (< nat (expt 2 width)))) (let ((__function__ 'nat=>bebits)) (declare (ignorable __function__)) (nat=>bendian 2 width nat)))
Theorem:
(defthm bit-listp-of-nat=>bebits (b* ((digits (nat=>bebits width nat))) (bit-listp digits)) :rule-classes :rewrite)
Theorem:
(defthm nat=>bebits-of-nfix-width (equal (nat=>bebits (nfix width) nat) (nat=>bebits width nat)))
Theorem:
(defthm nat=>bebits-nat-equiv-congruence-on-width (implies (nat-equiv width width-equiv) (equal (nat=>bebits width nat) (nat=>bebits width-equiv nat))) :rule-classes :congruence)
Theorem:
(defthm nat=>bebits-of-nfix-nat (equal (nat=>bebits width (nfix nat)) (nat=>bebits width nat)))
Theorem:
(defthm nat=>bebits-nat-equiv-congruence-on-nat (implies (nat-equiv nat nat-equiv) (equal (nat=>bebits width nat) (nat=>bebits width nat-equiv))) :rule-classes :congruence)
Theorem:
(defthm len-of-nat=>bebits (equal (len (nat=>bebits width nat)) (nfix width)))