Documentation

Examples.Language.ImportsCompiled

Compiling a caller of the imported recursive factorial #

The existing source client makes an actual call into the imported factorial library. Its correctness, realizability and cost proofs reuse the library contracts through the generated embedding, without reopening the factorial induction or constructing register proofs. The caller adds one call level and its own emitted return and function initialization.

The final theorem concerns this client's actual halted invocation in the combined program, including its internal library call and the outer calling convention. Code and stack capacity refer to that combined program, which also contains heap-writing traversal functions. No claim that the whole program is heap-free or that all RAM entry memory is unchanged is used.

The existing source result supplies the caller's total contract, including preservation of every initial source heap. No proposed instruction budget is required.

The caller adds one level to the library's existing recursive call capacity. The same factorial range premise bounds the argument and actual returned value.

The actual library call uses its imported body bound and unchanged compiler-derived overhead. The caller's scalar return and function initialization add six instructions.

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

    Structural cost rules account for the new caller; the library's recursive bound is transported rather than proved by another induction or copied from a different implementation.

    theorem Complexity.Language.Examples.Imports.factorial_runUntil_le {w heapLimit : ℕ} (hw : 0 < w) (n : ℕ) (fits : n.factorial < 2 ^ w) (entry : Ram.Source.State w) (codeCapacity : List.length (Ram.LanguageCompiler.lowerCode Implementation.program Implementation.factorialId) < 2 ^ w) (stackCapacity : heapLimit + (n + 2) * Ram.ABI.frameSize (Ram.LanguageCompiler.programControl Implementation.program) < 2 ^ w) :

    The actual compiled imported-function caller halts with factorial and a complete instruction bound. The new caller, original recursive calls and outer invocation all count toward stack capacity; the capacity uses the combined program's actual frame layout.