Loop framing, amortized potential inductions, and triple bridges for realization #
This module connects Memory.Triple and Memory.FramedTriple to the Realization interpreter
(memoryCost, clientResult, clientState, ValidHistory), supplies the missing Memory.alloc /
Memory.allocDirty step lemmas, and provides single-pass invariant and amortized-potential loop
inductions (ℕ and abstract-witness ℚ potential) for both iterate and boundedWhile with
explicit Memory.Modifies framing.
Main results #
runClient_alloc,clientResult_alloc,clientState_alloc,validHistory_alloc_bind,clientResult_bind_alloc,clientState_bind_alloc,clientResult_bind_allocDirty,clientState_bind_allocDirty: primitive allocation step reductions.triple_iff_realization,framedTriple_iff_realization,framedTriple_with_realization: equivalences and realization-state wrappers between memory triples andRealizationjudgments.iterate_rat_witness_spec,iterate_potential_spec,iterate_framedTriple_of_step: witness-indexedℚ, amortizedℕ, and step-triple inductions foriteratewithMemory.Modifiesframing.boundedWhile_rat_witness_spec,boundedWhile_potential_spec,boundedWhile_spec: witness-indexedℚ, amortizedℕ, and rank-bounded worst-case inductions forboundedWhile.
Allocation step reductions #
Characterization of (Memory.spec w).runClient on Memory.alloc.
Memory.alloc k returns the old frontier.
Memory.alloc k clears k cells at the frontier and advances it by k.
Split ValidHistory across Memory.alloc k >>= q in closed form.
Reduce clientResult across Memory.alloc k >>= q.
Reduce clientState across Memory.alloc k >>= q.
Reduce clientResult across Memory.allocDirty k >>= q.
Reduce clientState across Memory.allocDirty k >>= q.
Triple bridges to Realization #
Equivalence between Memory.Triple and Realization interpreter quantities.
Equivalence between Memory.FramedTriple and Realization interpreter quantities.
Witness-indexed rational potential loop inductions #
Amortized rational potential-method induction for iterate parameterized by an abstract
witness type W, rational step credit B : ℚ, and Memory.Modifies framing.
Amortized rational potential-method induction for boundedWhile parameterized by an abstract
witness type W, nonnegative step credit B : ℚ, rank rank : W → ℕ, and Memory.Modifies
framing.
Single-pass iterate and boundedWhile ℕ-potential inductions #
Amortized potential-method induction for iterate with Memory.Modifies framing.
Amortized potential-method induction for boundedWhile with Memory.Modifies framing.
Rank-bounded loop invariant induction for boundedWhile with worst-case cost B per
iteration and Memory.Modifies framing.
Refine a Memory.FramedTriple to expose equality with (Memory.spec 0).clientResult and
clientState.
Lift a step FramedTriple (whose safety guard may depend on the step ValidHistory) into
iterationSafe and a FramedTriple for iterate body d n a₀.