The loops of the shapes over a block #
The loops of the four shapes over the steps of a block (Ratpoints.Sieve.squaresBlock,
Ratpoints.Sieve.squares1Block, Ratpoints.Sieve.wordsBlock, Ratpoints.Sieve.allBlock, with the
walk through the set bits of a word Ratpoints.Sieve.walkDens, the positions of the forbidden
divisors at the first word Ratpoints.Sieve.forbStarts and the word of the denominators
Ratpoints.Sieve.denWord), and the dispatch over the shapes (Ratpoints.Sieve.Shape.blockLoop),
each for any step that sifts a denominator: when the step delivers the lists L x b of the
denominator b, for every x with P x, keeps a property Q of the store of the tables of rows
and adds the counts κ b to the counters when the callback does not stop the search, the loop
delivers the lists of the denominators of its steps that pass the tests of the shape, in order,
keeps Q, and adds their counts (Ratpoints.Sieve.BlockPost). The search for the decision in
force for a block ends at the decision in force for it (Ratpoints.Sieve.Decision.InForce), the
last whose first block is at most the block (Ratpoints.Sieve.findDecision_spec).
Main definitions #
Ratpoints.Sieve.BlockPost,Ratpoints.Sieve.BlockInv: what a loop of a block does to its state, and the invariant of the loops.Ratpoints.Sieve.ForbFits,Ratpoints.Sieve.PosAt: forbidden divisors tested with words whose positions at the first word of a blockRatpoints.Sieve.forbStartsfinds, and their positions at a word.Ratpoints.Sieve.wordDens: the denominators of a word of the word shape.Ratpoints.Sieve.Shape.stepDens,Ratpoints.Sieve.Shape.ForbFits,Ratpoints.Sieve.Shape.LoopFits: the denominators of a step of a shape, and what the loops of the shapes need.Ratpoints.Sieve.Decision.InForce: the decision in force for a block.
Main statements #
Ratpoints.Sieve.squaresBlock_spec,Ratpoints.Sieve.squares1Block_spec,Ratpoints.Sieve.allBlock_spec,Ratpoints.Sieve.walkDens_spec,Ratpoints.Sieve.wordsBlock_spec: the contracts of the loops of the shapes over a block, for the contract of the step as a hypothesis.Ratpoints.Sieve.posAt_forbStarts,Ratpoints.Sieve.denWord_spec: the positions of the forbidden divisors at the first word of a block, and the word of the denominators of a word, that ofRatpoints.Sieve.wordBits, with the positions at the next word.Ratpoints.Sieve.Shape.blockLoop_spec: the loop of a shape over a block delivers the lists of the denominators of its steps (Ratpoints.Sieve.Shape.stepDens) that pass the tests of the shape.Ratpoints.Sieve.findDecision_spec: the decision in force for a block.
Implementation notes #
The loops with a cursor (repeat, while) end by measures: the steps left for the loops of a block
over a ≤ e, the word for the walk, the index for the search of the decision. The deliveries are
stated for a family L x of lists with a property P x, since the run states its delivery for
every choice of the words of the classes and the ranges of the numerators, which the program does
not mention.
What a loop over the denominators M of a block does to its state, from st to st', for a
step that delivers the points L b of each denominator b, keeps the property Q of the store of
the tables of rows and adds the counts κ b to the counters: the delivery is that of the points of
the denominators of M in order, the store has the property Q, and when the callback has not
stopped the search, the counters are those of st plus the counts of the denominators of M.
- deliver (x : ι) : P x → st'.1 = Delivery.deliver process st.1 (List.flatMap (L x) M)
The delivery is that of the points of the denominators of
M, for everyxwithP x. - store : Q st'.2.1
The store has the property
Q. - counts : st'.1.quit = false → st'.2.2 = List.foldl (fun (x1 x2 : Counters) => x1 + x2) st.2.2 (List.map κ M)
While the callback has not stopped the search, the counts of the denominators of
Mare added to the counters.
Instances For
Ratpoints.Sieve.BlockPost with the callback not stopping the search: the invariant of the
loops of the blocks after the denominators M.
The callback has not stopped the search.
- post : BlockPost process P L κ Q M st0 st
What the loop did to the state, after the denominators
M.
Instances For
The denominators N after the denominators M.
No denominator: the state is kept.
At a stop, the delivery is that of the points of all the denominators of the block.
The loops over the steps of a block with a cursor #
At the exit of a loop of a block with a cursor, after its last step e.
The step b of a loop of a block with a cursor after which the callback stops the search.
The step b = e of a loop of a block with a cursor, after which the loop ends.
A step b < e of a loop of a block with a cursor after which the callback has not stopped the
search.
A step b with one denominator, sifted when it passes the test.
The step b = e with one denominator that the test rejects.
A step b < e with one denominator that the test rejects.
What the step at the denominator b of a loop with a cursor needs.
The loops over a range of steps #
After the return of a loop of a block at a stop, the state returned.
At the end of a loop of a block over the steps a, …, e, the state after all of them.
What the step at the step cur needs.
The step at the step cur at which the callback stops the search.
The step at the step cur after which the callback has not stopped the search.
A step whose denominator the test rejects.
The invariant of the loops of Ratpoints.Sieve.squaresBlock and
Ratpoints.Sieve.squares1Block over the steps a, …, e of a block, whose state is the value of a
return and the state of the block, for the denominator f k of the step k and the test keep of
the shape, from the state st0: before a return, Ratpoints.Sieve.BlockInv after the denominators
of the steps done that pass the test; after the return at a stop, the state returned is that after
all the denominators of the block that pass the test.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The loop of the square shape over the steps a, …, e of a block, for a step that delivers the
lists of L, keeps Q and counts κ b for each denominator b with D b: the squares k ^ 2 of
the steps whose class has a pattern, in order (Ratpoints.Sieve.BlockPost).
The loop of a segment of the divisor shape, of the divisor dv, over the steps a, …, e of a
block, for a step that delivers the lists of L, keeps Q and counts κ b for each denominator
b with D b: the products dv k ^ 2 of the steps whose class has a pattern and that pass the
valuation test (Ratpoints.Sieve.denInfoTest), in order.
The invariant of the loop of Ratpoints.Sieve.allBlock over the denominators a, …, e of a
block, whose state is the value of a return, the state of the block and the cursor b, for the test
keep of the shape, from the state st0: before a return, a ≤ b ≤ e and
Ratpoints.Sieve.BlockInv after the denominators before b, and after b too at the exit; after
the return at a stop, the state returned is that after all the denominators of the block.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The loop of the shape of every denominator over the steps a ≤ e of a block, for a step that
delivers the lists of L, keeps Q and counts κ b for each denominator b with D b: the
denominators a, …, e whose class has a pattern, in order; the loop ends, since the steps left
decrease.
The walk through the set bits of a word of the word shape #
The invariant of the loop of Ratpoints.Sieve.walkDens through the set bits of the word x0
of the denominators base + t, whose state is the value of a return, the word and the state of the
block, for the test keep of the word shape, from the state st0: before a return,
Ratpoints.Sieve.WalkWhileInvariant for Ratpoints.Sieve.BlockInv after the denominators of the
set bits below k that pass the test; after the return at a stop, the state returned is that after
all of them.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The denominators base + t of the set bits t of x0 up to the lowest set bit of x, which
has the bits of x0 below k cleared, that pass the test keep.
At the exit of the walk, after all the set bits of x0.
What the step at the lowest set bit of x needs: its denominator is one of the walk.
The step at the lowest set bit of x after which the callback stops the search.
A step of the walk at whose set bit the callback does not stop the search, or whose denominator
the test rejects (st' = st).
A step whose denominator the test passes.
A step whose denominator the test rejects.
The walk through the set bits t of the word x, lowest first, for a step that delivers
the lists of L, keeps Q and counts κ b for each denominator b with D b: the denominators
base + t that pass the test test, in order; the walk ends, since clearing the lowest set bit
makes a word other than 0 smaller.
The words of the word shape #
The forbidden divisors forb tested with words have positive primes p ≤ 2 ^ 32 with their
reciprocals (Ratpoints.Sieve.magic), so that Ratpoints.Sieve.forbStarts finds the position of
each at the first word of a block.
Equations
Instances For
The positions cur of the forbidden divisors forb tested with words are those at the word
w: one for each, w mod p for the prime p.
Equations
Instances For
The positions of the forbidden divisors tested with words at the first word a of a block are
those at a: a mod p, by the reciprocal of p when a ≤ Ratpoints.mulModLimit
(Ratpoints.Sieve.mulMod_magic) and by Ratpoints.Sieve.modLong otherwise.
The word of the denominators of the word w that the class test and the forbidden divisors
forb tested with words leave, from their positions cur at w, with the masks of the first and
the last word of the run: the word of Ratpoints.Sieve.wordBits; the positions are then those at
w + 1.
The denominators 64 w + t of the word w of the word shape, of the set bits t of its word
(Ratpoints.Sieve.wordBits), lowest first.
Equations
- Ratpoints.Sieve.wordDens db forb bLow bHigh w = List.map (fun (x : ℕ) => 64 * w + x) (List.filter (Ratpoints.Sieve.wordBits db forb bLow bHigh w).toBitVec.getLsbD (List.range 64))
Instances For
The invariant of the loop of Ratpoints.Sieve.wordsBlock over the words a, …, e of a block,
whose state is the value of a return, the positions of the forbidden divisors forb tested with
words, the state of the block and the word w, for the test keep of the word shape, from the
state st0: before a return, a ≤ w ≤ e, Ratpoints.Sieve.BlockInv after the denominators of the
words before w (Ratpoints.Sieve.wordDens), and of w too at the exit, and the positions those
at w before it; after the return at a stop, the state returned is that after all the denominators
of the block.
Equations
- One or more equations did not get rendered due to their size.
Instances For
What the word of the denominators of w needs.
The walk through the word of w is through its denominators (Ratpoints.Sieve.wordDens).
What the walk through the word of w needs: its denominators are those of the block.
The loop of the word shape over the words a ≤ e of a block, with the first and last words of
the run bLow / 64 and bHigh / 64 and forbidden divisors that have what the loop needs
(Ratpoints.Sieve.ForbFits), for a step that delivers the lists of L, keeps Q and counts κ b
for each denominator b with D b: the denominators of the words (Ratpoints.Sieve.wordDens) that
pass the tests test, in order; the positions of the divisors step on with the words
(Ratpoints.Sieve.posAt_forbStarts, Ratpoints.Sieve.denWord_spec), and the loop ends, since the
words left decrease.
The loop of a shape over a block #
The denominators of the step k of the segment seg of the shape shape for the
denominators bLow, …, bHigh, before the tests of the shape on a single denominator: the square
k ^ 2, the product s k ^ 2 with the divisor s of the segment, the denominators of the word k
that the class test and the forbidden divisors tested with words leave
(Ratpoints.Sieve.wordDens, with the word db of the classes that admit a numerator), and k
itself.
Equations
- Ratpoints.Sieve.Shape.squares.stepDens db bLow bHigh seg k = [k * k]
- (Ratpoints.Sieve.Shape.squares1 info divisors).stepDens db bLow bHigh seg k = [divisors[seg]! * k * k]
- (Ratpoints.Sieve.Shape.words forb forbVal useJacobi fast lcf).stepDens db bLow bHigh seg k = Ratpoints.Sieve.wordDens db forb bLow bHigh k
- Ratpoints.Sieve.Shape.all.stepDens db bLow bHigh seg k = [k]
Instances For
The forbidden divisors tested with words of the word shape have what the loop of a block over
the words needs (Ratpoints.Sieve.ForbFits); the other shapes have none.
Equations
- (Ratpoints.Sieve.Shape.words forb forbVal useJacobi fast lcf).ForbFits = Ratpoints.Sieve.ForbFits forb
- x✝.ForbFits = True
Instances For
What the loop of the shape over a block of the blocks plan for the denominators
bLow, …, bHigh needs: for the word shape, forbidden divisors that have what the loop needs
(Ratpoints.Sieve.ForbFits) and the first segment of the blocks from the word of bLow to that of
bHigh, the first and last words of the run, which the masks compare with; nothing for the other
shapes.
Equations
- Ratpoints.Sieve.Shape.LoopFits plan bLow bHigh (Ratpoints.Sieve.Shape.words forb forbVal useJacobi fast lcf) = (Ratpoints.Sieve.ForbFits forb ∧ plan.segs[0]! = (bLow / 64, bHigh / 64))
- Ratpoints.Sieve.Shape.LoopFits plan bLow bHigh x✝ = True
Instances For
The loop of the shape over the steps a ≤ e of a block of the segment seg, each denominator
that passes the tests of the shape handed to a step that delivers L b, keeps Q and counts κ b,
for the denominators of the steps (Ratpoints.Sieve.Shape.stepDens) that pass the tests of the
shape (Ratpoints.Sieve.Shape.keep), in order; for the word shape, with the first and last words of
the run as the first segment of the blocks and forbidden divisors that have what the loop needs.
The decision in force for a block #
Decision dd of decs is the one in force for block i: it exists, its first block is at most
i, and every later decision is for a block after i.
Equations
Instances For
The invariant of the search of Ratpoints.Sieve.findDecision for the decision in force for
block i, whose state is the index dd of a decision: while the search goes on, every later
decision is for a block after i, and at the exit the decision dd is the one in force for block
i (Ratpoints.Sieve.Decision.InForce).
Equations
- One or more equations did not get rendered due to their size.
Instances For
For decisions of which the first is for block 0, the decision in force for block i is the
last whose first block is at most i: the search from the last decision back ends there, at the
first decision at the latest.