Linear resource credits, guarded interaction trees, and bit-level layouts
Design for amortized time/resource credits in
Delta, cofixpoint-free guarded Interaction Trees for reactive services, and Dargent-style declarative layout lenses beyond the first-release subset.
Scope and boundary
The prototypes address three distinct obligations.
- Linear credits and amortized potential account for work in the resource context.
- Step-indexed interaction trees model reactive loops within the minimal CIC profile.
- Declarative layout lenses describe packed field access, padding and CHERI capability alignment for representation proofs.
Unified linear resource and amortized time credits
Resource credits extend Delta with tokens $(n) for nonnegative work
budgets. Each credit can be spent once.
credit_splitpartitions a budget across subcomputations.credit_conservationaccounts for spending andcredit_frame_rulepreserves credits outside a call's budget.- When every loop iteration or recursive call spends at least one credit, a
finite budget bounds the number of iterations or calls. The model checks
this connection with
finite_positive_credit_loop_terminatesandloop_exec_bounded_by_credits. PotentialJudgcombines credits with stored potentialPhi(state). The two-stack queue proofs use that potential to pay for occasional transfers under a constant amortized operation budget.
The affine inference trial chooses the least natural coefficient k for
Phi(size) = k * size. Each transition requires
cost + k * after <= budget + k * before for all natural input sizes.
The input gives before, after, cost and budget as nonnegative
[constant, slope] pairs in a transitions array. The producer computes
coefficient bounds and emits a Rocq proof of the inequalities over those
rows. The locked queue trial connects the rows to provider behavior and
checks an unchanged caller against a private representation edit. Its budget
uses a source operation count.
Potential Functions as Types ·
Command ·
Queue replay
This input infers coefficient two. Enqueue adds one item of potential, and refill spends two work units per pending item.
{
"transitions": [
{"label": "enqueue", "before": [0, 1], "after": [1, 1], "cost": [1, 0], "budget": [3, 0]},
{"label": "refill", "before": [0, 1], "after": [0, 0], "cost": [1, 2], "budget": [1, 0]}
]
}
Interaction trees and copattern guarded recursion
The reactive-service prototype uses finite interaction trees (ITree E R)
and a copattern guardedness check within the cofixpoint-free kernel profile.
ITree E Rexposes fuel exhaustion (ITFuelOut), return (ITRet r), an internal step (ITTau k) or a visible event (ITVis e k). The event signature isE : Type -> Type. The model relates runs across finite horizons withapproxandguarded_iter_coherent.guarded_iteremits an internal step or a visible event before each recursive unfolding.guarded_iter_productivedescribes the emitted step and the structurally smaller fuel budget.- Trace and handler laws: Monadic laws (
bind_ret_l,bind_ret_r,bind_assoc), handler interpretation (interp_ret,interp_bind), and weak equivalence up to finiteITTausteps (eutt_n,eutt_n_tau_l,eutt_n_tau_r) discharge reactive protocol theorems such as bounded request-response packet echo services (echo_server_responds).
The finite copattern prototype visits sequence and branch children in their listed order and checks guardedness separately for each branch alternative. A reachable recursive call restarts the body. A finite body emits a return state, with each internal or visible step consuming one unit of horizon fuel. The handler must cover every reachable visible event, including events beyond the simulated prefix. Rocq replays the emitted service's state equations and independently specified traces. Replay controls
Declarative bit-level layout and lens algebra
The layout prototype takes field offsets and widths for packed wire headers and CHERI-capable structures.
- Disjointness and bounds: Every declared field
BitRange { bit_off, bit_width }must have positive width, fit within total layout size, and be pairwise disjoint from all sibling fields (ranges_disjoint). - CHERI capability alignment: Fields holding hardware capabilities enforce a 128-bit (16-byte) alignment and width. The layout proof checks disjointness from scalar fields. The machine interpretation must still establish the behavior and tag effects of capability loads and stores.
- Synthesized lens laws: Bitwise
get_bits/set_bitsoperations paired withzero_paddinggenerate closed-context Rocq lemmas for round-trip (get_set_same), last-write behavior (set_set_same), disjoint frame preservation (get_set_other), and padding confidentiality (zero_padding_clears_pad_bit).
Proof obligations
| Obligation | Required artifact and refusal predicate |
|---|---|
RC-soundness |
Prove credit_soundness, credit_frame_rule, credit_conservation, and finite_positive_credit_loop_terminates; reject credit underflow or forged/duplicated tokens. |
RC-amortized |
Prove potential-transfer invariants (including two-stack queue enqueue/dequeue constant amortized credits); reject unbounded loops without decreasing potential. |
IT-monad-eutt |
Prove ITree monad and interp laws in minimal CIC strictly without CoInductive/CoFixpoint/cofix; reject any coinductive kernel construct. |
IT-productive |
Prove guarded_iter advances horizon fuel across every loop path; reject unguarded silent recursion (RecCall not behind Tau/Vis). |
LL-lens-laws |
Prove get_set_same, set_set_same, and pairwise get_set_other over declared bit ranges; reject overlapping or out-of-bounds fields. |
LL-padding-cheri |
Prove zero_padding_preserves_field, zero_padding_clears_pad_bit, and CHERI 128-bit granule alignment/disjointness; reject misaligned capability fields. |
Qualification and implementation artifacts
| Component | Artifact | Role |
|---|---|---|
| Rocq credit mechanization | resource_credits.v | Zero-axiom ResourceCredits linear/amortized credit and two-stack queue proofs (rocqchk) |
| Credit checker prototype | resource_credits.py | Linear credit/potential verifier and Gallina budget emitter |
| Rocq ITree mechanization | guarded_itrees.v | Cofixpoint-free step-indexed GuardedITrees monad, guarded_iter, and reactive echo proofs (rocqchk) |
| Guardedness/ITree prototype | guarded_itrees.py | Copattern guardedness checker, ITree simulator, and minimal-CIC emitter |
| Rocq layout lens mechanization | layout_lenses.v | Zero-axiom LayoutLenses bitfield get/set, frame, padding, and CHERI granule proofs (rocqchk) |
| Layout lens prototype | layout_algebra.py | Bit-layout validator, runtime lens, and Gallina .Model lemma emitter |
| Qualification tracks | Q25es · Q25et · Q25eu | Linear credits, guarded ITrees, and bit-level layouts |