• 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
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Axe
      • Poseidon
      • Where-do-i-place-my-book
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
                • Flatten-statements/branches
                  • Flatten-statement
                    • Flatten-statement-list
                    • Flatten-branch-list
                    • Flatten-branch
                  • Simplify-flattened-if
                  • Flatten-expression
                  • Fenv-option
                  • Flatten-fundecl
                  • Fenv-const-add
                  • Fenv
                  • Fenv-const-lookup
                  • Init-fenv
                  • Const-fenv
                • Abstract-syntax
                • Dynamic-semantics
                • Compilation
                • Static-semantics
                • Concrete-syntax
        • 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
    • Flatten-statements/branches

    Flatten-statement

    Flatten a statement.

    Signature
    (flatten-statement stmt env) → new-stmt
    Arguments
    stmt — Guard (statementp stmt).
    env — Guard (fenvp env).
    Returns
    new-stmt — Type (statement-resultp new-stmt).

    For a variable declaration, we flatten the initializer. The variable declaration remains, even if the initializer is a constant expression: here we only propagate actual constants, not also variables that happen to have a constant value. The latter kind of transformation will be handled separately.

    Constant declarations are handled not here but in the ACL2 function to flatten lists of statements. The reason is that constant declarations are incorporated into the flattening environments and removed; the removal does not produce any statement in that place. Because of that, the code in this ACL2 function for the constant declaration case should be unreachable.

    For an assignment, we flatten the left-hand side and the right-hand side. In the current version of Leo flattening the left-hand side has no effect in type-correct code, where the left-hand side is always a variable.

    For a return statement, we flatten the expression.

    For now we reject loop statements, because we only do constant propagation and unfolding. We will do loop unrolling later.

    Conditional statements are flattened in two phases. The first phase, carried out in these ACL2 functions here, homomorphically flattens their constituents. The second phase, carried out in simplify-flattened-if, simplifies the resulting constituents.

    For a console statement, we transform its arguments.

    For a block, we flatten its statements.