• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
          • Std/strings
            • Pretty-printing
            • Printtree
            • Base64
            • Charset-p
            • Strtok!
            • Cases
            • Concatenation
            • Html-encoding
            • Character-kinds
            • Substrings
            • Strtok
            • Equivalences
            • Url-encoding
            • Lines
            • Explode-implode-equalities
            • Ordering
            • Numbers
            • Pad-trim
              • Rpadstr
              • Rpadchars
                • Lpadchars
                • Lpadstr
                • Trim-bag
                • Trim
              • Coercion
              • Std/strings/digit-to-char
              • Substitution
              • Symbols
            • String-listp
            • Stringp
            • Length
            • Search
            • Remove-duplicates
            • Position
            • Coerce
            • Concatenate
            • Reverse
            • String
            • Subseq
            • Substitute
            • String-upcase
            • String-downcase
            • Count
            • Char
            • String<
            • String-equal
            • String-utilities
            • String-append
            • String>=
            • String<=
            • String>
            • Hex-digit-char-theorems
            • String-downcase-gen
            • String-upcase-gen
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Pad-trim

    Rpadchars

    Pad a character-list with spaces on the right.

    (rpadchars x len) extends the character list x to length len by adding spaces on the right. For instance,

    (rpadchars '(#\f #\o #\o) 5)
       -->
    '(#\f #\o #\o #\Space #\Space)

    This is completely dumb: we don't try to account for newlines, tabs, or anything like that, and just add #\Space characters until reaching the desired width.

    If no new spaces are needed, x is returned unchanged and no consing is performed.

    Definitions and Theorems

    Function: rpadchars

    (defun rpadchars (x len)
      (declare (xargs :guard (and (character-listp x) (natp len)))
               (type integer len))
      (mbe :logic
           (append (make-character-list x)
                   (repeat (nfix (- (nfix len) (len x)))
                           #\Space))
           :exec
           (let* ((x-len (length (the list x)))
                  (diff (- len x-len)))
             (if (> diff 0)
                 (append x (repeat diff #\Space))
               x))))

    Theorem: character-listp-of-rpadchars

    (defthm character-listp-of-rpadchars
      (character-listp (rpadchars x len)))

    Theorem: len-of-rpadchars

    (defthm len-of-rpadchars
      (equal (len (rpadchars x len))
             (max (len x) (nfix len))))

    Theorem: charlisteqv-implies-equal-rpadchars-1

    (defthm charlisteqv-implies-equal-rpadchars-1
      (implies (charlisteqv x x-equiv)
               (equal (rpadchars x len)
                      (rpadchars x-equiv len)))
      :rule-classes (:congruence))

    Theorem: icharlisteqv-implies-icharlisteqv-rpadchars-1

    (defthm icharlisteqv-implies-icharlisteqv-rpadchars-1
      (implies (icharlisteqv x x-equiv)
               (icharlisteqv (rpadchars x len)
                             (rpadchars x-equiv len)))
      :rule-classes (:congruence))