The AKS congruence for one a on the word RAM #
Step 5 of the AKS algorithm Agrawal, Kayal, Saxena, Section 4 tests
(X + a)^n ≡ X^n + a (mod X^r - 1, n). The program writes the coefficients of X + a into a base
block B and those of 1 into a result block R, raises by repeated squaring
(Cslib.Algorithms.WordRAM.AKS.PolyPow.program) so that R holds (X + a)^n, writes the
coefficients of X^n + a into the scratch block T, and compares R with T. Both blocks are
reduced, so they agree exactly when the classes agree (Cslib.AKS.toQuot_eq_toQuot_iff), which is
the congruence (Cslib.AKS.congruence_iff_toQuot).
Main definitions #
Cslib.Algorithms.WordRAM.AKS.Congruence.program: the congruence test.Cslib.Algorithms.WordRAM.AKS.Congruence.time: its instruction bound.
Main results #
Cslib.Algorithms.WordRAM.AKS.Congruence.exec: the flag is1exactly whenCslib.AKS.Congruence n r aholds, withintime r ninstructions.
References #
Base address of the result block.
Base address of the base block.
Base address of the scratch block.
The number r of coefficients.
The modulus n, which is also the exponent.
The exponent of the power.
Block argument of the subroutines.
Second block argument of the comparison.
The tested value a, preserved.
The exponent residue for Fill.
The constant term for Fill.
The answer: 1 when the congruence holds.
The power runs on the first 21 registers.
Fill writes the block at pa, with scratch shared with the power.
Write X^e + a into the block at pa.
The instruction bound of program.
The registers that every subroutine call preserves.
Instances For
The AKS congruence for one a. For r ≥ 1 and n ≥ 1, with the result, base and scratch
blocks [a, a + r), [b, b + r) and [t, t + r) pairwise disjoint, and the word size holding the
block ends, 2 r, n² + n and the tested value A, the program leaves 1 in flag if
(X + A)^n ≡ X^n + A (mod X^r - 1, n) and 0 otherwise, within time r n instructions.