Proofs: Pohlig-Hellman algorithm
These are the human proofs of Pohlig-Hellman algorithm, at full length.
Correctness of the Pohlig-Hellman algorithm full
This proof shows: correctness, termination, minimality.
Let be a finite abelian group, , and a multiple of , with each prime.
Lemma 1 (exact order). After lines L1 to L3, .
Proof. Let . Throughout, : this holds for , and is replaced by only if , that is, only if . When the loop for ends, either , or , so . In both cases the exponent of in equals the exponent of in : it is at least that, since , and if it were larger then . Later rounds only remove other primes, so they keep this exponent and keep . At the end every prime has the same exponent in and in , and has no other primes, so .
Lemma 2 (membership in a cyclic group). If is cyclic, then if and only if .
Proof. If then . A cyclic group has exactly one subgroup of each order dividing , and the elements with form a subgroup of order (in a cyclic group of order with generator , satisfies exactly when , which gives elements, as ). This subgroup contains , of order , so the two are equal.
So if line L4 returns NONE, then , in any group. For the rest of the proof, suppose first that , where is the least non-negative solution; then .
Lemma 3 (projection). Let and . Then has order , , and for an integer , if and only if .
Proof. has order , so has order . Then , and holds exactly when .
Lemma 4 (digits). Write with . Before round of lines L11 to L15, . In round , baby-step giant-step returns .
Proof. By induction on ; for , by line L10. Assume the claim before round . By Lemma 3, with , and . Raising to gives , and
So , with of order . Baby-step giant-step with the bound returns the least with , which is since . Line L15 then gives .
Correctness for . By Lemma 2 and the first direction of its proof, line L4 does not return. By Lemma 4, line L14 never returns, and after the loop for , . The moduli for the distinct primes are pairwise coprime with product , so line L17 returns the unique with for all , by the Chinese remainder theorem. Since , . Line L18 finds , and line L19 returns the least solution.
Correctness for . Any value that reaches line L19 has passed the test of line L18, so and . Hence for the algorithm returns NONE at line L4, L14 or L18. If is cyclic, Lemma 2 shows that line L4 already returns NONE.
Termination. The loop of lines L2 and L3 divides by at each round and so runs at most rounds for each . The digit loop runs rounds per prime, and baby-step giant-step terminates. So the algorithm stops after finitely many group operations, bounded as in the Complexity section.