The contracts of the plain sieve #
The contracts of the loops of the plain sieve of one denominator, the reference of the bit arrays of
words, as @[spec] theorems proved with vcgen, the program logic of Lean core, with loop
invariants that are named definitions.
Main statements #
Ratpoints.Sieve.sieveDen_spec: entryiof the sieve of a denominatorbis the survivor testRatpoints.Sieve.survivesof the numeratori - H.Ratpoints.Sieve.checkDen_spec: if entryiof the array iskeep (i - H)for everyi, the survivors of the array give the points of the brute-force reference overband the numerators that passkeep.
Implementation notes #
The file uses Lean core and Std only, so that the grind calls of the proofs see only the lemmas
of core, untouched by the updates of Mathlib. The lemmas on the brute-force reference that the
contracts need, Ratpoints.BruteForce.pointsOfDen_nil, Ratpoints.BruteForce.pointsOfDen_append,
Ratpoints.BruteForce.pointsOfDen_singleton and Ratpoints.BruteForce.pointsOfDen_filter, and
those on the numerators -H, …, H that the contracts of the sieve need,
Ratpoints.BruteForce.map_toList_range_eq_numerators,
Ratpoints.BruteForce.natAbs_le_of_mem_numerators and
Ratpoints.BruteForce.pairwise_lt_numerators, are stated here, without Mathlib, rather than with
the other lemmas on the reference in Ratpoints.Proof.BruteForce.
Filtering the numerators by p filters the points by p of their first components, since the
points of a numerator x are triples (x, y, z).
The numerators -H, …, H are increasing.
The sieve of one denominator #
The invariant of the loop of Ratpoints.Sieve.sieveDen over the sieve entries: after the
entries pref, the entry of each numerator i - H is its survivor test for them.
Equations
Instances For
The invariant of the loop of Ratpoints.Sieve.sieveDen over the numerators for the sieve entry
e, after the entries pref: after the positions done, the entry of each numerator i - H is
its survivor test for pref followed by e if i is among them, and for pref otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The survivors of one denominator #
The invariant of the loop of Ratpoints.Sieve.checkDen over the positions: after the positions
pref, the points found are those of the brute-force reference over the denominator b and the
numerators i - H, i ∈ pref, that pass keep.
Equations
- Ratpoints.Sieve.CheckDenInvariant c d H b keep pref out = (out.toList = Ratpoints.BruteForce.pointsOfDen c d (↑b) (List.filter keep (List.map (fun (i : Nat) => ↑i - ↑H) pref)))