Mathematical reasoning about the implemented factorial function #
eval and bodyTime observe the one function defined in
Ram.Examples.Factorial.functions. They do not execute its optional stream
driver. The definitions mention neither mathematical factorial nor a proposed
cost; the equations below establish those properties of the implementation.
The initial state is hidden once, then eval_eq_of_execution proves that this
view agrees with the returned value at every actual caller state. The example
uses mathlib's Part: these are noncomputable proof views, not a new interpreter
or ordinary Lean code accepted by the RAM compiler. Word overflow remains
explicit, and the time observation excludes the enclosing call overhead.
Observe its actual body count, independently of any bound or specification.
Equations
Instances For
When the result fits, an ordinary function-value equation states correctness.
Hiding the initial state did not change the function's meaning: the view agrees with a call in any shared state, and that state is preserved on return.
The time equation is proved from the existing exact body execution, separately from the function's result theorem.
The time observation agrees with every actual invocation, not just the
canonical initial state hidden by bodyTime.