Manuscript Offprint
arXiv:2610.35994Re-Ordering the Generalized Hofstadter Functions G, H, and Beyond
Abstract
Hofstadter's G function is recursively defined via and then . Following Hofstadter, we vary the number k of nested recursive calls in this equation and obtain a family of functions . In a previous article, we proved that this family is ordered pointwise: for all k and n, we have . Here we propose a much shorter proof of this theorem, without infinite morphic words. The key ingredient for this direct proof is a new formula expressing iterates of the preimages of . Thanks to this formula, we also prove several conjectures mentioned in our previous article. In particular we obtain that when . We provide a certified formalization of all these results in the Rocq proof assistant.
1 Introduction
In a previous article [11], we provided the first proof of pointwise monotonicity for a family of generalized Hofstadter functions. We also expressed several conjectures concerning these functions, and in particular a conjecture about their strict ordering. The present article is a follow-up of this last work: this time we provide a much shorter proof for the main theorem of our last article as well as first proofs for our former conjectures. Once again, all these proofs has been formalized and verified in the Rocq proof assistant, as described in Section 1.3.
This new article can be read alone, since it contains again all the required initial definitions. The basic properties are also mentioned again briefly, before focusing on the novel content. Nevertheless, much of the context described in the former article is still fully relevant but not duplicated here, in particular the discussion on related works [11, Sect. 1.7].
The function is well defined, since one may prove that for all . This family of functions is due to Hofstadter [6, Chap. 5]. In particular, is Hofstadter's function (see OEIS entry A005206 [15, 6, 3, 5]). Note that where is the golden ratio . Similarly, is Hofstadter's function (see OEIS A005374 and the recent study by Shallit [14]). The generalization to higher degrees of recursive nesting in the definition of was already suggested by Hofstadter [6]. To be complete, the OEIS database already includes as A005375, as A005376, and as A100721. On the other hand, we choose to start this sequence with , where only one recursive call is done. This function can easily be shown to verify . Note that we could extend the previous definition down to and obtain a non-recursive function constantly equal to 1 except in 0. But this has little in common with the other functions, so we exclude this case most of the time.
1.2 Summary of our main results
The main result of our previous article [11] is the following theorem, stating that the family of functions is ordered pointwise.
Theorem 1.1. For all , , we have .
In Section 4 we revisit this theorem, providing this time a concise and direct proof. In particular this new proof does not require anymore the use of morphic words as in our previous work. Then we refine further this proof method and manage to prove in Section 5 the following theorem, that was only conjectured in our previous article [11, Sect. 7].
Theorem 1.2. For all and , we have .
For the rest of this article, we abbreviate for .
As a side note, if we include the degenerated function in our sequence , these Theorems 1.1 and 1.2 also hold trivially for . Our formalization in the Rocq prover includes this extension (see Section 1.3).
In Section 7.2 we finally prove another statement that we conjectured in our previous article.
Theorem 1.3. For all , , we have .
In all this work, the n-th exponent of a function denotes its n-th iterate. For instance, is , not the square of .
See, for instance, Allouche and Shallit [1] for an introduction to morphic words, also called morphic sequences.

Figure 1.1: Plotting . Note that after .
1.3 The Rocq formalization
All the proofs presented in this article have been formally certified using the Rocq proof assistant [13] (previously known as Coq). This implementation in Rocq is freely available [8]. Thanks to this Rocq formalization, we ensure precise definitions and statements while preventing any error during the corresponding proofs. It can hence serve as a reference for the interested reader. In particular, the recommended entry point to read alongside this article is
https://github.com/letouzey/hofstadter_g/blob/main/DirectGrowth.v
The current article tries to be faithful to this formal work while staying readable by a large audience, at the cost of possible remaining mistakes during the transcription.
The provided Rocq files can be machine-checked again by any recent installations of Rocq; see the joint README.md file in the repository [8]. All the proofs presented in this article have been preformed within Rocq core logic, with no axioms. This fact can be checked via the Rocq command Print Assumptions on our theorems.
1.4 Summary of the current article
In Section 2 we recall some basic properties of the function . Then Section 3 presents key formulas for the iterates the preimages of . This allows us to provide in Section 4 a direct proof of Theorem 1.1 stating that . Then Section 5 is dedicated to the proof of Theorem 1.2, i.e., for large enough points . In Section 6, we explore further this zone where , up to the first difference of 2 between and . Then in Section 7 we prove two remaining conjectures. As a conclusion, we present in Section 8 some numerical experiments about larger differences between and .
2 Basic properties of function
We recall some basic properties of , and in particular the Proposition 2.1 of our last article [11]. Here denotes the difference .
Proposition 2.1. For all , the function satisfies the following basic properties:
(a)
(b) whenever ,
(c) whenever ,
(d) for all , ,
(e) hence for all ,
(f) the function is monotonically increasing and onto (but not one-to-one).
Two functions are particularly important for our work, since they express the least and greatest preimage maps of .
Definition 2.2. For , we define the functions and :
We already encountered in our previous article [11], where we defined it as the length of a substituted prefix of the morphic word (see Proposition 2.3 there). The chosen name comes from this earlier definition (L for Length). Then the equality of this length with the expression was proved later (see Proposition 4.2 there). This time, we are able to avoid referring to this morphic word . Hence we favor this alternative choice of definition of . The other function (where stands for preImage or Inverse) is actually a variant of , since for we clearly have . More generally, for and by immediate induction over . Some other basic properties of and are given in the following Proposition.
Proposition 2.3. For and ,
(a) the functions and are strictly monotonically increasing over n,
(b) we have , with equality only when or ,
(c) we have , with equality only when or ,
(d) finally .
Proof. All these statements are obvious when j = 0.
For (a), the possible increments are when , or 1 when . Thanks to Proposition 2.1 these increments are 1 or 2. The increments of are also 1 or 2. Moreover the iteration of a strictly increasing function is also a strictly increasing function.
For (b), when and we have which is 0 when and strictly positive when . Moreover . From there, we obtain for and . Moreover for , we have only for or 1. The proof of the statement (c) is very similar.
Concerning statement (d), for and we have thanks to Proposition 2.1 (and ). We extend this to all by induction. Let and assume . Then
The rightmost difference above is either 0 or 1 as already seen for the case . In the other difference above, the function is applied on an interval no larger than , thanks to the induction hypothesis. Moreover this function has increments of either 1 or 2. The sum of these two differences is hence between 0 and . This concludes the induction.
Note that the generic upper bound given above for is reached in the case , but is quite coarse for higher values of . In particular in Section 3 we obtain instead a bound of as long as . At least the current bound is fine for .
We retrieve the important relations between and , also expressed thanks to this time. Note that all intervals mentioned in this article are discrete intervals of , i.e., , possibly reduced to a singleton when .
Proposition 2.4. For and , we have
(a) and and in particular ,
(b) and and in particular ;
(c)
Proof. See [11, Sect. 3]. Alternatively, here comes a more direct proof, just relying on Definition 2.2 and Propositions 2.1 and 2.3. For statement (a), first note that
By Proposition 2.1, hence . We recall that is onto, as mentioned in Proposition 2.1. So let us pick such that . We proceed as before, but for this time:
Either and hence . Or and hence .
This extends to by induction on . Let and assume that for all , In particular, this implies and hence , which concludes this induction. Similarly, we prove by induction on (thanks to the monotonicity of ). This ends the proof of statement (a).
Now we focus on statement (c). This statement is obvious when . Let and let be . By (a), we know that . Hence cannot be . Since has increments of 0 or 1, and , we hence obtain that . Since is increasing, it cannot diminish back to later. So is the greatest antecedent of by . This equality can also be reformulated as . Together with the obvious fact , this establishes that for all , we have . Besides, for we have . Hence is the least antecedent of by . We finish the proof of statement (c) by noting that all natural numbers between and are also antecedents of by , thanks to the monotonicity of .
For statement (b), we have already proved in the previous paragraph. For , we prove that . For that, note that is obviously in . So by point (c), we have . We prove similarly that . Indeed, is in . So by point (c) for , we have . Finally, Proposition 2.3 indicates that is either or , so is or .
Corollary 2.5. For all and , the functions and form a Galois connection [4] between and itself (with as left adjoint and as right adjoint). Indeed, for all we have iff . Said otherwise, iff .
Proof. See [11, Cor. 3.2]. Alternatively, if , then by Proposition 2.4 and by monotonicity of (Proposition 2.3). Conversely, implies . Finally, the formulation with strict inequalities is obtained by contrapositive: iff iff iff .
Corollary 2.6. For all and , the functions and also form a Galois connection between and itself (this time is the right adjoint and the left adjoint). Indeed, for all we have iff . Said otherwise, iff .
Proof. If , then by Proposition 2.4 and by monotonicity of . Conversely, implies . Here again, the formulation with strict inequalities is obtained by contrapositive.
3 Explicit formulas for iterated preimages
The following lemma expresses the first iterates of and via simple sums of iterated terms. This is the key ingredient that was lacking in our previous article [11]. Its use is essential during the short proof of Theorem 1.1 in Section 4 and during the first proof of Theorem 1.2 in Section 5. This lemma has been contributed to us by Jeffrey Shallit, who himself obtained it with the help of ChatGPT 5.5 Extended. This is the only statement of this article that is due to AI. As the rest of this work, we checked it with the Rocq proof assistant (see Section 1.3). We should also mention that ChatGPT suggested a different proof of Theorem 1.1 (but ours is significantly simpler) as well as a shortcut in our proof of Lemma 5.6 (we implemented this shortcut).
Lemma 3.1. For and , we have
Proof. By induction over . The cases and are clear. Let and assume for all the previous formulas about . For , we have that . The formula at this point gives
In the sum, we simplify . After shifting the sum index and incorporating the extra term in the sum, we obtain
This concludes the induction. The formula about can be proved in the same way. ☐
The constraint is crucial for keeping the formulas in such a simple form, without coefficients in the sum. For higher values of , we could obtain similar formulas but with non-trivial coefficients. As a example, the formula for is given below (it is used in Section 7.2).
Proposition 3.2. For , we have
Proof. Continuing Lemma 3.1, we start with the formula for and use one more time the same method, i.e., apply this formula at :
In the sum, we consider the case separately, obtaining an extra , for a total of . The other terms of the sum are handled as in the proof of Lemma 3.1.
As an immediate application of Lemma 3.1, we can provide an improved upper bound for when . Instead of the generic given in Proposition 2.3, we obtain by subtracting the two formulas of Lemma 3.1 and recalling that is at most 1. Thanks to Proposition 2.4, this means that for , the function has at most antecedents for a given value. Such situations with antecedents are easy to exhibit, consider for instance the antecedents of 1.
In a very similar way, we can also consider the increments of the function , and find these increments to be in as long as . The same property also holds for . We use this fact later in the particular case . In this case the sum of differences always includes . This leads to a slightly refined range.
Corollary 3.3. For , the increment is in the range . In particular this increment is 2 when and it is when for all .
4 Direct proof of non-strict ordering
The Lemma 3.1 is a powerful tool: from the knowledge of and its iterates at a given point, we deduce at the next point, which in turn controls the behavior of at a greater location. This allows us to simultaneously establish and in the proof by induction of Theorem 1.1 given below.
Note that using the least preimage instead of the greatest preimage is mostly a matter of taste. The following proofs can be adapted to as well. However, it seems crucial to exploit the -th iterate of a preimage function of . For instance, a similar proof based on instead of does not seem possible. Indeed, comparing and is equivalent to comparing and , which is not directly related with the comparison of and .
First, we show that whenever . More precisely, we split this property in two parts.
Proposition 4.1. For and :
(a) if then ;
(b) if then .
Proof. (a) Assume , or equivalently . By Corollary 2.6, this is also equivalent to .
(b) Assume , or equivalently , i.e., . By Corollary 2.5, this is also equivalent to . Hence .
Then we compare and , assuming that and (and their iterates) are well ordered just before.
Lemma 4.2. For and , if for all then .
Proof. By Lemma 3.1 we obtain
All the differences in the sum are non-negative thanks to the hypothesis. And of course is also non-negative. So as desired.
Now we are equipped to prove the Theorem 1.1 in a direct way.
Proof of Theorem 1.1. Let . We prove by strong induction on . First, since both are 0. Now let and assume that everywhere in . This induction hypothesis extends to iterates of these functions: for all , we have on . This is proved by a routine induction on where all the functions involved are monotonically increasing and smaller than the identity hence preserve the interval .
We focus on the value . First this is in since is smaller than the identity. We hence have for all . By Lemma 4.2 we deduce that .
Furthermore, the chosen value of ensures that Indeed, we have . Hence by Corollary 2.6 we have .
Finally . Indeed the left side is a direct use of Proposition 4.1(a). And the right side comes from combined with Proposition 4.1(b). This concludes the proof by induction.
In the previous proof, note that the induction hypothesis is used only on or less. This point is also equal to (so in fact instead of the mere inequality used above). This coincides with for but becomes quite smaller than afterwards. For instance, we clearly have when . Moreover, this could have being chosen as instead of with only minor adaptations to the rest of the proof. Despite being smaller, this alternative choice does not improve the proof. This situation occurs again in Section 5.3, but there the smaller alternative is actually more cumbersome that using .
From Theorem 1.1, we retrieve some immediate consequences (also see Theorem 7.4 and Equation (7.3) in [11]).
Corollary 4.3. For and , we have .
Proof. By induction on i, just as in the beginning of the previous proof.
Corollary 4.4. For and , we have as well as .
Proof. The case is clear. Otherwise we use the Lemma 4.2, whose precondition is proved by Corollary 4.3. Finally we recall that and similarly for .
5 Strict ordering of and
This Section is dedicated to the proof of Theorem 1.2. After studying the initial values of and in Section 5.1, we provide an ad-hoc early comparison of and in Section 5.2. This allows us to prove Theorem 1.2 by induction in Section 5.3.
5.1 Initial behavior of and
Now we establish a few elementary properties of the initial values of and that are needed in the rest of this Section.
For now on, we abbreviate for the -th triangular number . Note that the value introduced earlier can also be expressed as .
First, the function admits an initial zone where it satisfies . We call it the “linear” initial zone. More generally, we express and in this zone.
Proposition 5.1. Let .
(a) For and , we have ;
(b) for we have .
Proof. (a) By induction on . The base case is clear: . Now let and assume for all . We prove for all . The case is obvious. Now we consider . In that case, since here. Finally, for , . This ends the current induction.
(b) For , we use Lemma 3.1 and the previous point. This gives
When , this last sum can be split in the following way.
Instead of adapting this computation to the case , we use Corollary 3.3 in this case, with an increment of compared to . Indeed for all thanks to point (a). Since the previous computation provides , we obtain the desired equality .
The linear zone we just considered is followed by a “triangular” zone where the behavior of is governed by triangular numbers. First we express a few particular cases at the left of this triangular zone.
Proposition 5.2. For we have the following particular cases.
Proof. We compute by Proposition 5.1(a). In particular, this means that and more generally for all . Then we exploit the fact that cannot be flat twice in a row. More precisely, we have by Proposition 2.1, so .
For the equations concerning , we proceed once again by incremental differences thanks to Corollary 3.3.
• We established in the previous Proposition.
- . Indeed, by Proposition 5.1(a) we have for all
• . Indeed .
- . Indeed for we have and similarly .
From there, the desired equations are obtained by routine reasoning on triangular numbers.
We recall that the triangular numbers form a strictly increasing sequence starting at , so for all numbers , there is a unique such that . We call this the “triangular index” of . In the interval , the value of is governed by the triangular index of .
Proposition 5.3. Let and .
(a) For all p such that , we have ;
(b) for all p such that , we have ;
(c) consequently where p is the triangular index of .
Proof. Let and .
(a) Let such that . If , we indeed have for by Proposition 2.1(c). Now we assume . By Proposition 4.1(a), to prove that , it is actually sufficient to establish . Note that we have since . Hence we are entitled to use Proposition 5.1(b) and obtain .
(b) Let such that . By Proposition 4.1(b), to prove that , it is actually sufficient to establish . If , we can use Proposition 5.1(b) to obtain . Otherwise and in this case we have by Propositions 2.3(a) and 5.2.
(c) Direct combination of the two previous points.
As a side note, two other descriptions of this triangular zone are worth mentioning. First, Hofstadter [6] noticed that can be presented thanks to an infinite tree obtained from a pattern specific to , and then labeled by successive numbers in a breadth-first way. For a node in this tree, the function transforms its label into the label of its parent node. On this topic, also see Celaya and Ruskey [2] and our earlier work [9]. Here, the triangular zone corresponds to the initial part of the tree where just one binary node occurs per row.
Secondly, is deeply related with a non-standard numeration system that we describe in a separate work [10], following Meek and Van Rees [12]. In this numeration system, the weights of the digits are given by a generalization of the Fibonacci sequence. For Fibonacci, we recursively add the last two terms of the sequence to obtain the next one. Here we recursively add -apart terms in the sequence: combined with the initial terms when . When a number is written in this numeration system, the value of is obtained by shifting down the digits of by one position, with a particular treatment of the least-significant digit. We recall that the triangular zone we just explored ends with . This happens to be the first number to necessitate three non-zero digits in this numeration system. All the other numbers in the linear and triangular zones can be written with at most two non-zero digits. Thanks to this fact, it is possible to obtain alternative proofs for our results about the triangular zone, including the tedious Lemma 5.6 given in the next Section. But these alternative proofs are not significantly simpler than the ones presented here. Finally, these interpretations of based on trees or numeration systems do not seem to provide direct proofs of Theorems 1.1 nor 1.2.
From Proposition 5.3, it is actually possible to express the general iterates in the triangular zone. In particular is alternatively flat there (after triangular numbers or immediately before) or growing several times (further away from the previous triangular number). The exact details are rather intricate. Fortunately, we can avoid them for the rest of this article. Instead, we just propose some simple lower bounds for and in the triangular zone.
Proposition 5.4. Let and . For all such that , we have and .
Proof. For the first inequality, is expressed as while Proposition 5.3(a) leads to .
We obtain the second inequality by proving additionally that . This is ensured by Proposition 2.1(c) as soon as . But we have , and hence by monotonicity. Finally by Proposition 5.1(a).
Finally, we describe the early differences between and .
Proposition 5.5. Let .
(a) For , we have .
(b) For , we have when is a triangular number, otherwise .
(c) In particular
Proof. Let .
(a) We clearly have and , while for we have by Proposition 5.1(a).
(b) Let . There exists such that . By Proposition 5.3, this means that .
If is exactly a triangular number, it can only be . Moreover and so another instance of Proposition 5.3 gives .
Suppose now that is not a triangular number. This implies and hence , so finally .
(c) For , we have . For , we have which is not a triangular number. Finally for we have . For , this value cannot be a triangular number. The actual values for these instances of and are obtained by Propositions 5.2 and 5.3.
14
☐
5.2 Ad-hoc early comparison of and
This section is dedicated to the comparison of and in the triangular zone . More precisely, we establish the following lemma, which is essential to “bootstrap” the proof by induction of Theorem 1.2 given in Section 5.3.
Lemma 5.6. For and , we have .
Note that this result actually holds for all , as shown in Section 5.3. But the generic argument given later for does not hold in the triangular zone, where we do not have everywhere (see Proposition 5.5). Instead, we proceed in a rather ad-hoc manner here: we compare once again the sums obtained by Lemma 3.1, but this time the initial terms in these sums may induce a “debt” that have to be compensated for by the extra term in the rightmost sum. Before giving the proof of Lemma 5.6, we start by a few auxiliary results for comparing respective terms in these sums.
Proposition 5.7. Let and .
(a) We have ;
(b) if then for all we also have .
Proof. (a) By Corollary 4.3, we have . Moreover by Proposition 2.1.
(b) From , we obtain
by monotonicity of (Proposition 2.1) then by Corollary 4.3.
Proposition 5.8. Let and and . If then we have .
Proof. If , we have either or . In these cases, and by Propositions 5.1 and 5.2. Now we assume . By Proposition 5.3, we have . We can also obtain that hence another instance of Proposition 5.3 provides .
The more differs from the previous triangular number, the more we have to iterate and to get a favorable situation.
Proposition 5.9. Let and and . If then we have .
Proof. Let . We prove by induction over that for all and such that , then . The case is directly implied by the previous Proposition. Now let and assume the desired property holds at . Let and such that . First, if , then Proposition 5.7(b) directly gives the desired inequality. Now we assume . Thanks to Proposition 5.7(a), this implies . We abbreviate as . Our goal can be reformulated at , which is an instance of the induction hypothesis for . Indeed, we show below that is still in and . For that, first note that by Proposition 5.3 (here the additional constraint is used to obtain ). Moreover, if we suppose that , then the previous Proposition provides , which is impossible here. We hence have .
-
Let us show that . The right part is obvious since . Now is equivalent to . If , we indeed have . Otherwise cannot be less than , so . In this case, can only be , which is greater than .
-
The fact that is a direct consequence of and and .
Now that these constraints on are established, we obtain as planned thanks to the induction hypothesis. This concludes the current induction.
Now we are ready to prove Lemma 5.6.
Proof of Lemma 5.6. Let and . We prove . Let be such that . Note that is at least 1, otherwise we would have hence . Also note that , since . Let be . This ensures . Moreover we have , otherwise we would have hence . By Lemma 3.1 we obtain
For , the differences are all non-negative. Indeed we have by Proposition 5.9. This propagates to all by Proposition 5.7(b). Now we consider the low indices . The corresponding differences are all at least -1 thanks to Proposition 5.7(a). There are such low indices, so the whole sum is at least . Meanwhile, is at least , thanks to Proposition 5.4 used with
and and . Indeed here, since . And hence . Finally is at least .
The previous proof could be adapted to obtain the strict inequality except when , but this refinement does not seem useful later.
5.3 The main induction for strict ordering
This Section presents the core of the proof of Theorem 1.2, namely that when exceeds . The proof given here is similar to the one of Theorem 1.1 in Section 4. Here again, we relate and on one side and and on the other side. The Lemma 3.1 is once again crucial in one direction. But this time, a strict order such as at some point is not sufficient to guarantee a strict order at some other point. Instead, we need a stronger property between and , more precisely that for some position . Moreover, this time the desired properties only hold after a transitory phase, leading to a quite delicate proof. In particular we rely on the “bootstrap” Lemma 5.6 proved in the previous section.
First, the next lemma is an adaptation of Lemma 4.2 in the case of strict monotonicity.
Lemma 5.10. For and , if then .
Proof. Let be such that . This implies that is at least (see Proposition 5.5). In particular, is strictly positive. By Lemma 3.1 we obtain
Since we have by Proposition 5.1(a). Moreover, all the differences in the remaining sum are non-negative. Indeed, we recall from Proposition 2.1 that . Since , this implies that . More generally, for , we have
by Corollary 4.3 and then monotonicity of .
Now we finally prove Theorem 1.2.
Proof of Theorem 1.2. Let . We prove by strong induction on . Let and assume that everywhere in . We consider , which is also . The chosen value of ensures that . Indeed, we have , so by Corollary 2.6 we have . By Proposition 5.2 we obtain . The strict monotonicity of (see Proposition 2.3) implies , i.e., . Now we prove , or equivalently (since ). By Proposition 4.1(b), this inequality holds as soon as . Since , it is sufficient to establish . This fact is provided by the “bootstrap” Lemma 5.6 when . Besides, when the induction hypothesis holds for and can be combined with Lemma 5.10 to conclude.
In the previous proof, the strong induction is presented without explicit base case. Nevertheless, for and the values immediately after, the corresponding is less than or equal to , leading to the use of the “bootstrap” Lemma 5.6 and preventing any circularity.
Besides, the value used during the proof could also be chosen as instead of . But this time, the adaptations to the proof are more consequent than in Section 4: this smaller alternative might be smaller than , so a few extra cases have been to dealt with.
Corollary 5.11. For and , we have .
Proof. If , the result is given by Lemma 5.6. Otherwise and we apply Lemma 5.10 whose condition is ensured by Theorem 1.2.
Corollary 5.12. For and , we have .
Proof. By Theorem 1.2, we have here. Moreover by Proposition 2.1.
The following corollary is mentioned as a conjecture in our previous article [11, Sect. 7].
Corollary 5.13. For and , we have .
Proof. • The case n = 0 is obvious.
• If , we have by Proposition 5.1(a).
• For , we consider such that . Then by Proposition 5.3. Similarly, we have by Proposition 5.3, since and and .
• Finally, if , we have by Theorem 1.2 and then monotonicity of .
6 First difference of 2 between and
From Theorem 1.2, we know that when . In this section we extend Proposition 5.5 by studying immediately after . This difference remains exactly 1 as long as and reaches 2 for the first time in .
Proposition 6.1. For and such that , we have .
Proof. Consider such and . By Theorem 1.2 we know that . Hence it is sufficient to prove that . We pose , which is also . The chosen value of ensures that by Corollary 2.6. This implies that . Indeed, by Proposition 5.2. Since is strictly increasing, we hence have . Similarly, by Proposition 5.2, and hence .
Moreover the inequality can also be stated as . By Proposition 4.1, it is sufficient to prove , which is here a consequence of . We prove this last inequality in the two possible cases and . If , we have by Proposition 5.2 and by Proposition 5.1. If , we have by Proposition 5.2 and by Proposition 5.1.
Proposition 6.2. For , we have .
Proof. The left equality is implied by Proposition 5.5(c) for . Now we prove that or equivalently that . Thanks to Proposition 4.1, it is hence sufficient to establish . These inequalities are valid since by Proposition 5.2, while is at least thanks to Corollary 3.3.
7 Proving two remaining conjectures
In this section, we prove two properties that were mentioned as conjectures in our previous article [11, Sect. 7].
7.1 Strict ordering of and
Here we prove that when is large enough. It is a relatively direct consequence of Theorem 1.2. First, we express some more equations about around .
Proposition 7.1. Let . We have
Proof. The equation already appears in Proposition 5.5(c). More generally, we can reformulate the desired equations into with respectively then then then . Indeed, note that . By Proposition 4.1, the equation holds as soon as . We recall from Propositions 5.1 and 5.2 that and and . From there, the necessary inequalities are proved by routine reasoning on triangular numbers.
Theorem 7.2. For and , we have . When , we have equality at , namely .
Proof. We start by proving the equality of and at . Let . By proposition 2.4, we know that is the greatest value satisfying . Thanks to the previous proposition 7.1 and the monotonicity of , we conclude . Moreover, Proposition 5.5 states that for such that is not a triangular number. In particular, we have for and (the latter case requires instead of the usual ). As a consequence, the greatest value such that is also . Hence .
Now we prove when and . By Corollary 2.5, this is equivalent to . We reformulate the first occurrence of as by Proposition 2.4. The obtained inequation is a instance of Theorem 1.2, provided that . Since and is monotonically increasing, it is sufficient to prove that . But . Indeed, the previous proposition 7.1 indicates that is the greatest such that .
Since for , we can reformulate the previous theorem for and .
Corollary 7.3. For and , we have .
7.2 Weak ordering of and
Here we prove Theorem 1.3, which compares and . In particular, it confirms that the conjectured arrows in the Figure 7.1 of our earlier article [11] can be turned into proved relations.
Proposition 7.4. For and , we have .
Proof. Let and . First, is equivalent to where . We prove for all . For that, it is handy to consider the function which is the greatest preimage of . We recall that and by Proposition 2.4. Said otherwise, . Finally by repeated use of Theorem 1.1.
Proposition 7.5. For and , we have .
Proof. The case n = 0 is obvious. For n > 0 we use Proposition 3.2 twice.
All the differences in the sum are non-negative thanks to Corollary 4.3. Finally is also non-negative since by Corollary 4.3 and by Proposition 7.4.
Proof of Theorem 1.3. Let and . We prove . By Corollary 2.6, this is equivalent to . We prove it by Propositions 7.5 and 2.4:
8 Conclusion
In the current article, we proved several properties of functions that we conjectured previously. Moreover we vastly improved the proof of Theorem 1.1. If we note the difference , we can rephrase Theorem 1.1 as . Besides, the last occurrence of a difference of 0 is at (see Proposition 5.5 and Theorem 1.2), while the first occurrence of 1 is at (Proposition 5.5) and the first occurrence of 2 is at (Proposition 6.2).
From there, one may wonder whether these results could be generalized to an arbitrary difference instead of just 0 or 1 or 2. First note that for a fixed , the difference becomes arbitrarily large when grows, as shown in the asymptotic study of our previous article [11, Sect. 6]. More specifically, when we have where is the positive zero of . Furthermore, we studied in a separate work [10] the discrepancy . This discrepancy is finite for , logarithmic for and for and some exponent depending on . See also Shallit [14] for the case . Thanks to that, we can provide some rough bounds for the zone where a difference of may occur. For instance, we established that and . As a consequence, we have . Hence a point such that must satisfy . However, these bounds are far from giving exactly the first and last occurrences of a given difference . For greater values of , a similar analysis is possible, but this time the unbounded discrepancies lead to bounds that are harder to express and probably less precise.
As a side remark, the difference evolves by steps of -1 or 0 or 1 when grows. Indeed, and similarly for . So follows a discrete version of the intermediate value theorem [7]. Combined with and and the limit of mentioned previously, this ensures that differences are strictly smaller than before the first occurrence of and strictly greater than after the last occurrence of .
As an experiment, we computed some of these (in practice for and ). According to this experiment, for a given and sufficiently large, the smallest for which appears to be
For instance, this formula seems to hold for and , or for and , or for and . For , the value obtained in Proposition 6.2 is close to this formula, but the final term should be replaced in this case by 5.
During this experiment, we also tried to determine the largest for which . This computation only provides partial answers, since could possibly occur again after the tested zone. In practice, the differences seem pretty regular and we restrict ourselves to values of that are much smaller than the highest observed difference. For a given and sufficiently large, the largest for which appears to be given by a polynomial of degree 3 whose leading coefficient is . For instance:
Note that for , we have of degree 2 (see Theorem 1.1 and Proposition 5.5). But this case seems to be an exception compared with the aforementioned polynomials of degree 3 for .
It is currently unclear whether the polynomials given above could be expressed in an unified way. Moreover, proving these experimental formulas seems out of reach for now. Finally, it is rather unsatisfactory that these formulas cannot handle the low values of . Indeed, the most popular are arguably and , i.e., and in Hofstadter's terminology. This can be hinted by the lengths of their OEIS pages A005206 and A005374 compared to, say, A005375 for .
9 Acknowledgments
The author thank Jeffrey Shallit and Wolfgang Steiner and Shuo Li for their great help during this work.
References
[1] J.-P. Allouche and J. Shallit, Automatic Sequences: Theory, Applications, Generalizations, Cambridge University Press, 2003.
[2] M. Celaya and F. Ruskey, Morphic words and nested recurrence relations, 2013. arXiv:1307.0153.
[3] P. J. Downey and R. E. Griswold, On a family of nested recursions, Fibonacci Quart. 22 (1984), 310–317.
[4] M. Erné, J. Koslowski, A. Melton, and G. E. Strecker, A primer on Galois connections, Ann. N. Y. Acad. Sci. 704 (1993), 103–125.
[5] D. Gault and M. Clint, “Curiouser and curiouser” said Alice. Further reflections on an interesting recursive function, Int. J. Comput. Math. 26 (1988), 35–43.
[6] D. R. Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid, Basic Books, 1979.
[7] R. Johnsonbaugh and D. W. DeTemple, A discrete intermediate value theorem, The College Mathematics Journal 29 (1998), 42–42.
[8] P. Letouzey, Coq/Rocq proofs about Hofstadter's function G. 2015–2026. https://github.com/letouzey/hofstadter_g.
[9] P. Letouzey, Hofstadter's problem for curious readers, 2015. Research Report, Université Paris Diderot and INRIA Paris. hal-01195587v4.
[10] P. Letouzey, Generalized Hofstadter functions G, H and beyond: numeration systems and discrepancy, 2025. To appear. Preprint available at https://arxiv.org/abs/2502.12615.
[11] P. Letouzey, S. Li, and W. Steiner, Pointwise Order of Generalized Hofstadter Functions G, H and Beyond, J. Integer Sequences 29 (2026), Article 26.3.3.
[12] D. S. Meek and G. H. J. Van Rees, The solution of an iterated recurrence, Fibonacci Quart. 22 (1984), 101–104.
[13] The Rocq Core Team, The Rocq proof assistant. 2025–2026 (and 1985–2025 under the name Coq). https://rocq-prover.org.
[14] J. Shallit, The Narayana morphism and related words, 2025. arXiv:2503.01026.
[15] N. J. A. Sloane and The OEIS Foundation Inc., The on-line encyclopedia of integer sequences, 2026. Published electronically at https://oeis.org.