• 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-dec/oct/hex-const

    Validate a decimal, octal, or hexadecimal constant.

    Signature
    (valid-dec/oct/hex-const const) → value
    Arguments
    const — Guard (dec/oct/hex-constp const).
    Returns
    value — Type (natp value).

    This kind of constant is always valid, but for this function we use the naming scheme valid-... for uniformity with the other validator's functions.

    This function actually evaluates the constant, to a natural number. This is needed by the validator in order to assign types to integer constants. This function returns a natural number, which can be arbitrarily large; whether an integer constant is too large is checked elsewhere.

    For a decimal or octal constant, the value is a component of the fixtype. For a hexadecimal constant, we use a library function to convert the digits into a value; the digits are as they appear in the concrete syntax, i.e. in big-endian order.

    Definitions and Theorems

    Function: valid-dec/oct/hex-const

    (defun valid-dec/oct/hex-const (const)
      (declare (xargs :guard (dec/oct/hex-constp const)))
      (dec/oct/hex-const-case
           const
           :dec const.value
           :oct const.value
           :hex (str::hex-digit-chars-value const.digits)))

    Theorem: natp-of-valid-dec/oct/hex-const

    (defthm natp-of-valid-dec/oct/hex-const
      (b* ((value (valid-dec/oct/hex-const const)))
        (natp value))
      :rule-classes :rewrite)

    Theorem: valid-dec/oct/hex-const-of-dec/oct/hex-const-fix-const

    (defthm valid-dec/oct/hex-const-of-dec/oct/hex-const-fix-const
      (equal (valid-dec/oct/hex-const (dec/oct/hex-const-fix const))
             (valid-dec/oct/hex-const const)))

    Theorem: valid-dec/oct/hex-const-dec/oct/hex-const-equiv-congruence-on-const

    (defthm
     valid-dec/oct/hex-const-dec/oct/hex-const-equiv-congruence-on-const
     (implies (dec/oct/hex-const-equiv const const-equiv)
              (equal (valid-dec/oct/hex-const const)
                     (valid-dec/oct/hex-const const-equiv)))
     :rule-classes :congruence)