Proofs: Succinct permutation representation
These are the human proofs of Succinct permutation representation, at full length.
Correctness and step bound of the shortcut inverse full
This proof shows: correctness.
Fix , let be its cycle with , indices mod , and let . The answer is .
Lemma 1 (the walk stays on the cycle). Every value of is an element of : initially , a forward step moves from to , and a shortcut moves from a marked to (or, for , to the last mark with ), both on .
Lemma 2 (stopping). The loop stops exactly when , that is, when , since is injective. So if it stops, it returns .
Short cycles (). No element of is marked, so the walk takes forward steps only: , and reaches after steps, with reads of .
Long cycles (). The marks are , so between two consecutive marks along the cycle there are at most unmarked elements: the gaps are , except the last, from around to , which is because is the largest integer with .
Phase 1. The walk goes forward from until it either stops at or sits at a marked element , with the first index at or after (cyclically) that is marked. This takes at most steps, since is within positions of . If the predecessor is met first, the loop stops (Lemma 2).
Phase 2. At the walk takes the shortcut to the previous mark . By the choice of , no element strictly between and is marked, so the previous mark is at or before , cyclically: either and is the mark before , or and is before because itself is unmarked. Its distance to is less than the gap .
Phase 3. From , forward steps reach after at most steps, without passing , and the loop stops there. A mark met in this phase is passed by a forward step, because jumped is set.
In total, the walk reads at most times in phase 1, once after the jump, and at most more times in phase 3, plus the initial read: at most reads, so INVERSE takes time and always terminates.
Space. Each long cycle of length has marks and there are at most long cycles, so .