The call-aware monadic-interpreter stepper, over any PureExpr #
Calls.stepCmd π steps a CmdExt P command: a base command through the generic
stepBaseCmdStore, and a .call as an exact run-to-completion of the callee
body in the same effect monad, at strictly smaller fuel: a structured body through the
Imperative driver runInterp, a CFG body through the CFG driver runInterpCFG. It follows the
reference rule Calls.EvalCmdExtE.call_sem: callEntryStore is its InitCallFrame, the
argument evaluation and out read its other CallEntry premises, the trailing
readVarList/bindPositional pair its CallExit, and the callee's non-free pre- and
postconditions are emitted as assertion events (never adjudicated) around the body run.
An unresolved callee and a positional arity mismatch are refused.
It also defines, over this stepper, the target-event predicates assertFailureHalt and
targetReached and the replay verdicts genuine, genuineFeasible, genuineEnforced.
Lemmas about these definitions are in InterpreterCallProps.lean.
Executable call helpers #
Evaluate a list of expressions with the language's fuel-bounded evaluator,
short-circuiting to none if any does not reduce.
Equations
Instances For
A point update of a store of any value type (runtime or semantic).
Instances For
On semantic stores, storeUpdate is SemanticStore.update.
Positionally bind names to values on top of a store (point updates, in order). Extra names or extra values are dropped.
Equations
- Imperative.Calls.bindPositional store (name :: names_2) (value :: values_2) = Imperative.Calls.bindPositional (Imperative.Calls.storeUpdate store name value) names_2 values_2
- Imperative.Calls.bindPositional store names values = store
Instances For
Read a list of variables from a store, short-circuiting to none if any is
undefined.
Equations
- Imperative.Calls.readVarList store [] = some []
- Imperative.Calls.readVarList store (name :: rest) = match store name with | some value => Option.map (fun (x : List V) => value :: x) (Imperative.Calls.readVarList store rest) | none => none
Instances For
The typed write-back check of a call: every written-back value passes the runtime value check
isValue and has the type of the value its target held before the call (sameType), pairing
the targets' previous values olds with the written values vals positionally.
Equations
Instances For
withOldSnapshots over stores of any value type (runtime or semantic): every name of
snapshot is also readable under its old name.
Equations
- Imperative.Calls.withOldSnapshotsV snapshot σ id = match List.find? (fun (g : P.Ident) => Imperative.HasOldIdent.mkOld g == id) snapshot with | some g => σ g | none => σ id
Instances For
On semantic stores, withOldSnapshotsV is withOldSnapshots.
The runtime counterpart of defaultAssertEvents: the non-free clauses of checks as
runtime assert events at the runtime snapshot (rf, σ).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The callee's entry frame σAO: a fresh, empty store in which the input formals
hold the evaluated input values, the output-only formals hold the caller's
out-actual values, and each inout formal is snapshotted under old.
Executable counterpart of InitCallFrame.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The stepper #
The callee body run of a .call, from the entry frame entryStore at the caller's factory
fac and driver fuel fuel, over the command stepper step; it returns the body's final
store. A structured body ss runs as .block "" ss through runInterp, and its final
store is the store of the terminal configuration. A CFG body g runs through
runInterpCFG from its entry block, each command through step at the running store, and
its final store is the halting store projected through the entry frame (projectStore), as
in BigStepE. A body that does not end in a terminal configuration stops with
programCallBodyExited.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The call-aware command stepper, generic over the effect monad m. depth is the
remaining call-depth budget: how many more calls may nest inside this one. Base
commands go through stepBaseCmdStore (presented as .terminal). .call at
fuel fuel' + 1 stops with callDepthExceeded at budget 0; at budget depth' + 1 it
evaluates its arguments, builds the callee frame, emits the non-free preconditions with
their site metadata (checksAtCall md), runs the callee body (runCallee) at the caller's
factory with this stepper baked at budget depth' and fuel fuel', emits the non-free
postconditions at the callee's final store, checks that each output has the type of the value
its target held (writeBackTyped; illTypedValue otherwise), and writes the outputs back.
Equations
- One or more equations did not get rendered due to their size.
- Imperative.Calls.stepCmd π depth 0 env (Imperative.CmdExt.call procName args md) = throw Imperative.StopReason.replayFuelExhausted
- Imperative.Calls.stepCmd π 0 depth'.succ env (Imperative.CmdExt.call procName args md) = throw Imperative.StopReason.callDepthExceeded
Instances For
The call-aware driver: runInterp over stepCmd π maxCallDepth, nesting at most
maxCallDepth calls.
Equations
- Imperative.Calls.runCallInterp π fuel cfg maxCallDepth = Imperative.runInterp (Imperative.Calls.stepCmd π maxCallDepth) fuel cfg
Instances For
Target-event predicates #
The halting predicate: fire on the event matching the target obligation id
(label and md) whose recorded condition evaluates, under the bounded
evaluator, to the literal that witnesses the obligation, up to metadata
(InterpLang.eqModuloMeta): ff (a failing assertion) for an .assert, tt (a reached
cover) for a .cover.
Equations
- One or more equations did not get rendered due to their size.
- Imperative.Calls.assertFailureHalt target fuel x✝ = false
Instances For
Target-id match of an event (an .assert/.cover with the target's label and
metadata), with no evaluation of the condition.
Equations
- Imperative.Calls.targetReached target (Imperative.REvent.assert arg) = (target.label == arg.label && decide (target.md = arg.metadata))
- Imperative.Calls.targetReached target (Imperative.REvent.cover arg) = (target.label == arg.label && decide (target.md = arg.metadata))
- Imperative.Calls.targetReached target x✝ = false
Instances For
Target-id match of a semantic event, with no evaluation of the condition: the semantic
counterpart of targetReached.
Equations
- Imperative.Calls.targetReachedE target (Imperative.Event.assert arg) = (target.label == arg.label && decide (target.md = arg.metadata))
- Imperative.Calls.targetReachedE target (Imperative.Event.cover arg) = (target.label == arg.label && decide (target.md = arg.metadata))
- Imperative.Calls.targetReachedE target x✝ = false
Instances For
Replay verdicts over the call-aware stepper #
Production stop hook, interrupt only: throw .interrupted at a failing target
occurrence.
Equations
- Imperative.Calls.targetInterrupt target fuel ev = if Imperative.Calls.assertFailureHalt target fuel ev = true then some (Imperative.StopReason.interrupted "target failure reached") else none
Instances For
Production stop hook: targetInterrupt, plus a throw on an .assume not evaluating to tt
up to metadata (InterpLang.boolLit?).
Equations
- One or more equations did not get rendered due to their size.
- Imperative.Calls.enforceInterrupt target fuel ev = if Imperative.Calls.assertFailureHalt target fuel ev = true then some (Imperative.StopReason.interrupted "target failure reached") else none
Instances For
Path-feasibility of a replay trace: every .assume event evaluates under the bounded
evaluator to tt up to metadata (InterpLang.boolLit?).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Strict record-only replay of cex through runCallInterp π at fuel fuel and call-depth
limit maxCallDepth, halting on the target id.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Genuineness: cex replays, at fuel fuel and call-depth limit maxCallDepth, to the
target failure.
Equations
- Imperative.Calls.genuine π target fuel cex maxCallDepth = (Imperative.Calls.replayWith cex target fuel π maxCallDepth = Imperative.CEValidationVerdict.genuine)
Instances For
Genuineness with path-feasibility of the enforcing production run's trace.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Genuineness of the enforcing production run.
Equations
- One or more equations did not get rendered due to their size.