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