• 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
              • Validator
                • Valid-exprs/decls/stmts
                • Valid-stmt
                • Valid-expr
                • Valid-dirdeclor
                • Valid-binary
                • Valid-type-spec
                • Valid-transunit
                • Valid-stor-spec-list
                • Valid-prototype-args
                • Valid-fundef
                • Valid-unary
                • Valid-init-declor
                • Valid-stringlit-list
                • Valid-type-spec-list-residual
                • Valid-transunit-ensemble
                • Valid-cond
                • Valid-lookup-ord
                • Valid-c-char
                • Valid-funcall
                • Valid-iconst
                • Valid-add-ord-objfuns-file-scope
                • Valid-initer
                • Valid-declor
                • Valid-add-ord
                • Valid-arrsub
                • Valid-update-ext
                • Valid-ext-declon-list
                • Valid-ext-declon
                • Valid-univ-char-name
                • Valid-memberp
                • Valid-add-ord-file-scope
                • Valid-var
                • Valid-s-char
                • Valid-decl-spec
                • Valid-cconst
                • Valid-cast
                • Valid-sizeof/alignof
                • Valid-stringlit
                  • Valid-spec/qual
                  • Valid-oct-escape
                  • Valid-get-fresh-uid
                  • Valid-param-declon
                  • Valid-struct-declon
                  • Valid-struct-declor
                  • Valid-has-internalp
                  • Valid-escape
                  • Valid-enum-const
                  • Valid-gensel
                  • Valid-const
                  • Valid-desiniter-list
                  • Valid-designor
                  • Valid-param-declor
                  • Valid-dec/oct/hex-const
                  • Valid-s-char-list
                  • Valid-decl-spec-list
                  • Valid-c-char-list
                  • Valid-member
                  • Valid-init-table
                  • Valid-lookup-ord-file-scope
                  • Valid-comp-stmt
                  • Valid-spec/qual-list
                  • Valid-lookup-ext
                  • Valid-designor-list
                  • Valid-fconst
                  • Valid-block-item
                  • Valid-struct-declor-list
                  • Valid-genassoc-list
                  • Valid-align-spec
                  • Valid-enumer
                  • Valid-declon
                  • Valid-simple-escape
                  • Valid-enum-spec
                  • Valid-dirabsdeclor
                  • Valid-declor-option
                  • Valid-pop-scope
                  • Valid-initer-option
                  • Valid-expr-list
                  • Valid-block-item-list
                  • Valid-absdeclor
                  • Valid-struct-declon-list
                  • Valid-push-scope
                  • Valid-label
                  • Valid-genassoc
                  • Valid-tyname
                  • Valid-struni-spec
                  • Valid-dirabsdeclor-option
                  • Valid-const-expr
                  • Valid-init-declor-list
                  • Valid-absdeclor-option
                  • Valid-param-declon-list
                  • Valid-desiniter
                  • Valid-const-expr-option
                  • Valid-table-num-scopes
                  • Valid-expr-option
                  • Valid-statassert
                  • Valid-enumer-list
                  • Valid-member-designor
                  • Valid-declon-list
                  • Valid-empty-scope
                • Validation-information
              • Gcc-builtins
              • 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
    • Validator

    Valid-stringlit

    Validate a string literal.

    Signature
    (valid-stringlit strlit ienv) → (mv erp type)
    Arguments
    strlit — Guard (stringlitp strlit).
    ienv — Guard (ienvp ienv).
    Returns
    erp — Type (maybe-msgp erp).
    type — Type (typep type).

    We check the characters that form the string literal, with respect to the prefix (if any). If validation is successful, we return the type of the string literal. If the literal is a character string literal (i.e. it has no encoding prefix) or a UTF-8 string literal (i.e. it has the u8 prefix), it has an array type with element type char. If an encoding prefix is present, the literal may have type wchar_t or char16_t or char32_t. Since we do not yet model the values of these type definitions, we return an array type with an unknown element type in these cases.

    Definitions and Theorems

    Function: valid-stringlit

    (defun valid-stringlit (strlit ienv)
      (declare (xargs :guard (and (stringlitp strlit) (ienvp ienv))))
      (b* (((reterr) (irr-type))
           ((stringlit strlit) strlit)
           ((erp &)
            (valid-s-char-list strlit.schars strlit.prefix? ienv)))
        (retok (make-type-array
                    :of
                    (if (or (not strlit.prefix?)
                            (eprefix-case strlit.prefix? :locase-u8))
                        (type-char)
                      (type-unknown))))))

    Theorem: maybe-msgp-of-valid-stringlit.erp

    (defthm maybe-msgp-of-valid-stringlit.erp
      (b* (((mv acl2::?erp ?type)
            (valid-stringlit strlit ienv)))
        (maybe-msgp erp))
      :rule-classes :rewrite)

    Theorem: typep-of-valid-stringlit.type

    (defthm typep-of-valid-stringlit.type
      (b* (((mv acl2::?erp ?type)
            (valid-stringlit strlit ienv)))
        (typep type))
      :rule-classes :rewrite)

    Theorem: valid-stringlit-of-stringlit-fix-strlit

    (defthm valid-stringlit-of-stringlit-fix-strlit
      (equal (valid-stringlit (stringlit-fix strlit)
                              ienv)
             (valid-stringlit strlit ienv)))

    Theorem: valid-stringlit-stringlit-equiv-congruence-on-strlit

    (defthm valid-stringlit-stringlit-equiv-congruence-on-strlit
      (implies (stringlit-equiv strlit strlit-equiv)
               (equal (valid-stringlit strlit ienv)
                      (valid-stringlit strlit-equiv ienv)))
      :rule-classes :congruence)

    Theorem: valid-stringlit-of-ienv-fix-ienv

    (defthm valid-stringlit-of-ienv-fix-ienv
      (equal (valid-stringlit strlit (ienv-fix ienv))
             (valid-stringlit strlit ienv)))

    Theorem: valid-stringlit-ienv-equiv-congruence-on-ienv

    (defthm valid-stringlit-ienv-equiv-congruence-on-ienv
      (implies (ienv-equiv ienv ienv-equiv)
               (equal (valid-stringlit strlit ienv)
                      (valid-stringlit strlit ienv-equiv)))
      :rule-classes :congruence)