• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
        • Soft
        • C
          • Syntax-for-tools
            • Disambiguator
            • Abstract-syntax
            • Parser
            • Validator
              • Valid-exprs/decls/stmts
              • Valid-stmt
              • Valid-expr
              • Valid-dirdeclor
              • Valid-type-spec
              • Valid-transunit
              • Valid-stor-spec-list
              • Valid-binary
              • Valid-unary
              • Valid-initdeclor
              • Valid-fundef
              • Valid-type-spec-list-residual
              • Valid-cond
              • Valid-lookup-ord
              • Valid-transunit-ensemble
              • Valid-declor
              • Valid-iconst
              • Valid-initer
              • Valid-c-char
              • Valid-stringlit-list
              • Valid-funcall
              • Valid-add-ord
              • Valid-arrsub
              • Valid-univ-char-name
              • Valid-extdecl
              • Valid-extdecl-list
              • Valid-cast
              • Valid-add-ord-file-scope
              • Valid-spec/qual
              • Valid-sizeof/alignof
              • Valid-memberp
              • Valid-decl-spec
              • Valid-var
              • Valid-param-declon
              • Valid-oct-escape
              • Valid-structdeclor
              • Valid-structdecl
              • Valid-designor
              • Valid-escape
              • Valid-enum-const
              • Valid-cconst
              • Valid-s-char
              • Valid-dec/oct/hex-const
              • Valid-const
                • Valid-gensel
                • Valid-decl-spec-list
                • Valid-lookup-ord-file-scope
                • Valid-member
                • Valid-param-declor
                • Valid-spec/qual-list
                • Valid-fconst
                • Valid-stringlit
                • Valid-s-char-list
                • Valid-c-char-list
                • Valid-block-item
                • Valid-structdeclor-list
                • Valid-simple-escape
                • Valid-align-spec
                • Valid-enumer
                • Valid-dirabsdeclor
                • Valid-decl
                • Valid-pop-scope
                • Valid-enumspec
                • Valid-declor-option
                • Valid-push-scope
                • Valid-initer-option
                • Valid-block-item-list
                • Valid-absdeclor
                • Valid-label
                • Valid-genassoc
                • Valid-tyname
                • Valid-strunispec
                • Valid-structdecl-list
                • Valid-genassoc-list
                • Valid-dirabsdeclor-option
                • Valid-designor-list
                • Valid-const-expr
                • Valid-initdeclor-list
                • Valid-desiniter-list
                • Valid-absdeclor-option
                • Valid-table-num-scopes
                • Valid-expr-list
                • Valid-param-declon-list
                • Valid-desiniter
                • Valid-const-expr-option
                • Valid-expr-option
                • Valid-statassert
                • Valid-enumer-list
                • Valid-init-table
                • Valid-empty-scope
                • Valid-member-designor
                • Valid-decl-list
              • Printer
              • Formalized-subset
              • Mapping-to-language-definition
              • Input-files
              • Defpred
              • Output-files
              • Abstract-syntax-operations
              • Validation-information
              • Implementation-environments
              • Concrete-syntax
              • Unambiguity
              • Ascii-identifiers
              • Preprocessing
              • Abstraction-mapping
            • Atc
            • Language
            • Representation
            • Transformation-tools
            • Insertion-sort
            • Pack
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Validator

    Valid-const

    Validate a constant.

    Signature
    (valid-const const table ienv) → (mv erp new-const type)
    Arguments
    const — Guard (constp const).
    table — Guard (valid-tablep table).
    ienv — Guard (ienvp ienv).
    Returns
    new-const — Type (constp new-const).
    type — Type (typep type).

    If validation is successful, we return the type of the constant.

    Definitions and Theorems

    Function: valid-const

    (defun valid-const (const table ienv)
      (declare (xargs :guard (and (constp const)
                                  (valid-tablep table)
                                  (ienvp ienv))))
      (let ((__function__ 'valid-const))
        (declare (ignorable __function__))
        (b* (((reterr) (irr-const) (irr-type)))
          (const-case const :int
                      (b* (((erp iconst type)
                            (valid-iconst const.unwrap ienv)))
                        (retok (const-int iconst) type))
                      :float
                      (b* ((type (valid-fconst const.unwrap)))
                        (retok (const-fix const) type))
                      :enum
                      (b* (((erp type)
                            (valid-enum-const const.unwrap table)))
                        (retok (const-fix const) type))
                      :char
                      (b* (((erp type)
                            (valid-cconst const.unwrap)))
                        (retok (const-fix const) type))))))

    Theorem: constp-of-valid-const.new-const

    (defthm constp-of-valid-const.new-const
      (b* (((mv acl2::?erp ?new-const ?type)
            (valid-const const table ienv)))
        (constp new-const))
      :rule-classes :rewrite)

    Theorem: typep-of-valid-const.type

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

    Theorem: valid-const-of-const-fix-const

    (defthm valid-const-of-const-fix-const
      (equal (valid-const (const-fix const)
                          table ienv)
             (valid-const const table ienv)))

    Theorem: valid-const-const-equiv-congruence-on-const

    (defthm valid-const-const-equiv-congruence-on-const
      (implies (const-equiv const const-equiv)
               (equal (valid-const const table ienv)
                      (valid-const const-equiv table ienv)))
      :rule-classes :congruence)

    Theorem: valid-const-of-valid-table-fix-table

    (defthm valid-const-of-valid-table-fix-table
      (equal (valid-const const (valid-table-fix table)
                          ienv)
             (valid-const const table ienv)))

    Theorem: valid-const-valid-table-equiv-congruence-on-table

    (defthm valid-const-valid-table-equiv-congruence-on-table
      (implies (valid-table-equiv table table-equiv)
               (equal (valid-const const table ienv)
                      (valid-const const table-equiv ienv)))
      :rule-classes :congruence)

    Theorem: valid-const-of-ienv-fix-ienv

    (defthm valid-const-of-ienv-fix-ienv
      (equal (valid-const const table (ienv-fix ienv))
             (valid-const const table ienv)))

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

    (defthm valid-const-ienv-equiv-congruence-on-ienv
      (implies (ienv-equiv ienv ienv-equiv)
               (equal (valid-const const table ienv)
                      (valid-const const table ienv-equiv)))
      :rule-classes :congruence)