M6: the reservation loop at Level M #
reservation k: up to k rounds; a round resumes the running job, or, with no job, pops the
fullest quiet chunk and starts its split, or stops when the queue is empty. The machine has no
return, so a flag dn makes the remaining rounds empty, as in driveGroupFrom.
theorem
OrderMaintenance.Impl.reservation_eq
(k : ℕ)
(s : Model.Core)
:
EStateM.run (Model.reservation k) s = EStateM.run
(do
let r ← forIn (List.range k) (none, ()) resF
match r.1 with
| some r => pure r
| none => pure ())
s
Procedure performing one suspended reservation-job step.
Equations
- OrderMaintenance.Impl.jobP = { name := "jobStep", params := [], rets := [], body := OrderMaintenance.Impl.jobStepS }
Instances For
Procedure starting a chunk split and its reservation job.
Equations
- OrderMaintenance.Impl.splitP = { name := "splitChunkStart", params := ["x"], rets := [], body := OrderMaintenance.Impl.splitChunkStartS }
Instances For
Spend one reservation iteration on the active job or the largest queued chunk.
Equations
- One or more equations did not get rendered due to their size.
Instances For
reservation reservationBudget.
Equations
Instances For
A Level M round that agrees with a Level F one (stop: Level F's round ended the loop).
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Impl.reservationS_agree
(κ : Caps)
(s : Model.Core)
(L : Loc)
{D : ℕ}
(I : ℕ → Model.Core → Prop)
(h0 : I 0 s)
(hstep :
∀ (j : ℕ) (t : Model.Core),
I j t →
j < s.P.reservationBudget →
∃ (stop : Bool) (t' : Model.Core),
EStateM.run (resF j (none, ())) t = EStateM.Result.ok (resOut stop) t' ∧ (stop = false → I (j + 1) t') ∧ ResAgree κ t t' stop D)
:
∃ (t' : Model.Core) (L' : Loc) (n : ℕ),
EStateM.run (Model.reservation s.P.reservationBudget) s = EStateM.Result.ok () t' ∧ evalF κ reservationS s L = Res.ok t' L' n ∧ n ≤ 5 + s.P.reservationBudget * (D + 6)
The three kinds of rounds #
The program agrees with Level F's jobStep j from t (within D steps).
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Impl.resF_job
{t t1 : Model.Core}
{i : ℕ}
{j : Model.Job}
{r : Option Model.Job}
(hj : t.resJob = some j)
(h : EStateM.run (Model.jobStep j) t = EStateM.Result.ok r t1)
:
EStateM.run (resF i (none, ())) t = EStateM.Result.ok (resOut false)
{ P := t1.P, E := t1.E, Gs := t1.Gs, C := t1.C, freeG := t1.freeG, count := t1.count, head := t1.head,
tail := t1.tail, firstGroup := t1.firstGroup, firstChunk := t1.firstChunk, ready := t1.ready, prep := t1.prep,
resJob := r, fallbacks := t1.fallbacks, pqHead := t1.pqHead, pqNext := t1.pqNext, pqPrev := t1.pqPrev,
pqWhere := t1.pqWhere, nbNext := t1.nbNext, nbPrev := t1.nbPrev, pqHi := t1.pqHi, pqLo := t1.pqLo,
nodes := t1.nodes, path := t1.path, cin := t1.cin, lpar := t1.lpar }
theorem
OrderMaintenance.Impl.resAgree_job
{κ : Caps}
{t t1 : Model.Core}
{j : Model.Job}
{r : Option Model.Job}
{D : ℕ}
(hj : t.resJob = some j)
(hA : JobAgree κ t j D)
(h : EStateM.run (Model.jobStep j) t = EStateM.Result.ok r t1)
:
ResAgree κ t
{ P := t1.P, E := t1.E, Gs := t1.Gs, C := t1.C, freeG := t1.freeG, count := t1.count, head := t1.head,
tail := t1.tail, firstGroup := t1.firstGroup, firstChunk := t1.firstChunk, ready := t1.ready, prep := t1.prep,
resJob := r, fallbacks := t1.fallbacks, pqHead := t1.pqHead, pqNext := t1.pqNext, pqPrev := t1.pqPrev,
pqWhere := t1.pqWhere, nbNext := t1.nbNext, nbPrev := t1.nbPrev, pqHi := t1.pqHi, pqLo := t1.pqLo,
nodes := t1.nodes, path := t1.path, cin := t1.cin, lpar := t1.lpar }
false (D + 10)
The program agrees with Level F's splitChunkStart c from t (within D steps).
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Impl.resF_split
{t t1 t2 : Model.Core}
{i c : ℕ}
(hj : t.resJob = none)
(h0 : t.pqHi ≠ 0)
(hp : EStateM.run Model.pqPopMax t = EStateM.Result.ok c t1)
(hs : EStateM.run (Model.splitChunkStart c) t1 = EStateM.Result.ok () t2)
:
theorem
OrderMaintenance.Impl.resAgree_split
{κ : Caps}
{t t1 t2 : Model.Core}
{c D : ℕ}
(hj : t.resJob = none)
(hq : PQCaps κ t)
(h0 : t.pqHi ≠ 0)
(hp : EStateM.run Model.pqPopMax t = EStateM.Result.ok c t1)
(hA : SplitAgree κ t1 c D)
(hs : EStateM.run (Model.splitChunkStart c) t1 = EStateM.Result.ok () t2)
:
theorem
OrderMaintenance.Impl.splitAgree_ok
{κ : Caps}
{s : Model.Core}
{x f1x i1 B : ℕ}
(hx0 : x ≠ Model.NIL)
(hxs : x < s.C.size)
(hC : s.C.size + 2 ≤ κ.tbl Tbl.C)
(hp : (s.C.getX x).prev ≠ Model.NIL → (s.C.getX x).prev < s.C.size)
(hn : (s.C.getX x).next ≠ Model.NIL → (s.C.getX x).next < s.C.size)
(hia : IAOK κ (Model.linkChunkPair (Proof.push2 s) x s.C.size (s.C.size + 1)) x s.C.size (s.C.size + 1) f1x i1 B)
:
SplitAgree κ s x (150 + iaCost (Model.linkChunkPair (Proof.push2 s) x s.C.size (s.C.size + 1)) x B)