NLA-lib Explorer

NLAlib.Ops.Examples.backwardStep_whileFuel_skip

Library · theorem

A loop with early exit, in the shape of the deflation worklist ("while the stack is not empty"): the test at round i has an outcome described by T i; on a true outcome the round runs c, a backward step with error u \ge 0 from S i to S (i + 1); on a false outcome the loop stops, and the outcome gives S' (the stack is empty); after N rounds S N gives S'. The loop is a backward step with error N u.

NLAlib.Ops.Examples.backwardStep_whileFuel_skip.{u_1} {Op Tst K : Type} {α : Type u_1}
  {md : Ops.Mode} {I : Ops.Interp Op Tst K} {τ : Ops.Tape K} {ρ : Ops.Env} {F : Ops.Fp}
  {R : ℝ → α → α → Prop} (hR : Ops.IsBackwardErrorRel R) {fuel : Ops.IExp} {N : ℕ}
  (hn : Ops.IExp.eval ρ.idx fuel = some N) {q : Tst} {ds : List Ops.IExp} {ins : List Ops.Operand}
  {c : Ops.Stmt Op Tst} {u : ℝ} (hu : 0 ≤ u) (S : ℕ → α → Ops.Mem K → Prop)
  {S' : α → Ops.Mem K → Prop} (T : ℕ → Bool → α → Ops.Mem K → Prop)
  (htest :
    ∀ i < N,
      ∀ (a : α) (m : Ops.Mem K),
        S i a m → md.Holds (I.testAt q ds ins (ρ.pushIdx i) m) fun b ↦ T i b a m)
  (hc :
    ∀ i < N,
      Ops.BackwardStep md I τ c (ρ.pushIdx i) F R (fun a m ↦ S i a m ∧ T i true a m) (S (i + 1)) u)
  (hexit : ∀ i < N, ∀ (a : α) (m : Ops.Mem K), S i a m → T i false a m → S' a m)
  (hcap : ∀ (a : α) (m : Ops.Mem K), S N a m → S' a m) :
  Ops.BackwardStep md I τ (Ops.Stmt.whileFuel fuel q ds ins c Ops.Stmt.skip) ρ F R (S 0) S' (↑N * u)

Full source on GitHub

Import NLAlib.Ops.Examples.Backward.