Convert a natural number to its minimum-length big-endian list of digits.
(nat=>bendian* base nat) → digits
The resulting list is empty if
See also nat=>bendian+ and nat=>bendian.
Function:
(defun nat=>bendian* (base nat) (declare (xargs :guard (and (dab-basep base) (natp nat)))) (let ((__function__ 'nat=>bendian*)) (declare (ignorable __function__)) (mbe :exec (nat=>digits-exec base nat nil) :logic (rev (nat=>lendian* base nat)))))
Theorem:
(defthm return-type-of-nat=>bendian* (b* ((digits (nat=>bendian* base nat))) (dab-digit-listp base digits)) :rule-classes :rewrite)
Theorem:
(defthm natp-listp-of-nat=>bendian* (b* ((digits (nat=>bendian* base nat))) (nat-listp digits)) :rule-classes :rewrite)
Theorem:
(defthm consp-of-nat=>bendian* (implies (not (zp nat)) (b* ((digits (nat=>bendian* base nat))) (consp digits))) :rule-classes :type-prescription)
Theorem:
(defthm consp-of-nat=>bendian*-iff-not-zp (equal (consp (nat=>bendian* base nat)) (not (zp nat))))
Theorem:
(defthm nat=>bendian*-of-0 (equal (nat=>bendian* base 0) nil))
Theorem:
(defthm len-0-of-nat=>bendian* (equal (equal (len (nat=>bendian* base x)) 0) (zp x)))
Theorem:
(defthm expt-of-len-of-nat=>bendian*-is-upper-bound (implies (and (natp nat) (dab-basep base)) (< nat (expt base (len (nat=>bendian* base nat))))) :rule-classes :linear)
Theorem:
(defthm nat=>bendian*-does-not-start-with-0 (not (equal (car (nat=>bendian* base nat)) 0)))
Theorem:
(defthm len-of-nat=>bendian*-leq-width (implies (and (natp nat) (dab-basep base) (natp width)) (equal (<= (len (nat=>bendian* base nat)) width) (< nat (expt base width)))) :rule-classes ((:rewrite :corollary (implies (and (natp nat) (dab-basep base) (natp width)) (equal (> (len (nat=>bendian* base nat)) width) (>= nat (expt base width)))) :hints (("Goal" :in-theory '(not))))))
Theorem:
(defthm nat=>bendian*-of-dab-base-fix-base (equal (nat=>bendian* (dab-base-fix base) nat) (nat=>bendian* base nat)))
Theorem:
(defthm nat=>bendian*-dab-base-equiv-congruence-on-base (implies (dab-base-equiv base base-equiv) (equal (nat=>bendian* base nat) (nat=>bendian* base-equiv nat))) :rule-classes :congruence)
Theorem:
(defthm nat=>bendian*-of-nfix-nat (equal (nat=>bendian* base (nfix nat)) (nat=>bendian* base nat)))
Theorem:
(defthm nat=>bendian*-nat-equiv-congruence-on-nat (implies (nat-equiv nat nat-equiv) (equal (nat=>bendian* base nat) (nat=>bendian* base nat-equiv))) :rule-classes :congruence)