Skip to content

Add Euler's criterion and quadratic reciprocity for Zmod - #307

Closed
JasonGross wants to merge 2 commits into
rocq-prover:masterfrom
JasonGross:fable/zmod-reciprocity
Closed

JasonGross wants to merge 2 commits into
rocq-prover:masterfrom
JasonGross:fable/zmod-reciprocity

Conversation

@JasonGross

Copy link
Copy Markdown
Member

Depends on #306 (stacked on its branch); review the last commit only.

Adds theories/Zmod/QuadraticReciprocity.v: the Chinese-remainder decomposition of Zmod.elements/Zstar.elements for coprime moduli, the product of all units modulo a prime, Euler's criterion for Zstar and Zmod, and the law of quadratic reciprocity for odd primes (quadratic_reciprocity': Z.smodulo (q^((p-1)/2)) p * Z.smodulo (p^((q-1)/2)) q = (-1)^((q-1)/2*((p-1)/2))). This is the fully proved part of Andres Erbsen's WIP ZmodSqrt branch (andres-erbsen/stdlib@5bd6d0db); the square-root algorithms are left for a later PR.

The generic lemmas it needs go to List.v, Finite.v, Permutation.v, Zdiv.v and Zdivisibility.v.

  • Added changelog.
  • Added / updated documentation (nothing beyond the changelog applies).

Written by Claude Fable 5.1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YJbiRBkJtM7x6PvYV6hmEm

JasonGross and others added 2 commits September 17, 2026 14:42
Factoring.v comes from Andres Erbsen's WIP ZmodSqrt branch
(andres-erbsen/stdlib@5bd6d0db, theories/ZArith/Factoring.v).  It
defines the p-adic valuation `val`, the prime-power factorization
`ppfactor`, the sorted prime factorization `factor` and Euler's
`totient` on positive numbers, all computable, and proves the
fundamental theorem of arithmetic together with the induction principles
`factor_ind` and `ppfactor_ind`.  The two unfinished scratch lemmas of
the WIP (`in_ppfactor`, `val_ext`) are left out.

Zdivisibility.v gains `Z.coprime_mul_l_iff`, `Z.coprime_mul_r_iff`,
`Z.coprime_pow_l_iff`, `Z.coprime_pow_r_iff` and `Z.coprime_prime_prime`,
which the same WIP used.  The generic list lemmas it needed go to their
natural homes: `Forall_repeat` and `repeat_inj` in List.v;
`Sorted_repeat`, `StronglySorted_app`, `NoDup_StronglySorted`,
`HdRel_map`, `Sorted_map`, `StronglySorted_Permutation_unique` and
`Sorted_Permutation_unique` in Sorted.v (which now requires
Permutation); `fold_right_Permutation` in Permutation.v.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJbiRBkJtM7x6PvYV6hmEm
QuadraticReciprocity.v is the fully proved part of Andres Erbsen's WIP
ZmodSqrt branch (andres-erbsen/stdlib@5bd6d0db, theories/Zmod/ZmodSqrt.v):
the Chinese-remainder decomposition of `Zmod.elements` and
`Zstar.elements` for coprime moduli, the product of all units modulo a
prime (`prod_elements_prime`), Euler's criterion for `Zstar` and `Zmod`,
and the law of quadratic reciprocity for odd primes
(`quadratic_reciprocity'`).  The square-root algorithms and their
partially proved correctness lemmas are not included.

The generic lemmas it needs move to their homes: `filter_filter`,
`negb_existsb`, `existsb_as_filter` and the `list_prod` lemmas in
List.v, `NoDup_list_prod` in Finite.v, `Permutation_partition` in
Permutation.v, `Z.mod_prod_mod_factor_l/r` in Zdiv.v and
`Z.coprime_comm` in Zdivisibility.v.  The WIP's `Permutation_filter`
already exists on master as a `Proper` instance.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJbiRBkJtM7x6PvYV6hmEm
@JasonGross

Copy link
Copy Markdown
Member Author

Closing: the author of the development asked for this to go to mit-plv/fiat-crypto instead of stdlib for now. Sorry for the noise.

@JasonGross JasonGross closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant