Let S be the sequence of all possible expressions built from numbers 2 and exponentiations (^), sorted according to their natural structural ordering (2, 2^2, 2^(2^2), (2^2)^2, 2^(2^(2^2)), 2^((2^2)^2) and so on - see the exact definition in Haskell below).

Let S' be S stable-sorted according to the numeric values of its elements in ascending order (the stable sorting is a sorting that keeps the order of elements with equal keys - so 2^(2^2) and (2^2)^2 will be kept in the original order).

This sequence is S' where each expression is replaced with its original index (1-based) in S; it is a permutation of the natural numbers sequence.