• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
        • Pretty-printing
        • Printtree
        • Base64
        • Charset-p
        • Strtok!
        • Cases
        • Concatenation
        • Html-encoding
          • Html-encode-string-aux
          • Html-encode-chars-aux
          • Html-encode-push
          • Html-encode-string-basic-aux
          • Html-encode-string
          • Html-encode-char-basic
            • Html-encode-chars-basic-aux
            • Html-encode-string-basic
          • Character-kinds
          • Substrings
          • Strtok
          • Equivalences
          • Url-encoding
          • Lines
          • Ordering
          • Numbers
          • Pad-trim
          • Coercion
          • Std/strings-extensions
          • Std/strings/digit-to-char
          • Substitution
          • Symbols
        • Std/io
        • Std/osets
        • Std/system
        • Std/basic
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
        • Std-extensions
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Html-encoding

    Html-encode-char-basic

    HTML encode a single character (simple version, no tab support).

    Signature
    (html-encode-char-basic x acc) → new-acc
    Arguments
    x — Character to encode.
        Guard (characterp x).
    acc — Accumulator for output characters, reverse order.
    Returns
    new-acc — Type (character-listp new-acc), given (character-listp acc).

    Definitions and Theorems

    Function: html-encode-char-basic$inline

    (defun html-encode-char-basic$inline (x acc)
           (declare (xargs :guard (characterp x)))
           (declare (type character x))
           (declare (xargs :split-types t))
           (let ((acl2::__function__ 'html-encode-char-basic))
                (declare (ignorable acl2::__function__))
                (b* (((the character x)
                      (mbe :logic (char-fix x) :exec x)))
                    (case x
                          (#\Space (if (or (atom acc)
                                           (eql (car acc) #\Space)
                                           (eql (car acc) #\Newline))
                                       (revappend (html-space) acc)
                                       (cons #\Space acc)))
                          (#\Newline (revappend (html-newline) acc))
                          (#\< (revappend (html-less) acc))
                          (#\> (revappend (html-greater) acc))
                          (#\& (revappend (html-amp) acc))
                          (#\" (revappend (html-quote) acc))
                          (otherwise (cons x acc))))))

    Theorem: character-listp-of-html-encode-char-basic

    (defthm
         character-listp-of-html-encode-char-basic
         (implies (character-listp acc)
                  (b* ((new-acc (html-encode-char-basic$inline x acc)))
                      (character-listp new-acc)))
         :rule-classes :rewrite)

    Theorem: html-encode-char-basic$inline-of-char-fix-x

    (defthm html-encode-char-basic$inline-of-char-fix-x
            (equal (html-encode-char-basic$inline (char-fix x)
                                                  acc)
                   (html-encode-char-basic$inline x acc)))

    Theorem: html-encode-char-basic$inline-chareqv-congruence-on-x

    (defthm
         html-encode-char-basic$inline-chareqv-congruence-on-x
         (implies (chareqv x x-equiv)
                  (equal (html-encode-char-basic$inline x acc)
                         (html-encode-char-basic$inline x-equiv acc)))
         :rule-classes :congruence)