Gray codes for Fibonacci q-decreasing words
aa r X i v : . [ c s . D M ] O c t Gray codes for Fibonacci q -decreasing words Jean-Luc Baril, Sergey Kirgizov, and Vincent Vajnovszki
LIB, Université de Bourgogne Franche-ComtéB.P. 47 870, 21078 Dijon Cedex France {barjl,sergey.kirgizov,vvajnov}@u-bourgogne.fr
Abstract. An n -length binary word is q -decreasing, q ě , if every of itslength maximal factor of the form a b satisfies a “ or q ¨ a ą b . We showconstructively that these words are in bijection with binary words havingno occurrences of q ` , and thus they are enumerated by the p q ` q -generalized Fibonacci numbers. We give some enumerative results andreveal similarities between q -decreasing words and binary words havingno occurrences of q ` in terms of frequency of bit. In the second part ofour paper, we provide an efficient exhaustive generating algorithm for q -decreasing words in lexicographic order, for any q ě , show the existenceof 3-Gray codes and explain how a generating algorithm for these Graycodes can be obtained. Moreover, we give the construction of a morerestrictive 1-Gray code for -decreasing words, which in particular settlesa conjecture stated recently in the context of interconnection networksby Eğecioğlu and Iršič. The Fibonacci sequence origins have been traced back to the works of ancient In-dian mathematician ¯Ac¯arya Pi ˙ngala dealing with rhythmic structure patterns inSanskrit poetry [18,11, p. 50]. Over the time, the study of words and patterns be-came more abstract and systematic (see for instance Lothaire’s books [12,13,14]and [3]). An important amount of questions concerning efficient enumeration andgeneration of words respecting certain properties (including pattern avoidance)were mathematically formulated and answered only relatively recently, the worksclosely related to the present study include [1,2,4,5,7,20,21,22].In this paper we introduce q -decreasing words, a novel class of run-restrictedbinary words enumerated by the p q ` q -generalized Fibonacci numbers, q ě .For q “ the subclass of such words that start with was recently consideredin the context of induced subgraphs of hypercubes [4,5]. In Section 2 we presenta bijection between this novel class of words and Fibonacci words, i.e. binarywords avoiding consecutive s. Section 3 is devoted to the presentation of severalgenerating functions and enumeration results. Finally, in Section 4, we show theexistence of a 3-Gray code for any q ě , give an efficient exhaustive generatingalgorithms and a much more involved construction for a 1-Gray code in thespecial case q “ . In particular, the latter Gray code gives a Hamiltonian pathin Fibonacci-run graphs whose existence is conjectured in [4]. J.-L. Baril, S. Kirgizov and V. Vajnovszki
The following set of notations is adopted. Let B denote the set of all finite-length binary words, i.e. strings over alphabet t , u , and B n , n ě , be the setof all binary words of length n . For a given binary word w we use the notation w i to mean the letter at position i . A non empty sequence of adjacent letters insidea word is called factor . A factor x repeated k times is denoted by x k , for instance p q “ . For a given length n , the notation x ˚ is used to repeat factor x as many times as possible, until the length n is reached, possibly trimmingextra bits at the end; and the length n will be understood from the context. Forexample, if a word w of length n “ is equal to p q ˚ it means w “ .The set of all n -length binary words containing no occurrences of factor x is denoted by B n p x q . The concatenation of two words w and x is denoted by w ¨ x or simply by wx . If x is a binary word and W is a set of binary words, let W ¨ x “ t w ¨ x : w P W u , and x ¨ W is defined similarly. Whenever A and B aretwo subsets of B , we define A ¨ B “ t a ¨ b : a P A , b P B u .Following [15] the n th k -generalized Fibonacci number is defined as f n,k “ $’&’% if ď n ď k ´ , if n “ k ´ , ř ki “ f n ´ i,k otherwise . (1) Classical fact.
The number of words in B n p k q equals f n ` k,k for k ě , more-over B n ` k ˘ “ B n if n ă k, Ť k ´ i “ i ¨ B n ´ i ´ ` k ˘ otherwise. (2)The classical fact comes, for instance, from [10, p. 286]. The binary wordsavoiding consecutive 1s are counted by Fibonacci numbers, words without factor111 are counted by Tribonacci numbers, etc. We call such words (generalized) Fi-bonacci words . The On-line Encyclopedia of Integer Sequences founded by N.J.A.Sloane [19] contains several corresponding sequences (see for example A000045and A000073, after taking a binary complement). Gray codes for Fibonacci wordsare discussed in [20], and in [21].The Hamming distance between two same length binary words equals thenumber of positions at which they differ. A k -Gray code for a set A Ă B n isan ordered list, denoted by A , for A , such that the Hamming distance betweenany two consecutive words in A is at most k , and we say that words in A arelisted in Gray code order . Frank Gray’s patent [7] discusses an early example andapplication of such a code for the set of n -length binary words. The concatenationof two ordered lists L and L is denoted by L ˝ L , and L designates the reverseof the list L . If L is a list of words, then L i “ L whenever i is even, and L i “ L otherwise. First and last elements of L are denoted respectively by first p L q and last p L q . Also, we denote by p L the list obtained from L by deleting its last element. Definition 1.
A binary word is called q -decreasing , for q ě , if any of itslength maximal factors of the form a b , a ą , satisfies q ¨ a ą b . ray codes for Fibonacci q -decreasing words 3 The set of q -decreasing words of length n is denoted by W qn . For example wehave W “ t , , , , , , , u . See also Table 1 forthe sets W and W . In this section we prove that q -decreasing words, q ě , are enumerated by p q ` q -generalized Fibonacci numbers defined in relation (1). We start with adefinition and several propositions. Definition 2.
For any q ě , we define the map ψ q from B n to B n ` q ` as ψ q p w q “ v k ` q if w “ v k , v P B , k ě , n ` q ` otherwise.Less formally, ψ q inserts a factor q immediately after the last occurrence of , and it adds the suffix q ` to the word containing no . For example ψ p q “ , ψ p q “ , ψ p q “ and ψ p q “ .The value of q will be clear from the context, so by slight abuse of notation ψ q will be denoted ψ throughout the paper. Proposition 1. ψ is an injective map.Proof. For two n -length words w ‰ w we show that ψ p w q ‰ ψ p w q . It is clearthat if at least one of the given words contains no 0 the injectivity holds. Oth-erwise we have two cases. If w “ v k and w “ v k then we have necessary v ‰ v and v k ` q ‰ v k ` q , so the images are different. If w “ v k and w “ v ℓ with k ‰ ℓ , then v k ` q ‰ v ℓ ` q and again ψ p w q ‰ ψ p w q . [\ In the following, we will use the restriction of ψ to the set of q -decreasingwords, namely ψ : W qn Ñ W qn ` q ` . It is possible due to Proposition 2 below. Proposition 2.
For n, q ą , ψ p W qn q consists of all q -decreasing words of length n ` q ` ending with at least q ones.Proof. If w “ n , then ψ p w q “ n ` q ` . Otherwise, we write w “ v a b where a ą b { q ě and the word v is either empty or ends with 1. So ψ p v a b q “ v a ` q ` b . As we have ` a ą ` b { q “ p q ` b q{ q , ψ p w q is a q -decreasing wordending with at least q s. Similarly, any p n ` q ` q -length q -decreasing wordending with at least q s can be obtained from a (unique) word in W qn by ψ . [\ Now, we present a one-to-one correspondence between Fibonacci and q -de-creasing words. Recall that, for q ě , the set B p q ` q of p q ` q -generalizedFibonacci words is the set of binary words with no q ` factors, see relation (2)for the recursive definition of these words according to their length. J.-L. Baril, S. Kirgizov and V. Vajnovszki
Definition 3.
We define the length-preserving map φ : B p q ` q Ñ W q as φ p w q “ $’&’% k if w “ k and k P r , q s ,ψ ` φ p v q ˘ if w “ q v,φ p v q k if w “ k v and k P r , q ´ s . (3)See Table 1(a) for the images of the words in B p q through φ . Theorem 1.
The map φ is a bijection between B p q ` q and W q .Proof. We proceed by induction on n . The classical decomposition in relation(2) gives rise to three cases. (i) Any word of the form k is sent by φ to k for any k P r , q s . (ii) Words of the form q v , where v P B p q ` q are sent towords ending by at least q s. (iii) Words of the form k v, k P r , q ´ s , where v P B p q ` q are sent to words ending by at most q ´ s. Using the bijectivityof ψ (see Proposition 1 and Proposition 2) and induction hypothesis, one caneasily show that for any two different words w ‰ w we have φ p w q ‰ φ p w q .Similarly, by induction on n , any word in W q can be obtained by φ from aword in B p q ` q , and the statement holds. [\ It follows that Fibonacci words of order p q ` q and q -decreasing words areequinumerous. Here we provide a bivariate generating function W q p x, y q “ ř n,k ě w n,k x n y k ,where w n,k is the number of n -length q -decreasing words having k s. Thisbivariate generating function is of a particular interest since it will help us (seeCorollary 1) to prove a necessary condition for the existence of 1-Gray code,called parity condition . More precisely, if a set A of binary words admits a 1-Gray code, and A ` (resp. A ´ ) denotes the subset of A having even (resp. odd)number of s, then the parity difference | A ` | ´ | A ´ | must be equal to either , , or ´ . This parity condition is used for instance in [20] to investigate thepossibility of 1-Gray code for a set of words avoiding a given factor.In order to derive the expression of W q p x, y q , we use the following decompo-sition of the set W q : W q “ Y W q ¨ S q , where “ Y n “ t n u and S q corresponds to the set of all factors of the form a b respecting q -decreasing property (i.e. a ą b { q ě ) such that none of themis a concatenation of others factors from S q . More precisely, a is the smallestinteger strictly greater than b { q , i.e. a “ t b { q u ` . A factor from S q will becalled q -prime factor , and thus S q is the set of such factors. For instance: S “t , , , , . . . u , S “ t , , , , , , . . . u . ray codes for Fibonacci q -decreasing words 5 Lemma 1.
The bivariate generating function S q p x, y q “ ř n,k ě s n,k x n y k wherethe coefficient s n,k is the number of q -prime factors of length n having exactly k s is: S q p x, y q “ x p ´ p xy q q qp xy ´ qp x q ` y q ´ q . Proof.
Any q -prime factor is of the form a b with a “ t b { q u ` . So, if b “ kq ` r with k ě and r P r , q ´ s , then a ` b “ k p q ` q ` r ` and we can write: S q p x, y q “ ÿ k “ q ´ ÿ r “ x k p q ` q` r ` y kq ` r . A simple calculation results to the claimed formula. [\ Theorem 2.
The bivariate generating function W q p x, y q “ ř n,k ě w n,k x n y k where the coefficient w n,k is the number of n -length q -decreasing words containingexactly k s is given by: W q p x, y q “ ´ x q ` y q ´ xy ´ x ` x q ` y q ` . Proof.
Due to the decomposition W q “ Y W q ¨ S q , we have W q p x, y q “ ´ xy ¨ ´ S q p x,y q , and the result hold after applying Lemma 1. [\ Corollary 1.
For any n, q ě , the set W qn satisfies the parity condition.Proof. The generating function D q p x q “ ř n ě d n x n where the coefficient d n isthe parity difference corresponding to the set W qn is obtained by making thesubstitution y “ ´ in W q p x, y q : D q p x q “ p´ q q x q ` ´ p´ q q x q ` ´ . When q is even, D q p x q “ x q ` ´ x q ` ´ “ ř n “ ` x n p q ` q ´ x n p q ` q` q ` ˘ , otherwise D q p x q “ x q ` ` x q ` ` “ ř n “ p´ q n ` x n p q ` q ` x n p q ` q` q ` ˘ . All involved coefficientsare from t´ , , u , and the parity condition holds.The following two corollaries are obtained by respectively calculating theexpressions: W q p x, y q ˇˇ y “ , B W q p x,y qB y ˇˇ y “ and B W q p xy, { y qB y ˇˇ y “ . Corollary 2.
The generating function F q p x q “ ř n ě f n x n where the coefficient f n is the number of n -length q -decreasing words is given by: F q p x q “ ´ x q ` ´ x ` x q ` . J.-L. Baril, S. Kirgizov and V. Vajnovszki
Note that, as predicted by Theorem 1, F q p x q is the generating function for theinteger sequence p f n ` q ` ,q ` q n ě , see relation (1) and the classical fact followingit. The popularity of a symbol in a set of words is the overall number of thesymbol in the words of the set. Corollary 3.
The generating function P q, p x q “ ř n ě p n x n where the coeffi-cient p n is the popularity of s in all n -length q -decreasing words is: P q, p x q “ x ` ´ qx q ` qx q ` ´ x q ` ` x q ` ˘ p ´ x ` x q ` q . Similarly, the generating function for the popularity of s in all n -length q -decreasing words is: P q, p x q “ x p ´ x q qp ´ x ` x q ` q . The popularity of 1s in B n p q is equal to the number of edges in the Fi-bonacci cube [8] of order n , see [9] and comments to the sequence A001629in [19]. The generating function P , p x q allows us to show that the popularity of s in W n is a shift of the sequence A006478 enumerating the number of edges inthe Fibonacci hypercube [16], i.e. in a polytope determined by the convex hull ofthe Fibonacci cube.Despite the q -decreasing words and Fibonacci words have quite different def-initions, they are equinumerous and share some common features. We end thissection by showing that the 1s frequency (define formally below) of both setshave the same limit when n tends to infinity.If u n (resp. v n ) is the ratio between the popularity of s and that of sin the words in W n (resp. in B n p q ), then lim n Ñ8 u n “ lim n Ñ8 v n . Indeed,extracting the coefficients of x n in both P , and of P , , their ratio tends to ´ ϕ « . when n tends to infinity, where ϕ is the golden ratio; andthis is also the limit of v n .The
1s frequency of a set of binary words is the ratio between the popularityof s and the overall number of bits in the words of the set. Alternatively, it isthe expected value when a bit is randomly chosen in the words of the set. Withthe notations above, we have that the 1s frequency of W n is ` un and that of B n p q is ` vn , and we have the next result. Corollary 4.
The 1s frequency of W n and of B n p q both tend to ´ ϕ ´ ϕ when n tends to infinity, where ϕ is `? . More generally, for any q ě , the overall number of bits in both sets W qn and B n p q ` q is n ¨ f n ` q ` ,q ` , and due to the second rule in relation (3) definingthe bijection φ : B p q ` q Ñ W q we have that in W qn there are more s than in B n p q ` q . However, the next corollary shows that the difference between the 1sfrequency of W qn and that of B n p q ` q tends to zero when n tends to infinity. ray codes for Fibonacci q -decreasing words 7 Corollary 5.
For any q ě , if u n,q (resp. v n,q ) is the popularity of s in W qn (resp. in B n p q ` q ), then we have lim n Ñ8 u n,q ´ v n,q n ¨ f n ` q ` ,q ` “ . Proof.
Since, for any q ě , u n,q ´ v n,q ě , it suffices to prove that we have u n,q ´ v n,q ď f n ` q ` ,q ` . Alternative to relation (2), the set B p q ` q of (anylength) binary words avoiding q ` can be defined recursively as B p q ` q “ q Y q ď i “ i ¨ B p q ` q where q “ Ť qi “ t i u . It follows that the bivariate generating function F q p x, y q where the coefficient of x n y k is the number of Fibonacci words having k ď q sin B n p q ` q satisfies the functional equation F q p x, y q “ q ÿ i “ x i y i ` F q p x, y q q ÿ i “ x i ` y i , and we have F q p x, y q “ y p ´p xy q q ` q y ´ xy ´ xy `p xy q q ` . Using Corollary 3, the generatingfunction H p x q where the coefficient of x n is f n ` q ` ,q ` ` v n,q ` ´ u n,q is H p x q “ F q p x, q ` B F q p x, y qB y ˇˇˇˇ y “ ´ P q, p x q“ ´ x q ` ´ x ` x q ` , which satisfies the functional equation H p x q “ ´ x q ` ` xH p x q ´ x q ` H p x q .By a simple observation, H p x q is also the generating function with respect tothe length of binary words different from q ` and q ` and that do not startwith q ` . Then we have u n,q ´ v n,q ď f n ` q ` ,q ` . Dividing by nf n ` q ` ,q ` , andtaking the limit when n tends to infinity, we obtain the expected result. [\ Corollary 4 says that, for q “ , the 1s frequency of W qn and that of B n p q ` q have a common limit when n tends to infinity. For q ě , Corollary 5 does notensure that each of the 1s frequency of W qn (that is u n,q n ¨ f n ` q ` ,q ` ) and that of B n p q ` q (that is v n,q n ¨ f n ` q ` ,q ` ) has a limit when n tends to infinity. However,using asymptotic analysis (see for instance [6]) it can be shown that v n,q n ¨ f n ` q ` ,q ` converges to a non-zero value when n tends to infinity, and the limit can beapproximated by numerical methods. From Corollary 5 it follows that so does u n,q n ¨ f n ` q ` ,q ` , and the two limits are equal.Since the proof of this result is beyond the scope of the present paper westate it (including the case q “ in Corollary 4) without proof. Corollary 6.
For q ě the 1s frequency of W qn and of B n p q ` q have a commonnon-zero limit when n tends to infinity. J.-L. Baril, S. Kirgizov and V. Vajnovszki q -decreasingwords Here we show that q -decreasing words can be efficiently generated in lexicograph-ical order and explain how the obtained generating algorithm can be turned intoa -Gray code generating one. Then, we give a more intricate construction ofa -Gray code for the particular case q “ . As a byproduct, this constructiongives a positive answer for the existence a Hamiltonian path in Fibonacci-rungraph conjectured in [4]. -Gray codes and exhaustive generation Algorithm in Figure 1 generates prefixes of q -decreasing words in lexicographicalorder, and eventually all n -length q -decreasing words. The size n , parameter q and the array w of length n ` are global variables and the main call is LexFib ( , n ). For convenience, w r s is initialized by and the parameter delta is the number of consecutive s that can be added to the current generatedprefix without violating the q -decreasingness. It can be seen that this algorithmsatisfies Frank Ruskey’s constant amortized time principle [17], and thus it is anefficient exhaustive generating algorithm. procedure LexFib ( pos , delta : integer) if ( pos “ n ` ) print w ; else w r pos s : “ ; if ( w r pos ´ s “ ) d : “ q ´ ; else d := delta ` q ; endif LexFib ( pos ` , d ); if ( delta ą ) w r pos s : “ ; LexFib ( pos ` , delta ´ ); endifendifend procedure Fig. 1: Lexicographic generation algorithm for q -decreasing words.The bijection φ in relation (3) does not preserve Graycodeness : for instance,when n “ k ` and q “ the Gray code for Fibonacci words in [21] alwayscontains two consecutive words u “ p q k and v “ p q k , but their images φ p u q “ k ` and φ p v q “ k ` k have arbitrarily large Hamming distance forenough large n . A similar phenomenon happens when n “ k and q “ with u “ p q k ´ and v “ p q k ´ : φ p u q “ k and φ p v q “ k ` k ´ . See alsoTable 1(a) for the image through φ of the 1-Gray code in [21] for B p q .Below we show that BRGC order (that is, the order induced by Binary Re-flected Gray Code in [7]) yields a 3-Gray code on W qn . Much more interestingly, ray codes for Fibonacci q -decreasing words 9 u P B p q φ p u q P W W in BRGC order Table 1: (a) The images of words in B p q under the bijection φ . Words in B p q are listed in a BRGC-like order, called local reflected order in [21], whichyields a 1-Gray code order. (b) The set W in BRGC order together with theHamming distance between consecutive words.thanks to Corollary 1, the necessary condition for the existence of a -Gray codeis satisfied, and we will provide such a Gray code for W n in the following part.In [22] the author introduces the notion of absorbent set , which (up to comple-ment) is defined as: a binary word set X Ă t , u n is called absorbent if for any u P X and any k, ď k ă n , u u . . . u k ´ n ´ k is also a word in X . Corollary 1from the same paper proves that any absorbent set listed in BRGC order yields a3-Gray. Clearly, W qn is an absorbent set and we have the following consequence. Corollary 7.
The restriction of BRGC order yields a 3-Gray code for W qn . Reversing lists technique [17] allows to turn the algorithm in Figure 1 into onegenerating the same class of words in BRGC order, so producing a 3-Gray codefor W qn . See for an example Table 1(b). -Gray code for W n In this part, we construct a -Gray code for the set W qn , n ě , when q “ ,which in particular gives a positive answer to a conjecture in [4]. For this purpose,we decompose W n , n ě , as W n “ Z n Y ¨ W n ´ where W “ H and Z n is the subset of words starting with in W n . In turn,we decompose Z n as Z n “ t n u Y n ď r “ D rn where D rn “ Ť t r ´ u j “ r ´ j j ¨ Z n ´ r . We refer to Figure 2(a) for a graphical illustra-tion of the decomposition of Z n for n “ where the point at coordinates p i, j q corresponds to the set i j ¨ Z n ´ i ´ j , ď j ă i ď n ´ , ď i ` j ď n , exceptthe lowest point which corresponds to t n u . The sets D rn , ď r ď n , correspondto the southwest-northeast diagonals of the graphic. ji i j ¨ Z ´ i ´ j D D (a) ......... .... ........ .. ....... ...... ..... .... ... .. . (b) Fig. 2: (a) Decomposition of Z as a union of subsets i j ¨ Z ´ i ´ j (or equiv-alently a union of diagonals D r ). (b) Illustration of the 1-Gray code Z . Thepairs of consecutive diagonals dealt with Lemma 3 are shown in gray-filled area;the other pairs are dealt with Lemma 4. A point labelled ....... (that is followed by seven dots) corresponds to the set of words in ¨ Z .According to the above definitions, it is straightforward to check the followinglemma. ray codes for Fibonacci q -decreasing words 11 Lemma 2.
For any k ă n , we suppose that Z k is a -Gray code for Z k with first p Z k q “ p q ‹ and last p Z k q “ p q ‹ . Given i and j such that ď j ă i ď n and ď i ` j ď n , then( i ) the list L “ i j ¨ Z n ´ i ´ j is a -Gray code for i j ¨ Z n ´ i ´ j with first p L q “ i j p q ‹ and last p L q “ i j p q ‹ ;( ii ) for i ` j ‰ n , the list L “ i j ` ¨ Z n ´ i ´ j ´ ˝ i j ¨ Z n ´ i ´ j is a -Graycode for i j ¨ Z n ´ i ´ j Y i j ` ¨ Z n ´ i ´ j ´ with first p L q “ i j ` p q ‹ and last p L q “ i j p q ‹ ;( iii ) the list L “ i j ¨ Z n ´ i ´ j ˝ i ´ j ` ¨ Z n ´ i ´ j is a -Gray code for i j ¨ Z n ´ i ´ j Y i ´ j ` ¨ Z n ´ i ´ j with first p L q “ i j p q ‹ and last p L q “ i ´ j ` p q ‹ ;( iv ) the list L “ i j ¨ Z n ´ i ´ j ˝ i ´ j ` ¨ Z n ´ i ´ j is a -Gray code for i j ¨ Z n ´ i ´ j Y i ´ j ` ¨ Z n ´ i ´ j with first p L q “ i j p q ‹ and last p L q “ i ´ j ` p q ‹ . Lemma 3.
Let us consider r “ , ď r ď n . For any k ă n , we supposethat Z k is a -Gray code for Z k with first p Z k q “ p q ‹ and last p Z k q “ p q ‹ .( i ) If r ‰ n ´ , then there is a -Gray code ∆ rn for D rn Y D r ´ n such that first p ∆ rn q “ r ´ p q ‹ and last p ∆ rn q “ r ´ p q ‹ .( ii ) If r “ n ´ , then there is a -Gray code ∆ n ´ n for D nn Y D n ´ n Y D n ´ n suchthat first p ∆ n ´ n q “ n ´ and last p ∆ n ´ n q “ n ´ .Proof. For the first assertion ( i ), it suffices to consider the list ∆ rn “ (cid:13) r ´ j “ r ´ ´ j j Z jn ´ r ` ˝ (cid:13) r ´ j “ r ´ j j Z jn ´ r . After considering assertions of Lemma 2, it remains to examine the transitionbetween w “ r ´ ´ j j Z j n ´ r ` for j “ r ´ and w “ r ´ j j Z j n ´ r for j “ r ´ . Since r “ , we have necessarily j ` “ j which implies that w and w differ by exactly one bit.For the second assertion ( ii ), we consider the list: ∆ n ´ n “ (cid:13) n ´ j “ n ´ ´ j j ˝ n n ´ ˝ (cid:13) n ´ j “ p n ´ j ´ j ` ˝ n ´ ´ j j q j ´ ˝ n ´ . A simple study of each kind of transitions allows us to see that ∆ n ´ n is a -Graycode for D nn Y D n ´ n Y D n ´ n satisfying first p ∆ n ´ n q “ n ´ and last p ∆ n ´ n q “ n ´ . An illustration of this Gray code for n “ (and thus r “ ) can befound in the last sketch of Figure 4. [\ Lemma 4.
Let us consider r “ , ď r ď n . For any k ă n , we supposethat Z k is a -Gray code for Z k with first p Z k q “ p q ‹ and last p Z k q “ p q ‹ .( i ) If r “ , then there is a -Gray code ∆ n for D n such that first p ∆ n q “ p q ‹ and last p ∆ n q “ p q ‹ . ( ii ) If r “ n ´ , then there is a -Gray code ∆ n ´ n for D n ´ n Y D n ´ n such that first p ∆ n ´ n q “ n ´ and last p ∆ n ´ n q “ n ´ .( iii ) If r “ n ´ , then there is a -Gray code ∆ n ´ n for D nn Y D n ´ n Y D n ´ n zt n ´ u such that first p ∆ n ´ n q “ n ´ and last p ∆ n ´ n q “ n ´ .( iv ) If r “ n , then there is a -Gray code ∆ nn for D nn Y D n ´ n such that first p ∆ nn q “ n ´ and last p ∆ nn q “ n ´ .( v ) If r R t , n ´ , n ´ , n u , then there is a -Gray code ∆ rn for D rn Y D r ´ n suchthat first p ∆ rn q “ r ´ p q ‹ and last p ∆ rn q “ r ´ p q ‹ .Proof. For the case ( i ), we set: ∆ “ Z n ´ .For the case ( ii ), we set: ∆ n ´ n “ (cid:13) n ´ j “ n ´ ´ j j Z j ´ ˝ (cid:13) n ´ j “ n ´ ´ j j Z .Since we have Z “ and Z “ , , it is straightforward to see that ∆ n ´ n is a -Gray code with first p ∆ n ´ n q “ n ´ and last p ∆ n ´ n q “ n ´ .For the case ( iii ), we set: ∆ n ´ n “ (cid:13) n ´ j “ n ´ ´ j j Z ˝ n n ´ Z ˝ (cid:13) n ´ j “ p n ´ ´ j j ` ˝ n ´ ´ j j Z q j . Knowing that Z “ and Z “ , we can easily check that any pair of con-secutive words differ by exactly one bit, which proves that ∆ n ´ n is a -Graycode.For the case ( iv ), we set: ∆ nn “ (cid:13) n ´ j “ n ´ ´ j j ˝ (cid:13) n ´ j “ n ´ j j . As previouslythe result can be obtained easily.The case ( v ) is more challenging to handle. The set D rn Y D r ´ n consists ofthe union of the following subsets: K “ r ´ Z n ´ r ` , K “ r ´ Z n ´ r ` , . . . , K a “ r ´ r ´ Z n ´ r ` and L “ r ´ Z n ´ r , L “ r ´ Z n ´ r , . . . , L b “ r ` r ´ Z n ´ r with a “ t r ´ u “ r ´ and b “ t r ´ u “ a ` . Let us denoteby K , K , . . . , K a and L , L , . . . , L b the associated Gray codes obtained byreplacing Z k with the Gray code Z k .Remark that for ď i ď a ´ (resp. ď i ď a ) and for a given j , the j thword of K i (resp. L i ) and the j th word of K i ` (resp. L i ` ) differ by exactly onebit; the words last p K i q and first p L i ` q differ by one bit. Since r “ , a iseven, and thus last pp K a ˝ z L a ` q a q “ last p z L a ` q differs by one bit from last p L a ` q .Taking into account all these remarks, the list ∆ rn defined below is a Gray code: ∆ rn “ x L ˝ (cid:13) ai “ ` K i ˝ z L i ` ˘ i ˝ (cid:13) a ` i “ last p L i q . We refer to Figure 3 for a graphical representation of this Gray code. [\ Theorem 3.
For any n ě , there exists a -Gray code Z n for Z n such that first p Z n q “ p q ‹ and last p Z n q “ p q ‹ .Proof. We define recursively the -Gray code Z n as follows: Z n “ $’’’&’’’% ∆ n ˝ ∆ n ˝ ¨ ¨ ¨ ˝ ∆ nn ˝ n ˝ ∆ n ´ n ˝ ¨ ¨ ¨ ˝ ∆ n ˝ ∆ n if n “ ,∆ n ˝ ∆ n ˝ ¨ ¨ ¨ ˝ ∆ n ´ n ˝ n ˝ ∆ n ´ n ˝ ¨ ¨ ¨ ˝ ∆ n ˝ ∆ n if n “ ,∆ n ˝ ∆ n ˝ ¨ ¨ ¨ ˝ ∆ n ´ n ˝ n ˝ ∆ nn ˝ ¨ ¨ ¨ ˝ ∆ n ˝ ∆ n if n “ .∆ n ˝ ∆ n ˝ ¨ ¨ ¨ ˝ ∆ n ´ n ˝ n ´ ˝ n ˝ ∆ n ´ n ˝ ¨ ¨ ¨ ˝ ∆ n ˝ ∆ n if n “ . ray codes for Fibonacci q -decreasing words 13 L L L L L L L K K K K K K Fig. 3: Illustration of the Gray code ∆ rn for the case ( v ) in the proof of Lemma 4(we consider a “ ). Vertical sequences of squares are Gray codes K i , ď i ď a ,and L i , ď i ď a ` , so that the first and the last elements are respectively thetop and bottom squares of the segments. The walk illustrates the Gray code ∆ rn that starts with first p L q and ends with last p L q .Due to Lemmas 2-4, last p ∆ i ` n q differ by one bit from last p ∆ i ` n q and last p ∆ i ` n q differ by one bit from last p ∆ i ` n q which ensure that Z n is a -Graycode. [\ We refer to Figure 4 for a graphical representation of Z n for ď n ď , seealso Figure 2(b) for n “ .An immediate consequence of Theorem 3 is the following. Theorem 4.
For any n ě , W n “ ¨ W n ´ ˝ Z n is a -Gray code for W n such that first p W n q “ n and last p W n q “ p q ‹ . Table 2: The Gray code W for the set W . The Hamming distance betweentwo consecutive words is one.Fibonacci-run graph introduced in [4] is the induced subgraphs of the hyper-cube on the run-length restricted words as vertices. It turns out that run-lengthrestricted words are precisely the reverse of -decreasing words beginning by . In this light, the Gray code Z n in Theorem 3 gives a Hamiltonian path in theFibonacci-run graph. The next corollary settles a conjecture in [4]. Corollary 8.
The Fibonacci-run graph has a Hamiltonian path.
Finally, the validity of parity condition stated in Corollary 1 and experimentalinvestigations for small q suggest the following extension of Theorem 4 . Conjecture 1
For any n ě and q ě , there is a -Gray code for W qn . . .. . Fig. 4: Illustration of the recursive definition for the Gray codes Z n , ď n ď . References
1. Baril, J.-L., Vajnovszki, V.: Minimal change list for Lucas strings and some graphtheoretic consequences. Theoretical Computer Science (2-3), 189–199 (2005)ray codes for Fibonacci q -decreasing words 152. Bernini, A.: Restricted binary strings and generalized Fibonacci numbers. In: In-ternational Workshop on Cellular Automata and Discrete Complex Systems. pp.32–43. Springer (2017)3. Berstel, J., Perrin, D.: The origins of combinatorics on words. European Journalof Combinatorics (3), 996–1022 (2007)4. Eğecioğlu, O., Iršič, V.: Fibonacci-run graphs I: Basic properties. arXiv:2010.05518[Math.CO] (2020)5. Eğecioğlu, O., Iršič, V.: Fibonacci-run graphs II: Degree sequences.arXiv:2010.05521 [Math.CO] (2020),6. Flajolet, P., Sedgewick, R.: Analytic Combinatorics. Cambridge University Press(2009)7. Gray, F.: Pulse code communication (Mar 17 1953), US Patent 2,632,0588. Hsu, W.-J.: Fibonacci cubes–a new interconnection topology. IEEE Transactionson Parallel and Distributed Systems (1), 3–12 (1993)9. Klavžar, S.: On median nature and enumerative properties of Fibonacci-like cubes.Discrete Mathematics (1), 145 – 153 (2005)10. Knuth, D.: The Art of Computer Programming, Volume 3: Sorting and Searching.Addison Wesley Longman Publishing Co., Inc., 2 edn. (1998)11. Knuth, D.: The Art of Computer Programming, Volume 4, Fascicle 3, GeneratingAll Combinations and Partitions. Addison-Wesley Professional (2006)12. Lothaire, M.: Combinatorics on words, vol. 17. Cambridge University Press (1997)13. Lothaire, M.: Algebraic combinatorics on words, vol. 90. Cambridge UniversityPress (2002)14. Lothaire, M.: Applied combinatorics on words, vol. 105. Cambridge UniversityPress (2005)15. Miles, E.: Generalized Fibonacci numbers and associated matrices. The AmericanMathematical Monthly (8), 745–752 (1960)16. Rispoli, F., Cosares, S.: The Fibonacci hypercube. The Australasian Journal ofCombinatorics [electronic only] , 187–196 (2008)17. Ruskey, F.: Combinatorial Generation. electronic available book (2003)18. Singh, P.: The so-called Fibonacci numbers in ancient and medieval India. HistoriaMathematica (3), 229–244 (1985)19. Sloane, N.J.A.: The On-line Encyclopedia of Integer Sequences, available electron-ically at http://oeis.org20. Squire, M.: Gray codes for A-free strings. The Electronic Journal of Combinatorics (1996)21. Vajnovszki, V.: A loopless generation of bitstrings without p consecutive ones. In:Combinatorics, computability and logic, pp. 227–240. Springer (2001)22. Vajnovszki, V.: Gray code order for Lyndon words. Discrete Mathematics & The-oretical Computer Science9