Documentation

LeanPool.OrderMaintenance.Proof.Cost.Zeroing

Theorem Z: the zeroing game (docs/PROOF.md §4.4) #

Dietz–Sleator 1987, Theorem 5, scaled and with decreases. Variables x₁, …, x_n ≥ 0 start at 0. Each round, the player sets a maximal x_i to 0; then the adversary adds nonnegative amounts summing to at most R, and may decrease any variables (keeping them nonnegative). Then always

x_i ≤ R · (H_{n−1} + 1).

The proof shows by induction over rounds that the sum of any k variables is at most k·R·(H_{n−1} − H_{k−1} + 1).

def OrderMaintenance.Zeroing.Round {n : ℕ} (R : ℝ) (x x' : Fin n → ℝ) :

One round: zero a maximal variable x i, then add amounts a ≥ 0 with ∑ a ≤ R, and decrease arbitrarily (keeping every variable nonnegative).

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    inductive OrderMaintenance.Zeroing.Reach {n : ℕ} (R : ℝ) :
    (Fin n → ℝ) → Prop

    The states reachable from all zeros.

    Instances For
      noncomputable def OrderMaintenance.Zeroing.Hn (k : ℕ) :

      Harmonic numbers, in ℝ.

      Equations
      Instances For
        theorem OrderMaintenance.Zeroing.Hn_succ (k : ℕ) :
        Hn (k + 1) = Hn k + 1 / (↑k + 1)
        theorem OrderMaintenance.Zeroing.Hn_mono {k l : ℕ} (h : k ≤ l) :
        Hn k ≤ Hn l
        noncomputable def OrderMaintenance.Zeroing.bound {n : ℕ} (R : ℝ) (k : ℕ) :

        The bound on a sum of k variables.

        Equations
        Instances For
          def OrderMaintenance.Zeroing.Inv {n : ℕ} (R : ℝ) (x : Fin n → ℝ) :

          The invariant: nonnegative, and every sum of k ≥ 1 variables is within bound R k.

          Equations
          Instances For
            theorem OrderMaintenance.Zeroing.inv_zero {n : ℕ} {R : ℝ} (hR : 0 ≤ R) :
            Inv R 0
            theorem OrderMaintenance.Zeroing.sum_le_card_mul {n : ℕ} {x : Fin n → ℝ} {i : Fin n} (hmax : ∀ (j : Fin n), x j ≤ x i) (s : Finset (Fin n)) :
            ∑ j ∈ s, x j ≤ ↑s.card * x i

            The sum of k variables, none above x i, is at most k · x i.

            theorem OrderMaintenance.Zeroing.zeroed_sum_le {n : ℕ} {x : Fin n → ℝ} (hx : ∀ (j : Fin n), 0 ≤ x j) {i : Fin n} (hmax : ∀ (j : Fin n), x j ≤ x i) (s : Finset (Fin n)) (hs : s.card < n) :
            ∃ (t : Finset (Fin n)), t.card = s.card + 1 ∧ ((↑s.card + 1) * ∑ j ∈ s, if j = i then 0 else x j) ≤ ↑s.card * ∑ j ∈ t, x j

            After zeroing x i (maximal), a set of k < n variables sums to at most k/(k+1) of some set of k + 1 variables.

            theorem OrderMaintenance.Zeroing.inv_round {n : ℕ} {R : ℝ} {x x' : Fin n → ℝ} (h : Inv R x) (hr : Round R x x') :
            Inv R x'
            theorem OrderMaintenance.Zeroing.inv_reach {n : ℕ} {R : ℝ} (hR : 0 ≤ R) {x : Fin n → ℝ} (h : Reach R x) :
            Inv R x
            theorem OrderMaintenance.Zeroing.zeroing {n : ℕ} {R : ℝ} (hR : 0 ≤ R) {x : Fin n → ℝ} (h : Reach R x) (i : Fin n) :
            x i ≤ R * (Hn (n - 1) + 1)

            Theorem Z. In every reachable state, every variable is at most R·(H_{n−1} + 1).