Documentation

LeanPool.KrafftSieve.Defs

Core Definitions for the Krafft Sieve #

This module establishes the foundational definitions for the sieve:

Definition of the set of primes primeWindow. Let $\mathcal{P}_n$ denote the set of primes $p$ such that $5 \le p < 6n+2$.

Equations
Instances For
    def KrafftSieve.q (n : ) :

    Definition of the primorial q. Define the primorial $q = \prod_{p \in \mathcal{P}_n} p$.

    Equations
    Instances For
      def KrafftSieve.w (n : ) :

      Definition of w as the cardinality of primeWindow. Let $w = |\mathcal{P}_n|$ be the number of distinct prime factors of $q$.

      Equations
      Instances For

        Definition of the sorted list of primes and the accessor function p_i. Index the primes in $\mathcal{P}_n$ as $p_1, p_2, \dots, p_w$.

        Equations
        Instances For
          def KrafftSieve.p (n : ) (i : Fin (w n)) :

          Access the $i$-th prime $p_i$. Note that we use 0-based indexing for the implementation, so $p_0$ corresponds to the user's $p_1$.

          Equations
          Instances For
            def KrafftSieve.krafftResidue (n : ) (i : Fin (w n)) :

            Define r^K Define the Krafft tuple r^K such that for each 1 <= i <= w, r^K_i = floor((p_i+1)/6).

            Equations
            Instances For

              Define evalInterval Define the target interval of indices: evalInterval = {x in N | 6n^2 - 2n <= x <= 6n^2 + 10n + 3}.

              Equations
              Instances For
                noncomputable def KrafftSieve.g (n : ) (i : Fin (w n)) (x : ZMod (q n)) :

                Define the local hit function g_i(x) Define the local hit function $g_i : \mathbb{Z}/q\mathbb{Z} \to \mathbb{R}$ for each prime index $i \in \{1, \dots, w\}$.

                • $g_i(x) = 1$ if $x \equiv r^K_i \pmod{p_i}$ or $x \equiv -r^K_i \pmod{p_i}$.
                • Otherwise, $g_i(x) = 0$.
                Equations
                Instances For
                  noncomputable def KrafftSieve.c (n : ) (x : ZMod (q n)) :

                  Define the global additive hit counter c(x) Define the global additive hit counter $c : \mathbb{Z}/q\mathbb{Z} \to \mathbb{R}$ as the sum of all local hits: $$ c(x) = \sum_{i=1}^w g_i(x) $$

                  Equations
                  Instances For
                    noncomputable def KrafftSieve.sum1 (n : ) (W : ZMod (q n)) :

                    Define the total weighted mass of the interval sum1(n, W) Define the total weighted mass of the interval $sum1(n, W)$: $$ sum1(n, W) = \sum_{x \in \mathcal{A}_n} W(x) $$

                    Equations
                    Instances For
                      noncomputable def KrafftSieve.sum2 (n : ) (W : ZMod (q n)) :

                      Define the weighted hit count sum2(n, W) Define the weighted hit count $sum2(n, W)$: $$ sum2(n, W) = \sum_{x \in \mathcal{A}_n} W(x) c(x) $$

                      Equations
                      Instances For