• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
          • Omaps
          • Directed-untranslate
          • Include-book-paths
          • Ubi
          • Numbered-names
          • Digits-any-base
            • Defdigits
            • Nat=>lendian*
            • Group-lendian
            • Defdigit-grouping
            • Ungroup-lendian
            • Lendian=>nat
            • Defthm-dab-return-types
            • Bendian=>nat
            • Nat=>bendian*
            • Trim-bendian*
            • Trim-lendian*
            • Nat=>lendian
            • Dab-digit-list-fix
            • Nat=>bendian
              • Ungroup-bendian
              • Group-bendian
              • Digits=>nat-injectivity-theorems
              • Dab-digit-listp
              • Nat=>lendian+
              • Dab-basep
              • Nat=>bendian+
              • Digits=>nat=>digits-inverses-theorems
              • Trim-lendian+
              • Trim-bendian+
              • Nat=>digits=>nat-inverses-theorems
              • Dab-digitp
              • Group/ungroup-inverses-theorems
              • Dab-digit-fix
              • Nat=>digits-injectivity-theorems
              • Dab-base
              • Digits-any-base-pow2
              • Dab-base-fix
            • Context-message-pair
            • With-auto-termination
            • Make-termination-theorem
            • Theorems-about-true-list-lists
            • Checkpoint-list
            • Sublis-expr+
            • Integers-from-to
            • Prove$
            • Defthm<w
            • System-utilities-non-built-in
            • Integer-range-fix
            • Minimize-ruler-extenders
            • Add-const-to-untranslate-preprocess
            • Unsigned-byte-fix
            • Signed-byte-fix
            • Defthmr
            • Paired-names
            • Unsigned-byte-list-fix
            • Signed-byte-list-fix
            • Show-books
            • Skip-in-book
            • Typed-tuplep
            • List-utilities
            • Checkpoint-list-pretty
            • Defunt
            • Keyword-value-list-to-alist
            • Magic-macroexpand
            • Top-command-number-fn
            • Bits-as-digits-in-base-2
            • Show-checkpoint-list
            • Ubyte11s-as-digits-in-base-2048
            • Named-formulas
            • Bytes-as-digits-in-base-256
            • String-utilities
            • Make-keyword-value-list-from-keys-and-value
            • Defmacroq
            • Integer-range-listp
            • Apply-fn-if-known
            • Trans-eval-error-triple
            • Checkpoint-info-list
            • Previous-subsumer-hints
            • Fms!-lst
            • Zp-listp
            • Trans-eval-state
            • Injections
            • Doublets-to-alist
            • Theorems-about-osets
            • Typed-list-utilities
            • Book-runes-alist
            • User-interface
            • Bits/ubyte11s-digit-grouping
            • Bits/bytes-digit-grouping
            • Message-utilities
            • Subsetp-eq-linear
            • Oset-utilities
            • Strict-merge-sort-<
            • Miscellaneous-enumerations
            • Maybe-unquote
            • Thm<w
            • Defthmd<w
            • Io-utilities
          • Set
          • Soft
          • C
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Digits-any-base

    Nat=>bendian

    Convert a natural number to its big-endian list of digits of specified length.

    Signature
    (nat=>bendian base width nat) → digits
    Arguments
    base — Guard (dab-basep base).
    width — Guard (natp width).
    nat — Guard (natp nat).
    Returns
    digits — Type (dab-digit-listp base digits).

    The number must be representable in the specified number of digits. The resulting list starts with zero or more 0s.

    See also nat=>bendian* and nat=>bendian+.

    Definitions and Theorems

    Function: nat=>bendian

    (defun nat=>bendian (base width nat)
      (declare (xargs :guard (and (dab-basep base)
                                  (natp width)
                                  (natp nat))))
      (declare (xargs :guard (< nat (expt base width))))
      (let ((__function__ 'nat=>bendian))
        (declare (ignorable __function__))
        (rev (nat=>lendian base width nat))))

    Theorem: return-type-of-nat=>bendian

    (defthm return-type-of-nat=>bendian
      (b* ((digits (nat=>bendian base width nat)))
        (dab-digit-listp base digits))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-nat=>bendian

    (defthm nat-listp-of-nat=>bendian
      (b* ((digits (nat=>bendian base width nat)))
        (nat-listp digits))
      :rule-classes :rewrite)

    Theorem: consp-of-nat=>bendian

    (defthm consp-of-nat=>bendian
      (implies (not (zp width))
               (b* ((digits (nat=>bendian base width nat)))
                 (consp digits)))
      :rule-classes :type-prescription)

    Theorem: nat=>bendian-of-mod

    (defthm nat=>bendian-of-mod
     (implies (and (dab-basep base)
                   (natp width)
                   (natp nat)
                   (equal expt-base-width (expt base width)))
              (equal (nat=>bendian base width (mod nat expt-base-width))
                     (nat=>bendian base width nat))))

    Theorem: len-of-nat=>bendian

    (defthm len-of-nat=>bendian
      (equal (len (nat=>bendian base width nat))
             (nfix width)))

    Theorem: nat=>bendian-of-dab-base-fix-base

    (defthm nat=>bendian-of-dab-base-fix-base
      (equal (nat=>bendian (dab-base-fix base)
                           width nat)
             (nat=>bendian base width nat)))

    Theorem: nat=>bendian-dab-base-equiv-congruence-on-base

    (defthm nat=>bendian-dab-base-equiv-congruence-on-base
      (implies (dab-base-equiv base base-equiv)
               (equal (nat=>bendian base width nat)
                      (nat=>bendian base-equiv width nat)))
      :rule-classes :congruence)

    Theorem: nat=>bendian-of-nfix-width

    (defthm nat=>bendian-of-nfix-width
      (equal (nat=>bendian base (nfix width) nat)
             (nat=>bendian base width nat)))

    Theorem: nat=>bendian-nat-equiv-congruence-on-width

    (defthm nat=>bendian-nat-equiv-congruence-on-width
      (implies (nat-equiv width width-equiv)
               (equal (nat=>bendian base width nat)
                      (nat=>bendian base width-equiv nat)))
      :rule-classes :congruence)

    Theorem: nat=>bendian-of-nfix-nat

    (defthm nat=>bendian-of-nfix-nat
      (equal (nat=>bendian base width (nfix nat))
             (nat=>bendian base width nat)))

    Theorem: nat=>bendian-nat-equiv-congruence-on-nat

    (defthm nat=>bendian-nat-equiv-congruence-on-nat
      (implies (nat-equiv nat nat-equiv)
               (equal (nat=>bendian base width nat)
                      (nat=>bendian base width nat-equiv)))
      :rule-classes :congruence)