• 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
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
          • Transformations
          • Language
            • Abstract-syntax
            • Dynamic-semantics
              • Exec
                • Exec-statement
                • Exec-function
                  • Exec-for-iterations
                  • Exec-block
                  • Exec-switch-rest
                  • Exec-expression-list
                  • Exec-funcall
                  • Exec-statement-list
                  • Exec-expression
                • Find-fun
                • Init-local
                • Write-vars-values
                • Add-vars-values
                • Add-funs
                • Eoutcome
                • Soutcome
                • Ensure-funscope-disjoint
                • Write-var-value
                • Restrict-vars
                • Add-var-value
                • Funinfo
                • Exec-top-block
                • Values
                • Cstate
                • Funinfo+funenv
                • Read-vars-values
                • Read-var-value
                • Funenv
                • Funscope-for-fundefs
                • Exec-path
                • Path-to-var
                • Funinfo+funenv-result
                • Exec-literal
                • Soutcome-result
                • Mode-set-result
                • Literal-evaluation
                • Funscope-result
                • Funinfo-result
                • Funenv-result
                • Eoutcome-result
                • Cstate-result
                • Paths-to-vars
                • Funinfo-for-fundef
                • Lstate
                • Funscope
                • Mode-set
                • Modes
              • Concrete-syntax
              • Static-soundness
              • Static-semantics
              • Errors
            • Yul-json
          • 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
    • Exec

    Exec-function

    Execution a function on some values.

    Signature
    (exec-function fun args cstate funenv limit) → outcome
    Arguments
    fun — Guard (identifierp fun).
    args — Guard (value-listp args).
    cstate — Guard (cstatep cstate).
    funenv — Guard (funenvp funenv).
    limit — Guard (natp limit).
    Returns
    outcome — Type (eoutcome-resultp outcome).

    The code in this ACL2 function could be inlined into exec-funcall, but it seems useful to have a separate ACL2 function that takes values directly as arguments, in case we want to formally talk about function calls.

    We find the function in the function environment, also obtaining the (generally smaller) function environment for executing the function. We initialize the local state with the function's inputs and outputs. We run the function body on the resulting computation state and on the function environment for executing the function. We read the final values of the function output variables and return them as result. We also restore the local state prior to the function call.

    As a defensive check, we ensure that the function's body terminates regularly or via leave, not via break or continue.