• 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
          • Atc
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
            • Dynamic-semantics
            • Static-semantics
              • Check-stmt
              • Check-cond
              • Check-binary-pure
              • Var-table-add-var
              • Check-unary
              • Check-obj-declon
              • Fun-table-add-fun
              • Check-fundef
              • Fun-sinfo
              • Check-expr-asg
              • Check-expr-call
              • Check-arrsub
              • Uaconvert-types
              • Apconvert-type-list
              • Check-initer
                • Adjust-type-list
                • Types+vartab
                • Promote-type
                • Check-tag-declon
                • Check-expr-call-or-asg
                • Check-ext-declon
                • Check-param-declon
                • Check-member
                • Check-expr-pure
                • Init-type-matchp
                • Check-obj-adeclor
                • Check-memberp
                • Check-expr-call-or-pure
                • Check-cast
                • Check-struct-declon-list
                • Check-fun-declor
                • Expr-type
                • Check-ext-declon-list
                • Check-transunit
                • Check-fun-declon
                • Var-defstatus
                • Struct-member-lookup
                • Preprocess
                • Wellformed
                • Check-tyspecseq
                • Check-param-declon-list
                • Check-iconst
                • Check-expr-pure-list
                • Var-sinfo-option
                • Fun-sinfo-option
                • Var-scope-all-definedp
                • Funtab+vartab+tagenv
                • Var-sinfo
                • Var-table-lookup
                • Apconvert-type
                • Var-table
                • Check-tyname
                • Types+vartab-result
                • Funtab+vartab+tagenv-result
                • Fun-table-lookup
                • Wellformed-result
                • Var-table-add-block
                • Var-table-scope
                • Var-table-result
                • Fun-table-result
                • Expr-type-result
                • Adjust-type
                • Check-fileset
                • Var-table-all-definedp
                • Check-const
                • Fun-table-all-definedp
                • Check-ident
                • Fun-table
                • Var-table-init
                • Fun-table-init
              • Grammar
              • Integer-formats
              • Types
              • Portable-ascii-identifiers
              • Values
              • Integer-operations
              • Computation-states
              • Object-designators
              • Operations
              • Errors
              • Tag-environments
              • Function-environments
              • Character-sets
              • Flexible-array-member-removal
              • Arithmetic-operations
              • Pointer-operations
              • Bytes
              • Keywords
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • 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
    • Static-semantics

    Check-initer

    Check an initializer.

    Signature
    (check-initer initer funtab vartab tagenv constp) → type
    Arguments
    initer — Guard (initerp initer).
    funtab — Guard (fun-tablep funtab).
    vartab — Guard (var-tablep vartab).
    tagenv — Guard (tag-envp tagenv).
    constp — Guard (booleanp constp).
    Returns
    type — Type (init-type-resultp type).

    If the initializer is a single expression, we ensure that it is a well-formed pure or call expression, and we return the type as a single initialization type.

    If the initializer is a list of expressions, for now we require them to be pure expressions, and we return their types as a list initialization type.

    The parameter constp passed to this ACL2 function is a flag indicating whether the initializer must be constant or not.

    Definitions and Theorems

    Function: check-initer

    (defun check-initer (initer funtab vartab tagenv constp)
     (declare (xargs :guard (and (initerp initer)
                                 (fun-tablep funtab)
                                 (var-tablep vartab)
                                 (tag-envp tagenv)
                                 (booleanp constp))))
     (let ((__function__ 'check-initer))
      (declare (ignorable __function__))
      (initer-case
        initer :single
        (b* (((okf type)
              (check-expr-call-or-pure initer.get funtab vartab tagenv))
             ((when (and constp (not (expr-constp initer.get))))
              (reserrf (list :not-constant
                             :single initer.get))))
          (init-type-single type))
        :list
        (b* (((okf types)
              (check-expr-pure-list initer.get vartab tagenv))
             ((when (and constp
                         (not (expr-list-constp initer.get))))
              (reserrf (list :not-constant
                             :multi initer.get))))
          (init-type-list types)))))

    Theorem: init-type-resultp-of-check-initer

    (defthm init-type-resultp-of-check-initer
      (b* ((type (check-initer initer funtab vartab tagenv constp)))
        (init-type-resultp type))
      :rule-classes :rewrite)

    Theorem: check-initer-of-initer-fix-initer

    (defthm check-initer-of-initer-fix-initer
      (equal (check-initer (initer-fix initer)
                           funtab vartab tagenv constp)
             (check-initer initer funtab vartab tagenv constp)))

    Theorem: check-initer-initer-equiv-congruence-on-initer

    (defthm check-initer-initer-equiv-congruence-on-initer
      (implies (initer-equiv initer initer-equiv)
               (equal (check-initer initer funtab vartab tagenv constp)
                      (check-initer initer-equiv
                                    funtab vartab tagenv constp)))
      :rule-classes :congruence)

    Theorem: check-initer-of-fun-table-fix-funtab

    (defthm check-initer-of-fun-table-fix-funtab
      (equal (check-initer initer (fun-table-fix funtab)
                           vartab tagenv constp)
             (check-initer initer funtab vartab tagenv constp)))

    Theorem: check-initer-fun-table-equiv-congruence-on-funtab

    (defthm check-initer-fun-table-equiv-congruence-on-funtab
      (implies (fun-table-equiv funtab funtab-equiv)
               (equal (check-initer initer funtab vartab tagenv constp)
                      (check-initer initer
                                    funtab-equiv vartab tagenv constp)))
      :rule-classes :congruence)

    Theorem: check-initer-of-var-table-fix-vartab

    (defthm check-initer-of-var-table-fix-vartab
      (equal (check-initer initer funtab (var-table-fix vartab)
                           tagenv constp)
             (check-initer initer funtab vartab tagenv constp)))

    Theorem: check-initer-var-table-equiv-congruence-on-vartab

    (defthm check-initer-var-table-equiv-congruence-on-vartab
      (implies (var-table-equiv vartab vartab-equiv)
               (equal (check-initer initer funtab vartab tagenv constp)
                      (check-initer initer
                                    funtab vartab-equiv tagenv constp)))
      :rule-classes :congruence)

    Theorem: check-initer-of-tag-env-fix-tagenv

    (defthm check-initer-of-tag-env-fix-tagenv
      (equal (check-initer initer
                           funtab vartab (tag-env-fix tagenv)
                           constp)
             (check-initer initer funtab vartab tagenv constp)))

    Theorem: check-initer-tag-env-equiv-congruence-on-tagenv

    (defthm check-initer-tag-env-equiv-congruence-on-tagenv
      (implies (tag-env-equiv tagenv tagenv-equiv)
               (equal (check-initer initer funtab vartab tagenv constp)
                      (check-initer initer
                                    funtab vartab tagenv-equiv constp)))
      :rule-classes :congruence)

    Theorem: check-initer-of-bool-fix-constp

    (defthm check-initer-of-bool-fix-constp
      (equal (check-initer initer funtab
                           vartab tagenv (acl2::bool-fix constp))
             (check-initer initer funtab vartab tagenv constp)))

    Theorem: check-initer-iff-congruence-on-constp

    (defthm check-initer-iff-congruence-on-constp
      (implies (iff constp constp-equiv)
               (equal (check-initer initer funtab vartab tagenv constp)
                      (check-initer initer
                                    funtab vartab tagenv constp-equiv)))
      :rule-classes :congruence)