• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Community
    • 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$
        • Defconst
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • 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
              • Defcharset
                • Count-leading-charset
                • Str-count-leading-charset-fast
                • Str-count-leading-charset
                • Chars-in-charset-p
                • Code-in-charset-p
                • Char-in-charset-p
              • Strtok!
              • Cases
              • Concatenation
              • Html-encoding
              • 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
    • Charset-p

    Defcharset

    Define a recognizer for a particular set of characters.

    Defcharset is a macro for introducing a charset-p and proving that it recognizes the correct characters.

    Example
    (defcharset whitespace
      (or (eql x #\Newline)
          (eql x #\Space)
          (eql x #\Tab)))

    This example introduces:

    • (whitespace-char-p x) — a "slow" function for recognizing newline, space, and tab characters
    • (whitespace-chars) — a charset-p that is proven to correspond to whitespace-char-p,
    • (whitespace-charlist-p x) — an ordinary std::deflist to recognize lists whose every character satisfies whitespace-char-p.
    General Form
    (defcharset prefix criteria
      [:in-package-of package]
      [:parents ...]
      [:short ...]
      [:long ...]

    All functions will be introduced in pkg, determined as follows:

    • If an :in-package-of argument is provided, then the corresponding package must be a symbol, and we will use its package.
    • Otherwise, the package of prefix will be used.

    The prefix is a symbol that is used for name generation. Some common examples would be whitespace, alpha, digit, etc.

    The criteria is some term involving the variable pkg::x. The criteria term may assume that x is a character, and is responsible for determining whether x is a member of the desired set. Normally you should not worry about the efficiency of criteria. Although the term you write here does become part of recognizers like whitespace-char-p and whitespace-charlist-p, the actual character set, i.e., whitespace-chars, is represented as a bit mask, and the speed of your criteria term will not have any bearing on how fast it is to look up its bits.

    The :parents, :short, and :long options are as in defxdoc, and allow you to provide documentation to the character recognizer, e.g., whitespace-char-p. The other functions are documented automatically.