Skip to content

Conversation

xavierleroy
Copy link
Contributor

@xavierleroy xavierleroy commented Jan 16, 2025

This PR adds Z.solve_linear_congruences , a solver for linear Diophantine equations of one variable:

    a₁·x = b₁ mod m₁ /\ ... /\ aₙ·x = bₙ mod mₙ

This includes the Chinese remainder theorem as a special case (with aᵢ = 1).

I wrote this code several times in the past, once to implement RSA in Cryptokit, the other times for programming / mathematical puzzles such as the Euler project. The interface and implementation in this PR is taken from https://github.com/gmevel/euler-lib , which uses OCaml's plain int instead of arbitrary-precision integers.

Maybe this function is too specialized for a library such as Zarith. On the other hand, it's nontrivial code that nicely complements the existing number-theoretic functions of Zarith.

Solves linear Diophantine equations of one variable.
Generalization of the Chinese remainder theorem.
@xavierleroy xavierleroy changed the title Add for linear Diophantine equations Add solver for linear Diophantine equations Jan 16, 2025
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