Documentation

LeanPool.OrderMaintenance.Impl.GlueTop

M6: the glue for the top structure #

Level F's top proofs establish the hypotheses of the run lemmas inside their proofs. Here they are exported as lemmas from the top invariant, so that the Level M case lemmas apply.

theorem OrderMaintenance.Proof.Top.Shape.drain_move_hyps {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape (ts s) cl ord) {v : ℕ} (hg : ghostN (ts s) v) (hne : rng (ts s) cl v ≠ []) (hL : LList (cN s) (cP s) s.firstChunk cl) :
have y := dsY s v; have h := ht (ts s) v; have pv := digit (ts s) y (h + 1); have vb := digit (ts s) y h; have pt := ((nd (ts s) (pp (ts s) y (h + 1))).lab? (dsT s v)).getD 0; have tb := ((nd (ts s) (dsT s v)).lab? (pp (ts s) y (h - 1))).getD 0; (s.nodes.getX v).alive = true ∧ (s.nodes.getX v).first ≠ Model.NIL ∧ (goesLeft s v ∨ Model.lookup (s.nodes.getX v).side (belowY s v (s.nodes.getX v).first) = some Model.Side.right ∧ Model.lookup (s.nodes.getX v).side (belowY s v (s.nodes.getX v).last) = some Model.Side.right) ∧ (s.nodes.getX v).height + 1 < (s.path.getX (dsY s v)).size ∧ (s.nodes.getX ((s.path.getX (dsY s v)).getX ((s.nodes.getX v).height + 1))).lab? (dsT s v) = some pt ∧ (s.nodes.getX (dsT s v)).lab? (belowY s v (dsY s v)) = some tb ∧ (s.nodes.getX ((s.path.getX (dsY s v)).getX ((s.nodes.getX v).height + 1))).lab? v = some pv ∧ (s.nodes.getX v).lab? (belowY s v (dsY s v)) = some vb ∧ pv <<< ((s.nodes.getX v).height * s.P.beta) ||| vb <<< (((s.nodes.getX v).height - 1) * s.P.beta) ≤ (s.C.getX (dsY s v)).tag ∧ TagOK s (dsY s v) (dsTag s v pt tb pv vb) ∧ 1 ≤ (s.nodes.getX v).height ∧ (s.path.getX (dsY s v)).size = s.P.H + 1 ∧ tb < 2 ^ s.P.beta ∧ vb < 2 ^ s.P.beta ∧ dsT s v ≠ v ∧ v < s.nodes.size ∧ dsT s v < s.nodes.size ∧ dsY s v ∈ cl ∧ (s.nodes.getX v).height < s.P.H ∧ (s.path.getX (dsY s v)).getX ((s.nodes.getX v).height + 1) < s.nodes.size

The hypotheses of a sweep step that moves a chunk (those of drainStep_move, and the shape facts the Level M program needs), from the order invariant: the proof of Shape.drain_run.

theorem OrderMaintenance.Proof.Top.Shape.drain_finish_hyps {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Shape (ts s) cl ord) {v : ℕ} (hg : ghostN (ts s) v) (hemp : rng (ts s) cl v = []) :
(s.nodes.getX v).alive = true ∧ (s.nodes.getX v).first = Model.NIL ∧ (s.nodes.getX v).inTables.Nodup ∧ (∀ T ∈ (s.nodes.getX v).inTables, v ∈ (s.nodes.getX T).order) ∧ v ≠ 0 ∧ v < s.nodes.size ∧ ((s.nodes.getX v).height - 1 ≠ 0 → v ∉ (s.nodes.getX v).order) ∧ (∀ T ∈ (s.nodes.getX v).inTables, T < s.nodes.size) ∧ (s.nodes.getX v).t1 < s.nodes.size ∧ (s.nodes.getX v).t2 < s.nodes.size ∧ (∀ e ∈ (s.nodes.getX v).order, (s.nodes.getX v).height - 1 ≠ 0 → e < s.nodes.size ∧ (s.nodes.getX e).inTables.length ≤ 2) ∧ ∀ e ∈ (s.nodes.getX v).order, (s.nodes.getX v).height - 1 = 0 → e ∈ cl ∧ (s.cin.getX e).length ≤ 2

The hypotheses of a sweep step that ends the drain (those of drainStep_finish, and the shape facts the Level M program needs).

The capacities the top structure's programs need, at state s: the record counts below the capacities (with room for the two records a step may add), node capacity covering chunk indices, and list capacities above the invariant bounds (tables of at most 160 entries, entries in at most 2 tables).

Instances For

    The cost bound of startDrain, from tables of at most 160 entries and entries in at most two tables.

    Equations
    Instances For
      theorem OrderMaintenance.Impl.sdCost_le {K T I S B P : ℕ} (hK : K ≤ 160) (hT : T ≤ 160) (hI : I ≤ 2) (hS : S ≤ 160) (hB : B ≤ 160) (hP : P ≤ 160) :
      sdCost K T I S B P ≤ sdBound

      startDrain agrees at a drain start (the context of sr_run).

      The cost bound of one sweep step (drainStep), from tables of at most 160 entries and entries in at most two tables: the end of a drain dominates.

      Equations
      Instances For
        theorem OrderMaintenance.Impl.dsAgree_moveI {κ : Caps} {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} (S : Proof.Top.Shape (Proof.Top.ts s) cl ord) {dr n0 : ℕ → ℕ} (hTL : Proof.Top.TabLen (Proof.Top.ts s) dr n0) {v : ℕ} (hg : Proof.Top.ghostN (Proof.Top.ts s) v) (hne : Proof.Top.rng (Proof.Top.ts s) cl v ≠ []) (hcl : Proof.Top.CLok s cl) (hprep : s.prep = none) (K : TopCaps κ s) :
        ∃ D ≤ dsBound, DSAgree κ s v D

        A sweep step that moves a chunk agrees (outside a preparation).

        theorem OrderMaintenance.Impl.dsAgree_finishI {κ : Caps} {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} (S : Proof.Top.Shape (Proof.Top.ts s) cl ord) (hTL : Proof.Top.TabLen (Proof.Top.ts s) dr n0) {v : ℕ} (hg : Proof.Top.ghostN (Proof.Top.ts s) v) (hemp : Proof.Top.rng (Proof.Top.ts s) cl v = []) (hcl : Proof.Top.CLok s cl) (K : TopCaps κ s) :
        ∃ D ≤ dsBound, DSAgree κ s v D

        A sweep step that ends the drain agrees.

        theorem OrderMaintenance.Impl.dsAgree_fund {κ : Caps} {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {v up src k : ℕ} (hcl : Proof.Top.CLok s cl) (hprep : s.prep = none) (hI : Proof.Top.InvJ (Proof.Top.ts s) cl ord dr n0 (some { x := j.x, y := j.y, z := j.z, pc := Model.JobPc.fund v up src k })) (K : TopCaps κ s) :
        ∃ D ≤ dsBound, DSAgree κ s src D

        The funding loop's sweep step agrees: its source is a ghost, so the step moves a chunk or ends the drain.

        theorem OrderMaintenance.Impl.SDAgree.mono {κ : Caps} {S : Model.Core} {v D D' : ℕ} (h : SDAgree κ S v D) (hD : D ≤ D') :
        SDAgree κ S v D'
        theorem OrderMaintenance.Impl.DSAgree.mono {κ : Caps} {S : Model.Core} {v D D' : ℕ} (h : DSAgree κ S v D) (hD : D ≤ D') :
        DSAgree κ S v D'
        theorem OrderMaintenance.Impl.walkAgree {κ : Caps} {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {v : ℕ} (hpc : j.pc = Model.JobPc.walk (some v)) (hTP : Proof.Top.TopParams s.P) (hcl : Proof.Top.CLok s cl) (hprep : s.prep = none) (hI : Proof.Top.InvJ (Proof.Top.ts s) cl ord dr n0 (some j)) (K : TopCaps κ s) :

        The walk step's agreements, at node v of the walk: startDrain where the walk starts a drain, and the sweep step of the funding loop where v has an overflow source.

        theorem OrderMaintenance.Impl.copyS_frame (t : Proof.Top.TS) (j : Model.Job) (l : ℕ) (hxy : j.x ≠ j.y) (hxz : j.x ≠ j.z) :

        A copy step keeps the node count and the path of the chunk copied from.

        theorem OrderMaintenance.Impl.copyRest_frame (j : Model.Job) (H : ℕ) (hxy : j.x ≠ j.y) (hxz : j.x ≠ j.z) (k : ℕ) (t : Proof.Top.TS) (l : ℕ) :
        H + 1 - l = k → (Proof.Top.copyRest j H t l).nodes.size = t.nodes.size ∧ (Proof.Top.copyRest j H t l).path.getX j.x = t.path.getX j.x
        theorem OrderMaintenance.Impl.job_chunks {t : Proof.Top.TS} {s : Model.Core} {cl : List ℕ} {j : Model.Job} (hcl : Proof.Top.CLok s cl) (hJ : Proof.Top.JobOK t cl j) :
        j.x ∈ cl ∧ j.y ∈ cl ∧ j.z ∈ cl ∧ j.x ≠ j.y ∧ j.x ≠ j.z ∧ j.y ≠ j.z

        The running job's chunks: in the chunk list, distinct, not NIL.

        theorem OrderMaintenance.Impl.copyAgree {κ : Caps} {s : Model.Core} {cl : List ℕ} {ord : ℕ → List ℕ} {dr n0 : ℕ → ℕ} {j : Model.Job} {l : ℕ} (hpc : j.pc = Model.JobPc.copy l) (hres : s.resJob = some j) (hcl : Proof.Top.CLok s cl) (hprep : s.prep = none) (hI : Proof.Top.InvJ (Proof.Top.finS (Proof.Top.ts s) (some j)) cl ord dr n0 (some j)) (K : TopCaps κ s) :
        JobAgree κ s j 140

        A copy step agrees.

        The cost bound of one job step at Level M.

        Instances For
          theorem OrderMaintenance.Impl.jobAgree {κ : Caps} {s : Model.Core} {j : Model.Job} (hT : Proof.Top.TopInv s) (hres : s.resJob = some j) (hprep : s.prep = none) (hpow : s.P.a = 2 ^ s.P.a.log2) (K : TopCaps κ s) :

          Every job step agrees under the top invariant, outside preparation, with the capacities.

          The cost bound of a split start at Level M.

          Equations
          Instances For
            theorem OrderMaintenance.Impl.splitAgree_top {κ : Caps} {s : Model.Core} {A : Proof.Abs} {x : ℕ} (hA : Proof.INV s A) (hT : Proof.Top.TopInv s) (hres : s.resJob = none) (hxL : Proof.LiveC s x) (hprep : s.prep = none) (hrow : ∀ (c : ℕ), s.C.size ≤ c → ∀ (j : ℕ), (s.path.getX c).getX j = 0) (K : TopCaps κ s) :
            ∃ D ≤ splitBound, SplitAgree κ s x D

            A split start agrees, under the top invariant with no job running, outside a preparation, with the capacities and zero path rows beyond the chunks.