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 #
theorem
OrderMaintenance.Proof.Top.cutLen_max
(ws : List ℕ)
(b : ℕ)
(h : Model.cutLen ws b < ws.length)
:
The pair shifts #
The cut only asks about pairs inside #
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
Lemma T0 #
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))
:
Lemma T0. The cut is strictly inside, does not separate a pair, and both parts weigh at
most ⌊S/2⌋ + U.