• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • 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
        • Std/osets
        • Std/io
        • Std/basic
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • 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))