The closed form of the rows #
The closed form of a row of words (Ratpoints.Sieve.closedRow): for an admission test adm, a
modulus m and a residue r, the (m + chunk - 1) Ratpoints.rbaPack words whose word j has bit
t set exactly when adm r admits the numerator 64 j + t. Every builder of the rows of init.c
and of the generators of the headers of the build computes the closed form of its admission test
(Ratpoints.Proof.PrimeRows, Ratpoints.Proof.CompositeRows), and the tables of rows of a run hold
closed forms (Ratpoints.Proof.RowStore). For a test of period m the closed form repeats its
first m bit arrays in the Ratpoints.chunk - 1 after them
(Ratpoints.Sieve.getElem!_closedRow_mod), the copies that the chunked first stage reads
(Ratpoints.Sieve.SieveSpec.Wraps). The words of a forbidden divisor
(Ratpoints.Sieve.forbiddenRow) have bit t of word r clear exactly when p ∣ 64 r + t, and the
row of 0 of a prime of the table (Ratpoints.Sieve.sieves0) is the closed form of the row of 0
of every table of the prime, the first p of its words those of the forbidden divisor p.
The words of a pattern in the shape in which the builders compute them: a word holding a stretch of
bits of a pattern of period m (Ratpoints.Sieve.PatternBits), and the words of a row that are the
windows of 64 bits of the pattern (Ratpoints.Sieve.RowWords), which give the closed form
(Ratpoints.Sieve.RowWords.toArray_eq_closedRow); a word of a stretch, or-ed with another shifted
left (Ratpoints.Sieve.PatternBits.or_shiftLeft), or shifted right
(Ratpoints.Sieve.PatternBits.shiftRight), holds a stretch of the pattern again. The bits of a bit
array of words that the C code reads with a shift and a mask (Ratpoints.Sieve.bitAt) are the bits
of its words (Ratpoints.Sieve.bitAt_eq_getLsbD), set one at a time
(Ratpoints.Sieve.bitAt_setBitAt).
Main definitions #
Ratpoints.Sieve.wordOfBits: the word of the bitsc t,t < 64.Ratpoints.Sieve.closedRow: the closed form of a row.Ratpoints.Sieve.PatternBits,Ratpoints.Sieve.RowWords: a word holding a stretch of a periodic pattern, and the words of a row that are windows of it.
Main statements #
Ratpoints.Sieve.getLsbD_closedRow: bittof wordjof the closed form says whether the test admits64 j + t.Ratpoints.Sieve.getElem!_closedRow_mod,Ratpoints.Sieve.wraps_closedRow,Ratpoints.Sieve.SieveEntry.wraps_closedRow: the closed form of a test of periodmrepeats its firstmbit arrays.Ratpoints.Sieve.PatternBits.or_shiftLeft,Ratpoints.Sieve.PatternBits.shiftRight: the stretches of a pattern under an or with a shifted word and under a shift right.Ratpoints.Sieve.RowWords.toArray_eq_closedRow: words of a row that are the windows of a pattern are the closed form of a test that reads the pattern.Ratpoints.Sieve.bitAt_eq_getLsbD,Ratpoints.Sieve.bitAt_setBitAt: the bit of a bit array of words that the C code reads, and the bits after one is set.Ratpoints.Sieve.getLsbD_getElem!_forbiddenRow: the bits of the words of a forbidden divisor.Ratpoints.Sieve.sieves0_eq_closedRow,Ratpoints.Sieve.extract_sieves0: the row of0of a prime is the closed form of the row of0of its table, and its firstpwords are those of the forbidden divisorp.
Implementation notes #
The file uses Lean core and Std only, as the contracts of the sieve do; the proofs use only that
Ratpoints.rbaPack and Ratpoints.chunk are positive, never their values.
A row of p + Ratpoints.chunk - 1 bit arrays of Ratpoints.rbaPack words has at least p
words.
The closed form #
The closed form of the row of the residue r for the admission test adm of the modulus m:
m + chunk - 1 bit arrays of Ratpoints.rbaPack words, for the chunk Ratpoints.chunk, word j
with bit t set exactly when adm r admits the numerator 64 j + t. With the test
Ratpoints.Sieve.SieveEntry.admits of a sieve entry, or Ratpoints.Sieve.Factor.admits of a
factor, this is the row that ratpoints builds for the residue, m bit arrays and the copies of
the first chunk - 1 of them (Ratpoints.Sieve.getElem!_closedRow_mod).
Equations
- Ratpoints.Sieve.closedRow adm m r = Array.map (fun (j : Nat) => Ratpoints.Sieve.wordOfBits fun (t : Nat) => adm r (64 * ↑j + ↑t)) (Array.range ((m + Ratpoints.chunk - 1) * Ratpoints.rbaPack))
Instances For
An array of (m + chunk - 1) rbaPack words whose word j has bit t set exactly when adm r
admits 64 j + t is the closed form.
The closed form of a test of period m > 0 repeats its first m bit arrays: word j is word
j mod m rbaPack.
The row of a sieve spec that is the closed form of a test of period p > 0 repeats its first
p bit arrays where the chunked first stage reads it.
The sieve spec of the closed form of a row of the sieve entry e, of a modulus p > 0, with
any offset, start and end, repeats its first bit arrays where the chunked first stage reads it.
Words of a periodic pattern #
The word x holds n ≤ 64 bits of the pattern g of period m from the position s on: bit
t < n of x is the bit of the pattern at s + t, and the bits from n on are clear.
Equations
Instances For
The k < 64 bits of the pattern from s on in x, or-ed with the n bits from s + k on in
y shifted left by k: the min (k + n) 64 bits from s on.
The n bits of the pattern from s on in x, shifted right by k < 64: the n - k bits from
s + k on.
The words 0, …, L - 1 of si are the windows of the pattern g of period m: word j the
64 bits from the position 64 j on.
Equations
- Ratpoints.Sieve.RowWords g m L si = ∀ (j : Nat), j < L → Ratpoints.Sieve.PatternBits g m (64 * j) 64 si[j]!
Instances For
Words that repeat the first p words of a row, whose word j < p is the window of the pattern
at 64 j, are windows of the pattern, since 64 j ≡ 64 (j mod p) (mod p).
Words of a row of (m + chunk - 1) rbaPack words that are the windows of the pattern g of
period m are the closed form of a test adm r that reads the pattern at the residues of the
numerators.
The bits of a bit array of words #
The words of a forbidden divisor #
Bit t of word r < p of the words of the forbidden divisor p is clear exactly when
p ∣ 64 r + t, the multiples p i of p with i < 64 being cleared.
The row of 0 of a prime #
The row of 0 of the prime p = e.p > 0 of the table is the closed form of the row of 0 of
the table e of the prime, whatever its entries: bit t of word x set exactly when
p ∤ 64 x + t.
The first p words of the row of 0 of the prime p are the words of the forbidden divisor
p.