Resource-proof infrastructure for structured RAM programs #
This internal module packages the generic proof obligations that arise when a
structured program is verified against the concrete logarithmic-cost RAM:
finite register envelopes, their induced finsum space bounds, and compositional
source executions carrying exact steps with upper bounds on time and space.
A register store fits an index/value envelope. Every nonzero register lies
below indexBound, and every stored value is at most valueBound.
Instances For
Enlarging either side of a store envelope preserves the bound.
A reserved-prefix bit input fits any envelope containing its length register, input interval, list length, and Boolean values.
Logarithmic space occupied by the largest store admitted by an envelope.
Equations
- Complexity.RAM.Structured.Internal.envelopeSpace indexBound valueBound = indexBound * (Complexity.RAM.bitlen indexBound + Complexity.RAM.bitlen valueBound)
Instances For
A store envelope bounds the real finite-sum source-space measure.
Updating an in-envelope register with an in-envelope value preserves the store envelope.
Register written by a basic instruction in a given store. The store argument is relevant only for indirect writes.
Equations
- Complexity.RAM.Structured.Internal.Basic.writeIndex (Complexity.RAM.Structured.Basic.imm dst value) x✝ = dst
- Complexity.RAM.Structured.Internal.Basic.writeIndex (Complexity.RAM.Structured.Basic.add dst left right) x✝ = dst
- Complexity.RAM.Structured.Internal.Basic.writeIndex (Complexity.RAM.Structured.Basic.sub dst left right) x✝ = dst
- Complexity.RAM.Structured.Internal.Basic.writeIndex (Complexity.RAM.Structured.Basic.mul dst left right) x✝ = dst
- Complexity.RAM.Structured.Internal.Basic.writeIndex (Complexity.RAM.Structured.Basic.load dst address) x✝ = dst
- Complexity.RAM.Structured.Internal.Basic.writeIndex (Complexity.RAM.Structured.Basic.store address src) x✝ = x✝ address
Instances For
Value written by a basic instruction in a given store.
Equations
- Complexity.RAM.Structured.Internal.Basic.writeValue (Complexity.RAM.Structured.Basic.imm dst value) x✝ = value
- Complexity.RAM.Structured.Internal.Basic.writeValue (Complexity.RAM.Structured.Basic.add dst left right) x✝ = x✝ left + x✝ right
- Complexity.RAM.Structured.Internal.Basic.writeValue (Complexity.RAM.Structured.Basic.sub dst left right) x✝ = x✝ left - x✝ right
- Complexity.RAM.Structured.Internal.Basic.writeValue (Complexity.RAM.Structured.Basic.mul dst left right) x✝ = x✝ left * x✝ right
- Complexity.RAM.Structured.Internal.Basic.writeValue (Complexity.RAM.Structured.Basic.load dst address) x✝ = x✝ (x✝ address)
- Complexity.RAM.Structured.Internal.Basic.writeValue (Complexity.RAM.Structured.Basic.store address src) x✝ = x✝ src
Instances For
Basic execution is a single functional update, uniformly across direct and indirect instructions.
A concrete straight-line execution stays inside one store envelope at its initial store and after every instruction. Unlike a uniform preservation condition, this certificate can use semantic facts about the actual store at each program point.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.RAM.Structured.Internal.Basic.EnvelopeChain indexBound valueBound [] x✝ = Complexity.RAM.Structured.Internal.StoreEnvelope indexBound valueBound x✝
Instances For
A basic instruction preserves an envelope when its destination and written value fit that envelope.
With distinct destinations, a listed immediate write determines the final value at its destination.
A one-bit cushion over the width of the envelope's largest value.
Equations
- Complexity.RAM.Structured.Internal.valueWidth valueBound = Complexity.RAM.bitlen valueBound + 1
Instances For
Any basic instruction whose pre- and post-stores fit the same envelope has logarithmic cost at most four times the envelope value width.
A source execution with an exact transition count and upper bounds on its logarithmic cost and peak space.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A straight-line basic block always has an exact source execution. This certificate deliberately leaves cost and space existential, allowing semantic proofs to proceed before a client chooses a resource envelope.
A straight-line list of basic instructions inherits uniform resource bounds when every listed instruction preserves the chosen store envelope.
A concrete per-program-point envelope chain yields the same exact-step, uniform-cost certificate as a globally uniform preservation proof.
Exact source transition count obtained by iterating bodies with the given per-element step count. Each nonempty iteration also pays two loop-control transitions, and the final zero test pays one.
Equations
- Complexity.RAM.Structured.Internal.MeasuredRuns.whileFoldSteps bodySteps [] = 1
- Complexity.RAM.Structured.Internal.MeasuredRuns.whileFoldSteps bodySteps (item :: rest) = bodySteps item + Complexity.RAM.Structured.Internal.MeasuredRuns.whileFoldSteps bodySteps rest + 2
Instances For
Compositional cost bound for a list-indexed loop. Each nonempty iteration pays three envelope widths for its nonzero test and back edge; the final zero test pays one envelope width.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.RAM.Structured.Internal.MeasuredRuns.whileFoldCost width bodyCost [] = width
Instances For
Verify a structured loop by folding an abstract state over a logical input list. The client supplies only its invariant, one body certificate, and the zero/nonzero interpretations of the test register; run stitching and resource accounting are generic.