AFTD Auto-Formalizing Theoretical Domains

arrival_walk_discounted_iterates_error_bound

theoremverified

For any real discount factor q with 0 ≤ q ≤ 1 and sequence E : ℕ → ℝ satisfying E 0 = 0 and E (k + 1) ≤ q * E k + (1 - q) * k for all k, the bound E k ≤ (1 - q) * (k * (k - 1) / 2) holds for all k : ℕ.

Statement

theorem arrival_walk_discounted_iterates_error_bound
    (q : ℝ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) (E : ℕ → ℝ)
    (hE0 : E 0 = 0)
    (hErec : ∀ k, E (k + 1) ≤ q * E k + (1 - q) * (k : ℝ)) (k : ℕ) :
    E k ≤ (1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2)
Source
arXiv:2611.33785, Lemma 2.2 proof
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

Read back from the Lean

For any real number $q$ with $0 \le q \le 1$, any function $E : \mathbb{N} \to \mathbb{R}$ satisfying $E(0) = 0$ and $E(k + 1) \le q \cdot E(k) + (1 - q) \cdot k$ for all $k \in \mathbb{N}$, and for every $k \in \mathbb{N}$, $E(k) \le (1 - q) \cdot \frac{k(k - 1)}{2}$ (where $k$ is cast to $\mathbb{R}$).

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The proof proceeds by mathematical induction on k. The base case k = 0 is immediate since both sides evaluate to 0. For the inductive step, substituting the induction hypothesis into the recurrence produces an upper bound on E (k + 1); subtracting this from the target bound at k + 1 yields (1 - q)^2 * (k * (k - 1) / 2), which is non-negative because squares and k * (k - 1) / 2 are non-negative for all k ∈ ℕ.

  1. We set up an induction on k.

    Line 7 brings q ≤ 1 into the local context, and line 8 starts induction on k ∈ ℕ, denoting the induction hypothesis by ih.

    lines 7–8

      have _ := hq1
      induction' k with k ih
  2. The base case k = 0 holds.

    For k = 0, the assumption E 0 = 0 and the right-hand side (1 - q) * (0 * (0 - 1) / 2) both evaluate to 0, which simp verifies directly.

    line 9

      · simp [hE0]
  3. The recurrence and the induction hypothesis provide an upper bound on E (k + 1).

    Pushing casts to real numbers (line 10), we instantiate the recurrence at k to obtain E (k + 1) ≤ q * E k + (1 - q) * k (line 11). Since 0 ≤ q, multiplying the induction hypothesis E k ≤ (1 - q) * (k * (k - 1) / 2) by q on the left via mul_le_mul_of_nonneg_left yields q * E k ≤ q * ((1 - q) * (k * (k - 1) / 2)) (lines 12–13).

    lines 10–13

    uses mul_le_mul_of_nonneg_left

      · push_cast
        have h1 : E (k + 1) ≤ q * E k + (1 - q) * (k : ℝ) := hErec k
        have h2 : q * E k ≤ q * ((1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2)) :=
          mul_le_mul_of_nonneg_left ih hq0
  4. The factor k * (k - 1) / 2 is non-negative for every natural number k.

    We split into cases on k (line 15). If k = 0, the product is 0 (line 16). If k = k' + 1, k' is non-negative in ℝ by Nat.cast_nonneg (line 18), so (k' + 1) * k' / 2 is a product of non-negative reals, which non-linear arithmetic (nlinarith) closes (line 19).

    lines 14–19

    uses Nat.cast_nonneg

        have hk : 0 ≤ (k : ℝ) * ((k : ℝ) - 1) / 2 := by
          rcases k with _ | k'
          · simp
          · push_cast
            have : (0 : ℝ) ≤ k' := Nat.cast_nonneg k'
            nlinarith
  5. The difference between the target bound for k + 1 and the recurrence bound is non-negative.

    Algebraic rearrangement by ring shows that (1 - q) * ((k + 1) * k / 2) - (q * ((1 - q) * (k * (k - 1) / 2)) + (1 - q) * k) equals (1 - q)^2 * (k * (k - 1) / 2) (lines 20–22). Since squares are non-negative by sq_nonneg (line 23) and k * (k - 1) / 2 ≥ 0 from the previous step, their product is non-negative by mul_nonneg (lines 24–25).

    lines 20–25

    uses sq_nonneg, mul_nonneg

        have hdiff : (1 - q) * (((k : ℝ) + 1) * ((k : ℝ) + 1 - 1) / 2) -
            (q * ((1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2)) + (1 - q) * (k : ℝ)) =
            (1 - q) ^ 2 * ((k : ℝ) * ((k : ℝ) - 1) / 2) := by ring
        have hsq : 0 ≤ (1 - q) ^ 2 := sq_nonneg (1 - q)
        have hpos : 0 ≤ (1 - q) ^ 2 * ((k : ℝ) * ((k : ℝ) - 1) / 2) :=
          mul_nonneg hsq hk
  6. The bound holds for k + 1, completing the induction.

    Because the difference between the target bound and q * ((1 - q) * (k * (k - 1) / 2)) + (1 - q) * k is non-negative, linear arithmetic (linarith) establishes that the latter is at most the former (lines 26–28). Combining this with the recurrence upper bound on E (k + 1) and the bound on q * E k, a final call to linarith concludes E (k + 1) ≤ (1 - q) * ((k + 1) * k / 2) (line 29).

    lines 26–29

        have h3 : q * ((1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2)) + (1 - q) * (k : ℝ) ≤
            (1 - q) * (((k : ℝ) + 1) * ((k : ℝ) + 1 - 1) / 2) := by
          linarith
        linarith
mul_le_mul_of_nonneg_left
Multiplying both sides of an inequality by a non-negative value on the left preserves the inequality: if b ≤ c and 0 ≤ a, then a * b ≤ a * c.
Nat.cast_nonneg
The canonical embedding of any natural number into an ordered semiring (such as ℝ) is non-negative: 0 ≤ (n : ℝ).
sq_nonneg
In an ordered semiring, the square of any element is non-negative: 0 ≤ a ^ 2.
mul_nonneg
The product of two non-negative elements is non-negative: if 0 ≤ a and 0 ≤ b, then 0 ≤ a * b.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

/-- Error bound E_k <= (1-q) * k * (k-1) / 2 for iterates satisfying E_{k+1} <= q*E_k + (1-q)*k with E_0 = 0. -/theorem arrival_walk_discounted_iterates_error_bound    (q : ℝ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) (E : ℕ → ℝ)    (hE0 : E 0 = 0)    (hErec : ∀ k, E (k + 1) ≤ q * E k + (1 - q) * (k : ℝ)) (k : ℕ) :    E k ≤ (1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2) := by  have _ := hq1  induction' k with k ih  · simp [hE0]  · push_cast    have h1 : E (k + 1) ≤ q * E k + (1 - q) * (k : ℝ) := hErec k    have h2 : q * E k ≤ q * ((1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2)) :=      mul_le_mul_of_nonneg_left ih hq0    have hk : 0 ≤ (k : ℝ) * ((k : ℝ) - 1) / 2 := by      rcases k with _ | k'      · simp      · push_cast        have : (0 : ℝ) ≤ k' := Nat.cast_nonneg k'        nlinarith    have hdiff : (1 - q) * (((k : ℝ) + 1) * ((k : ℝ) + 1 - 1) / 2) -        (q * ((1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2)) + (1 - q) * (k : ℝ)) =        (1 - q) ^ 2 * ((k : ℝ) * ((k : ℝ) - 1) / 2) := by ring    have hsq : 0 ≤ (1 - q) ^ 2 := sq_nonneg (1 - q)    have hpos : 0 ≤ (1 - q) ^ 2 * ((k : ℝ) * ((k : ℝ) - 1) / 2) :=      mul_nonneg hsq hk    have h3 : q * ((1 - q) * ((k : ℝ) * ((k : ℝ) - 1) / 2)) + (1 - q) * (k : ℝ) ≤        (1 - q) * (((k : ℝ) + 1) * ((k : ℝ) + 1 - 1) / 2) := by      linarith    linarith
See it in the graphDiscuss this resultChallenge it