• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Zcash
      • Des
      • X86isa
      • Sha-2
      • 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
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Axe
        • Poseidon
        • Where-do-i-place-my-book
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Static-safety-checking

    Check-safe-top-block

    Check if the top block is safe.

    Signature
    (check-safe-top-block block) → _
    Arguments
    block — Guard (blockp block).
    Returns
    _ — Type (reserr-optionp _).

    We check the safety of the block starting with no variables or functions in scope, because this is the block at the top level. Since the top block is not inside a function or loop, it is only allowed to terminate regularly. If the checking succeeds, we return nothing (i.e. nil). Otherwise, we return an error.

    Definitions and Theorems

    Function: check-safe-top-block

    (defun check-safe-top-block (block)
      (declare (xargs :guard (blockp block)))
      (let ((__function__ 'check-safe-top-block))
        (declare (ignorable __function__))
        (b* (((okf modes)
              (check-safe-block block nil nil)))
          (if (equal modes (insert (mode-regular) nil))
              nil
            (reserrf (list :top-block-mode modes))))))

    Theorem: reserr-optionp-of-check-safe-top-block

    (defthm reserr-optionp-of-check-safe-top-block
      (b* ((_ (check-safe-top-block block)))
        (reserr-optionp _))
      :rule-classes :rewrite)

    Theorem: check-safe-top-block-of-block-fix-block

    (defthm check-safe-top-block-of-block-fix-block
      (equal (check-safe-top-block (block-fix block))
             (check-safe-top-block block)))

    Theorem: check-safe-top-block-block-equiv-congruence-on-block

    (defthm check-safe-top-block-block-equiv-congruence-on-block
      (implies (block-equiv block block-equiv)
               (equal (check-safe-top-block block)
                      (check-safe-top-block block-equiv)))
      :rule-classes :congruence)