Documentation

LeanPool.OrderMaintenance.Proof.Correct.Handles

The live handles of a core #

The client sees a core through the handles of its live elements, in list order: liveH c l = (l.filter live).map h. This file relates it to insertion, deletion, order queries and appending, for generic p (live) and f (handle).

Filter-map lemmas #

def OrderMaintenance.Proof.FM (p : ℕ → Bool) (f : ℕ → ℕ) (l : List ℕ) :

Filter element indices by liveness and map the retained indices to their handles.

Equations
Instances For
    @[simp]
    theorem OrderMaintenance.Proof.FM_nil (p : ℕ → Bool) (f : ℕ → ℕ) :
    FM p f [] = []
    theorem OrderMaintenance.Proof.FM_cons (p : ℕ → Bool) (f : ℕ → ℕ) (a : ℕ) (l : List ℕ) :
    FM p f (a :: l) = if p a = true then f a :: FM p f l else FM p f l
    theorem OrderMaintenance.Proof.FM_append (p : ℕ → Bool) (f : ℕ → ℕ) (l1 l2 : List ℕ) :
    FM p f (l1 ++ l2) = FM p f l1 ++ FM p f l2
    theorem OrderMaintenance.Proof.mem_FM (p : ℕ → Bool) (f : ℕ → ℕ) {l : List ℕ} {x : ℕ} :
    x ∈ FM p f l ↔ ∃ e ∈ l, p e = true ∧ f e = x
    theorem OrderMaintenance.Proof.FM_mem_of (p : ℕ → Bool) (f : ℕ → ℕ) {l : List ℕ} {e : ℕ} (he : e ∈ l) (hp : p e = true) :
    f e ∈ FM p f l
    theorem OrderMaintenance.Proof.FM_congr (p : ℕ → Bool) (f : ℕ → ℕ) {p' : ℕ → Bool} {f' : ℕ → ℕ} {l : List ℕ} (h : ∀ e ∈ l, p' e = p e ∧ f' e = f e) :
    FM p' f' l = FM p f l
    theorem OrderMaintenance.Proof.FM_insertAfterL (p : ℕ → Bool) (f : ℕ → ℕ) {l : List ℕ} {a b : ℕ} (ha : a ∈ l) (hpa : p a = true) (hnd : (FM p f l).Nodup) (hb : b ∉ l) (hpb : p b = true) :
    FM p f (Spec.insertAfterL a b l) = Spec.insertAfterL (f a) (f b) (FM p f l)
    theorem OrderMaintenance.Proof.FM_insertAfterL_head (p : ℕ → Bool) (f : ℕ → ℕ) {a b : ℕ} (t : List ℕ) (hpa : p a = false) (hpb : p b = true) :
    FM p f (Spec.insertAfterL a b (a :: t)) = f b :: FM p f t
    theorem OrderMaintenance.Proof.FM_kill (p : ℕ → Bool) (f : ℕ → ℕ) {p' : ℕ → Bool} {l : List ℕ} {a : ℕ} (ha : a ∈ l) (hpa : p a = true) (hp'a : p' a = false) (hp' : ∀ (e : ℕ), e ≠ a → p' e = p e) (hl : l.Nodup) (hnd : (FM p f l).Nodup) :
    FM p' f l = (FM p f l).erase (f a)

    Killing a erases its handle.

    theorem OrderMaintenance.Proof.FM_idxOf_lt (p : ℕ → Bool) (f : ℕ → ℕ) {l : List ℕ} {a b : ℕ} (ha : a ∈ l) (hb : b ∈ l) (hpa : p a = true) (hpb : p b = true) (hnd : (FM p f l).Nodup) :
    List.idxOf (f a) (FM p f l) < List.idxOf (f b) (FM p f l) ↔ List.idxOf a l < List.idxOf b l

    Positions of handles compare as positions of elements.

    theorem OrderMaintenance.Proof.FM_mem_pre (p : ℕ → Bool) (f : ℕ → ℕ) {pre post : List ℕ} {e : ℕ} (he : e ∈ pre ++ post) (hp : p e = true) (hnd : (FM p f (pre ++ post)).Nodup) :
    f e ∈ FM p f pre ↔ e ∈ pre

    In a split pre ++ post with distinct handles, an element's handle is among pre's iff the element is in pre.

    Cores seen through handles #

    Read the liveness flag of an element in a core.

    Equations
    Instances For

      Read the external handle stored in an element.

      Equations
      Instances For
        @[reducible, inline]

        List the live external handles in an ordered list of element indices.

        Equations
        Instances For

          A well-formed core: INV-S, good parameters, and a dead sentinel at the head.

          Instances For

            idx maps every handle of L to a live element with that handle.

            Equations
            Instances For
              theorem OrderMaintenance.Proof.liveH_frame {c c' : Model.Core} {l : List ℕ} (h : ∀ e ∈ l, live c' e = live c e ∧ hdl c' e = hdl c e) :
              liveH c' l = liveH c l
              theorem OrderMaintenance.Proof.core_insert {c : Model.Core} {A : Abs} (hR : CoreR c A) {xi : ℕ} (hx : xi ∈ A.elist) (hh : ℕ) :
              ∃ (c' : Model.Core) (A' : Abs), EStateM.run (Model.insertAfter xi hh) c = EStateM.Result.ok c.E.size c' ∧ CoreR c' A' ∧ A'.elist = Spec.insertAfterL xi c.E.size A.elist ∧ (∀ e ∈ A.elist, live c' e = live c e ∧ hdl c' e = hdl c e) ∧ live c' c.E.size = true ∧ hdl c' c.E.size = hh ∧ c.E.size ∉ A.elist ∧ c.E.size ≠ Model.NIL ∧ c'.head = c.head ∧ c'.P = c.P

              Core insertion through handles.

              theorem OrderMaintenance.Proof.core_kill {c : Model.Core} {A : Abs} (hR : CoreR c A) {xi : ℕ} (hx : xi ∈ A.elist) (hl : live c xi = true) (hnd : (liveH c A.elist).Nodup) :
              ∃ (c' : Model.Core), EStateM.run (Model.markDead xi) c = EStateM.Result.ok () c' ∧ CoreR c' A ∧ liveH c' A.elist = (liveH c A.elist).erase (hdl c xi) ∧ (∀ (e : ℕ), e ≠ xi → live c' e = live c e) ∧ (∀ (e : ℕ), hdl c' e = hdl c e) ∧ c'.head = c.head ∧ live c' xi = false

              Core deletion through handles.