M5: a step of the running job #
Every resumption of the job (jobStep) succeeds and keeps the invariant, and the job measure
decreases (top_step). The cases: a copy step; a walk step (with or without a drain start); the
step after a drain start; a step of the funding loop.
The chunk list across top-structure steps #
The chunk list facts of TopInv.
Equations
- OrderMaintenance.Proof.Top.CLok s cl = (OrderMaintenance.Proof.LList (OrderMaintenance.Proof.cN s) (OrderMaintenance.Proof.cP s) s.firstChunk cl ∧ ∀ (c : ℕ), c ∈ cl ↔ 1 ≤ c ∧ c < s.C.size)
Instances For
theorem
OrderMaintenance.Proof.Top.CLok.topRel
{s s' : Model.Core}
{cl : List ℕ}
(h : CLok s cl)
(hr : TopRel s s')
:
CLok s' cl
The job measure #
The funding loop #
theorem
OrderMaintenance.Proof.Top.fund_run
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v up src k : ℕ}
(hTP : TopParams s.P)
(hcl : CLok s cl)
(hI : InvJ (ts s) cl ord dr n0 (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.fund v up src k }))
:
∃ (j' : Model.Job) (s' : Model.Core) (ord' : ℕ → List ℕ),
EStateM.run (Model.fundLoop j v up src k) s = EStateM.Result.ok (some j') s' ∧ TopRel s s' ∧ InvJ (ts s') cl ord' dr n0 (some j') ∧ jobLeft (ts s') j' < jobLeft (ts s) { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.fund v up src k } ∧ ∀ (l : ℕ), j'.pc ≠ Model.JobPc.copy l
The funding loop moves a chunk, ends the drain, or finishes its remaining work.
The end of a job #
The walk #
What startDrain must do: the statement M5 proves in PresStart.lean.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Proof.Top.run_walkBody_noDrain
(j : Model.Job)
(s : Model.Core)
(v : ℕ)
(hv : v ≠ Model.NIL)
(hno :
¬((nd (ts s) v).livePar ≠ Model.NIL ∧ (nd (ts s) v).draining = false ∧ (nd (ts s) v).overflowOf = Model.NIL ∧ Wd s.P (ht (ts s) v) < (nd (ts s) v).weight + 2))
:
EStateM.run (Model.walkBody j v) s = EStateM.run (Model.afterDrain j v (nd (ts s) v).livePar) (wiC s v)
The walk at v ≠ NIL, when v starts no drain.
theorem
OrderMaintenance.Proof.Top.run_walkBody_drain
(j : Model.Job)
(s : Model.Core)
(v : ℕ)
(hv : v ≠ Model.NIL)
(h1 : (nd (ts s) v).livePar ≠ Model.NIL)
(h2 : (nd (ts s) v).draining = false)
(h3 : (nd (ts s) v).overflowOf = Model.NIL)
(h4 : Wd s.P (ht (ts s) v) < (nd (ts s) v).weight + 2)
{s' : Model.Core}
(hsd : EStateM.run (Model.startDrain v) (wiC s v) = EStateM.Result.ok () s')
:
EStateM.run (Model.walkBody j v) s = EStateM.Result.ok (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.afterDrain v (nd (ts s) v).livePar }) s'
The walk at v ≠ NIL, when v starts a drain.
theorem
OrderMaintenance.Proof.Top.run_afterDrain
(j : Model.Job)
(v up : ℕ)
(t : Model.Core)
:
EStateM.run (Model.afterDrain j v up) t = if (t.nodes.getX v).overflowOf = Model.NIL then
EStateM.Result.ok (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.walk (some up) }) t
else EStateM.run (Model.fundLoop j v up (t.nodes.getX v).overflowOf 0) t
theorem
OrderMaintenance.Proof.Top.walk_run
(hSD : SDOK)
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v : ℕ}
(hpc : j.pc = Model.JobPc.walk (some v))
(hTP : TopParams s.P)
(hcl : CLok s cl)
(hI : InvJ (ts s) cl ord dr n0 (some j))
:
∃ (r : Option Model.Job) (s' : Model.Core) (ord' : ℕ → List ℕ) (dr' : ℕ → ℕ) (n0' : ℕ → ℕ),
EStateM.run (Model.walkBody j v) s = EStateM.Result.ok r s' ∧ TopRel s s' ∧ InvJ (ts s') cl ord' dr' n0' r ∧ ∀ (j' : Model.Job), r = some j' → jobLeft (ts s') j' < jobLeft (ts s) j ∧ ∀ (l : ℕ), j'.pc ≠ Model.JobPc.copy l
A walk step.
The step after a drain start #
theorem
OrderMaintenance.Proof.Top.afterDrain_step
{s : Model.Core}
{cl : List ℕ}
{ord : ℕ → List ℕ}
{dr n0 : ℕ → ℕ}
{j : Model.Job}
{v up : ℕ}
(hpc : j.pc = Model.JobPc.afterDrain v up)
(hI : InvJ (ts s) cl ord dr n0 (some j))
:
EStateM.run (Model.jobStep j) s = EStateM.Result.ok (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.walk (some up) }) s ∧ InvJ (ts s) cl ord dr n0 (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.walk (some up) }) ∧ jobLeft (ts s) { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.walk (some up) } < jobLeft (ts s) j
The walk's start #
A step of the running job #
theorem
OrderMaintenance.Proof.Top.top_step
(hSD : SDOK)
{s : Model.Core}
{job : Model.Job}
(hT : TopInv s)
(hres : s.resJob = some job)
:
∃ (r : Option Model.Job) (s' : Model.Core),
EStateM.run (Model.jobStep job) s = EStateM.Result.ok r s' ∧ TopInv
{ P := s'.P, E := s'.E, Gs := s'.Gs, C := s'.C, freeG := s'.freeG, count := s'.count, head := s'.head,
tail := s'.tail, firstGroup := s'.firstGroup, firstChunk := s'.firstChunk, ready := s'.ready, prep := s'.prep,
resJob := r, fallbacks := s'.fallbacks, pqHead := s'.pqHead, pqNext := s'.pqNext, pqPrev := s'.pqPrev,
pqWhere := s'.pqWhere, nbNext := s'.nbNext, nbPrev := s'.nbPrev, pqHi := s'.pqHi, pqLo := s'.pqLo,
nodes := s'.nodes, path := s'.path, cin := s'.cin, lpar := s'.lpar } ∧ ∀ (j' : Model.Job),
r = some j' →
1 ≤ topMu
{ P := s'.P, E := s'.E, Gs := s'.Gs, C := s'.C, freeG := s'.freeG, count := s'.count, head := s'.head,
tail := s'.tail, firstGroup := s'.firstGroup, firstChunk := s'.firstChunk, ready := s'.ready,
prep := s'.prep, resJob := r, fallbacks := s'.fallbacks, pqHead := s'.pqHead, pqNext := s'.pqNext,
pqPrev := s'.pqPrev, pqWhere := s'.pqWhere, nbNext := s'.nbNext, nbPrev := s'.nbPrev, pqHi := s'.pqHi,
pqLo := s'.pqLo, nodes := s'.nodes, path := s'.path, cin := s'.cin, lpar := s'.lpar } ∧ topMu
{ P := s'.P, E := s'.E, Gs := s'.Gs, C := s'.C, freeG := s'.freeG, count := s'.count, head := s'.head,
tail := s'.tail, firstGroup := s'.firstGroup, firstChunk := s'.firstChunk, ready := s'.ready,
prep := s'.prep, resJob := r, fallbacks := s'.fallbacks, pqHead := s'.pqHead, pqNext := s'.pqNext,
pqPrev := s'.pqPrev, pqWhere := s'.pqWhere, nbNext := s'.nbNext, nbPrev := s'.nbPrev, pqHi := s'.pqHi,
pqLo := s'.pqLo, nodes := s'.nodes, path := s'.path, cin := s'.cin, lpar := s'.lpar } < topMu s
A step of the running job keeps the top invariant and decreases the job measure.