NLA-lib Explorer

NLAlib.Ops.RunsFromW.loop

Library · theorem

Loop, with an invariant on the counts added so far and the memory, indexed by the number of rounds done: the bound of a round comes from the invariant.

NLAlib.Ops.RunsFromW.loop {Op Tst K : Type} {I : Ops.Interp Op Tst K} {W : Op → List ℕ → ℕ}
  {τ : Ops.Tape K} {ρ : Ops.Env} {st : Ops.St Op Tst K} {p : ℕ} {n : Ops.IExp}
  {body : Ops.Stmt Op Tst} {k : ℕ} (hn : Ops.IExp.eval ρ.idx n = some k)
  (Inv : ℕ → Ops.Count Op Tst → Ops.Mem K → Prop) (h0 : Inv 0 0 st.mem)
  (hstep :
    ∀ i < k,
      ∀ (st' : Ops.St Op Tst K) (c : Ops.Count Op Tst),
        Inv i c st'.mem →
          Ops.RunsFromW I W τ body (ρ.pushIdx i) st' p fun c' m ↦ Inv (i + 1) (c + c') m) :
  Ops.RunsFromW I W τ (Ops.Stmt.loop n body) ρ st p (Inv k)

Full source on GitHub

Import NLAlib.Ops.Counted.