Documentation

Complexity.Algorithms.WordRAM.FusionTree.Query.Program

Actual fusion-tree traversal instructions #

The traversal uses eight caller registers, disjoint from both node routines. A width-indexed choice of node code is made at compilation. The stored tree, its keys and its query remain runtime inputs. Leaves return an option as a presence flag and a full-key value.

Main definitions #

Main results #

References #

@[reducible, inline]

Both node subroutines use the same fixed register file.

Instances For
    @[reducible, inline]

    Query key, preserved throughout traversal.

    Instances For
      @[reducible, inline]

      Current record pointer.

      Instances For
        @[reducible, inline]

        Inclusive rank returned by either node routine.

        Instances For
          @[reducible, inline]

          Loop flag.

          Instances For
            @[reducible, inline]

            Answer presence flag.

            Instances For
              @[reducible, inline]

              Answer full key, zero on absence.

              Instances For
                @[reducible, inline]

                Constant one.

                Instances For
                  @[reducible, inline]

                  Constant zero.

                  Instances For
                    @[reducible, inline]

                    Address scratch.

                    Instances For
                      @[reducible, inline]

                      Record tag, then leaf key.

                      Instances For
                        @[reducible, inline]

                        Leaf presence or child-table offset.

                        Instances For

                          Conventional presence/value representation, including key zero.

                          Instances For

                            Constant-register installation is part of the charged query.

                            Instances For

                              Inspect a literal leaf record; comparison is inclusive at equality.

                              Instances For

                                Positive rank r selects pointer entry p + 19 + 2(r-1).

                                Instances For

                                  Code selection depends only on the physical word width.

                                  Instances For

                                    Zero rank terminates with absence; positive rank follows an actual stored pointer.

                                    Instances For

                                      One traversal iteration first loads the current record tag.

                                      Instances For

                                        Descent terminates at a leaf or a zero child rank.

                                        Instances For

                                          Actual width-indexed query code, with initialization included.

                                          Instances For

                                            Flat query program; it halts with the value register, with presence retained in found.

                                            Instances For

                                              Persistent registers before visiting a record. No scratch-register assumptions occur.

                                              Instances For

                                                Initialization data, with arbitrary preexisting workspace and memory.

                                                Instances For

                                                  Five charged constant instructions establish all traversal constants.

                                                  theorem Cslib.Algorithms.WordRAM.FusionTree.QueryProgram.Entry.set_scratch {q p : ℕ} {x : WordRAM.Data registers} (hx : Entry q p x) (i : Fin registers) (hi : 36 ≤ ↑i) (hi' : ↑i ≤ 38) (v : ℕ) :
                                                  Entry q p (x.set i v)

                                                  Updating traversal scratch preserves the entry invariant.

                                                  Charged presence/key loads and comparisons need at most twelve instructions.

                                                  Leaf execution stops, preserves memory and query, and returns a canonical option.

                                                  Literal register updates and load for the selected child pointer.

                                                  Instances For
                                                    theorem Cslib.Algorithms.WordRAM.FusionTree.QueryProgram.exec_follow {w q p r : ℕ} {x : WordRAM.Data registers} (hx : Entry q p x) (hr : x.regs rank = r) (ha : WordRAM.Fits w (p + 19 + 2 * (r - 1))) :

                                                    Six real instructions compute and load the interleaved pointer.

                                                    Following a child preserves the invariant, changing only the current record address.

                                                    Child-pointer traversal has no memory writes.