Turn a natural number into a vl-bitlist-p of the given width.
(vl-bitlist-from-nat x width) → bits
Function:
(defun vl-bitlist-from-nat (x width) (declare (xargs :guard (and (natp x) (natp width)))) (let ((__function__ 'vl-bitlist-from-nat)) (declare (ignorable __function__)) (b* (((when (zp width)) nil) (width (1- width)) (bit (if (logbitp width (lnfix x)) :vl-1val :vl-0val))) (cons bit (vl-bitlist-from-nat x width)))))
Theorem:
(defthm vl-bitlist-p-of-vl-bitlist-from-nat (b* ((bits (vl-bitlist-from-nat x width))) (vl-bitlist-p bits)) :rule-classes :rewrite)
Theorem:
(defthm len-of-vl-bitlist-from-nat (equal (len (vl-bitlist-from-nat x width)) (nfix width)))
Theorem:
(defthm vl-bitlist-from-nat-of-nfix-x (equal (vl-bitlist-from-nat (nfix x) width) (vl-bitlist-from-nat x width)))
Theorem:
(defthm vl-bitlist-from-nat-nat-equiv-congruence-on-x (implies (acl2::nat-equiv x x-equiv) (equal (vl-bitlist-from-nat x width) (vl-bitlist-from-nat x-equiv width))) :rule-classes :congruence)
Theorem:
(defthm vl-bitlist-from-nat-of-nfix-width (equal (vl-bitlist-from-nat x (nfix width)) (vl-bitlist-from-nat x width)))
Theorem:
(defthm vl-bitlist-from-nat-nat-equiv-congruence-on-width (implies (acl2::nat-equiv width width-equiv) (equal (vl-bitlist-from-nat x width) (vl-bitlist-from-nat x width-equiv))) :rule-classes :congruence)