• 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
              • 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
          • 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
  • 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