Documentation

Complexity.Algorithms.WordRAM.ExactTriangle.WriteMatrices

Native zero/one matrices for an Exact Triangle instance #

The input contains ordinary unsigned residues. Each output cell computes its row, middle vertex and label through charged division/remainder instructions. Cells outside the selected piece are zero; all other cells test the required modular adjacency. The same seventeen registers serve the left n×D and right D×n matrices, with no supplied indexing table.

The X/Y output entries are raw unsigned words 0 and 1. A consumer using canonical Signed.encode matrix entries must double each entry while copying it into that input and charge the conversion instruction. Scalar headers, pointers and query coordinates remain raw unsigned words.

This directly adapts the adjacency formulas in the pinned Theorem 17 instance builder. The native implementation visits each output cell once; the source clears and then marks cells.

Main definitions #

Main results #

Runtime arguments of one matrix-building call.

  • src : ℕ

    Residue matrix base.

  • dst : ℕ

    Output matrix base.

  • n : ℕ

    Number of vertices in each outer part.

  • D : ℕ

    Padded middle dimension.

  • p : ℕ

    Positive modulus.

  • first : ℕ

    First vertex of the selected piece.

  • length : ℕ

    Number of vertices in the piece.

  • rho : ℕ

    A–B query residue.

Instances For

    Raw unsigned zero/one row-major adjacency. A true side chooses the right D×n matrix; false chooses the left n×D matrix. The source residue matrix has shape n×n. A signed-matrix consumer encodes these entries by doubling them.

    Instances For
      @[reducible, inline]

      Residue input pointer.

      Instances For
        @[reducible, inline]

        Output matrix pointer.

        Instances For
          @[reducible, inline]

          Outer dimension.

          Instances For
            @[reducible, inline]

            Middle dimension.

            Instances For
              @[reducible, inline]

              Modulus.

              Instances For
                @[reducible, inline]

                First vertex of the piece.

                Instances For
                  @[reducible, inline]

                  Piece length.

                  Instances For
                    @[reducible, inline]

                    Query residue.

                    Instances For
                      @[reducible, inline]

                      Flat output cursor.

                      Instances For
                        @[reducible, inline]

                        Number of output cells.

                        Instances For
                          @[reducible, inline]

                          Selected source row.

                          Instances For
                            @[reducible, inline]

                            Selected vertex within the piece.

                            Instances For
                              @[reducible, inline]

                              Middle label.

                              Instances For
                                @[reducible, inline]

                                Address temporary.

                                Instances For
                                  @[reducible, inline]

                                  Residue and output value temporary.

                                  Instances For
                                    @[reducible, inline]

                                    Constant zero.

                                    Instances For
                                      @[reducible, inline]

                                      Constant one.

                                      Instances For

                                        The eight runtime arguments occupy registers 0–7.

                                        Instances For

                                          Compute the source row and decode the middle label using actual arithmetic instructions.

                                          Instances For

                                            Read the selected residue and form its required label.

                                            Instances For

                                              Write one zero/one cell and increment the flat cursor.

                                              Instances For

                                                The complete builder initializes constants and visits all output positions once.

                                                Instances For

                                                  The instruction graph has fixed size and never reads the physical word width.

                                                  theorem Cslib.Algorithms.WordRAM.ExactTriangle.WriteMatrices.exec {w : ℕ} (side : Bool) (A : Args) (R : ℕ → ℕ) (x : WordRAM.Data 17) (hx : Entry A x) (hrho : A.rho < A.p) (hpiece : A.first + A.length ≤ A.n) (hR : ∀ i < A.n * A.n, R i < A.p) (hinput : ∀ i < A.n * A.n, x.mem (A.src + i) = R i) (hsrc : WordRAM.Fits w (A.src + A.n * A.n)) (hdst : WordRAM.Fits w (A.dst + A.n * A.D)) (hmod : WordRAM.Fits w (2 * A.p)) (hdisj : A.src + A.n * A.n ≤ A.dst) :
                                                  ∃ (y : WordRAM.Data 17), WordRAM.ExecWithin w (program side) x y (20 * (A.n * A.D) + 6) ∧ Entry A y ∧ y.regs idx = A.n * A.D ∧ ({ base := A.dst, length := A.n * A.D }.Realizes y.mem fun (i : Fin { base := A.dst, length := A.n * A.D }.length) => entry side A R ↑i) ∧ ∀ (a : ℕ), ¬{ base := A.dst, length := A.n * A.D }.Owns a → y.mem a = x.mem a

                                                  Construct every entry of a left or right instance matrix in 20nD+6 native instructions, excluding the halt. The source is an actual residue array below the output. All cells outside the output block and all eight arguments are preserved. No adjacency table is supplied.