• 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-for-iterations

    Execute the iterations of a loop statement.

    Signature
    (exec-for-iterations test update body cstate funenv limit) 
      → 
    outcome
    Arguments
    test — Guard (expressionp test).
    update — Guard (blockp update).
    body — Guard (blockp body).
    cstate — Guard (cstatep cstate).
    funenv — Guard (funenvp funenv).
    limit — Guard (natp limit).
    Returns
    outcome — Type (soutcome-resultp outcome).

    We execute the test, ensuring it returns one value. As also explained for if (see exec-statement), we consider 0 to be false and any non-0 value to be true.

    If the test is false, we terminate regularly.

    If the test is true, we first execute the body. If it terminates with break, we turn that into a regular termination: we break out of the loop gracefully, no more iterations will happen. If the body terminates with leave, we terminate in the same way. If the body terminates with continue or regularly, we continue the iteration, by executing the update block. If the update block terminates with leave, we terminate the loop in the same way. If the update block terminates with break or continue, we defensively return an error. If the update block terminates regularly, we recursively call this ACL2 function, to continue iterating.