• 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
          • Html-encode-string-aux
          • Html-encode-chars-aux
          • Html-encode-push
            • Html-encode-next-col
            • Distance-to-tab
            • Repeated-revappend
          • 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
        • Explode-implode-equalities
        • Ordering
        • Numbers
        • Pad-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
  • Html-encoding

Html-encode-push

HTML encode a single character, with column/tabsize support.

Signature
(html-encode-push char1 col tabsize acc) → new-acc
Arguments
char1 — Character to be printed.
    Guard (characterp char1).
col — Current column number before printing char1 (for tab computations).
    Guard (natp col).
tabsize — Guard (posp tabsize).
acc — Reverse order characters we're building.
Returns
new-acc — Type (character-listp new-acc), given (character-listp acc).

Definitions and Theorems

Function: html-encode-push

(defun html-encode-push (char1 col tabsize acc)
  (declare (xargs :guard (and (characterp char1)
                              (natp col)
                              (posp tabsize))))
  (let ((acl2::__function__ 'html-encode-push))
    (declare (ignorable acl2::__function__))
    (b* (((the character char1)
          (mbe :logic (char-fix char1)
               :exec char1)))
      (case char1
        (#\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))
        (#\Tab (repeated-revappend (distance-to-tab col tabsize)
                                   (html-space)
                                   acc))
        (otherwise (cons char1 acc))))))

Theorem: character-listp-of-html-encode-push

(defthm character-listp-of-html-encode-push
  (implies (character-listp acc)
           (b* ((new-acc (html-encode-push char1 col tabsize acc)))
             (character-listp new-acc)))
  :rule-classes :rewrite)

Theorem: html-encode-push-of-char-fix-char1

(defthm html-encode-push-of-char-fix-char1
  (equal (html-encode-push (char-fix char1)
                           col tabsize acc)
         (html-encode-push char1 col tabsize acc)))

Theorem: html-encode-push-chareqv-congruence-on-char1

(defthm html-encode-push-chareqv-congruence-on-char1
  (implies (chareqv char1 char1-equiv)
           (equal (html-encode-push char1 col tabsize acc)
                  (html-encode-push char1-equiv col tabsize acc)))
  :rule-classes :congruence)

Theorem: html-encode-push-of-nfix-col

(defthm html-encode-push-of-nfix-col
  (equal (html-encode-push char1 (nfix col)
                           tabsize acc)
         (html-encode-push char1 col tabsize acc)))

Theorem: html-encode-push-nat-equiv-congruence-on-col

(defthm html-encode-push-nat-equiv-congruence-on-col
  (implies (acl2::nat-equiv col col-equiv)
           (equal (html-encode-push char1 col tabsize acc)
                  (html-encode-push char1 col-equiv tabsize acc)))
  :rule-classes :congruence)

Theorem: html-encode-push-of-pos-fix-tabsize

(defthm html-encode-push-of-pos-fix-tabsize
  (equal (html-encode-push char1 col (acl2::pos-fix tabsize)
                           acc)
         (html-encode-push char1 col tabsize acc)))

Theorem: html-encode-push-pos-equiv-congruence-on-tabsize

(defthm html-encode-push-pos-equiv-congruence-on-tabsize
  (implies (acl2::pos-equiv tabsize tabsize-equiv)
           (equal (html-encode-push char1 col tabsize acc)
                  (html-encode-push char1 col tabsize-equiv acc)))
  :rule-classes :congruence)

Subtopics

Html-encode-next-col
Compute where we'll be after printing a character, accounting for tab sizes and newlines.
Distance-to-tab
Repeated-revappend