The sequence in question.
See also Hofstadter's chaotic Function Q.
In Douglas Hofstadter's book, Gödel, Escher, Bach, a recursive definition is presented for a tree-structure with a few interesting properties (p. 137).
Diagram G gives rise to the Fibonacci numbers if you read the numbers going up the right side of the tree (i.e., (1), 1, 2, 3, 5, 8, 13, 21, ...). To achieve this pattern, we follow a recursive blueprint for building the tree (like a fractal) and number the nodes we construct from left to right as we move "up" in the diagram. The recursive structure can be gleaned by staring at any of the junctures somewhere in the middle of the tree: up and to the left the pattern is replicated; up and to the right, we add a node and then proceed to repeat the pattern of the structure.
Curiously, Diagram G can be described by a recursive algebratic definition that tells us which value we must put under each other value as we build the tree. To build the tree we must:
- put 1 under 2
- put 2 under 3
- put 3 under 4
- put 3 under 5
- put 4 under 6
- put 4 under 7
- and so on...
G(n) = n - G(G(n - 1)), where G(0) = 0
happens to descibe this pattern. We place a node with value G(n) under a node with value n.
The function G produces the sequence:
0, 1, 1, 2, 3, 4, 4, 5, 6, 6, ...
where the index of each element is n, and the element itself is the value of the node which must be a parent to the node with value n. It is this sequence that is computed using a memoized recursive function and then built into a tree structure so that we can visualize the graphical presentation of the function G.
Note that numbers appear twice when they serve as the parent for two other nodes in the tree.
A challenge Hofstadter poses to the reader involves attempting to find an algebraic definition like the one above which can be used to label the same tree after it has been flipped, as if in a mirror. In other words: we flip the structure of the nodes and then label them, again proceeding left to right as you move up (down the tree). We want a recursive definition which tells us how the values are related to one another. In the case of the original Diagram G, the recursive definition describes the immediate successors for each node in the tree.
It turns out that such a recursive definition for flipped Diagram G is rather tricky to come up with.
I've spent way too much time trying to figure this out. Do you actually define the algebraic method to flip the tree, and if so can you please share it? I need to sleep this week.
I only see the standard Hofstadter function defined here (
A[i] = i - A[A[i - 1]];) but I don't see the method to invert
EDIT: Nvm figured it out