• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
          • Syntax-for-tools
            • Formalized-subset
            • Mapping-to-language-definition
            • Input-files
            • Compilation-database
            • Printer
            • Output-files
            • Abstract-syntax-operations
            • Implementation-environments
            • Abstract-syntax
            • Concrete-syntax
            • Disambiguation
            • Validation
            • Gcc-builtins
            • Preprocessing
              • Preprocessor
                • Preprocessor-states
                  • Plexeme
                    • Plexeme-fix
                      • Plexemep
                      • Plexeme-case
                      • Plexeme-equiv
                      • Plexeme-kind
                      • Plexeme-string
                      • Plexeme-spaces
                      • Plexeme-punctuator
                      • Plexeme-other
                      • Plexeme-number
                      • Plexeme-newline
                      • Plexeme-line-comment
                      • Plexeme-ident
                      • Plexeme-header
                      • Plexeme-char
                      • Plexeme-block-comment
                      • Plexeme-vertical-tab
                      • Plexeme-horizontal-tab
                      • Plexeme-form-feed
                    • Ppstate
                    • Pnumber
                    • Macro-info
                    • Macro-add
                    • Init-ppstate
                    • Plexeme-token/newline-p
                    • Newline
                    • Plexeme-option
                    • Macro-info-option
                    • Macro-table
                    • Plexeme+span
                    • Update-ppstate->lexemes-unread
                    • Update-ppstate->lexemes-read
                    • Update-ppstate->lexemes-length
                    • Update-ppstate->chars-unread
                    • Update-ppstate->chars-read
                    • Update-ppstate->version
                    • Update-ppstate->position
                    • Update-ppstate->macros
                    • Update-ppstate->chars-length
                    • Macro-lookup
                    • Update-ppstate->bytes
                    • Update-ppstate->size
                    • Plexeme-token/space-p
                    • Plexeme-tokenp
                    • Ppstate->gcc
                    • Plexeme-list-token/space-p
                    • Ppstate->size
                    • Ppstate->lexemes-unread
                    • Ppstate->lexemes-read
                    • Ppstate->lexemes-length
                    • Ppstate->chars-unread
                    • Ppstate->bytes
                    • Plexeme-list-token/newline-p
                    • Plexeme-list-not-token/newline-p
                    • Ident-macroinfo-alist
                    • Update-ppstate->lexeme
                    • Update-ppstate->char
                    • Ppstate->version
                    • Ppstate->macros
                    • Ppstate->chars-read
                    • Ppstate->chars-length
                    • Plexeme-list-tokenp
                    • Plexeme-list-not-tokenp
                    • Macro-table-init
                    • Ppstate->lexeme
                    • Ppstate->char
                    • Ppstate-fix
                    • Plexeme+span-list
                    • Plexeme-list
                    • Irr-pnumber
                    • Irr-plexeme
                    • Irr-macro-table
                    • Ppstate->position
                  • Preprocessor-printer
                  • Pread-token/newline
                  • Pread-token
                  • Preprocessor-lexer
                  • Pproc-files
                  • Pproc-file
                  • Filepath-plexeme-list-alist-to-filepath-filedata-map
                  • Filepath-plexeme-list-alist
                  • Preprocessor-reader
                  • Preprocessor-messages
                • External-preprocessing
              • Parsing
            • Atc
            • Transformation-tools
            • Language
            • Representation
            • Insertion-sort
            • Pack
          • Soft
          • Bv
          • Imp-language
          • Ethereum
          • Event-macros
          • Java
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Plexeme

    Plexeme-fix

    Fixing function for plexeme structures.

    Signature
    (plexeme-fix x) → new-x
    Arguments
    x — Guard (plexemep x).
    Returns
    new-x — Type (plexemep new-x).

    Definitions and Theorems

    Function: plexeme-fix$inline

    (defun plexeme-fix$inline (x)
     (declare (xargs :guard (plexemep x)))
     (mbe
      :logic
      (case (plexeme-kind x)
        (:header (b* ((name (header-name-fix (std::da-nth 0 (cdr x)))))
                   (cons :header (list name))))
        (:ident (b* ((ident (ident-fix (std::da-nth 0 (cdr x)))))
                  (cons :ident (list ident))))
        (:number (b* ((number (pnumber-fix (std::da-nth 0 (cdr x)))))
                   (cons :number (list number))))
        (:char (b* ((const (cconst-fix (std::da-nth 0 (cdr x)))))
                 (cons :char (list const))))
        (:string (b* ((literal (stringlit-fix (std::da-nth 0 (cdr x)))))
                   (cons :string (list literal))))
        (:punctuator
             (b* ((punctuator (acl2::str-fix (std::da-nth 0 (cdr x)))))
               (cons :punctuator (list punctuator))))
        (:other (b* ((char (nfix (std::da-nth 0 (cdr x)))))
                  (cons :other (list char))))
        (:block-comment
             (b* ((content (nat-list-fix (std::da-nth 0 (cdr x)))))
               (cons :block-comment (list content))))
        (:line-comment
             (b* ((content (nat-list-fix (std::da-nth 0 (cdr x)))))
               (cons :line-comment (list content))))
        (:newline (b* ((chars (newline-fix (std::da-nth 0 (cdr x)))))
                    (cons :newline (list chars))))
        (:spaces (b* ((count (pos-fix (std::da-nth 0 (cdr x)))))
                   (cons :spaces (list count))))
        (:horizontal-tab (cons :horizontal-tab (list)))
        (:vertical-tab (cons :vertical-tab (list)))
        (:form-feed (cons :form-feed (list))))
      :exec x))

    Theorem: plexemep-of-plexeme-fix

    (defthm plexemep-of-plexeme-fix
      (b* ((new-x (plexeme-fix$inline x)))
        (plexemep new-x))
      :rule-classes :rewrite)

    Theorem: plexeme-fix-when-plexemep

    (defthm plexeme-fix-when-plexemep
      (implies (plexemep x)
               (equal (plexeme-fix x) x)))

    Function: plexeme-equiv$inline

    (defun plexeme-equiv$inline (acl2::x acl2::y)
      (declare (xargs :guard (and (plexemep acl2::x)
                                  (plexemep acl2::y))))
      (equal (plexeme-fix acl2::x)
             (plexeme-fix acl2::y)))

    Theorem: plexeme-equiv-is-an-equivalence

    (defthm plexeme-equiv-is-an-equivalence
      (and (booleanp (plexeme-equiv x y))
           (plexeme-equiv x x)
           (implies (plexeme-equiv x y)
                    (plexeme-equiv y x))
           (implies (and (plexeme-equiv x y)
                         (plexeme-equiv y z))
                    (plexeme-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: plexeme-equiv-implies-equal-plexeme-fix-1

    (defthm plexeme-equiv-implies-equal-plexeme-fix-1
      (implies (plexeme-equiv acl2::x x-equiv)
               (equal (plexeme-fix acl2::x)
                      (plexeme-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: plexeme-fix-under-plexeme-equiv

    (defthm plexeme-fix-under-plexeme-equiv
      (plexeme-equiv (plexeme-fix acl2::x)
                     acl2::x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Theorem: equal-of-plexeme-fix-1-forward-to-plexeme-equiv

    (defthm equal-of-plexeme-fix-1-forward-to-plexeme-equiv
      (implies (equal (plexeme-fix acl2::x) acl2::y)
               (plexeme-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: equal-of-plexeme-fix-2-forward-to-plexeme-equiv

    (defthm equal-of-plexeme-fix-2-forward-to-plexeme-equiv
      (implies (equal acl2::x (plexeme-fix acl2::y))
               (plexeme-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: plexeme-equiv-of-plexeme-fix-1-forward

    (defthm plexeme-equiv-of-plexeme-fix-1-forward
      (implies (plexeme-equiv (plexeme-fix acl2::x)
                              acl2::y)
               (plexeme-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: plexeme-equiv-of-plexeme-fix-2-forward

    (defthm plexeme-equiv-of-plexeme-fix-2-forward
      (implies (plexeme-equiv acl2::x (plexeme-fix acl2::y))
               (plexeme-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: plexeme-kind$inline-of-plexeme-fix-x

    (defthm plexeme-kind$inline-of-plexeme-fix-x
      (equal (plexeme-kind$inline (plexeme-fix x))
             (plexeme-kind$inline x)))

    Theorem: plexeme-kind$inline-plexeme-equiv-congruence-on-x

    (defthm plexeme-kind$inline-plexeme-equiv-congruence-on-x
      (implies (plexeme-equiv x x-equiv)
               (equal (plexeme-kind$inline x)
                      (plexeme-kind$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: consp-of-plexeme-fix

    (defthm consp-of-plexeme-fix
      (consp (plexeme-fix x))
      :rule-classes :type-prescription)

    Theorem: plexeme-fix$inline-of-plexeme-fix-x

    (defthm plexeme-fix$inline-of-plexeme-fix-x
      (equal (plexeme-fix$inline (plexeme-fix x))
             (plexeme-fix$inline x)))

    Theorem: plexeme-fix$inline-plexeme-equiv-congruence-on-x

    (defthm plexeme-fix$inline-plexeme-equiv-congruence-on-x
      (implies (plexeme-equiv x x-equiv)
               (equal (plexeme-fix$inline x)
                      (plexeme-fix$inline x-equiv)))
      :rule-classes :congruence)