Structural realization and cost proofs #
ram_source_realize (n limit) using feasible, specification introduces ordinary
arguments of a FunctionRealizable goal and composes the existing realization
rules. The supplied callee contracts stay opaque. The parameter names and the
using clause may be omitted. Mathematical ranges, callee preconditions and
call-depth inequalities remain ordinary proof goals.
The initial shared heap is quantified independently of the ordinary arguments;
scopes and calls retain their actual heaps through the existing state rules.
Buffer reads and writes expose successful current-heap operations and the actual
read values or updated heaps. Slices expose their relative extent. These are
mathematical proof obligations, not inferred validity or alias assumptions.
ram_source_cost (n limit) using calleeBound composes the existing cost rules,
then compares the derived returning-body bound with the requested bound. It
selects a branch when its condition follows from source values and local facts,
and otherwise uses a maximum for both branches. A call can omit its source
contract only when the continuation needs no facts about the callee's result
or final heap. Even a uniform numeric bound may need those facts to justify a
later call's precondition. An explicit next function on ram_source_call
also supports a result-dependent numerical bound.
Reads retain their actual successful read equations, so mathematical contents
can identify values used in a branch or a later callee's precondition.
using [recursiveBound, helperBound] supplies several named cost certificates;
the pass selects one for the actual callee and keeps its own precondition.
It does not construct a dependent function table or assume that precondition.
ram_source_cost_intro (n limit) only introduces ordinary source parameters
and the existing function-body cost rule. It leaves the heap, mathematical
precondition and statement proof to the author, without unpacking Env by hand.
The requested bound must have the rule's core + 2 shape; the full
ram_source_cost pass also supports an arbitrary budget via a comparison goal.
ram_source_realize_step and ram_source_cost_step run the same structural
passes on statement-level goals, without introducing a function contract or
unpacking function arguments. They accept the same optional callee facts.
Loop contracts remain goals for explicit invariant and potential rules; neither
pass unfolds a loop or a recursive callee implementation.
Without using, the passes stop at calls. ram_source_call using resource, specification applies the supplied contracts to just the current call, then
resumes structural reasoning until the next call. For realization, resource
is the callee's realizability contract; for costs it is the callee's cost bound.
The source specification carries actual return values and final-heap facts to
the continuation. A standalone call followed by another statement stays intact
until these facts are available, instead of taking a uniform sequence bound.
These tactics only construct proofs with public rules. They do not introduce an execution semantics, unfold callee bodies or maintain an instruction-price table. The source frontend does not import this backend module.
ram_source_call (next := fun value heap => remainingBound) using cost, total
uses a genuinely value- and heap-dependent continuation bound. It leaves the
continuation proof and final bound comparison under the same supplied
postcondition, with actual returned values and heaps introduced. Use the usual
statement pass after selecting any mathematical cases needed by that bound.
Run a structural pass on each current goal, retaining its mathematical leaves.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Expose only the selected statement, not recursive callee implementations.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replace a concrete typed argument environment by ordinary curried values.
Shared source-coordinate reductions. These do not unfold range predicates, source contracts, compiled code or native equivalence records.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Normalize only source coordinates at the requested ordinary Lean location. Additional rules must be checked coordinate declarations selected by the caller. No local context traversal or assumption/range solver is performed.
Instances For
Normalize source values and representation predicates, without unfolding source correctness contracts or machine execution.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compose realization rules, retaining mathematical heap, range and nesting goals. Optional names introduce ordinary source parameters; the two supplied callee facts are its realizability theorem and its source correctness contract.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Derive a structural cost bound from proved instruction charges and an optional callee bound, leaving its comparison with the requested budget. Known branch conditions select their actual path; otherwise branch bounds are uniform. A call needs no source contract only when its continuation uses no facts about the callee's result or final heap.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Introduce ordinary source parameters for the function-body cost rule,
without traversing the program or unfolding the statement contract. The goal
retains its actual heap and mathematical precondition; initialization costs two
instructions, so the requested bound has the shape core + 2.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compose the existing realization rules at a statement-level goal. Optional callee facts supply realizability and source correctness. Mathematical leaves and loop contracts remain goals, without introducing a function wrapper.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compose the existing cost rules at a statement-level goal, optionally using a callee bound. This does not add a function-body wrapper charge. Loop contracts remain goals for a separate potential argument.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Apply one callee's resource and source contracts to the current call, then
continue structurally until the next call. Its actual result and heap remain
available there; the supplied contracts are not reused for that later call.
An explicit next function instead leaves its continuation and comparison
proofs under the actual returned-value/heap postcondition. Other existing goals
are preserved.
Equations
- One or more equations did not get rendered due to their size.