• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Vwsim
      • Fgl
      • Vl
        • Syntax
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
          • Ps
          • Verilog-printing
          • Basic-printing
            • Vl-println?
            • Vl-printable-p
            • Vl-print
            • Vl-col-after-printing-chars
            • Vl-print-strings-with-commas
            • Vl-col-after-printing-string
            • Vl-string-needs-html-encoding-p
            • Vl-println-markup
            • Vl-print-strings-as-lines
            • Vl-print-url
            • Vl-print-nat
              • Vl-print-natchars-aux
                • Vl-print-int-main
              • Vl-indent
              • Vl-println
              • Vl-print-markup
              • Vl-ps-seq
              • Vl-cw-ps-seq
              • Vl-when-html
              • Vl-ps-span
            • Printing-locally
            • Formatted-printing
            • Accessing-printed-output
            • Json-printing
            • Vl-printedlist
          • Kit
          • Mlib
          • Transforms
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Testing-utilities
      • Math
    • Vl-print-nat

    Vl-print-natchars-aux

    Optimized base-10 natural number printing into ps.

    Signature
    (vl-print-natchars-aux n acc col) → (mv acc new-col)
    Arguments
    n — Guard (natp n).
    col — Guard (natp col).
    Returns
    new-col — Type (natp new-col).

    Definitions and Theorems

    Function: vl-print-natchars-aux

    (defun
     vl-print-natchars-aux (n acc col)
     (declare (xargs :guard (and (natp n) (natp col))))
     (declare (type unsigned-byte n col))
     (declare (xargs :split-types t))
     (let
      ((__function__ 'vl-print-natchars-aux))
      (declare (ignorable __function__))
      (if
       (mbe :logic (zp n)
            :exec (eql (the integer n) 0))
       (mv acc (lnfix col))
       (mv-let
        (acc col)
        (vl-print-natchars-aux
             (the integer (truncate (the integer n) 10))
             acc col)
        (mv
         (cons
              (the character
                   (code-char (the (unsigned-byte 8)
                                   (+ (the (unsigned-byte 8) 48)
                                      (the (unsigned-byte 8)
                                           (rem (the integer n) 10))))))
              acc)
         (the (integer 0 *) (+ 1 col)))))))

    Theorem: natp-of-vl-print-natchars-aux.new-col

    (defthm natp-of-vl-print-natchars-aux.new-col
            (b* (((mv ?acc ?new-col)
                  (vl-print-natchars-aux n acc col)))
                (natp new-col))
            :rule-classes :type-prescription)

    Theorem: acc-of-vl-print-natchars-aux

    (defthm acc-of-vl-print-natchars-aux
            (equal (mv-nth 0 (vl-print-natchars-aux n acc col))
                   (str::revappend-nat-to-dec-chars-aux n acc)))

    Theorem: vl-print-natchars-aux-of-nfix-n

    (defthm vl-print-natchars-aux-of-nfix-n
            (equal (vl-print-natchars-aux (nfix n) acc col)
                   (vl-print-natchars-aux n acc col)))

    Theorem: vl-print-natchars-aux-nat-equiv-congruence-on-n

    (defthm vl-print-natchars-aux-nat-equiv-congruence-on-n
            (implies (acl2::nat-equiv n n-equiv)
                     (equal (vl-print-natchars-aux n acc col)
                            (vl-print-natchars-aux n-equiv acc col)))
            :rule-classes :congruence)

    Theorem: vl-print-natchars-aux-of-nfix-col

    (defthm vl-print-natchars-aux-of-nfix-col
            (equal (vl-print-natchars-aux n acc (nfix col))
                   (vl-print-natchars-aux n acc col)))

    Theorem: vl-print-natchars-aux-nat-equiv-congruence-on-col

    (defthm vl-print-natchars-aux-nat-equiv-congruence-on-col
            (implies (acl2::nat-equiv col col-equiv)
                     (equal (vl-print-natchars-aux n acc col)
                            (vl-print-natchars-aux n acc col-equiv)))
            :rule-classes :congruence)