Documentation

LeanPool.OrderMaintenance.Proof.Top.Views

M5: views of the top structure #

The top structure (OrderMaintenance/Model/Top.lean, docs/PROOF.md §2.6) as the proofs see it:

And list facts: Before l a b (a strictly before b in l), and GapsGe β B ls (the labels ls, with sentinels -1 and 2^β, have all gaps at least B).

The fields the top structure reads #

The top structure's part of a core: everything its code reads, with the chunk tags.

  • Parameters controlling the projected top tree.

  • Allocated node records visible to the top-tree implementation.

  • path : Array (Array ℕ)

    Ancestor paths indexed by chunk.

  • cin : Array (List ℕ)

    Containing tables indexed by chunk.

  • lpar : Array ℕ

    Live parent indices of chunks.

  • tag : ℕ → ℕ

    Order tag of each chunk.

Instances For

    Project a core to the fields observed by the top-tree proofs.

    Equations
    Instances For

      TopSame keeps the top structure's part.

      Views #

      Read a node record, returning the default record outside the array.

      Equations
      Instances For

        Read a stored chunk ancestor at the specified height.

        Equations
        Instances For

          Read a chunk's live parent.

          Equations
          Instances For

            Read the list of tables containing a chunk.

            Equations
            Instances For

              Read a node's height.

              Equations
              Instances For

                The tables holding entry e of height h (h = 0: a chunk).

                Equations
                Instances For

                  Level j of chunk c's path; level 0 is c itself.

                  Equations
                  Instances For

                    The index denotes an allocated, alive, nonsentinel node.

                    Equations
                    Instances For

                      The index denotes an alive node that is not draining.

                      Equations
                      Instances For

                        The index denotes an alive draining node.

                        Equations
                        Instances For

                          Entries of a node table in their stored order.

                          Equations
                          Instances For

                            Labels of a node table in their stored order.

                            Equations
                            Instances For

                              Look up an entry's label in a node table.

                              Equations
                              Instances For

                                The live parent of entry e of height h; for a ghost, that of its targets.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  The ghost whose target p is (NIL if none).

                                  Equations
                                  Instances For

                                    The true weight of u: chunks of cl below u in the live tree.

                                    Equations
                                    Instances For

                                      The range of u: chunks of cl whose path passes through u.

                                      Equations
                                      Instances For

                                        Digit j ≥ 1 of c's tag: the label of p_{j-1}(c) in the table of p_j(c).

                                        Equations
                                        Instances For

                                          The tag that c's path spells.

                                          Equations
                                          Instances For

                                            Strict order in a list #

                                            a is strictly before b in l.

                                            Equations
                                            Instances For
                                              theorem OrderMaintenance.Proof.Top.Before.mono {l l' : List ℕ} {a b : ℕ} (h : Before l a b) (hl : l.Sublist l') :
                                              Before l' a b
                                              theorem OrderMaintenance.Proof.Top.Before.ne {l : List ℕ} {a b : ℕ} (h : Before l a b) (hl : l.Nodup) :
                                              a ≠ b
                                              theorem OrderMaintenance.Proof.Top.before_cons {x : ℕ} {t : List ℕ} {a b : ℕ} :
                                              Before (x :: t) a b ↔ Before t a b ∨ a = x ∧ b ∈ t
                                              theorem OrderMaintenance.Proof.Top.Before.trans {l : List ℕ} {a b c : ℕ} (h1 : Before l a b) (h2 : Before l b c) (hl : l.Nodup) :
                                              Before l a c
                                              theorem OrderMaintenance.Proof.Top.before_total {l : List ℕ} {a b : ℕ} (ha : a ∈ l) (hb : b ∈ l) (hab : a ≠ b) :
                                              Before l a b ∨ Before l b a

                                              Two distinct members of a list are in one order or the other.

                                              theorem OrderMaintenance.Proof.Top.Before.asymm {l : List ℕ} {a b : ℕ} (h : Before l a b) (hl : l.Nodup) :
                                              ¬Before l b a

                                              In a nodup list, the order of two members is asymmetric.

                                              theorem OrderMaintenance.Proof.Top.before_of_sublist {l o : List ℕ} {a b : ℕ} (hs : l.Sublist o) (ho : o.Nodup) (ha : a ∈ l) (hb : b ∈ l) (h : Before o a b) :
                                              Before l a b

                                              Order in a sublist of a nodup list is the order in the list.

                                              theorem OrderMaintenance.Proof.Top.before_append_left {l1 l2 : List ℕ} {a b : ℕ} (h : Before l1 a b) :
                                              Before (l1 ++ l2) a b
                                              theorem OrderMaintenance.Proof.Top.before_append_right {l1 l2 : List ℕ} {a b : ℕ} (h : Before l2 a b) :
                                              Before (l1 ++ l2) a b
                                              theorem OrderMaintenance.Proof.Top.before_append_mem {l1 l2 : List ℕ} {a b : ℕ} (ha : a ∈ l1) (hb : b ∈ l2) :
                                              Before (l1 ++ l2) a b
                                              theorem OrderMaintenance.Proof.Top.before_split {l1 l2 : List ℕ} {a b : ℕ} (ha : a ∈ l1) :
                                              Before (l1 ++ b :: l2) a b

                                              a before b in l1 ++ b :: l2, for a ∈ l1.

                                              theorem OrderMaintenance.Proof.Top.mem_of_before_split {l1 l2 : List ℕ} {a b : ℕ} (hl : (l1 ++ b :: l2).Nodup) (h : Before (l1 ++ b :: l2) a b) :
                                              a ∈ l1

                                              What is before b in a nodup list l1 ++ b :: l2 is in l1.

                                              Gaps between labels #

                                              The labels ls (in table order), with sentinels -1 and 2^β (shifted by one: 0 and 2^β + 1), have all gaps at least B.

                                              Equations
                                              Instances For

                                                Tags #

                                                theorem OrderMaintenance.Proof.Top.tagUp_lt {s : TS} {c : ℕ} (k : ℕ) (hd : ∀ (j : ℕ), 1 ≤ j → j ≤ k → digit s c j < 2 ^ s.P.beta) :
                                                tagUp s c k < 2 ^ (k * s.P.beta)
                                                theorem OrderMaintenance.Proof.Top.tagUp_lt_of_digit {s s' : TS} {c d : ℕ} (hβ : s'.P.beta = s.P.beta) {j : ℕ} (hj : 1 ≤ j) (hdc : ∀ (i : ℕ), 1 ≤ i → i ≤ j → digit s c i < 2 ^ s.P.beta) (hlt : digit s c j < digit s' d j) (k : ℕ) :
                                                j ≤ k → (∀ (i : ℕ), j < i → i ≤ k → digit s c i = digit s' d i) → tagUp s c k < tagUp s' d k

                                                Digit comparison: digits agree above level j, digit j is smaller, all digits fit.

                                                theorem OrderMaintenance.Proof.Top.lor_shift_eq_add {pv vb h β : ℕ} (hvb : vb < 2 ^ β) (h1 : 1 ≤ h) :
                                                pv <<< (h * β) ||| vb <<< ((h - 1) * β) = pv * 2 ^ (h * β) + vb * 2 ^ ((h - 1) * β)

                                                Two shifted digits, combined with |||, are added.

                                                theorem OrderMaintenance.Proof.Top.tagUp_congr {s s' : TS} {c c' : ℕ} (hβ : s'.P.beta = s.P.beta) (k : ℕ) :
                                                (∀ (i : ℕ), 1 ≤ i → i ≤ k → digit s' c' i = digit s c i) → tagUp s' c' k = tagUp s c k
                                                theorem OrderMaintenance.Proof.Top.tagUp_succ (s : TS) (c k : ℕ) :
                                                tagUp s c (k + 1) = tagUp s c k + digit s c (k + 1) * 2 ^ (k * s.P.beta)
                                                theorem OrderMaintenance.Proof.Top.tagUp_mono (s : TS) (c m k : ℕ) :
                                                m ≤ k → tagUp s c m ≤ tagUp s c k
                                                theorem OrderMaintenance.Proof.Top.tagUp_high {s s' : TS} {c c' : ℕ} (hβ : s'.P.beta = s.P.beta) (m k : ℕ) :
                                                m ≤ k → (∀ (i : ℕ), m < i → i ≤ k → digit s' c' i = digit s c i) → tagUp s' c' k + tagUp s c m = tagUp s c k + tagUp s' c' m
                                                theorem OrderMaintenance.Proof.Top.tagUp_replace2 {s s' : TS} {c c' : ℕ} (hβ : s'.P.beta = s.P.beta) {h k : ℕ} (h1 : 1 ≤ h) (hk : h + 1 ≤ k) (heq : ∀ (i : ℕ), 1 ≤ i → i ≤ k → i ≠ h → i ≠ h + 1 → digit s' c' i = digit s c i) :
                                                digit s c (h + 1) * 2 ^ (h * s.P.beta) + digit s c h * 2 ^ ((h - 1) * s.P.beta) ≤ tagUp s c k ∧ tagUp s' c' k = tagUp s c k - (digit s c (h + 1) * 2 ^ (h * s.P.beta) + digit s c h * 2 ^ ((h - 1) * s.P.beta)) + (digit s' c' (h + 1) * 2 ^ (h * s.P.beta) + digit s' c' h * 2 ^ ((h - 1) * s.P.beta))

                                                Two consecutive digits h, h+1 replaced: the arithmetic of drainStep's tag update.