NLA-lib Explorer

NLAlib.Ops.whileIter_preserves

Library · theorem

Tests and bodies that preserve an invariant also preserve it upon early termination.

NLAlib.Ops.whileIter_preserves {α : Type} {test : ℕ → α → Option (Bool × α)}
  {body : ℕ → α → Option α} {P : α → Prop}
  (htest : ∀ (i : ℕ) (a : α) (b : Bool × α), P a → test i a = some b → P b.2)
  (hbody : ∀ (i : ℕ) (a b : α), P a → body i a = some b → P b) {fuel i : ℕ} {a : α} {b : ℕ × α}
  (ha : P a) (hr : Ops.whileIter test body fuel i a = some b) : P b.2

Full source on GitHub

Import NLAlib.Ops.ContextIteration.