Returning from an ordinary-local block observation #
The ordinary-local observation retains all local values on every exit. At a
function continuation boundary, only normal completion passes those values to
the remaining statements. Return and fault exit immediately with the actual
final heap. Stmt.evalWith_eq_observe connects these two existing views using
the native exception transformer; it does not interpret the source again.
theorem
Complexity.Language.Stmt.evalWith_eq_observe
{signatures : List Signature}
{Γ : List Ty}
{result : Ty}
{Locals : Type}
(view : Env Γ ≃ Locals)
(stmt : Stmt signatures Γ result)
(program : Program signatures)
(entry : Env Γ)
(next : Env Γ → ExceptT Fault (StateT Heap Part) (Value result))
:
stmt.evalWith program entry next = do
let __discr ← ExceptT.lift (observe view stmt program (view entry))
match __discr with
| (control, locals) =>
match control with
| Control.normal => next (view.symm locals)
| Control.returned value => pure value
| Control.fault error => throw error
Connect a lossless block observation to the existing function continuation.
Normal completion uses the actual updated locals. Return and fault skip next
without discarding the block's heap effects.