The set bits of a word #
The bit of a numerator or a bit number in a word (Ratpoints.Sieve.classBit), the contract of the
loop of the lowest set bit of a word (Ratpoints.Sieve.ctz), and the invariant of a while loop
that walks through the set bits of a word, lowest first, clearing each with x &&& (x - 1)
(Ratpoints.Sieve.WalkWhileInvariant), which the walks of the extraction, of the packing of the
classes, of the 2-adic information and of the word shape share.
Main definitions #
Ratpoints.Sieve.classBit: whether a word letsathrough, bita mod 64of the word.Ratpoints.Sieve.ClearedBelow: a word with the bits of another below a position cleared.Ratpoints.Sieve.WalkWhileInvariant: the invariant of a walk through the set bits of a word, lowest first.Ratpoints.Sieve.bitNumbers: the bit numbers of the set bits of some words, in increasing order.
Main statements #
Ratpoints.Sieve.ctz_spec,Ratpoints.Sieve.run_ctz: for a word other than0, the loop ofRatpoints.Sieve.ctzends with the number of its trailing zeros.Ratpoints.Sieve.ClearedBelow.filter_range_succ_ctz,Ratpoints.Sieve.ClearedBelow.exists_lt_succ_iff: the set bits of the word up to the lowest set bit of the word with the bits belowkcleared.
Implementation notes #
The file uses Lean core and Std only; the lemmas on words that are not about the model are in
Ratpoints.Proof.Bits.
The bit of a number in a word #
Whether the word cw lets a through: bit a mod 64 of cw. For the 2-adic word of a class
of denominators (Ratpoints.Sieve.twoAdic), a is a numerator. For the pattern of a class in its
packing (Ratpoints.Sieve.NumClass.bits), which Ratpoints.Sieve.andRows writes into every word of
a piece, a is a bit number: bit a mod 64 of every word stands for the bits ≡ a (mod 64), since
64 divides Ratpoints.rbaLength. Ratpoints.Sieve.NumClass.Packs.classBit_bits converts between
the two.
Instances For
The lowest set bit #
The invariant of the loop of Ratpoints.Sieve.ctz on a word w ≠ 0: the word is w shifted
right by the count, the count is at most the position of the lowest set bit of w, and it is that
position at the exit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The walks through the set bits of a word #
Clearing the lowest set bit of x clears the bits of x0 up to that bit.
The set bits of x0 up to the lowest set bit of x are those below k, then that bit, since
x has the bits of x0 from k on.
The set bits j of x0 up to the lowest set bit of x that have the property P are those
below k, which x has cleared, and the lowest set bit of x if it has the property, a set bit of
x0 too.
The invariant of a while loop over the set bits of the word x0, lowest first, whose state is
a value of σ and the word, for a property P k of the value after the set bits below k: the
word is x0 with its bits below some k cleared (Ratpoints.Sieve.ClearedBelow), the value has
the property P k, and the word is 0 at the exit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The invariant after one step, with the lowest set bit of w cleared and the value s' with
the property P up to that bit, in the shape of the verification condition: the measure w.toNat
decreases.
The bit numbers of the set bits of words #
The bit numbers of the set bits of the words are the numbers base, …, base + 64 k - 1 that
pass p, when bit t of word κ is t < 64 and p (base + 64 κ + t).