The background work of one insertion #
After the insertion step: the optional group split start and the group drive, the chunk phase, and the reservation. Every guard passes, and the cost invariant holds again.
theorem
OrderMaintenance.Proof.bg_rest_run
{v s3 t4 s' : Model.Core}
{y g c k : ℕ}
(hg : eG v y = g)
(hdg : EStateM.run (Model.driveGroup g) v = EStateM.Result.ok () s3)
(hc : gC s3 (eG s3 y) = c)
(hdc : EStateM.run (Model.driveChunk c) s3 = EStateM.Result.ok () t4)
(hres : EStateM.run (Model.reservation k) t4 = EStateM.Result.ok () s')
:
EStateM.run
(do
let e ← Model.getE y
Model.driveGroup e.grp
let e ← Model.getE y
let G ← Model.getG e.grp
Model.driveChunk G.chk
Model.reservation k)
v = EStateM.Result.ok () s'
The background work after the group split start.
theorem
OrderMaintenance.Proof.background_ok
{TI : Model.Core → Prop}
{μ : Model.Core → ℕ}
{J k n R : ℕ}
{cap : Model.Params → ℕ}
{L : List ℕ}
{s0 s1 s2 : Model.Core}
{y g c : ℕ}
(hTC : TopContract TI μ J cap)
(hPost : InsPost TI k J n R μ L s0 g c s2)
(hy : y ∈ L)
(heg1 : eG s1 y = g)
(hgc1 : gC s1 g = c)
(hchunk : EStateM.run (Model.chunkSize c true) s1 = EStateM.Result.ok () s2)
(hE12 : s2.E = s1.E)
(hP1 : s1.P = s0.P)
(hkP : s0.P.reservationBudget = k)
(hn : 1 ≤ n)
(hsize : 2 + 2 * (s2.count / (s0.P.theta + 1 - cmax s0.P)) ≤ n + 1)
(hcap : 2 + 2 * (s2.count / (s0.P.theta + 1 - cmax s0.P)) ≤ cap s0.P)
(hI5 : ↑s0.P.theta + ↑R * (Zeroing.Hn (n - 1) + 1) ≤ ↑s0.P.T)
:
The background work of one insertion succeeds and restores the cost invariant.