Documentation

CslibFrontier.Computability.WordRAM.Realization.Grade

Combined memory and local-work currency #

combinedCost p work s adds the actual memory-history charge to an explicit local-work grading. The grading is supplied by the client and matched by its Realizes certificate; the extensional Memory.Prog term does not determine a canonical local-work cost. In particular, monad laws may erase pure binds, whereas a chosen native realization must still pay for its control and glue.

The bind law uses the actual interpreted reply and memory state and includes one control-work unit. The loop law reuses iterationSum_eq, retaining one control-work unit even on iterations that issue no memory query. These are currency identities, not native instruction certificates. A memory-only upper estimate requires a separate uniform bound on the supplied local work.

Main definitions #

Main results #

References #

This grading API is original infrastructure for the existing memory-client realization rules.

The actual memory-history charge plus an explicit realization grading. This definition alone does not certify that work pays for any native implementation.

@[simp]

Returning without a memory query still retains the supplied local-work grading.

Sequential local work includes one control unit and evaluates the continuation grading at the reply and state actually reached by the first computation.

theorem Cslib.WordRAM.Realization.combinedCost_iterate {δ σ : Type} (body : δ × σ → DataStructure.Memory.Prog σ) (work : δ × σ → DataStructure.Memory.State → ℕ) (d : δ) (n : ℕ) (a : σ) (s : DataStructure.Memory.State) :
combinedCost (iterate body d n a) (iterationWork body work d n a) s = iterationSum (iterationStep body d) (fun (q : σ × DataStructure.Memory.State) => combinedCost (body (d, q.1)) (work (d, q.1)) q.2) n (a, s) + n

Combined body charges are summed along the actual joint value/memory transition. The additional n pays control work on every iteration, including query-free iterations.

A memory-only estimate is available under an explicit uniform local-work envelope. The constants precede every state. This arithmetic estimate supplies no native execution claim.

theorem Cslib.WordRAM.Realization.scaled_potential_pay (M G n Φpre Φpost q factor a b : ℕ) (hn : n ≤ factor * (M + G + 1)) (hwork : G ≤ a * M + b) (hmem : M + Φpost ≤ q + Φpre) :
n + factor * (a + 1) * Φpost ≤ factor * (a + 1) * q + factor * (b + 1) + factor * (a + 1) * Φpre

Transfer a certified combined clock through an explicit local-work envelope and a memory amortization inequality. Scale the memory potential by the same fixed exchange factor; the result is pure arithmetic and does not supply an execution certificate. All constants and charges are explicit, so a consumer must discharge the three premises for its own operation.