• 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
              • Exec-expr
              • Exec
              • Exec-expr-pure
              • Exec-arrsub
              • Variable-resolution-preservation
              • Init-value-to-value
              • Apconvert-expr-value
              • Execution-limit-monotonicity
              • Exec-memberp
              • Exec-stmt
              • Exec-address
              • Init-scope
              • Exec-unary
              • Exec-member
              • Exec-fun
              • Exec-stmt-while
                • Eval-iconst
                • Exec-expr-pure-list
                • Exec-binary-strict-pure
                • Variable-visibility-preservation
                • Object-type-preservation
                • Eval-binary-strict-pure
                • Exec-block-item-list
                • Exec-indir
                • Exec-ident
                • Exec-block-item
                • Eval-cast
                • Frame-and-scope-peeling
                • Exec-obj-declon
                • Exec-cast
                • Exec-const
                • Eval-unary
                • Exec-stmt-dowhile
                • Exec-initer
                • Pure-expression-execution
                • Eval-const
                • Execution-without-function-calls
              • Static-semantics
              • 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
    • Dynamic-semantics
    • Exec

    Exec-stmt-while

    Execute a while statement.

    Signature
    (exec-stmt-while test body compst fenv limit) 
      → 
    (mv sval new-compst)
    Arguments
    test — Guard (exprp test).
    body — Guard (stmtp body).
    compst — Guard (compustatep compst).
    fenv — Guard (fun-envp fenv).
    limit — Guard (natp limit).
    Returns
    sval — Type (stmt-value-resultp sval).
    new-compst — Type (compustatep new-compst).

    First, we execute the test. If it yields a 0 scalar, we return a nil value result, because it means that the loop completes, and execution can proceed with any code after the loop. Otherwise, we recursively execute the body. We should push and then pop a scope, because the body of a loop forms a block [C17:6.8.5/5]; we plan to do that, but currently that makes no difference given how we are using our dynamic semantics of C. If the body terminates with a return, we terminate the loop with the same result. If the body does not terminate with a return, we re-execute the loop, by calling this ACL2 function recursively.