Documentation

Examples.Language.FactorialCompiled

Compiling the independently verified recursive factorial #

The imported source function and factorial theorem are unchanged. Mathematical induction establishes the extra value ranges and call nesting required by the word backend. The recursive call's actual returned value comes from the existing source contract, not a second proof of factorial correctness.

A separate induction composes the compiler-derived primitive and call charges into a linear instruction bound. Its fixed coefficient retains the actual generated function's call overhead, without copying constants from another factorial implementation. The final theorem concerns the real halted runner, subject to the generated code and stack fitting the chosen word width. Linearity is in the numeric argument n and counts word-RAM instructions; it is not linearity in the input's binary bit length or a claim about the bit-operation cost of arbitrary-precision multiplication.

This pure implementation accesses no heap objects. The runner bridge therefore uses an empty source-object representation and admits arbitrary RAM entry memory; the actual invocation preserves its shared entry state. The source theorem itself continues to hold for every initial source heap. No claim is made that arbitrary natural factorials fit a fixed word width.

Input n needs at most n nested source calls. Fitting n! also bounds all smaller inputs, recursive results, multiplication results and constants.

A proposed linear bound whose fixed call overhead is derived from the actual lowered function. The base case costs thirteen instructions; each successor adds twenty-four non-call instructions and its actual recursive call.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    A recursive cost hypothesis only concerns the actual smaller argument. No factorial-value, range, termination or machine-state proof is repeated.

    The independent linear body bound applies to every realized successful invocation, uniformly in word width and permitted call nesting.

    The complete invocation bound includes the actual outer call and final halt.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The actual compiled result is the ordinary mathematical factorial. Shared publication retains the runner, body-time equation and returned words; the independent frame and cost theorems concern that same result. Capacity includes the outer call and the n recursive call levels.