Ordinary proofs for recursive and iterative source factorials #
The source function makes a real self-call and multiplies its returned value. Its native Lean definition and ordinary natural-number induction prove the mathematical factorial result. Generated correspondence transfers that result to the same source program, retaining every initial shared heap.
The iterative declaration uses a finite source for and a mutable accumulator.
Its native proof reduces the same iteration to an ordinary list fold, then
reuses mathlib's factorial product formula. Generated correspondence supplies
source correctness without an author-written loop invariant or heap adapter.
This is the high-level counterpart of the factorial use case in
Examples.Ram.FactorialFunction. It proves independent source behavior, not
word-RAM realizability for arbitrary natural inputs or an execution-time bound.
Executable total value function generated from the same buffer-free source block.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One source-body equation in ordinary monadic notation; named callees remain opaque.
The actual source action terminates with the generated native result and preserves every initial heap. Lean's native recursion principle proves this once.
Apply a supplied source contract with ordinary named arguments and its actual returned value and final heap. No callee body or new contract is inferred.
Exact total source contract inherited from the generated native function.
Fold an actual source invocation back to its named ordinary-argument observation.
This named source function's index in its declared signature table.
Equations
Instances For
Prove the ordinary-parameter source contract with a total-correctness triple for the same action. The ghost initial heap equals the actual entry heap; successful results use the actual final heap, and faults are excluded.
The actual declared argument environment, constructed from ordinary source parameters. This is proof-side parameter transport, not an additional runtime operation.
Equations
Instances For
The finite table of actual named source bodies.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The source program's declared first-order signatures.
Equations
Instances For
Budget-free total correctness with ordinary source parameters and relational initial/final heap postconditions. This is the existing source function contract.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The named function's actual partial source action, with ordinary typed arguments and an explicitly supplied shared heap.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The source contract is equivalent to ordinary curried preconditions and successful result/heap postconditions, including termination and absence of faults.
Apply a predicate, postcondition or bound with ordinary source parameters to the actual argument environment. No new contract or execution is introduced.
Equations
- Complexity.Language.Examples.Factorial.Implementation.factorial_onArgs function✝ env✝ = function✝ env✝.head
Instances For
The named function's actual independently interpreted source body.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Ordinary induction proves the implementation's mathematical result.
Generated correspondence transfers the mathematical result to total source correctness without a second recursive proof or manual heap conversion.
Prove this actual loop using a related mathematical state and well-founded progress. Fixed captures are retained by the generated execution frames.
Introduce named mutable variables directly, without unpacking internal coordinates.
Introduce named mutable variables directly, without unpacking internal coordinates.
Apply a chosen mathematical contract to the native block action. Continuations see ordinary mutable outputs; proved frames restore the fixed captures.
Relational total correctness with ordinary mutable parameters and fixed captures. The existing block contract retains both actual heaps and excludes faults.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Introduce named mutable variables directly, without unpacking internal coordinates.
Source lexical immutability preserves these captures on every actual exit.
Prove a named loop from independent mathematical guard and body contracts. Actual guard effects and early body returns are retained; only normal iterations decrease.
The named function's actual partial source action, with ordinary typed arguments and an explicitly supplied shared heap.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Apply a supplied source contract with ordinary named arguments and its actual returned value and final heap. No callee body or new contract is inferred.
Apply a chosen mathematical contract to the native block action. Continuations see ordinary mutable outputs; proved frames restore the fixed captures.
Executable total value function generated from the same buffer-free source block.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Apply a chosen mathematical contract to the native block action. Continuations see ordinary mutable outputs; proved frames restore the fixed captures.
Prove the ordinary-parameter source contract with a total-correctness triple for the same action. The ghost initial heap equals the actual entry heap; successful results use the actual final heap, and faults are excluded.
Relational total correctness with ordinary mutable parameters and fixed captures. The existing block contract retains both actual heaps and excludes faults.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Source lexical immutability preserves these captures on every actual exit.
Fixed lexical captures, independent of the shared heap.
Instances For
The actual source block observed with ordinary named local inputs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Resume from actual mutable locals; immutable captures are preserved by the source frame.
Prove a named loop from independent mathematical guard and body contracts. Actual guard effects and early body returns are retained; only normal iterations decrease.
The actual source block observed with ordinary named local inputs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact total source contract inherited from the generated native function.
Coordinate conversion for composing this named observation.
The ordinary mutable locals of this source loop.
Instances For
The actual declared argument environment, constructed from ordinary source parameters. This is proof-side parameter transport, not an additional runtime operation.
Equations
Instances For
Prove this actual loop with fixed captures and well-founded progress on its mutable locals. Only normal body exits must decrease; guard effects, returns and faults retain their real heap.
Finite iteration correspondence, with its one-body obligation left in the enclosing function's callee and recursive-hypothesis scope.
One source-body equation in ordinary monadic notation; named callees remain opaque.
Relational total correctness with ordinary mutable parameters and fixed captures. The existing block contract retains both actual heaps and excludes faults.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compose an increasing count and a transitive heap frame from the actual guard and body contracts. The guard preserves the count and heap; normal body steps increase the count by one. Array effects and the exit consequence remain supplied mathematical facts, without a runtime budget.
Prove this actual loop with fixed captures and well-founded progress on its mutable locals. Only normal body exits must decrease; guard effects, returns and faults retain their real heap.
The source program's declared first-order signatures.
Equations
Instances For
This named source function's index in its declared signature table.
Equations
Instances For
The actual source action terminates with the generated native result and preserves every initial heap. Lean's native recursion principle proves this once.
Coordinate conversion for composing this named observation.
Source lexical immutability preserves these captures on every actual exit.
Apply a predicate, postcondition or bound with ordinary source parameters to the actual argument environment. No new contract or execution is introduced.
Equations
- Complexity.Language.Examples.Factorial.Iterative.factorial_onArgs function✝ env✝ = function✝ env✝.head
Instances For
The named function's actual independently interpreted source body.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Budget-free total correctness with ordinary source parameters and relational initial/final heap postconditions. This is the existing source function contract.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Fold an actual source invocation back to its named ordinary-argument observation.
The actual source block observed with ordinary named local inputs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Coordinate conversion for composing this named observation.
The finite table of actual named source bodies.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The finite source iteration computes mathlib's factorial. Its proof uses ordinary fold and product identities, without source execution bookkeeping.
The generated pure correspondence transfers the iterative result to the same source body, with no second termination proof or assumed machine budget.