NLA-lib Explorer

NLAlib.Ops.PBackwardStep.whileFuel

Library · theorem

The loop with early exit of probabilistic backward steps (PL5, the probabilistic NLAlib.Ops.BackwardStep.whileFuel): with the fuel N, if the test at round i < N succeeds on the memories of S i, a round with a true test is a backward step to S (i + 1) with error \varepsilon_i \ge 0 and failure \varphi_i \ge 0, and the continuation after a false test or at the cap is one to S' with error \varepsilon' and failure \psi \ge 0, then the loop is a backward step with error \sum_{i<N} \varepsilon_i + \varepsilon' and failure \sum_{i<N} \varphi_i + \psi.

NLAlib.Ops.PBackwardStep.whileFuel.{u_1} {Op Tst K : Type} {α : Type u_1} [Inhabited K]
  [MeasurableSpace K] {law : ℕ → Measure K} {I : Ops.Interp Op Tst K} {ρ : Ops.Env} {F G : Ops.Fp}
  {R : ℝ → α → α → Prop} {S' : α → Ops.Mem K → Prop} {ε' : ℝ} (hR : Ops.IsBackwardErrorRel R)
  (hI : I.IsMeasurable) {win : Op → List ℕ → ℕ} (hloc : ∀ (o : Op), I.TapeLocal o (win o))
  {fuel : Ops.IExp} {q : Tst} {ds : List Ops.IExp} {ins : List Ops.Operand}
  {body k : Ops.Stmt Op Tst} {N : ℕ} (hn : Ops.IExp.eval ρ.idx fuel = some N)
  (S : ℕ → α → Ops.Mem K → Prop) (ε φ : ℕ → ℝ) {ψ : ℝ} (hε : ∀ i < N, 0 ≤ ε i)
  (hφ : ∀ i < N, 0 ≤ φ i) (hψ : 0 ≤ ψ)
  (htest :
    ∀ i < N, ∀ (a : α) (m : Ops.Mem K), S i a m → ∃ b, I.testAt q ds ins (ρ.pushIdx i) m = some b)
  (h :
    ∀ i < N,
      Ops.PBackwardStep law I body (ρ.pushIdx i) F R
        (fun a m ↦ S i a m ∧ I.testAt q ds ins (ρ.pushIdx i) m = some true) (S (i + 1)) (ε i) (φ i))
  (hk :
    ∀ i < N,
      Ops.PBackwardStep law I k (ρ.pushIdx i) G R
        (fun a m ↦ S i a m ∧ I.testAt q ds ins (ρ.pushIdx i) m = some false) S' ε' ψ)
  (hcap : Ops.PBackwardStep law I k (ρ.pushIdx N) G R (S N) S' ε' ψ) :
  Ops.PBackwardStep law I (Ops.Stmt.whileFuel fuel q ds ins body k) ρ (F ⊔ G) R (S 0) S'
    (∑ i ∈ Finset.range N, ε i + ε') (∑ i ∈ Finset.range N, φ i + ψ)

Full source on GitHub

Import NLAlib.Ops.Logic.ProbabilisticBackward.