Termination
Correctness
By construction of Orbit, it is contained in the G-orbit of x.
If y
Gx, then
there are b1, ..., br
B such that
y = br ··· b1(x).
By construction,
Orbit is invariant under each of the elements in B, so also
br ··· b1(x)
belongs to Orbit. In particular, y is an element of the output Orbit.