Documentation

LeanPool.OrderMaintenance.Proof.Word.PeakFin

Theorem W, option (A), stage A2 spike: discharging the end-state bounds of insertAfter #

The last-write rule (PK.wr_fin, PKok.wr_fin_seq) takes Fin Q c s L: every normal run of c ends in a state satisfying Q (some field is small there). This file checks that option (B) provides these bounds in the form stage A2 needs, for the top-level tree.

Nothing here is used by Theorems A and B.

Fin from a run, into a call, and back from the rest #

theorem OrderMaintenance.Impl.Fin.of_run {κ : Caps} {s s1 : Model.Core} {L L1 : Loc} {Q : Model.Core → Prop} {c : Stm} {n1 : ℕ} (h : evalF κ c s L = Res.ok s1 L1 n1) (hQ : Q s1) :
Fin Q c s L

A normal run gives Fin of its end state (evalF is a function).

theorem OrderMaintenance.Impl.Fin.call {κ : Caps} {s : Model.Core} {L : Loc} {Q : Model.Core → Prop} {q : Proc} {args : List Exp} {ds : List Machine.Reg} {vs : List ℕ} (h : Fin Q (q.call args ds) s L) (ha : evList κ s L args = some vs) :
Fin Q q.body s (Machine.State.setLocs (fun (x : Machine.Reg) => 0) q.params vs)

Into a call: the callee's end state is the call's.

theorem OrderMaintenance.Impl.PKok.seq_fin {K KH W : ℕ} {κ : Caps} {s : Model.Core} {L : Loc} {Q Q' : Model.Core → Prop} {Γ Γ' : Machine.Reg → ℕ} {c d : Stm} (hF : Fin Q (c;; d) s L) (hQ : ∀ (s1 : Model.Core) (L1 : Loc) (n1 : ℕ) (s' : Model.Core) (L' : Loc) (n : ℕ), evalF κ c s L = Res.ok s1 L1 n1 → evalF κ d s1 L1 = Res.ok s' L' n → Q s' → Q' s1) (hc : Fin Q' c s L → PKok K KH κ Γ' W c s L) (hd : ∀ (s1 : Model.Core) (L1 : Loc) (n1 : ℕ), evalF κ c s L = Res.ok s1 L1 n1 → Gd K KH κ Γ' s1 L1 → Fin Q d s1 L1 → PKok K KH κ Γ W d s1 L1) :
PKok K KH κ Γ W (c;; d) s L

Sequencing with an end-state bound passed back: the first statement may assume Q' of its own end state, where Q' follows from Q at the end of the rest (e.g. the rest does not write the field, FBat.back).

theorem OrderMaintenance.Impl.PKok.call_fin {K KH W : ℕ} {κ : Caps} {s : Model.Core} {L : Loc} {Q : Model.Core → Prop} {Γ Γc : Machine.Reg → ℕ} {q : Proc} {args : List Exp} {ds : List Machine.Reg} {vs : List ℕ} (hG : Gd K KH κ Γ s L) (ha : evList κ s L args = some vs) (hpa : pkList κ s L args < 2 ^ W) (hF : Fin Q (q.call args ds) s L) (hb : Fin Q q.body s (Machine.State.setLocs (fun (x : Machine.Reg) => 0) q.params vs) → PKok K KH κ Γc W q.body s (Machine.State.setLocs (fun (x : Machine.Reg) => 0) q.params vs)) (hr : ∀ r ∈ q.rets, Γc r ≤ K) (hd : ∀ d ∈ ds, K ≤ Γ d) :
PKok K KH κ Γ W (q.call args ds) s L

A call whose callee may assume the call's end-state bound.

One index of a field #

def OrderMaintenance.Impl.FBat (K KH : ℕ) (κ : Caps) (f : Fld) (j : ℕ) (t : Model.Core) :

Field f of t is small at index j.

Equations
Instances For
    theorem OrderMaintenance.Impl.FB.at {K KH : ℕ} {κ : Caps} {f : Fld} {t : Model.Core} (h : FB K KH κ f t) (j : ℕ) :
    FBat K KH κ f j t
    theorem OrderMaintenance.Impl.FBat.back {K KH : ℕ} {κ : Caps} {s s' : Model.Core} {L L' : Loc} {n : ℕ} {c : Stm} {f : Fld} {j : ℕ} (hf : Stm.wf f c = false) (h : evalF κ c s L = Res.ok s' L' n) (hb : FBat K KH κ f j s') :
    FBat K KH κ f j s

    The rest does not write f: the bound at its end is the bound at its start.

    theorem OrderMaintenance.Impl.FBat.backAt {K KH : ℕ} {κ : Caps} {s s' : Model.Core} {L L' : Loc} {n : ℕ} {c : Stm} {f : Fld} {x : Machine.Reg} {j : ℕ} (hw : Stm.wfAt f x c = true) (hx : Stm.asg x c = false) (h : evalF κ c s L = Res.ok s' L' n) (hne : j ≠ L x) (hb : FBat K KH κ f j s') :
    FBat K KH κ f j s

    The rest writes f only at the index held by local x, and j is another one.

    theorem OrderMaintenance.Impl.PK.wr_finAt {K KH W : ℕ} {κ : Caps} (hC : CapsW K κ) {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} {f : Fld} {i e : Exp} {j : ℕ} (hG : Gd K KH κ Γ s L) (hi : Exp.OK Γ K KH W i) (he : Exp.OK Γ K KH W e) (hj : Exp.ev κ s L i = some j) (hF : Fin (FBat K KH κ f j) (Stm.wr f i e) s L) :
    PK K KH κ Γ W (Stm.wr f i e) s L

    The last write to index j of f (PK.wr_fin for one index): its value is the end state's.

    The syntactic side conditions of the top-level Fin sites #

    The rest of the step after each write that takes its bound from the step's end state.

    The weights of a drain start's new nodes (chS at u = v1): the second chS writes the weight only at u = v2, and neither the parent's children (stage7S), v's fields (stage8S) nor the job record (pcSet) write weights.

    The tag of a sweep (dsTagS): the rest of the move and of the job step write no tag.

    The tags of a split: guardedSetTag writes only at its c; after the second tag nothing in insertAround or markSplit writes a tag.

    guardedSetTag with its end-state bound #

    The locals of guardedSetTag: the tag t may be wide (2K + 2, the sweep's ty - old + new).

    Equations
    Instances For

      proveSafe with the locals of guardedSetTag.

      Equations
      Instances For
        theorem OrderMaintenance.Impl.gst_pk {K KH W : ℕ} {κ : Caps} {s : Model.Core} {L : Loc} (hC : CapsW K κ) (hK : 8 ≤ K) (hW : 2 * K + 4 ≤ W) (hG : Gd K KH κ (ΓG K) s L) (hF : Fin (FBat K KH κ (Fld.c CF.tag) (L "c")) gstP.body s L) :
        PKok K KH κ (ΓG K) W gstP.body s L

        guardedSetTag c t, the value t bounded by the end state's tag at c.

        theorem OrderMaintenance.Impl.gstCall_pk {K KH W : ℕ} {κ : Caps} {s : Model.Core} {L : Loc} (hC : CapsW K κ) (hK : 8 ≤ K) (hW : 2 * K + 4 ≤ W) {Γ : Machine.Reg → ℕ} {a b : Exp} {ja vb : ℕ} (hG : Gd K KH κ Γ s L) (ha : Exp.ev κ s L a = some ja) (hb : Exp.ev κ s L b = some vb) (hja : ja < 2 ^ K) (hvb : vb < 2 ^ (2 * K + 2)) (hpa : Exp.pk κ s L a < 2 ^ W) (hpb : Exp.pk κ s L b < 2 ^ W) (hF : Fin (FBat K KH κ (Fld.c CF.tag) ja) (gstP.call [a, b] []) s L) :
        PKok K KH κ Γ W (gstP.call [a, b] []) s L

        The call guardedSetTag a b, its value of width at most 2K + 2, bounded by the end state's tag at index a.

        theorem OrderMaintenance.Impl.gstCall_frame {κ : Caps} {s s' : Model.Core} {L L' : Loc} {n : ℕ} {a b : Exp} {ja : ℕ} (h : evalF κ (gstP.call [a, b] []) s L = Res.ok s' L' n) (ha : Exp.ev κ s L a = some ja) {j : ℕ} (hj : j < κ.tbl Tbl.C) (hne : j ≠ ja) :

        The frame of guardedSetTag a b: it writes the tag only at index a.

        theorem OrderMaintenance.Impl.dsMut_fin {K KH W : ℕ} {κ : Caps} {Γ Γ' : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} {j : ℕ} (hF : Fin (FBat K KH κ (Fld.c CF.tag) j) dsMutS s L) (hT : Fin (FBat K KH κ (Fld.c CF.tag) j) dsTagS s L → PKok K KH κ Γ' W dsTagS s L) (hR : ∀ (s1 : Model.Core) (L1 : Loc) (n1 : ℕ), evalF κ dsTagS s L = Res.ok s1 L1 n1 → Gd K KH κ Γ' s1 L1 → PKok K KH κ Γ W (Stm.pwr (Exp.var "y") (Exp.var "h") (Exp.var "t");; dsRangeS;; dsTgtS) s1 L1) :
        PKok K KH κ Γ W dsMutS s L

        The composition, at the sweep (dsMutS = dsTagS;; rest): the rest writes no tag, so the tag write may assume the bound that holds at the end of the move.

        powS: the walk's threshold a ^ ht #

        theorem OrderMaintenance.Impl.powS_pk {K KH W : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} (hC : CapsW K κ) (hW : 2 * K + 4 ≤ W) (hG : Gd K KH κ Γ s L) (hht : L "ht" ≤ s.P.H) (hΓ : Γ "ht" ≤ K) (hpw : K + 1 ≤ Γ "pw") :
        PK K KH κ Γ W powS s L

        pw := 1 <<< (log₂ a · ht), given the height bound ht ≤ H of the walk node (walk_lt) and log₂ a · H ≤ K (PRoom.aH).

        Option (B)'s bounds as Fin of the reservation's steps #

        theorem OrderMaintenance.Proof.Word.fld_n_of_WB {K : ℕ} {s : Model.Core} (hW : WB K s) (hK : 3 ≤ K) (k : Impl.NF) (j : ℕ) :

        The node fields of a core with WB are below 2^K.

        theorem OrderMaintenance.Proof.Word.fld_c_of_WB {K : ℕ} {s : Model.Core} (hW : WB K s) (hK : 3 ≤ K) (k : Impl.CF) (j : ℕ) :

        The chunk fields of a core with WB are below 2^K.

        theorem OrderMaintenance.Proof.Word.fbAt_n_of_WB {K KH : ℕ} {κ : Impl.Caps} {s : Model.Core} (hW : WB K s) (hK : 3 ≤ K) (k : Impl.NF) (j : ℕ) :
        Impl.FBat K KH κ (Impl.Fld.n k) j s
        theorem OrderMaintenance.Proof.Word.fbAt_c_of_WB {K KH : ℕ} {κ : Impl.Caps} {s : Model.Core} (hW : WB K s) (hK : 3 ≤ K) (k : Impl.CF) (j : ℕ) :
        Impl.FBat K KH κ (Impl.Fld.c k) j s
        theorem OrderMaintenance.Proof.Word.fld_g_of_WB {K : ℕ} {s : Model.Core} (hW : WB K s) (hK : 3 ≤ K) (k : Impl.GF) (j : ℕ) :
        theorem OrderMaintenance.Proof.Word.fld_s_of_WB {K : ℕ} {s : Model.Core} (hW : WB K s) (hK : 3 ≤ K) (k : Impl.SF) (j : ℕ) :
        theorem OrderMaintenance.Proof.Word.fin_insertElem {K KH : ℕ} {κ : Impl.Caps} {s s' : Model.Core} {x hh y : ℕ} (hK : 3 ≤ K) (hrun : EStateM.run (Model.insertElem x hh) s = EStateM.Result.ok y s') (hxE : x < s.E.size) (hgG : (s.E.getX x).grp < s.Gs.size) (hnE : (s.E.getX x).next = 0 ∨ (s.E.getX x).next < s.E.size) (hE : s.E.size < κ.tbl Impl.Tbl.E) (hG : s.Gs.size ≤ κ.tbl Impl.Tbl.G) (hW : WB K s) (hL : LabRoom K s.P) (hx : x < 2 ^ K) (hy : s.E.size < 2 ^ K) (hg : (s.Gs.getX (s.E.getX x).grp).size + 1 < 2 ^ K) (hc : s.count + 1 < 2 ^ K) :

        The element insertion ends with small sizes (Fin of insertElem_pkok): Theorem A's insertElem_agree gives the run, option (B)'s insertElem_wb its end state's bound.

        theorem OrderMaintenance.Proof.Word.fin_jobStep {K : ℕ} {κ : Impl.Caps} {t t1 : Model.Core} {job : Model.Job} {r : Option Model.Job} (hT : Top.TopInv t) (hres : t.resJob = some job) (hpr : t.prep = none) (hpow : t.P.a = 2 ^ t.P.a.log2) (hTC : Impl.TopCaps κ t) (hW : WB K t) (hR : TopRoom K t.P) (hN : t.nodes.size + 2 ≤ 2 ^ K) (hC : t.C.size ≤ 2 ^ K) (hr : EStateM.run (Model.jobStep job) t = EStateM.Result.ok r t1) (hT' : Top.TopInv { 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 }) :

        A job step ends with small stored values (Fin (WB K) of jobStepS, at the locals of jobP.call): Theorem A's jobAgree gives the run, option (B)'s jobStep_wb its end state's bound. The hypotheses are those reservation_wb and reservationAgree_top hold at each round.

        theorem OrderMaintenance.Proof.Word.split_wb {K : ℕ} {TI : Model.Core → Prop} {μ : Model.Core → ℕ} (hT : TopWB K TI μ) {t t2 : Model.Core} {A : Abs} {c : ℕ} (hI : INV t A) (hTI : TI t) (hnone : t.resJob = none) (hcL : LiveC t c) (hcq : cSt t c = Model.St.quiet) (hroom : t.C.size + 2 ≤ 2 ^ K) (hW : WB K t) (hc : c < 2 ^ K) (hsc : EStateM.run (Model.splitChunkStart c) t = EStateM.Result.ok () t2) (hTI2 : TI t2) :
        WB K t2

        A split start ends with small stored values (the split branch of reservation_wb).

        theorem OrderMaintenance.Proof.Word.fin_split {K : ℕ} {κ : Impl.Caps} {TI : Model.Core → Prop} {μ : Model.Core → ℕ} (hT : TopWB K TI μ) (hTI' : ∀ (u : Model.Core), TI u → Top.TopInv u) {t t2 : Model.Core} {A : Abs} {c : ℕ} (hI : INV t A) (hTI : TI t) (hnone : t.resJob = none) (hcL : LiveC t c) (hcq : cSt t c = Model.St.quiet) (hpr : t.prep = none) (hrow : ∀ (c : ℕ), t.C.size ≤ c → ∀ (j : ℕ), (t.path.getX c).getX j = 0) (hTC : Impl.TopCaps κ t) (hroom : t.C.size + 2 ≤ 2 ^ K) (hW : WB K t) (hc : c < 2 ^ K) (hsc : EStateM.run (Model.splitChunkStart c) t = EStateM.Result.ok () t2) (hTI2 : TI t2) :

        Fin (WB K) of splitChunkStartS (at the locals of splitP.call), from Theorem A's splitAgree_top and split_wb.

        The walk: bounds at the state before the step #

        theorem OrderMaintenance.Proof.Word.walk_lt {K : ℕ} {s : Model.Core} {job : Model.Job} (hT : Top.TopInv s) (hres : s.resJob = some job) {v : ℕ} (hv : job.pc = Model.JobPc.walk (some v) ∨ job.pc = Model.JobPc.walk none ∧ v = s.lpar.getX job.y) (hv0 : v ≠ Model.NIL) (hC : s.C.size ≤ 2 ^ K) :
        (s.nodes.getX v).weight + 2 < 2 ^ K ∧ (s.nodes.getX v).height ≤ s.P.H

        The walk node (wv of walkS: the job's node, or the leaf parent of y for a fresh walk): its weight + 2 is below 2^K (option (B)'s walk_weight, the chunk count bounding the true weight) and its height is at most H (Shape.htN), at the state before the step.

        The new PRoom field at the candidate word size #

        PRoom at wK = 64·L for the proof parameters, including log₂ a · H ≤ K (a = 8, H = L/3 + 1: 3·(L/3 + 1) ≤ 64·L).