Documentation

Complexity.Algorithms.WordRAM.ThreeSum.ChanHe.Search

Native least-prime collision searches #

The search scans the prime bitmap in increasing order. A candidate runs the complete native three-set collision query. Its first acceptance is retained while the remaining candidates are visited without further bitmap reads. If no candidate is accepted, the answer is one, matching ChanHe.minOrOne.

Main definitions #

Main results #

@[reducible, inline]

Largest candidate prime.

Instances For
    @[reducible, inline]

    Prime bitmap base.

    Instances For
      @[reducible, inline]

      Factor multiplied by the candidate prime.

      Instances For
        @[reducible, inline]

        Current candidate.

        Instances For
          @[reducible, inline]

          One past the largest candidate.

          Instances For
            @[reducible, inline]

            Selected prime, or the default one.

            Instances For
              @[reducible, inline]

              Whether an acceptance has already occurred.

              Instances For
                @[reducible, inline]

                Constant one.

                Instances For
                  @[reducible, inline]

                  Constant zero.

                  Instances For
                    @[reducible, inline]

                    Constant two, for positive signed encoding.

                    Instances For
                      @[reducible, inline]

                      Unencoded candidate modulus.

                      Instances For
                        @[reducible, inline]

                        Bitmap address scratch.

                        Instances For
                          @[reducible, inline]

                          Loaded primality bit.

                          Instances For
                            @[reducible, inline]

                            Encoded candidate modulus.

                            Instances For
                              @[reducible, inline]

                              Acceptance flag returned by the collision query.

                              Instances For

                                Compute and encode the candidate modulus, then run the full collision query.

                                Instances For

                                  Record an accepted candidate, or retain the previous answer.

                                  Instances For

                                    A charged instruction that retains the answer.

                                    Instances For

                                      Before the first acceptance, run the query exactly on prime candidates.

                                      Instances For

                                        One candidate and its charged cursor increment.

                                        Instances For

                                          Initialize the selector and scan the entire bounded candidate range.

                                          Instances For

                                            The five upper caller registers survive the complete native search.

                                            theorem Cslib.Algorithms.WordRAM.ThreeSum.ChanHe.Search.exec {w : ℕ} (x : WordRAM.Data 64) (values : Fin 3 → ℕ → ℤ) (hfactor : 0 < x.regs factor) (hmod : GenericRAM.Signed.Fits w ↑(x.regs factor * x.regs limit)) (hfit : WordRAM.Fits (w + 2) (x.regs limit + 3)) (haddr : WordRAM.Fits (w + 2) (x.regs primes + (x.regs limit + 1))) (hbefore : x.regs primes + (x.regs limit + 1) ≤ x.regs CountCall.scratch) (hbitmap : ∀ q ≤ x.regs limit, x.mem (x.regs primes + q) = if Nat.Prime q then 1 else 0) (hvalues : ∀ (j : Fin 3), ∀ i < x.regs (CountCall.length j), GenericRAM.Signed.Fits w (values j i)) (hs : ∀ (j : Fin 3), WordRAM.Fits (w + 2) (x.regs (CountCall.source j) + x.regs (CountCall.length j))) (hk : ∀ (j : Fin 3), WordRAM.Fits (w + 2) (x.regs CountCall.scratch + x.regs (CountCall.length j))) (hd : WordRAM.Fits (w + 2) (x.regs CountCall.histogram + x.regs factor * x.regs limit)) (ht : ∀ (j : Fin 3), WordRAM.Fits (w + 2) (x.regs (CountCall.length j) * x.regs (CountCall.length j) + x.regs (CountCall.length j) + 1)) (hproduct : ∀ (j : Fin 3), WordRAM.Fits (w + 2) (x.regs (CountCall.length j) * x.regs (CountCall.length j) * x.regs CollisionTest.card)) (hsk : ∀ (j : Fin 3), x.regs (CountCall.source j) + x.regs (CountCall.length j) ≤ x.regs CountCall.scratch) (hkd : ∀ (j : Fin 3), x.regs CountCall.scratch + x.regs (CountCall.length j) ≤ x.regs CountCall.histogram) (hinput : ∀ (j : Fin 3), ∀ i < x.regs (CountCall.length j), x.mem (x.regs (CountCall.source j) + i) = WordRAM.Signed.encode (values j i)) (hinj : ∀ (j : Fin 3), Set.InjOn (values j) ↑(Finset.range (x.regs (CountCall.length j)))) :
                                            ∃ (y : WordRAM.Data 64), WordRAM.ExecWithin (w + 2) program x y ((x.regs limit + 1) * (34 * (x.regs (CountCall.length 0) + x.regs (CountCall.length 1) + x.regs (CountCall.length 2)) + 15 * (x.regs factor * x.regs limit) + 102) + 9) ∧ (∀ (i : Fin 64), 28 ≤ ↑i ∧ ↑i ≤ 35 ∨ 40 ≤ ↑i ∧ ↑i ≤ 46 → y.regs i = x.regs i) ∧ (∀ a < x.regs CountCall.scratch, y.mem a = x.mem a) ∧ y.regs answer = ThreeSum.ChanHe.minOrOne ({q ∈ (x.regs limit).primesLE | ∀ (j : Fin 3), ThreeSum.ChanHe.coll (Finset.image (values j) (Finset.range (x.regs (CountCall.length j)))) (x.regs factor * q) * x.regs CollisionTest.card ≤ x.regs (CollisionTest.threshold j)})

                                            The least prime whose three actual collision counts satisfy the supplied thresholds. Every candidate query is executed by Query.program; the hypotheses only constrain native input values, layout and word fits. All instructions, including the scan after acceptance, are charged. The final halt is excluded.