NLA-lib Explorer

NLAlib.Ops.whileIter_sim_of_invariant

Library · theorem

Successful early-exit iteration transfers when both tests and bodies preserve the same invariant. The target contains no extra tests introduced by this proof rule.

NLAlib.Ops.whileIter_sim_of_invariant {α : Type} (P : α → Prop)
  (testTarget testSource : ℕ → α → Option (Bool × α)) (bodyTarget bodySource : ℕ → α → Option α)
  (htest :
    ∀ (i : ℕ) (a : α) (b : Bool × α),
      P a → testSource i a = some b → testTarget i a = some b ∧ P b.2)
  (hbody : ∀ (i : ℕ) (a b : α), P a → bodySource i a = some b → bodyTarget i a = some b ∧ P b)
  {fuel i : ℕ} {a : α} {b : ℕ × α} (ha : P a)
  (hr : Ops.whileIter testSource bodySource fuel i a = some b) :
  Ops.whileIter testTarget bodyTarget fuel i a = some b ∧ P b.2

Full source on GitHub

Import NLAlib.Ops.ContextIteration.