Proofs: Pollard's kangaroo algorithm
These are the human proofs of Pollard's kangaroo algorithm, at full length.
Correctness of Pollard's kangaroo algorithm full
This proof shows: correctness, termination.
Let , , and . Put and , as in line L1. For an integer , if and only if , so the task is to return for some with , or NONE if there is no such .
Lemma 1 (invariants). In every attempt, the tame kangaroo satisfies and the wild kangaroo satisfies , where and are their distances.
Proof. Line L4 sets with and with . Line L13 multiplies a kangaroo by and adds to its distance, which keeps both relations.
Lemma 2 (table entries). Every entry was written at line L12 by kangaroo while it stood at with distance .
Proof. Line L12 is the only line that writes to , and it writes the current point, kind and distance. Line L5 empties at the start of each attempt.
Soundness of the kangaroo phase. Suppose line L11 returns . Then and were checked on that line, so and . (By Lemmas 1 and 2 the check always succeeds when : the point was visited by the tame kangaroo at distance and by the wild one at distance , so and ; the check is kept because it costs one exponentiation and protects against mistakes in the bookkeeping.)
The certificate. Suppose line L15 is reached. Baby-step giant-step with bound uses , stores for with the least such for each element, and tests for . Let be the least integer with , if any.
- If , then , so with , and the test at hits. Any hit at a round yields a solution , and a hit at would give a solution smaller than , which is impossible. So the first hit is at and returns , a solution, hence equal to . Line L15 returns .
- If exists and , or no exists, then there is no solution in . Every hit returns a solution , so , and line L15 returns NONE; with no hit it also returns NONE.
Correctness. By the soundness of the kangaroo phase and the certificate, every value returned is in and satisfies , and NONE is returned only by line L15, which does so only when no satisfies , that is, when no satisfies .
Termination. Each attempt runs at most rounds of two jumps, there are attempts, and baby-step giant-step makes at most group operations. So the algorithm stops after group operations, which is for constant and .