Documentation

LeanPool.OrderMaintenance.Proof.Correct.Inv

The safety invariant INV-S (docs/PROOF.md §3.1) #

A core satisfies INV-S with respect to an abstract nesting A (the chunk list, and for each chunk its run of groups, for each group its run of elements) when:

Plus the facts that make the guards meaningful: a group or chunk outside the lists has NIL links (so an adjacency guard next(a) = b proves a is in the list), a group is alive iff it is in the list, and the free list holds only unused groups.

Lemma 3.1 (keys_sorted): keys strictly increase along the element list.

Linked lists #

The element after x in l (NIL if x is last or absent).

Equations
Instances For

    The element before x in l (NIL if x is first or absent).

    Equations
    Instances For
      structure OrderMaintenance.Proof.LList (nxt prv : ℕ → ℕ) (hd : ℕ) (l : List ℕ) :

      l is the doubly linked list starting at hd, with links nxt and prv.

      Instances For
        def OrderMaintenance.Proof.Ends (first last : ℕ) (r : List ℕ) :

        first/last pointers of a run r (NIL for an empty run).

        Equations
        Instances For

          Field accessors #

          @[reducible, inline]

          Next element index.

          Equations
          Instances For
            @[reducible, inline]

            Previous element index.

            Equations
            Instances For
              @[reducible, inline]

              Containing group of an element.

              Equations
              Instances For
                @[reducible, inline]

                Element order label.

                Equations
                Instances For
                  @[reducible, inline]

                  Next group index.

                  Equations
                  Instances For
                    @[reducible, inline]

                    Previous group index.

                    Equations
                    Instances For
                      @[reducible, inline]

                      First element of a group.

                      Equations
                      Instances For
                        @[reducible, inline]

                        Last element of a group.

                        Equations
                        Instances For
                          @[reducible, inline]

                          Containing chunk of a group.

                          Equations
                          Instances For
                            @[reducible, inline]

                            Group order label.

                            Equations
                            Instances For
                              @[reducible, inline]

                              Liveness flag of a group.

                              Equations
                              Instances For
                                @[reducible, inline]

                                Next chunk index.

                                Equations
                                Instances For
                                  @[reducible, inline]

                                  Previous chunk index.

                                  Equations
                                  Instances For
                                    @[reducible, inline]

                                    First group of a chunk.

                                    Equations
                                    Instances For
                                      @[reducible, inline]

                                      Last group of a chunk.

                                      Equations
                                      Instances For
                                        @[reducible, inline]

                                        Chunk order tag.

                                        Equations
                                        Instances For

                                          The abstract nesting #

                                          Ordered chunk, group and element lists representing a concrete core.

                                          • chunks : List ℕ

                                            Chunks in global list order.

                                          • grps : ℕ → List ℕ

                                            Groups in each chunk, in their list order.

                                          • elts : ℕ → List ℕ

                                            Elements in each group, in their list order.

                                          Instances For

                                            Concatenate the chunk-local group lists in global order.

                                            Equations
                                            Instances For

                                              Concatenate the group-local element lists in global order.

                                              Equations
                                              Instances For

                                                INV-S #

                                                Structural, allocation, label and membership invariants of a core’s abstract nesting.

                                                Instances For

                                                  Transfer: INV depends only on the fields it mentions #

                                                  theorem OrderMaintenance.Proof.INV.of_sameLinks' {s s' : Model.Core} {A : Abs} (h : INV s A) (hs : SameLinks s s') (hsorted : List.IsChain (fun (x1 x2 : ℕ) => x1 < x2) (List.map (cT s') A.chunks)) :
                                                  INV s' A

                                                  Lemma 3.1: keys increase along the element list #

                                                  The key of an element: (chunk tag, group label, element label).

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

                                                    Lexicographic order on keys.

                                                    Equations
                                                    Instances For
                                                      theorem OrderMaintenance.Proof.KeyLt.trans {a b c : ℕ × ℕ × ℕ} (h1 : KeyLt a b) (h2 : KeyLt b c) :
                                                      KeyLt a c
                                                      theorem OrderMaintenance.Proof.chain'_pairwise {l : List ℕ} (h : List.IsChain (fun (x1 x2 : ℕ) => x1 < x2) l) :
                                                      List.Pairwise (fun (x1 x2 : ℕ) => x1 < x2) l
                                                      theorem OrderMaintenance.Proof.keys_sorted {s : Model.Core} {A : Abs} (h : INV s A) :
                                                      List.Pairwise (fun (a b : ℕ) => KeyLt (keyOf s a) (keyOf s b)) A.elist
                                                      theorem OrderMaintenance.Proof.order_iff {s : Model.Core} {A : Abs} (h : INV s A) {x y : ℕ} (hx : x ∈ A.elist) (hy : y ∈ A.elist) :

                                                      Lemma 3.1. For elements of the list, order(x, y) holds iff x precedes y.