Documentation

Ratpoints.Proof.Params

The sieving parameters: the table and the array size #

Every entry of Ratpoints.primeTable is a prime, which norm_num checks one entry at a time, the table lists every odd prime below 1022 in increasing order, which decide checks, so that its first Ratpoints.numPrimes entries are below Ratpoints.maxPrimeEven, a bound that keeps the accumulator of Horner's rule in examine_prime and the values of examine_power in the range of their C types (the lemmas on the values of examine_power discharge the range obligations that the Deviation paragraphs of the model state, and no proof consumes them); and the pieces of the numerators have at least one bit array.

Main statements #

theorem Ratpoints.mem_primeTable_of_prime {q : ℕ} (hq : Nat.Prime q) (h2 : q ≠ 2) (h : q < 1022) :

The table holds every odd prime below 1022, which decide checks: every odd number below 1022 that it does not hold has a divisor 1 < d < 32.

theorem Ratpoints.mem_of_toList_primeTable_eq {pref suff : List ℕ} {cur q : ℕ} (hl : primeTable.toList = pref ++ cur :: suff) (hq : Nat.Prime q) (h2 : q ≠ 2) (hlt : q < cur) :
q ∈ pref

The table lists every odd prime below its entry cur before it, since it holds every odd prime below 1022 in increasing order: the cofactor that Ratpoints.Setup.factorLcf has left when it reaches cur has no prime factor below cur.

The table begins with 3, the first prime of the loop of Ratpoints.Setup.factorLcf.

theorem Ratpoints.eq_of_toList_primeTable_eq_append_singleton {pref : List ℕ} {cur : ℕ} (hl : primeTable.toList = pref ++ [cur]) :
cur = 1021

The last prime of the table is 1021.

theorem Ratpoints.le_of_toList_primeTable_eq_append_cons_cons {pref suff : List ℕ} {cur next p : ℕ} (hl : primeTable.toList = pref ++ cur :: next :: suff) (hp : Nat.Prime p) (hcp : cur < p) :
next ≤ p

No prime lies strictly between two neighbours of the table, which lists every odd prime below 1022 in increasing order.

The primes of the table by their positions #

The first Ratpoints.numPrimes primes of the table are below Ratpoints.maxPrimeEven, since the table increases.

The moduli in the range of the C types #

theorem Ratpoints.mul_add_lt_two_pow_64_of_lt_maxPrimeEven {m v x c : ℕ} (hm : m < maxPrimeEven) (hv : v < m) (hx : x < m) (hc : c < m) :
v * x + c < 2 ^ 64

The range obligation of the steps of Horner's rule in examine_power: for a modulus m < maxPrimeEven, the steps v x + c (find_points.c:2291, find_points.c:2298), with v, x and c below m, are below m ^ 2 ≤ 2 ^ 64 (Ratpoints.maxPrimeEven_le_two_pow_32): the unsigned longs do not wrap. The square of a residue, a product of longs, is Ratpoints.mul_self_lt_two_pow_63_of_lt_maxPrimeEven.

The range obligation of the square x x of a residue in examine_power (find_points.c:2284), a product of longs: for x below a modulus, so below maxPrimeEven ≤ 2 ^ 10 (Ratpoints.maxPrimeEven_le_two_pow_10), it is below 2 ^ 20, so below 2 ^ 63: the signed product does not overflow.

The defining formula hornerSteps = 64 / maxBitsInPrime - 1 without the truncated subtraction, since 1 ≤ hornerSteps (Ratpoints.one_le_hornerSteps).

The bound of the schedule of Horner's rule in examine_prime: p ^ (hornerSteps + 1) < 2 ^ 64 for p < maxPrimeEven, since hornerSteps + 1 = 64 / maxBitsInPrime (Ratpoints.hornerSteps_add_one) and maxBitsInPrime (64 / maxBitsInPrime) ≤ 64.

theorem Ratpoints.one_le_arraySizeAt (a : ℕ) {H : ℕ} (hH : 1 ≤ H) :

The pieces of the numerators are not empty, so that the loop over the pieces of a denominator advances; this reads off only that Ratpoints.defaultArraySize, Ratpoints.maxArraySize and the chunk Ratpoints.chunk are positive, the rounding up to a multiple of the chunk keeping the size at least 1.