Strong liars and the Miller–Rabin bound #
Write n - 1 = 2 ^ s * t with t odd. The Miller–Rabin test Rabin declares an odd
n > 1 composite when a random base a has a ^ t ≠ 1 and a ^ (2 ^ i * t) ≠ -1 for every
i < s modulo n. The bases that pass are the strong liars. Modulo a prime every nonzero
residue is a strong liar, because the only square roots of 1 are ±1. Modulo an odd composite
n, the strong liars lie in a proper subgroup of (ZMod n)ˣ: for the largest j < s such that
some unit has b ^ (2 ^ j * t) = -1, the units whose 2 ^ j * t-th power is ±1. Hence at most
half of the units are strong liars. The sharper Rabin–Monier bound φ(n) / 4 for n ≠ 9 is in
CslibFrontier.Foundations.NumberTheory.Primality.RabinMonier.
Main definitions #
ZMod.IsStrongLiar n a:apasses the Miller–Rabin test modulon.ZMod.powEqOneOrNegOne n m: the subgroup of units whosem-th power is±1.
Main results #
ZMod.isStrongLiar_of_prime: modulo a prime, every nonzero residue is a strong liar.ZMod.IsStrongLiar.isUnit: forn > 1, a strong liar is a unit.ZMod.exists_pow_eq_neg_one_forall_isStrongLiar: for oddn > 1, there is anmwith2 m ∣ n - 1and a unitbwithb ^ m = -1such that every strong liar lies inpowEqOneOrNegOne n m.ZMod.card_isStrongLiar_le_card: the strong liars number at most the elements of any subgroup of the units that contains them.ZMod.exists_subgroup_ne_top_isStrongLiar: modulo an odd composite, the strong liars lie in a proper subgroup of the units.ZMod.two_mul_card_isStrongLiar_le: modulo an odd compositen, twice the number of strong liars is at mostφ(n).
References #
a is a strong liar for n: writing n - 1 = 2 ^ s * t with t odd, a ^ t = 1 or
a ^ (2 ^ i * t) = -1 for some i < s.
Instances For
For n > 1, a strong liar is a unit.
Strong liars modulo a prime: modulo a prime, every nonzero residue is a strong liar. Going
down from a ^ (p - 1) = 1 by square roots, each is 1 or -1.
The exponent of the strong-liar test. For odd n > 1, write n - 1 = 2 ^ s * t with t
odd and take the largest j < s such that some unit b has b ^ (2 ^ j * t) = -1 (j = 0 works
with b = -1). Then m = 2 ^ j * t has 2 m ∣ n - 1, b ^ m = -1, and every strong liar a
has a ^ m = ±1.
Strong liars of a composite: modulo an odd composite n, the strong liars lie in a proper
subgroup of the units, namely powEqOneOrNegOne n m for the exponent m of
exists_pow_eq_neg_one_forall_isStrongLiar, which contains every strong liar. If p ^ 2 ∣ n for
an odd prime p, the unit 1 + n / p is outside it. Otherwise n = p q with p an odd prime
coprime to q > 1, and the unit that agrees with b modulo p and is 1 modulo q is outside
it.