• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • 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
          • 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
            • Code-char-injectivity-theorem
            • 8bitbytes-hexchars-conversions
            • Code-char-inverses-theorems
            • String-kinds
            • String-codelist-conversions
            • Charlist-codelist-conversions
              • Chars=>nats
              • Nats=>chars
                • Nats<=>chars-inverses-theorems
            • 8bitbytes-hexstrings-conversions
          • 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
  • Charlist-codelist-conversions

Nats=>chars

Convert a true list of natural numbers below 256 to the corresponding true list of characters.

Signature
(nats=>chars nats) → chars
Arguments
nats — Guard (unsigned-byte-listp 8 nats).
Returns
chars — Type (character-listp chars).

This operation has a natural-recursive definition for logic reasoning and a tail-recursive executional for execution.

Definitions and Theorems

Function: nats=>chars-exec

(defun nats=>chars-exec (nats rev-chars)
  (declare (xargs :guard (and (unsigned-byte-listp 8 nats)
                              (character-listp rev-chars))))
  (let ((__function__ 'nats=>chars-exec))
    (declare (ignorable __function__))
    (cond ((endp nats) (rev rev-chars))
          (t (nats=>chars-exec (cdr nats)
                               (cons (code-char (car nats))
                                     rev-chars))))))

Function: nats=>chars

(defun nats=>chars (nats)
  (declare (xargs :guard (unsigned-byte-listp 8 nats)))
  (let ((__function__ 'nats=>chars))
    (declare (ignorable __function__))
    (mbe :logic (cond ((endp nats) nil)
                      (t (cons (code-char (car nats))
                               (nats=>chars (cdr nats)))))
         :exec (nats=>chars-exec nats nil))))

Theorem: character-listp-of-nats=>chars

(defthm character-listp-of-nats=>chars
  (b* ((chars (nats=>chars nats)))
    (character-listp chars))
  :rule-classes :rewrite)

Theorem: len-of-nats=>chars

(defthm len-of-nats=>chars
  (equal (len (nats=>chars nats))
         (len nats)))

Theorem: nats=>chars-of-cons

(defthm nats=>chars-of-cons
  (equal (nats=>chars (cons nat nats))
         (cons (code-char nat)
               (nats=>chars nats))))

Theorem: nats=>chars-of-append

(defthm nats=>chars-of-append
  (equal (nats=>chars (append nats1 nats2))
         (append (nats=>chars nats1)
                 (nats=>chars nats2))))

Theorem: nats=>chars-of-repeat

(defthm nats=>chars-of-repeat
  (equal (nats=>chars (repeat n char))
         (repeat n (code-char char))))

Theorem: nth-of-nats=>chars

(defthm nth-of-nats=>chars
  (equal (nth i (nats=>chars nats))
         (if (< (nfix i) (len nats))
             (code-char (nth i nats))
           nil)))

Theorem: nats=>chars-of-revappend

(defthm nats=>chars-of-revappend
  (equal (nats=>chars (revappend x y))
         (revappend (nats=>chars x)
                    (nats=>chars y))))

Theorem: nats=>chars-of-nthcdr

(defthm nats=>chars-of-nthcdr
  (equal (nats=>chars (nthcdr n nats))
         (nthcdr n (nats=>chars nats))))

Theorem: nats=>chars-of-take

(defthm nats=>chars-of-take
  (implies (<= (nfix n) (len nats))
           (equal (nats=>chars (take n nats))
                  (take n (nats=>chars nats)))))

Subtopics

Nats<=>chars-inverses-theorems
nats=>chars and chars=>nats are mutual inverses.