Documentation

LeanPool.OrderMaintenance.Proof.Top.T0

M5: Lemma T0 (the partition of a drain) #

startDrain cuts the children's weights ws (total S) greedily at half, moves the cut right past a pair of targets it would separate, and back if that reaches the end (cutLen, shiftR, shiftL). With every unit (a child, or the two targets of a running drain) of weight at most U, both parts weigh at most ⌊S/2⌋ + U (docs/PROOF.md §4.5.2).

The greedy cut #

The pair shifts #

Pairs are disjoint: k - 1, k and k, k + 1 are not both pairs.

Equations
Instances For
    theorem OrderMaintenance.Proof.Top.shiftR_eq (pr : ℕ → Bool) (n : ℕ) (hp : PairsOK pr n) (k f : ℕ) (hf : 2 ≤ f) :
    Model.shiftR pr n f k = if 0 < k ∧ k < n ∧ pr k = true then k + 1 else k
    theorem OrderMaintenance.Proof.Top.shiftL_eq (pr : ℕ → Bool) (n : ℕ) (hp : PairsOK pr n) (k f : ℕ) (hf : 2 ≤ f) :
    Model.shiftL pr f k = if 0 < k ∧ pr k = true then k - 1 else k

    The cut only asks about pairs inside #

    theorem OrderMaintenance.Proof.Top.shiftR_congr {pr pr' : ℕ → Bool} {n : ℕ} (h : ∀ (k : ℕ), 1 ≤ k → k < n → pr k = pr' k) (f k : ℕ) :
    Model.shiftR pr n f k = Model.shiftR pr' n f k
    theorem OrderMaintenance.Proof.Top.shiftL_congr {pr pr' : ℕ → Bool} {n : ℕ} (h : ∀ (k : ℕ), 1 ≤ k → k < n → pr k = pr' k) (f k : ℕ) :
    k < n → Model.shiftL pr f k = Model.shiftL pr' f k
    theorem OrderMaintenance.Proof.Top.drainCut_congr {ws : List ℕ} {pr pr' : ℕ → Bool} (hh : Bool) (h : ∀ (k : ℕ), 1 ≤ k → k < ws.length → pr k = pr' k) :
    Model.drainCut ws pr hh = Model.drainCut ws pr' hh

    Lemma T0 #

    theorem OrderMaintenance.Proof.Top.sum_take_succ' (ws : List ℕ) (m : ℕ) (hm : m < ws.length) :
    (List.take (m + 1) ws).sum = (List.take m ws).sum + ws.getD m 0
    theorem OrderMaintenance.Proof.Top.sum_take_le (ws : List ℕ) {a b : ℕ} (h : a ≤ b) :
    (List.take a ws).sum ≤ (List.take b ws).sum
    theorem OrderMaintenance.Proof.Top.cutK_spec (ws : List ℕ) (pr : ℕ → Bool) (hh : Bool) (U : ℕ) (hn : 2 ≤ ws.length) (hp : PairsOK pr ws.length) (hU1 : ∀ i < ws.length, ws.getD i 0 ≤ U) (hU2 : ∀ (k : ℕ), pr k = true → ws.getD (k - 1) 0 + ws.getD k 0 ≤ U) (hgive : hh = true → ¬(ws.length = 2 ∧ pr 1 = true)) :
    have k := Model.drainCut ws pr hh; 1 ≤ k ∧ k ≤ ws.length - 1 ∧ (hh = true → pr k = false) ∧ (List.take k ws).sum ≤ ws.sum / 2 + U ∧ ws.sum - (List.take k ws).sum ≤ ws.sum / 2 + U

    Lemma T0. The cut is strictly inside, does not separate a pair, and both parts weigh at most ⌊S/2⌋ + U.