• 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
        • Soft
        • Bv
        • Imp-language
        • Ethereum
        • Event-macros
        • Java
        • Riscv
        • Bitcoin
        • Zcash
        • Yul
          • Transformations
          • Language
            • Abstract-syntax
            • Dynamic-semantics
            • Concrete-syntax
            • Static-soundness
            • Static-semantics
              • Static-safety-checking
                • Check-safe-statements/blocks/cases/fundefs
                • Check-safe-expressions
                • Check-safe-fundef-list
                • Check-safe-variable-multi
                • Check-safe-variable-single
                  • Check-safe-assign-multi
                  • Check-safe-assign-single
                  • Check-safe-path
                  • Check-safe-extends-varset
                  • Vars+modes
                  • Add-vars
                  • Add-var
                  • Add-funtypes
                  • Check-safe-literal
                  • Funtype
                  • Get-funtype
                  • Check-var
                  • Check-safe-top-block
                  • Check-safe-path-list
                  • Vars+modes-result
                  • Funtype-result
                  • Funtable-result
                  • Funtable-for-fundefs
                  • Funtype-for-fundef
                  • Funtable
                • Static-shadowing-checking
                • Mode-set-result
                • Literal-evaluation
                • Static-identifier-checking
                • Static-safety-checking-evm
                • Mode-set
                • Modes
              • Errors
            • Yul-json
          • 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-safety-checking

    Check-safe-variable-single

    Check if a single variable declaration is safe.

    Signature
    (check-safe-variable-single name init varset funtab) → varset?
    Arguments
    name — Guard (identifierp name).
    init — Guard (expression-optionp init).
    varset — Guard (identifier-setp varset).
    funtab — Guard (funtablep funtab).
    Returns
    varset? — Type (identifier-set-resultp varset?).

    This is used by check-safe-statement: see that function's documentation for background.

    The name of the variable must be an identifier that is not already in the variable table. The expression is checked if present, and it must return exactly one result.

    Definitions and Theorems

    Function: check-safe-variable-single

    (defun check-safe-variable-single (name init varset funtab)
      (declare (xargs :guard (and (identifierp name)
                                  (expression-optionp init)
                                  (identifier-setp varset)
                                  (funtablep funtab))))
      (let ((__function__ 'check-safe-variable-single))
        (declare (ignorable __function__))
        (b* ((name (identifier-fix name))
             (init (expression-option-fix init))
             ((okf varset-new) (add-var name varset))
             ((when (not init)) varset-new)
             ((okf results)
              (check-safe-expression init varset funtab))
             ((unless (= results 1))
              (reserrf (list :declare-single-var-mismatch
                             name results))))
          varset-new)))

    Theorem: identifier-set-resultp-of-check-safe-variable-single

    (defthm identifier-set-resultp-of-check-safe-variable-single
      (b*
        ((varset? (check-safe-variable-single name init varset funtab)))
        (identifier-set-resultp varset?))
      :rule-classes :rewrite)

    Theorem: check-safe-variable-single-of-identifier-fix-name

    (defthm check-safe-variable-single-of-identifier-fix-name
      (equal (check-safe-variable-single (identifier-fix name)
                                         init varset funtab)
             (check-safe-variable-single name init varset funtab)))

    Theorem: check-safe-variable-single-identifier-equiv-congruence-on-name

    (defthm
         check-safe-variable-single-identifier-equiv-congruence-on-name
     (implies
       (identifier-equiv name name-equiv)
       (equal
            (check-safe-variable-single name init varset funtab)
            (check-safe-variable-single name-equiv init varset funtab)))
     :rule-classes :congruence)

    Theorem: check-safe-variable-single-of-expression-option-fix-init

    (defthm check-safe-variable-single-of-expression-option-fix-init
      (equal
           (check-safe-variable-single name (expression-option-fix init)
                                       varset funtab)
           (check-safe-variable-single name init varset funtab)))

    Theorem: check-safe-variable-single-expression-option-equiv-congruence-on-init

    (defthm
     check-safe-variable-single-expression-option-equiv-congruence-on-init
     (implies
       (expression-option-equiv init init-equiv)
       (equal
            (check-safe-variable-single name init varset funtab)
            (check-safe-variable-single name init-equiv varset funtab)))
     :rule-classes :congruence)

    Theorem: check-safe-variable-single-of-identifier-set-fix-varset

    (defthm check-safe-variable-single-of-identifier-set-fix-varset
     (equal
       (check-safe-variable-single name init (identifier-set-fix varset)
                                   funtab)
       (check-safe-variable-single name init varset funtab)))

    Theorem: check-safe-variable-single-identifier-set-equiv-congruence-on-varset

    (defthm
     check-safe-variable-single-identifier-set-equiv-congruence-on-varset
     (implies
       (identifier-set-equiv varset varset-equiv)
       (equal
            (check-safe-variable-single name init varset funtab)
            (check-safe-variable-single name init varset-equiv funtab)))
     :rule-classes :congruence)

    Theorem: check-safe-variable-single-of-funtable-fix-funtab

    (defthm check-safe-variable-single-of-funtable-fix-funtab
      (equal (check-safe-variable-single
                  name init varset (funtable-fix funtab))
             (check-safe-variable-single name init varset funtab)))

    Theorem: check-safe-variable-single-funtable-equiv-congruence-on-funtab

    (defthm
         check-safe-variable-single-funtable-equiv-congruence-on-funtab
     (implies
       (funtable-equiv funtab funtab-equiv)
       (equal
            (check-safe-variable-single name init varset funtab)
            (check-safe-variable-single name init varset funtab-equiv)))
     :rule-classes :congruence)