So Beren Gunsolus came up with this nifty rule for generating a tree that is full of Fibonacci numbers, he and I and some others (Astra Kolomatskaia, Ophelia, Emma C) figured out what's going on with it, and now I want to tell you about it.1
Beren defined the tree iteratively. The root is 1. Then, at each step, we find the smallest number in the tree that does not have any children2, and give it two children; the left child is the smallest not yet in the tree, and the right child is the sum of the parent and the left child.
Here's a partial picture of what it looks like, having given children to every number up to 21:
1 /---------------+-----------------\ | | /---------2-------\ /-------3-------\ | | | | /------4---\ /---6---\ /---5---\ /---8---\ | | | | | | | | /--7--\ /-11-\ /-10-\ /-16-\ /-9-\ /-14-\ /-13-\ /-21-\ | | | | | | | | | | | | | | | | /-12\ /-19\ /18\ 29 /17\ 27 26 42 /15\ 24 23 37 22 35 34 55 | | | | | | | | | | /20\ 32 31 50 30 48 28 45 25 40 | | 33 53
If you stare at this a while, you'll likely notice some patterns, like the Fibonacci numbers going down the right-hand side, or the Fibonacci numbers minus one going down the left hand side, or any of the many other ways that Fibonacci numbers appear in the tree.3 You may also notice some relations that hold but aren't obvious from the original construction; like, for instance, not only does the parent plus the left child equal the right child, but also, the left child plus the right child equals the left child of the right child.4
It turns out that dual Zeckendorf is the key to Beren's tree, if we just subtract 1 from each number (so now 0 is the root). If we subtract 1 from each number, then the root is the empty string, taking the left child corresponds to appending 1, and taking the right child corresponds to appending 10. Every legal dual Zeckendorf representation can be made uniquely in this way, so the tree contains each whole number exactly once, as we saw earlier.
So, assume as an inductive hypothesis that the theorem is true for all numbers already in the tree; this means that cold and hot numbers have been added in pairs. Then, when we go to process a number n, and we want to determine L'(n), well, L'(n) cannot be hot, because each excluded hot number has a smaller cold number that is also excluded. So L'(n) must be cold, and the smallest excluded cold number is (applying the inductive hypothesis) n:1. Then to determine R'(n) we simply add n, L'(n), and 1, and this addition yields n:10. This proves the claim.
Now this new description of the tree may strike you as obviously related to some other trees, or cause you to ask hey what about such-and-such a natural-seeming variant, but, we'll get to variants down below. First, let's give a third description of the tree!
Write the original tree in ordinary Zeckendorf. The root is 1. Then, to get the children of a given node, if the node ends in an even number of zeroes, then the left child appends 0 and the right child appends 00. While if the node ends in an odd number of zeroes, then the left child appends 1, while the right child appends 01.
I know of two ways to prove this equivalence. The first is to once again adapt Ophelia's cold/hot argument to this new description, proving its equivalence with Beren's original description. This adaptation is straightforward and I won't belabor it.
The second is to directly prove its equivalence with the dual Zeckendorf description; I'm going to relegate that one to the footnotes. 8
Let's say we read across the rows of the tree, in order, from left to right. If we do this, we get the sequence
1, 2, 3, 4, 6, 5, 8, 7, 11, 10, 16, 9, 14, 13, 21...
Beren plugged this into OEIS and found that it's A232560, which is defined as the inverse permutation of A232559, which is in turn obtained from reading across a different tree (there's a picture of it at the link). This other tree is a tree of doubling or adding 1. It has 1 as the root, and each node has two children; for the left child you add 1, for the right child you double. Well, except that actually not every node has two children -- if we did that, the tree would be full of duplicates, so, we only allow adding 1 to numbers that are even. Odd numbers only get a single child.
From this description, this second tree doesn't seem to have anything to do with Fibonacci numbers! Why would it be somehow inverse to the first tree?
That's not the only seemingly odd thing here either. The second tree isn't even a binary tree. If the trees had the same shape, then we could regard these two permutations not as being on the linearly-ordered natural numbers, but rather on the nodes of the unlabeled tree of that shape, and show that the permutations were inverse that way, and then we'd never have to involve this whole "reading sequence" business. But since they're not the same shape, that means that in our two reading order sequences, the row boundaries are falling in different places. And yet they're inverse to each other!
Well, it turns out that there's a nice explanation, and that the shape of the tree is actually not a problem but rather the solution. You see, the tree that we started with was a tree based on Fibonacci numbers and (dual) Zeckendorf representation, but in shape it was a binary tree. The second tree is based on binary representation, but its shape is Fibonacci!
If you actually draw the second tree, you'll see the lengths of the rows are Fibonacci. Of course they are; it's doing the whole Fibonacci rabbit thing. Only even-valued nodes (adult rabbits) can have two children, with odd-valued nodes (juvenile rabbits) having only one.
So, we have a Fibonacci binary tree, and a binary Fiboncci tree. The inverse relation makes a bit more sense now, no?
What about our other tree? Well, if we don't subtract 1, then it's a tree of binary representations; 1 is the root; even numbers have two children, with the left child corresponding to changing the final 0 to a 1, and the right child corresponding to appending 0; and odd numbers have one child, corresponding to appending 0.
OK, but what if we do subtract 1? Well, then it's a tree of bijective binary representations! The doubling operation becomes double-and-increment. So now 0 (the empty string) is the root; it's odd numbers that have two children, with the left child meaning you change the final 1 to a 2, and the right child meaning you append a 1; and even numbers have only one child, corresponding to appending a 1.
That is to say -- consider the binary tree that, when read across, simply yields 0, 1, 2, 3, etc. This, if we look at it in bijective binary, can be described as a tree with root 0 (the empty string), where the left child is append a 1, and the right child is append a 2.
We can do the same thing on the other side; we can take a tree as the same shape as our Fibonacci-shaped tree of bijective binary numbers, but one whose reading sequence is simply 0, 1, 2, 3, etc. This similarly has a natural interpretation in terms of dual Zeckendorf; left children mean append a zero, right (or only) children mean you append a 1. Only numbers that are a 1-child can have a 0-child.10
So: Let us consider the permutation that takes our binary binary tree (whose reading sequence is just the whole numbers) to our Fibonacci (dual-Zeckendorf) binary tree (which has the same shape). What does it do to the number at any given spot? Well, what you do to the number is, you write the number in bijective binary; then you change each 2 to a 10 while leaving each 1 as a 1; then you interpret the string as dual Zeckendorf. So that's our permutation one way.
Now, we consider the permutation that takes our Fibonacci Fibonacci tree (whose reading sequence is just the whole numbers) to our binary Fibonacci tree (which has the same shape). What does this do to the number at any given spot? Well, you write the number in bijective binary; then, starting with the empty string, you interpret each 1 as an "append 1" and each 0 as a "change the final 1 to a 2" (because a 0-child must have a parent that is a 1-child, this is well-defined); then you interpret the string as bijective binary. That's our permutation the other way.
And, well, those two operations are inverse to each other, so there you go! Where did we use the reading order? How did we deal with the fact that the two trees are different shapes? By setting up two auxiliary trees which, although they had different shapes from each other, had identical reading sequences. Basically we had a chain of four trees, FB-BB-FF-BF, where the pairs FB-BB and FF-BF have the same shape, while the pairs BB-FF have the same reading sequence.
Namely, this new tree, if we write it in dual Zeckendorf, follows a parity rule like we saw earlier! The root is 0 (the empty string), and if a node ends in an even number of ones, then the left child appends 1 and the right child appends 11; while if the node ends in an odd number of ones, then the left child appends 0, while the right child appends 10.
One can prove this using an analogue of the parity proof from earlier; it's exactly analogous, so I won't bother writing it out.11
Yes! I won't bother proving it because again it's the same as above, but we'd once again get trees based on binary or bijective binary, only now, we'd be decrementing instead of incrementing.
That is to say, for the trees based on ordinary binary, your options would be to append a 1, or, if the number ends with a 1, to change the final 1 to a 0; and for bijective binary, you could append a 2, or change the final 2 (if there is one) to a 1.
Each tree I'll notate by two letters. The first letter will be one of:
Trees beginning with Z, B, or b will use 1 as the root, while trees beginning with D, J, or j will use 0 (the empty string) as the root. For clarity, I'll put the root in brackets after the name of the tree.
Beren's original tree is ZP[1].
We then get the following diagram of relations among the trees:
inverse flip inverse jD[0] -------- Db[0] ------ DB[0] ---------- JD[0] -1/| /-1 -1/ -1/| / | / / / | / |flip / / / | +1/ | /+1 flip +1/ inverse +1/ | bD[1] --+--------- Zp[1] ------ ZP[1] --------- BD[1] |flip | | inverse | | | | | | | | inverse flip inverse | | flip| jZ[0] --------- Dp[0] ------ DP[0] ---------+-- JZ[0] | /-1 /-1 -1/ | /-1 | / / / flip| / | / / / | / |/+1 inverse /+1 flip +1/ inverse |/+1 bZ[1] --------- Zb[1] ------ ZB[1] ---------- BZ[1]
By the way, you may be wondering, what about bijective Zeckendorf? Unfortunately, it doesn't seem to fit nicely into the picture above.
Define the t-Fibonacci numbers to be the sequence that starts with t 1's, and then obeys the recurrence Ft,k=Ft,k-1+Ft,k-t. So the 1-Fibonacci numbers are the powers of 2, while the 2-Fibonacci numbers are the Fibonacci numbers.
A number of facts transfer from the Fibonacci setting to the t-Fibonacci setting (I'll omit the proofs). One has t-Zeckendorf representations, where we require that any two 1's have at least t-1 0's between them. These exist, are unique, and can be compared lexicographically. One also has bijective t-Zeckendorf; again, representations exist, are unique, can be compared lexicographically, and have a relation to ordinary t-Zeckendorf that's similar to the t=2 case. (The number you have to adjust by is t, and the prefix you have to strip off is 10t-1.) And one has dual t-Zeckendorf; once again, this exists, is unique, and can be compared lexicographically.
Unfortunately, not everything works so well. Notably, the well-definedness of left-shift on pseudo-t-Zeckendorf does not hold for t=3. And while dual t-Zeckendorf exists, it's not clear how to sensibly put it in a tree for t>2.
Still, one can at least make an ordinary t-Zeckendorf tree for any t; the root is 1, edges are either 0 (left) or 1 (right), and you can't have a 1 edge except after t-1 consecutive 0 edges. We might call this tree ZtZt, following the pattern above (where Z2 means the same thing as Z and Z1 means the same thing as B). Of course, such a tree is not that interesting; its reading sequence will simply be the positive integers. What we want to know is about mixing values of t, like we did above with t=1 and t=2, to get more interesting trees.
Well, if t'<t, we can make the tree ZtZt' by having edges be either 0 (left) or 0t-t'1 (right); the latter can't occur except after t'-1 consecutive 0s. Notably we can take t'=1 and get ZtB. Unfortunately, if we subtract 1 from each number in ZtB, and write the results in dual-t-Zeckendorf, we don't seem to get any nice rule when, say, t=3.
Now if t'=t+1, we can make the tree ZtZt+1 where edges are either 0 (left) or "change final 0 to a 1" (right); the latter can occur only after t consecutive 0's. Unfortunately, I don't see how to make an analogous tree ZtZt' for t'>t+1.
Still, if you do this, then the trees ZtZt+1 and the trees Zt+1Zt will have inverse reading permutations! But for t>1, this fact doesn't seem to fit into a nice big diagram like the one above for t=1; it's fairly isolated. You can I'm sure write down trivial variants on it that will also be true, but for nontrivial variants, I'm not aware of any.
Beren's tree ZP uses 1 as the root and obeys n+L(n)=R(n). When you subtract 1 to get the tree DB, it uses 0 as the root and obeys n+L(n)+1=R(n). (In this section I'll just use L(n) and R(n) to mean the left and right child in the tree under discussion, not necessarily the original tree ZP.)
Let's generalize this. For c≥1, we'll define Tc,0, or just Tc, to be the 0-rooted tree, generated like Beren's tree but with the law n+L(n)+c=R(n). We'll also define Tc,1 to be the 1-rooted tree defined analogously but with n+L(n)+(c-1)=R(n). We subtract 1 from the contstant so that Tc,1 is equal to Tc,0 with 1 added to each node.
Then, as noted above, T1,0=DB, and T1,1=ZP. But the trees T2,0 and T2,1 are also trees that were discussed above! Namely, T2,1=ZB. One can prove this using the usual hot/cold-style argument. This means that T2,0=DP. One can prove this either by noting that T2,0=T2,1-1=ZB-1=DP, or one can again prove it hot/cold style. The latter approach, I suppose, would also function as an alternate proof that DP=ZP-1.
Let's make this into a table:
To give you a bit of the flavor of it, though... let S(n) denote the Zeckendorf left-shift operations. Then with c=1 (sticking to the 0-rooted trees), we have L(n)=S(n)+1. With c=2, we have L(n)=S(n+1)-1. With c=3, we have L(n)=S(n+2)-3... unless n is of the form Fk-3, then L(n)=S(n+2)-3+(-1)k. A little funky, right? And the exceptions grow thicker from there... and quadratically so! But again, I'll write about that some other time...
2This is always well-defined, because the tree contains no duplicates. Each new left child can't be a duplicate by definition. Each new right child must be bigger than the corresponding parent and left child, which, since parents are processed in order and left children are added in order, means that it must also be bigger than each existing left child and each existing parent. But also, from the monotonicity of addition, it must also be bigger than each existing right child, since each is a sum of a parent and a left child, and this new one is the sum of the largest parent and largest left child. (Also, the tree contains all positive integers, due to the rule for generating left children. So it contains each positive integer exactly once.)
3OK, you want a list of ways that we've found? OK. Here, L(n) means the left child of n, while R(n) means the right child of n.
4You want a list of what we found there too? OK. Again, L(n) means the left child of n, while R(n) means the right child of n.
5Speaking of Zeckendorf variants, there's also bijective Zeckendorf! As in, instead of 0 and 1, you use 1 and 2, and you can't have two consecutive 2's.6 Now, famously bijective binary holds a special relation with ordinary binary, where the bijective binary for n is the same as the ordinary binary for n+1, but with the initial 1 stripped off and each digit incremented by 1. A similar relation holds for bijective Zeckendorf; the bijective Zeckendorf for n is the ordinary Zeckendorf for n+2 but with the initial 10 stripped off and each digit incremented.
6Note that there's no such thing as dual bijective Zeckendorf, because in such a system it would be impossible to represent the number 3. (Actually, I won't prove it here, but n cannot be represented in dual bijective Zeckendorf iff n+3 starts with 1001 in ordinary Zeckendorf; for those numbers that can be represented, the representation is unique.)
7This proof is primarily due to Ophelia.
8This proof will rely on the following nontrivial fact about Fibonacci numbers: If we consider "pseudo-Zeckendorf representations", that is, Zeckendorf representations with no consecutivity restrictions, then the "left shift" operation (appending a 0) is well-defined. I'm going to relegate the proof of that to a separate footnote.9
Anyway, suppose w is the Zeckendorf representation of n, and w ends in k zeroes, so w=w'0k; w' is then also a Zeckendorf representation of some number n', and w' ends in a 1. Let v be the Zeckendorf representation of n'-1, which, since w' ends in a 1, is simply w' with its final 1 changed to a 0. Therefore, the value of v0k is n-fk, where here by fk I mean Fk+2 (that conflicts with another convention, I know, sorry).
Now let u be the dual Zeckendorf representation of n'-1; by the lemma, the value of u0k is therefore also equal to n-fk. So, if k is even with k=2ℓ, then u':=u(10)ℓ has value n-fk+(fk-1)=n-1, and is also in dual Zeckendorf; so it's the dual Zeckendorf representation of n-1. Similarly, if k is odd with k=2ℓ+1, then u':=u(10)ℓ1 has value n-fk+(fk-1)=n-1, and it too is in dual Zeckendorf, so once again it's the dual Zeckendorf representation of n-1.
Now let's consider what happens as n varies. Going by the above, if k is even, then u' ends in a 0; so appending 1 to u' corresponds to appending 0 to w, and appending 10 to u' corresponds to appending 00 to w.
On the other hand, if k is odd, then u' ends in a 1. Appending 1 to u' is the same as appending 0 and then incrementing; so this corresponds to appending 0 to w and then incrementing, which appends a 1. Similarly, appending 10 to u' we can think of as appending 01 and then incrementing; so this corresponds to appending 00 to w and then incrementing, which appends a 01. This completes the proof.
9It suffices to show that if w is a pseudo-Zeckendorf representation representing the number n, and v is the Zeckendorf representation of n, then w0 and v0 again represent the same number. Note that v0 is again a Zeckendorf representation, so we are showing that the number represented by w0 has Zeckendorf representation v0.
To show this, note that any pseudo-Zeckendorf representation can be converted to Zeckendorf representing the same number by the following procedure: Find the leftmost "11" (which cannot be preceded by another 1 or it would not be leftmost), then change this "011" to a "100"; repeat until there are no 11's (and this procedure must terminate because the number of 1's decreases with each step). Now observe that this procedure (both each step and the termination condition) commutes with appending a 0. This proves the claim.
10The identity of these two descriptions of the tree might not be obvious, but it follows from the fact that to compare two numbers written in dual Zeckendorf, you just do so lexicographically. This in turn can be proven by comparing the smallest possible dual Zeckendorf number of a given length with the largest possible dual Zeckendorf number that's one shorter in length.
11Note that this proof needs to use the fact that appending 1 to pseudo-Zeckendorf representations is well-defined. You could prove this by first proving it for 0, as done above, and then note that appending 1 is just appending 0 and then incrementing; or you could do it directly, mimicking the above proof for 0, except you'd use dual Zeckendorf instead of Zeckendorf.