NLA-lib Explorer

NLAlib.Ops.writes_whileStrict

Library · theorem

The strict loop (Stmt.whileStrict): the loop with early exit that fails if the test still holds after the fuel. nidx is the number of index variables in scope. At the round N (the fuel) the test must fail (only for success: in liberal mode a run that reaches it fails).

NLAlib.Ops.writes_whileStrict {Op Tst K : Type} {md : Ops.Mode} {I : Ops.Interp Op Tst K}
  {τ : Ops.Tape K} {ρ : Ops.Env} {m : Ops.Mem K} {nidx : ℕ} {fuel : Ops.IExp} {q : Tst}
  {ds : List Ops.IExp} {ins : List Ops.Operand} {body : Ops.Stmt Op Tst} {N : ℕ}
  (hn : Ops.IExp.eval ρ.idx fuel = some N) (hnidx : ρ.idx.length = nidx) (F : ℕ → Ops.Fp)
  (hF : ∀ i < N, F i ≤ F (i + 1)) (Inv : ℕ → Ops.Mem K → Prop) (P : Ops.Mem K → Prop) (h0 : Inv 0 m)
  (hstep :
    ∀ i < N,
      ∀ (m' : Ops.Mem K),
        Ops.Store.EqOff (F i) m.store m'.store →
          Inv i m' →
            md.Holds (I.testAt q ds ins (ρ.pushIdx i) m') fun c ↦
              if c = true then Ops.Writes md I τ body (ρ.pushIdx i) (F (i + 1)) (Inv (i + 1)) m'
              else P m')
  (hcap :
    ∀ (m' : Ops.Mem K),
      Ops.Store.EqOff (F N) m.store m'.store →
        Inv N m' →
          md.Holds (I.testAt q ds ins (ρ.pushIdx N) m') fun c ↦
            md.Needs (c = false) ∧ (c = false → P m')) :
  Ops.Writes md I τ (Ops.Stmt.whileStrict nidx fuel q ds ins body) ρ (F N) P m

Full source on GitHub

Import NLAlib.Ops.Logic.Loop.