Documentation

Complexity.Algorithms.WordRAM.ExactTriangle.Instances

Native ExactTriangle instance preparation #

The input header is (D,g,n,p), followed by the three signed weight matrices. The program first computes the real class/chunk catalogue. It then visits each actual chunk and piece, reads that chunk's descriptor, computes the piece boundaries and writes its record and two zero/one matrices. The records share the already computed query arrays. Every visit uses the existing native InstancePair.program rather than assuming a matrix-preparation routine.

The output records and matrices occupy consecutive variable-size blocks. Register output names the first record, produced gives their actual number and heap is their final allocation end. Each block has six record words followed by 2nD matrix words. This module prepares instances; it does not choose a prime, evaluate their queried products or decide ExactTriangle.

Main definitions #

Main results #

PreparationInput supplies the initialized flat-program interface and derived width bounds; PreparationBounds proves the preparation time bound in the source's parameter regime. Code-stage definitions are exposed for kernel-checked interpreter clients. Proof helpers are private.

References #

The matrix geometry follows the pinned Theorem 17 matrix construction. The native controller and resource proofs are original.

@[reducible, inline]

Outer matrix dimension.

Instances For
    @[reducible, inline]

    Target padded middle dimension.

    Instances For
      @[reducible, inline]

      Residue modulus.

      Instances For
        @[reducible, inline]

        Computed maximum vertices per piece.

        Instances For
          @[reducible, inline]

          Computed number of pieces.

          Instances For
            @[reducible, inline]

            Actual number of nonempty query chunks.

            Instances For
              @[reducible, inline]

              Computed chunk-descriptor array.

              Instances For
                @[reducible, inline]

                First output record.

                Instances For
                  @[reducible, inline]

                  Number of completely written instance blocks.

                  Instances For
                    @[reducible, inline]

                    Actual chunk count times piece count.

                    Instances For
                      @[reducible, inline]

                      Next free output record.

                      Instances For
                        @[reducible, inline]

                        Words per record and its two matrices.

                        Instances For
                          @[reducible, inline]

                          Constant one.

                          Instances For
                            @[reducible, inline]

                            Words per chunk descriptor.

                            Instances For
                              @[reducible, inline]

                              Words per instance record.

                              Instances For
                                @[reducible, inline]

                                Words in one matrix.

                                Instances For
                                  @[reducible, inline]

                                  Original A–C residue matrix.

                                  Instances For
                                    @[reducible, inline]

                                    Original B–C residue matrix.

                                    Instances For
                                      @[reducible, inline]

                                      Descriptor/header address temporary.

                                      Instances For
                                        @[reducible, inline]

                                        Current chunk ordinal.

                                        Instances For
                                          @[reducible, inline]

                                          Current piece ordinal.

                                          Instances For
                                            @[reducible, inline]

                                            Residue loaded from the actual chunk descriptor.

                                            Instances For
                                              @[reducible, inline]

                                              Query pointer loaded from the actual chunk descriptor.

                                              Instances For
                                                @[reducible, inline]

                                                Query count loaded from the actual chunk descriptor.

                                                Instances For
                                                  @[reducible, inline]

                                                  First vertex of the current piece.

                                                  Instances For
                                                    @[reducible, inline]

                                                    Actual length of the current piece.

                                                    Instances For
                                                      @[reducible, inline]

                                                      Original weight-matrix area temporary.

                                                      Instances For

                                                        Existing catalogue computation in the lower thirty-two registers.

                                                        Instances For

                                                          Save the actual catalogue outputs and compute the allocation stride and residue bases.

                                                          Instances For

                                                            Compute the chunk and piece ordinals, then load the real query reference and piece bounds.

                                                            Instances For

                                                              Deliver every actual pointer, coordinate and count to the existing instance-pair ABI.

                                                              Instances For

                                                                Existing native record and matrix-pair writer.

                                                                Instances For

                                                                  Advance only after the complete pair has been written.

                                                                  Instances For

                                                                    One actual instance; every selection, argument-delivery and matrix instruction is native.

                                                                    Instances For

                                                                      Prepare every actual chunk/piece pair after computing the catalogue.

                                                                      Instances For

                                                                        The catalogue prefix, twenty-six setup instructions, each 40nD+66 visit and its two loop instructions, the two loop-exit instructions and the final halt are accounted separately.

                                                                        Instances For

                                                                          Original-header bound for all arithmetic and allocated addresses. The conservative maximum p*n² chunk count and n pieces cover every actual catalogue entry. Signed weights have their separate magnitude fit premise; no layout information is supplied by the caller.

                                                                          Instances For

                                                                            One bounded instruction graph with no word-size reads.

                                                                            def Cslib.Algorithms.WordRAM.ExactTriangle.Instances.Output (n D g p : ℕ) (values : ℕ → ℤ) (initial y : WordRAM.Data 64) :

                                                                            Exact computed catalogue, record and raw zero/one matrix readback, with the complete input/output frame. The matrix predicates reuse the existing writer arguments and entry semantics.

                                                                            Instances For
                                                                              theorem Cslib.Algorithms.WordRAM.ExactTriangle.Instances.exec_at {w : ℕ} (n D g p : ℕ) (values : ℕ → ℤ) (initial : WordRAM.Data 64) (hDHeader : initial.mem 1 = D) (hgHeader : initial.mem 2 = g) (hnHeader : initial.mem 3 = n) (hpHeader : initial.mem 4 = p) (hinput : ∀ q < 3 * (n * n), initial.mem (5 + q) = WordRAM.Signed.encode (values q)) (hD : 1 ≤ D) (hDn : D ≤ n) (hg : 1 ≤ g) (hp : 0 < p) (hmod : GenericRAM.Signed.Fits w ↑p) (hvalues : ∀ q < 3 * (n * n), GenericRAM.Signed.Fits w (values q)) (hbudget : WordRAM.Fits (w + 2) (budget n D g p)) :
                                                                              have N := n * n; have R := fun (q : ℕ) => (values q % ↑p).toNat; have C := fun (rho : ℕ) => Nat.count (fun (q : ℕ) => R q = rho) N; have K := ChunkCatalogue.before C (ExactTriangle.queryCap n D) p; have H := ExactTriangle.numPieces n D g; ∃ (y : WordRAM.Data 64), WordRAM.ExecWithin (w + 2) program initial y (timeBound n D p K H - 1) ∧ Output n D g p values initial y

                                                                              Execute the complete preparation from the real header and signed matrices. Every output record refers to the actual computed query chunk, followed by its raw zero/one matrix pair. The only resource premises concern the original signed values and the explicit numeric budget; neither a catalogue nor a layout or execution certificate is an input. The final halt is excluded here and added by the initialized flat-program client.