Paying for the native catalogue traversal #
The remaining potential reserves one successful scan in total. A failed call consumes only its own distinct failed occurrences; a successful call consumes that reserve and terminates the traversal. These internal arithmetic lemmas do not provide an execution or cost oracle.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.FixedPrime.pay_return {T base C scans failures flag restBase restFailures : ℕ} (hT : T + 2 ≤ base + C * scans) (hscans : scans ≤ failures + flag) (hflag : flag ≤ 1) :
One actual return consumes its failed occurrences and, only on success, the single reserve. The base charge includes this iteration's real call/controller/loop overhead.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.FixedPrime.sum_prefix_le (charge : ℕ → ℕ) {i M : ℕ} (hi : i ≤ M) :
Nonnegative charges in a visited prefix are bounded by those in the complete range.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.FixedPrime.remainingCharge_step {base failures : ℕ → ℕ} {C M i T scans flag : ℕ} (hi : i < M) (hT : T + 2 ≤ base i + C * scans) (hscans : scans ≤ failures i + flag) (hflag : flag ≤ 1) :
The actual per-call bound decreases the potential by the charged body and loop work. The loop invariant establishes zero prior success whenever its guard still holds.