• 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
          • Atc
          • Transformation-tools
          • 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
              • Wellformed
              • Preprocess
              • Check-tyspecseq
              • Check-param-declon-list
              • Check-iconst
              • Check-expr-pure-list
              • Var-sinfo-option
              • Fun-sinfo-option
              • Funtab+vartab+tagenv
              • Var-scope-all-definedp
                • Var-sinfo
                • Var-table-lookup
                • Apconvert-type
                • Var-table
                • Check-tyname
                • Types+vartab-result
                • Funtab+vartab+tagenv-result
                • Wellformed-result
                • Fun-table-lookup
                • Var-table-scope
                • Var-table-result
                • Var-table-add-block
                • 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
              • Types
              • Integer-formats-definitions
              • Computation-states
              • Portable-ascii-identifiers
              • Values
              • Integer-operations
              • Object-designators
              • Operations
              • Errors
              • Tag-environments
              • Function-environments
              • Character-sets
              • Flexible-array-member-removal
              • Arithmetic-operations
              • Pointer-operations
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • 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
    • Static-semantics

    Var-scope-all-definedp

    CHeck if all the variables in a scope are defined.

    Signature
    (var-scope-all-definedp varscope) → yes/no
    Arguments
    varscope — Guard (var-table-scopep varscope).
    Returns
    yes/no — Type (booleanp yes/no).

    This applies to the file scope; see var-table-all-definedp.

    Even though C allows a variable to remain undefined in a translation unit (if it is not used in expressions), we are more strict and require every variable to be defined. This includes the case of a tentative definition, which is automatically turned into a full definition [C17:6.9.2/2]. So we go through the variables in the (file) scope, ensuring that they are defined or tentatively defined.

    Definitions and Theorems

    Function: var-scope-all-definedp

    (defun var-scope-all-definedp (varscope)
      (declare (xargs :guard (var-table-scopep varscope)))
      (b* ((varscope (var-table-scope-fix varscope))
           ((when (omap::emptyp varscope)) t)
           ((mv & info) (omap::head varscope))
           (defstatus (var-sinfo->defstatus info))
           ((unless (or (var-defstatus-case defstatus :defined)
                        (var-defstatus-case defstatus :tentative)))
            nil))
        (var-scope-all-definedp (omap::tail varscope))))

    Theorem: booleanp-of-var-scope-all-definedp

    (defthm booleanp-of-var-scope-all-definedp
      (b* ((yes/no (var-scope-all-definedp varscope)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: var-scope-all-definedp-of-var-table-scope-fix-varscope

    (defthm var-scope-all-definedp-of-var-table-scope-fix-varscope
      (equal (var-scope-all-definedp (var-table-scope-fix varscope))
             (var-scope-all-definedp varscope)))

    Theorem: var-scope-all-definedp-var-table-scope-equiv-congruence-on-varscope

    (defthm
     var-scope-all-definedp-var-table-scope-equiv-congruence-on-varscope
     (implies (var-table-scope-equiv varscope varscope-equiv)
              (equal (var-scope-all-definedp varscope)
                     (var-scope-all-definedp varscope-equiv)))
     :rule-classes :congruence)