Repository navigation
Conversation
Member
|
This would probably be best as 3 separate PRs (stacked):
We can probably merge as a single PR but it would be good to have the commits rebased into the above so each is meaningful in isolation. |
fdupress
reviewed
Nov 10, 2026
| by rewrite !exprS // -(modzMmr (m %% d)) ih modzMmr modzMml. | ||
| qed. | ||
|
|
||
| (* -------------------------------------------------------------------- *) |
Member
There was a problem hiding this comment.
Should this entire section move to IntDiv or a related theory on modular arithmetic without the algebra?
Contributor
Author
There was a problem hiding this comment.
I am agree with you, I will do that
| hint simplify powmod0, powmodS. | ||
| (* -------------------------------------------------------------------- *) |
Member
There was a problem hiding this comment.
Same, does this belong in IntDiv?
Member
There was a problem hiding this comment.
Or perhaps all of the generic, but computable stuff should be in a ComputableIntDiv theory?
bgregoir
marked this pull request as draft
November 10, 2026 18:08
…mial algebra(Pocklington): Pocklington's criterion and computable primality certificates (powmod and gcd evaluated by cbv through hint simplify). algebra(ZModP): clone ZModpField with <= substitutions, so that the field structure can be passed as a theory (e.g. to Poly.Poly). examples(ChaChaPoly): 2^130 - 5 is prime (certificate chain), polynomials over Z/(2^130 - 5), and the Poly1305 message polynomial of RFC 8439 with its injectivity.
bgregoir
force-pushed
the
pocklington
branch
from
November 10, 2026 18:17
9d89e03 to
07c6374
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Pocklington's primality criterion with computable certificates, and uses it to prove that the Poly1305 modulus 2^130 - 5 is prime. It is a port of coqprime's
Pocklington.v; names follow mathcomp where an equivalent exists.theories/algebra/Pocklington.ec(new)modzXm; the multiplicative order on integersorder a nwithorder_spec,order_gt0,expz_order,order_dvdz,order_dvd_pred;pdivP(an integer> 1has a prime divisor) andprimePns(characterisation of non-primes by a prime divisorpwithp^2 <= n);pocklington: ifN - 1 = F1 * R1and, for every primep | F1, someasatisfiesa^(N-1) = 1 mod Nandgcd(a^((N-1)/p) - 1, N) = 1, then every prime divisor ofNis1 mod F1;pocklington_primeconcludesprime NwhenN < F1^2. Unlike coqprime, the combination of the prime factors ofF1goes throughgcd/Gaussinstead of prime powers, and there is no1 < ahypothesis;pock_certif : pock_check N c => all (fun pa => prime pa.1) c => prime N, where the certificateclists pairs(p, a)whosepmultiply toF1. Modular exponentiation (powmod) and Euclid's gcd (egcd) are given ashint simplifyrules on dedicated operators, so thatcbvchecks a certificate.theories/algebra/ZModP.ec: theRing.FieldcloneZModpFieldnow uses<=substitutions, asZModpRingalready does. This keeps its type and operators as definitions, soZModpFieldcan be given for a field or integral-domain theory parameter, e.g.clone Poly.Poly with type coeff <- zmod, theory IDCoeff <- ZModpField. All ofstdlibandexamplesstill check.examples/ChaChaPoly(new files)poly1305_prime.ec:prime_p1305 : prime (2^130 - 5), as a chain of 9 certificates checked in about 3 s;poly1305_field.ec:Z/(2^130 - 5)and its polynomial ring;poly1305_msg.ec: the RFC 8439 message polynomial (MAC input with padding and little-endian lengths, 16-byte blocks, coefficientsle(b) + 2^128), its degree, and its injectivity (topol_inj) for lengths< 2^64.No new axioms;
poly1305_msg.ecis an abstract theory over a byte type, whose three axioms are the specification of the byte/int conversions. These are first steps towards replacing the Poly1305 axioms ofexamples/ChaChaPoly(topol_inj,pr_zeropol_spec); the root-counting bound needed next is in #1232.