The plan of the blocks of the run #
The run cuts the steps of its shape into segments (Ratpoints.Sieve.Shape.segments), one for each
divisor of the divisor shape and one otherwise, and each segment into blocks of one length
(Ratpoints.Sieve.Shape.blockPlan), the first block of each segment recorded with the number of
the blocks at the end; the steps of block i are found from the segment that holds it
(Ratpoints.Sieve.BlockPlan.steps). The plan that the run makes is well-formed
(Ratpoints.Sieve.BlockPlan.WF): blocks of at least one step, the first blocks of the segments the
running sums of the numbers of their blocks (Ratpoints.Sieve.numBlocks); for a well-formed plan
the search for the segment of a block ends, the steps of the block are those of
Ratpoints.Sieve.blockRange, its first step at most its last, and the blocks in order cover the
steps of the segments in order. A decision of the correction of the moduli is well-formed for the
entries of the run (Ratpoints.Sieve.DecisionWF) when its cut points are in order within the
entries and the entries from its second cut point on count no factor.
Main definitions #
Ratpoints.Sieve.numBlocks,Ratpoints.Sieve.blockRange: the number of the blocks of a segment and the first and last steps of each.Ratpoints.Sieve.Shape.numSegs,Ratpoints.Sieve.Shape.segment: the segments of a shape.Ratpoints.Sieve.BlockPlan.WF: a well-formed plan of the blocks.Ratpoints.Sieve.BlockPlan.blockSteps,Ratpoints.Sieve.BlockPlan.blockSeg: the steps and the segment of a block.Ratpoints.Sieve.DecisionWF: a decision whose cut points the blocks can use.
Main statements #
Ratpoints.Sieve.flatMap_blockRange: the blocks of a segment cover its steps in order.Ratpoints.Sieve.Shape.segments_spec,Ratpoints.Sieve.Shape.blockPlan_spec: the segments of a shape, and the plan of its blocks well-formed over them.Ratpoints.Sieve.one_le_blockLength: a block has at least one step.Ratpoints.Sieve.BlockPlan.WF.steps_spec,Ratpoints.Sieve.BlockPlan.WF.run_steps_eq: the steps of a block of a well-formed plan, from its segment.Ratpoints.Sieve.BlockPlan.WF.flatMap_blockSteps: the blocks of a well-formed plan, in order, cover the steps of its segments in order.Ratpoints.Sieve.BlockPlan.WF.run_steps_le: the first step of a block is at most its last, which the loops of the blocks need to end.Ratpoints.Sieve.DecisionWF.mk_sp2,Ratpoints.Sieve.DecisionWF.map_dinv: a well-formed decision stays well-formed with no third stage, and for the entries with the inverses of the strides thatRatpoints.Sieve.classOffsetssets.
Implementation notes #
The file uses Lean core and Std only, as the contracts of the sieve do.
The blocks of a segment #
The number of the blocks of len steps of the segment of the steps lo, …, hi, the last
possibly shorter: ⌊(hi - lo) / len⌋ + 1, and none for an empty segment, hi < lo.
Instances For
The first and last steps of block j of len steps of the segment of the steps lo, …, hi:
from lo + j len, len steps or up to hi.
Equations
Instances For
A block of a segment has its first step at most its last, both within the segment.
The blocks of a segment, in order, cover its steps in order.
The plan of the blocks #
The number of the segments of steps of the shape s: one for each divisor of the divisor
shape, and one otherwise.
Instances For
The first and last steps of segment n of the shape s for the denominators bLow, …, bHigh
(Ratpoints.Sieve.Shape.segments).
Equations
- Ratpoints.Sieve.Shape.squares.segment bLow bHigh n = (Ratpoints.Sieve.ceilSqrt bLow, Ratpoints.Sieve.floorSqrt bHigh)
- (Ratpoints.Sieve.Shape.squares1 info divisors).segment bLow bHigh n = (Ratpoints.Sieve.ceilSqrt ((bLow - 1) / divisors[n]! + 1), Ratpoints.Sieve.floorSqrt (bHigh / divisors[n]!))
- (Ratpoints.Sieve.Shape.words forb forbVal useJacobi fast lcf).segment bLow bHigh n = (bLow / 64, bHigh / 64)
- Ratpoints.Sieve.Shape.all.segment bLow bHigh n = (bLow, bHigh)
Instances For
The blocks plan are well-formed: blocks of at least one step, and the first block of each
segment the number of the blocks of the segments before it
(Ratpoints.Sieve.numBlocks), the number of all the blocks at the end.
The blocks have at least one step.
- segBlock_eq : plan.segBlock.toList = List.map (fun (j : Nat) => (List.map (fun (sg : Nat × Nat) => numBlocks sg.fst sg.snd plan.len) (List.take j plan.segs.toList)).sum) (List.range (plan.segs.size + 1))
The first block of each segment, and the number of all the blocks at the end.
Instances For
A block has at least one step: the length that a build sets is positive
(Ratpoints.blockLen_pos), and otherwise the length is at least 1.
The blocks that Ratpoints.Sieve.Shape.blockPlan makes are well-formed, over the segments
of Ratpoints.Sieve.Shape.segments.
The invariant of the search of Ratpoints.Sieve.BlockPlan.steps for the segment of block i,
whose state is the segment seg: a segment of the blocks whose first block is at most i, and at
the exit the segment whose blocks hold i.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The steps of block i < plan.nblocks of well-formed blocks: its segment, the one whose blocks
hold it, and its first and last steps (Ratpoints.Sieve.blockRange). The search for the segment
ends, since the first block after the last segment is the number of the blocks.
The steps of block i < plan.nblocks of well-formed blocks, from the segment whose blocks hold
it (Ratpoints.Sieve.BlockPlan.WF.steps_spec).
The steps of a block of well-formed blocks that lies in the segment seg: the block
i - segBlock[seg] of the segment (Ratpoints.Sieve.blockRange).
The blocks of well-formed blocks, in order, cover the steps of their segments in order, and so
the lists g seg k of the steps k of each segment seg, in order.
Well-formed decisions #
A decision d of the correction of the moduli is well-formed for the sieve entries es of the
run and the end sp1 of the first stage: sp1 ≤ d.sp2 ≤ d.sp3 ≤ |es|, and every entry from the
position d.sp2 on, those of the third stage and the reserve, counts no factor
(Ratpoints.Sieve.SieveEntry.nf zero), so that, for the entries of the choice of the moduli, it is
a prime of the table, as the third stage needs.
The end of the second stage is at least that of the first.
The end of the third stage is at least that of the second.
The end of the third stage is at most the number of the entries.
Every entry from the end of the second stage on counts no factor.
Instances For
A well-formed decision gives a well-formed decision with its end of the second stage and no third stage, for any first block.
A well-formed decision stays well-formed for the sieve entries with the inverses of the strides
that Ratpoints.Sieve.classOffsets sets.