NLA-lib Explorer

NLAlib.Ops.Reference.instrumented_loop

Library · theorem

A counted loop enters its raw sequence of instrumented rounds after its entry charge.

NLAlib.Ops.Reference.instrumented_loop {Op Tst K : Type} (I : Ops.Interp Op Tst K)
  (R : Ops.ResourceModel Op Tst) (τ : Ops.Tape K) (n : Ops.IExp) (body : Ops.Stmt Op Tst)
  (ρ : Ops.Env) (a : Ops.Reference.State Op Tst K) (ha : a.cur ≤ a.peak) {k : ℕ}
  (hn : Ops.IExp.eval ρ.idx n = some k) :
  Ops.Reference.instrumented I R τ (Ops.Stmt.loop n body) ρ a =
    Ops.iter
      (fun i ↦
        Ops.evalCounted I.instrument (Ops.instrumentWorkspace R.workspace) τ
          ((Ops.tally [Ops.Bookkeeping.round]).seq body.instrument) (ρ.pushIdx i))
      k (Ops.Reference.charge (Ops.Reference.index n + Ops.Reference.core Ops.Bookkeeping.loop) a)

Full source on GitHub

Import NLAlib.Ops.Reference.Accounting.