arXiv:1305.5765v2 [cs.IT] 11 Jun 2013 rjciesaegraph projective-space sa es slwa nw cee,adfrcranparameter certain for ones. and previously-known schemes, outperforms known scheme as new enumerative- low the algorit as ranges, an the least of induce at complexity is which computational The code, scheme. Gray coding Grassmannian the pc graph space obntra tutrs nwihvcosadsbesare graph ex Grassmann subsets prominent the Two field. and are finite amples a vectors over spaces vector which by replaced in structures, combinatorial w osrcin o pcfi aaeesaepoie,a w as provided, gr are projective-space results. parameters the non-existence specific for some for As co constructions parameters. optimal two all cyclic for of given constructions are graph, co network grap Grassmann in projective-space the applications found For the recently have and which of graph, both Grassmann the graphs: o uvyo rycdsterae srfre o[25]. to referred is reader [35]. the [17], codes [6], Gray on memories recent survey flash a and for For [26], schemes devices measurement also [23 [24], compression ord data testing [15], [21], circuit puzzles encoding [10], signal a hashing [20], processor documents [5], [2], statistics applications [3], retrieval cation and storage and as such once, code. the than of similar application more constitutes the What on no depends space, “similar”. then, appears usually some are Since of element elements . elements each adjacent the Gray single of that a a listing today, such of a where means value usually made, the code were by generalizations differ word numerous adjacent list that the such once, in exactly appearing each words, G usae fan of subspaces the sthe as niern,BnGro nvriyo h ee,Be Shev [email protected]). Beer Negev, (e-mail: the of University Ben-Gurion Engineering, probl middle-levels [1] the systems and Steiner [34], [27], problems [11], graph reconstruction Grassmann the in codes l h usae fan of subspaces the all oh cwrzi ihteDprmn fEetia n Comp and Electrical of Department the 134/10. with grant ISF is by Schwartz part in Moshe supported was work This ne Terms Index utemr,ecdn n eoigagrtm r ie fo given are decoding and encoding Furthermore, Abstract nteps e er,itrs a rw in grown has interest years, few past the In areas, of variety wide a reached has codes Gray of use The xmlso such of Examples q aao fteJhsngah hra h atrcontains latter the whereas graph, Johnson the of -analog eeoiial enda itn faltebinary the all of listing a as defined [16], Gray originally Frank inventor, were their after named codes, RAY q aao fteHmiggraph. Hamming the of -analog Ga oe o etrsae r osdrdi two in considered are spaces vector for codes —Gray P Ga oe,eueaiecdn,Grassmannian, coding, enumerative codes, —Gray q ryCdsadEueaieCoding Enumerative and Codes Gray ( n n dmninlvco pc over space vector -dimensional ) h omrcnan l the all contains former The . .I I. q aaossrcue r oe n anti- and codes are structures -analogs n NTRODUCTION dmninlvco pc,adacts and space, vector -dimensional G q ( n , oh Schwartz, Moshe k o etrSpaces Vector for ) n h projective- the and , k 400,Israel 8410501, a GF -dimensional q aaosof -analogs ( q ) n is and , ering ding. aph, hms llo- des uter em ity ell ly h, ], r s eirMme,IEEE Member, Senior - , O eoigagrtmo 2]when [22] of decoding ylwrcs etr,adsaasb re etr.Frave a For letters. Greek by space vect scalars denote and with letters, shall lower-case We sometimes by dimension. spaces, the vector indicating for superscript letters upper-case of ing eto ihasmayadoe problems. open and in summary conclude a We codes. with in Gray V continue subspace Section We studying functions. by well IV decoding as Section and codes, encoding paper Gray provide the Grassmannian construct as throughout we used III notation Section In and definitions basic the loih f[8 when [28] of algorithm loihso 2] epoieaohrdcdn loih o algorithm decoding another complexity provide We [28]. of algorithms ih htntol rag h usae naGa oe but code, Gray a in subspaces in the operate arrange also only not that rithm 2]sgetdol eoigagrtmwt complexity with algorithm decoding a only suggested [22] eoe h ubro prtosrqie o utpyn t multiplying with for required numbers operations of number the denotes ibrti n tin[8,wopoie noigadde- and encoding complexity provided with who algorithms [28], coding Etzion and Silberstein 1] n otnigwt 8,[] 1] 1] 2][1,[ [29]–[31], Kschischang [14], and [13], [9], Koetter [8], re- of with of work continuing area and the [19], theoretical netw with purely to starting application a important coding, an as found begun recently has has search, what But [7]. r aitna icisi h rjciesaegah an graph, projective-space the in circuits Hamiltonian are eetyue stebssfra nmrtv-oigscheme space enumerative-coding Grassmannian an the for for was designed basis specifically [4], the Cover as A used to recently space. due algorithm Grassmannian an enumerative-coding obtain the general we for provide, scheme we enumerative-coding algorithms decoding and below. from encoding large bound we a which resulting codes, freedom, Gray The of of functions. degrees number decoding many and has encoding a construction for as latte codes well the Gray as optimal For parameters, cyclic [7]. for in constructions bas provide discussed we parameters problem specific middle-levels for non-cyc we the constructions and on former, as cyclic the well for as For (both codes), graph. results Grassmann non-existence the present in circuits tonian k q aaosfrcntn-egtGa oe,wihaeHamil- are which codes, Gray constant-weight for -analogs ( = hogottepprw hl ananantto consist- notation a maintain shall we paper the Throughout h ae sognzda olw:I eto Iw provide we II Section In follows: as organized is paper The nti okw study we work this In sasd feto h rycd osrcinadthe and construction Gray-code the of effect side a As M [ O W n ( 2 n ] vrsm nt field finite some over log 1 − O ǫ ) ( n M ) m O o some for epoieecdn n eoigalgo- decoding and encoding provide We . [ ( nk iisec.Aohrwr yMedvedeva by work Another each. digits M ] I P II. [ k nk log ] n k 0 RELIMINARIES k ) log ) q < ie h aecmlxt sthe as complexity same the time, hc uprom h decoding the outperforms which , aaoso rycds which codes, Gray of -analogs k GF ǫ = < ( k q O o = ) ( 1 ( elet we , n ,adotefrsthe outperforms and ), M o ) ( √ [ freape when example, (for nk n ] ) n dim . ) where , ( G W q ( ) n denote , M k ) 33]. ctor [ ork ors wo m by lic ed ll r, d a 1 f ] . 2 the dimension of W. For two subspaces, W and W , W + W to be cyclic and P is its period. If P = [n] , then is called 1 2 1 2 k q will denote their sum. If that sum happens to be a direct sum, optimal. we’ll stress that fact by denoting it as W1 W2. For a vector ⊕ A similar definition holds for the graph q(n). v GF(q)n, we shall denote the space spanned by v as v . P ∈Let Wn be some fixed n-dimensional vector space overh i Definition 4. Let Wn be an n-dimensional vector space over n GF(q). For an 0 6 k 6 n, we denote by [W ] the GF(q). An (n; q)-subspace , , is a sequence of k C set of all k-dimensional subspaces of Wn. distinct subspaces

Definition 1. The Grassmann graph q(n, k)=(V, E) is de- = C0, C1,..., CP 1, n G C − W n fined by the vertex set V = [ k ], and two vertices W1, W2 V n W ∈ where Ci k=0 [ k ], and where Ci and Ci+1 are neighbors in are connected by an edge iff dim(W1 W2) = k 1. ∈ ∩ − q(n) for all 0 6 i 6 P 2. We say P is the size of the code P S − The q-number of k is defined as . If C0 and CP 1 are neighbors in q(n) then is said to be C − ∑Pn n C k cyclic and P is its period. If P = k=0 [k]q, then is called 2 k 1 q 1 C [k] = 1 + q + q + + q − = − . optimal. q ··· q 1 − By abuse of notation we denote III. GRASSMANNIAN GRAY CODES In this section we will study Grassmannian Gray codes. [k]q! =[k]q[k 1]q ... [1]q. − We will first describe a construction, and later introduce and The Gaussian coefficient is defined for n, k, and q as analyze encoding and decoding algorithms. These algorithms may be used as an enumerative-coding scheme. n [n] ! = q k q [k]q![n k]q!   − A. Construction (qn 1)(qn 1 1) ... (qn k+1 1) = − − − − − . The construction we describe is recursive in nature. We will (qk 1)(qk 1 1) ... (q 1) − − − − be constructing an (n, k; q)-Grassmannian Gray code by com- It is well known that the number of k-dimensional subspaces bining together an (n 1, k; q)-code with an (n 1, k 1; q)- of an -dimensional space over is given by n . code. We start by introducing− two useful lemmas.− − n GF(q) [k]q Furthermore, the Gaussian coefficients satisfy the following Lemma 5. Let Wn be an n-dimensional vector space over n 1 k 1 GF(q). Let W − and W − be (n 1)-dimensional and n − n n 1 n k n 1 (k 1)-dimensional subspaces of W , respectively, where = − + q − − , − k q k q k 1 q k 1 n 1 n      −  W − W − W . ⊆ ⊂ as well as the symmetry n k n Then there are q vectors v ,..., v n k GF(q) such − 0 q − 1 n n that: − ∈ = , k n k 1) Wk 1 v Wn 1 = Wk 1.  q  − q − ⊕ h ii ∩ − − k 1 6 6 2) The subspacesW − vi are distinct for all 0 k n (for example, see [32]). ⊕ h i Another graph of interest is the following. Proof: To maintain the first requirement it is obvious that v Wn Wn 1. We have Definition 2. The projective-space graph q(n)=(V, E) is i ∈ \ − WnP defined by the vertex set V = n [ ], and two vertices n n 1 n n 1 k=0 k W W − = q q − W , W V are connected by an edge iff \ − 1 2 ∈ S vectors to choose from. However, having chosen a vector dim(W1) + dim(W2) 2 dim(W1 W2) = 1. n n 1 − ∩ v W W − , to maintain the first requirement we cannot choose∈ vectors\ of the form αv + w, where w Wk 1 and Equivalently, two vertices, W1 and W2, are connected in − α (q) . Since there are (q )qk 1 distinct∈ choices q(n) iff dim(W1) dim(W2) = 1, and either W1 W2 GF 0 1 − P | − | ⊂ of∈α and w,\ resulting{ } in distinct forbidden− vectors, the maximal or W2 W1. We now⊂ provide the definitions for the Gray codes that we number of vectors we can choose which maintain the two study in this paper. requirements is given by n qn qn 1 Definition 3. Let W be an n-dimensional vector space over − = qn k − k 1 − . GF(q).An (n, k; q)-Grassmannian Gray code, , is a sequence (q 1)q − of distinct subspaces C − k 1 A closer look at the proof of Lemma 5 reveals that W − = C0, C1,..., CP 1, n n 1 C − induces an equivalence relation on the vectors of W W − , Wn n n 1 \ where Ci [ k ], and where Ci and Ci+1 are neighbors in where v, v′ W W − are equivalent if there exist α (n, k), for∈ all 0 6 i 6 P 2. We say P is the size of the GF(q) 0 ∈and w\ Wk 1 such that v = αv + w. A set of∈ Gq − \ { } ∈ − ′ code . If C0 and CP 1 are neighbors in q(n, k) then is said vectors whose existence is guaranteed by Lemma 5 is merely C − G C 3

a list of representatives from each of the equivalence classes We continue in the same manner, where for Ci′′ we choose induced by Wk 1. For such a vector v and a subspace Wk 1, equivalence-class representatives v ,..., v , where also − − i′′,0 i′′,qn k 1 k 1 − we shall denote the equivalence class of v induced by W − − ∅ as [v] k 1. [v′′ n k ] [v′′ ] = . W i 1,q − 1 Ci′′ 1 i,0 Ci′′ − − − − ∩ 6 Lemma 6. Let Wn 1 and Wn, be as in Lemma 5. Assume − Finally, for CP′′ 1, the last subspace in C′, we need both a non- k 1 k 1 ′′− W1− and W2− are two distinct (k 1)-dimensional sub- empty intersection of n 1 n − n 1 spaces of W − . Then for any v W W − we have ∈ \ [v′′ n k ]C [v′′ ]C = ∅, P′′ 2,q − 1 P′′ 2 P′′ 1,0 P′′ 1 − − ′′− ∩ − ′′− 6 [v]Wk 1 =[v]Wk 1. 1 − 6 2 − as well as a non-empty intersection of Proof: We observe that [v′′ n k ]C [v0,0′′ ]C = ∅, P′′ 1,q − 1 P′′ 1 ∩ 0′′ 6 k 1 and k 1 − − ′′− [v]Wk 1 = v W1− [v]Wk 1 = v W2− . 1 − h i ⊕ 2 − h i ⊕ i.e., with the first equivalenceclass induced by the first subspace D E D E Let us assume to the contrary that C0. Since, by Lemma 6, [v′′ ] has a non-empty intersection 0,0 C0′′ with at least two equivalence classes induced by CP′′ 1, we can [v] k 1 =[v] k 1. ′′− W1 − W2 − always find a suitable set of representatives. We now construct the auxiliary sequence as follows: We therefore have C∗ k 1 n 1 k 1 = W − = W − v W − ∗ C0′′ v0,0′′ , C0′′ v0,1′′ ,..., C0′′ v0,′′ qn k 1 , 1 ∩ h i ⊕ 1 C ⊕ ⊕ ⊕ − − n 1   D E C1′′ v1,0′′ , C1′′ v1,1′′ ,..., C1′′ v′′ n k , = W − [v]Wk 1 1,q − 1 ∩ 1 − ⊕ ⊕ ⊕ − D E . D E n 1 . = W − [v]Wk 1 ∩ 2 − n 1 D Ek 1 = W − v W − CP′′ 1 v′′P 1,0 ,..., CP′′ 1 v′′P 1,qn k 1 . ∩ h i ⊕ 2 ′′− ⊕ ′′− ′′− ⊕ ′′− − − k 1   In a more conciseD form, E D E = W2− , which is a contradiction. C∗ = C0∗, C∗,..., C∗ n k 1 P′′q − 1 Intuitively speaking, Lemma 6 states that the equivalence − n n 1 is a sequence of length P qn k in which the ith element is the classes that partition W W − and are induced by distinct ′′ − \ n 1 subspace (k 1)-dimensional subspaces of W − , do not contain two identical− classes. This fact will be used later in the construc- tion. i∗ = C′′ n k v′′ n k n k . C i/q − ⊕ i/q − ,i mod q − We shall now build an (n, k; q)-Grassmannian Gray code by ⌊ ⌋  ⌊ ⌋  combining an (n 1, k; q)-code with an (n 1, k 1; q)-code. We now turn to use the code ′. Let us choose an arbitrary − − − 6 6 C index 0 j P′ 1, and denote U = Cj′ Cj′+1, where the Construction A. Let Wn be an n-dimensional vector space − ∩ indices are taken modulo P . We observe that U Wn 1 is a over GF(q). We can write Wn as the direct sum Wn = ′ − (k 1)-dimensional subspace. ⊆ Wn 1 W1, where dim(Wn 1) = n 1 and dim(W1) = 1. − − Since− contains all the (k 1)-dimensional subspaces of Let⊕ us assume the existence of two− cyclic optimal Grass- ′ Wn 1, letC i be the index such− that C = U. Finally, we also mannian Gray codes: an (n 1, k; q)-code , and an (n − i′′ ′ choose an arbitrary index 0 6 ℓ 6 qn k 2. 1, k 1; q)-code . In both− cases we assumeC the ambient− − ′′ We now construct the code by inserting− a shifted version vector− space is WnC 1. For convenience, let us denote the code − of into the auxiliary as follows:C sequences as C′ C∗

=C0∗, C1∗,..., Ciq∗ n k+ℓ ′ = C0′ , C1′ ,..., CP′ 1, C − C ′− C′ , C′ ,..., C′ , C′ , C′ ,..., C′ ′′ = C′′, C′′,..., C′′ . j+1 j+2 P′ 1 0 1 j 0 1 P′′ 1 − C − (1) Ciq∗ n k+ℓ+1,..., CP∗ qn k 1. From these two codes we shall construct a new (n, k; q)- − ′′ − − Grassmannian Gray code. ✷ We start with , and choose equivalence-class rep- C0′′ Theorem 7. The sequence of subspaces from Construction A resentatives v ,..., v by Lemma 5. Continuing C 0,0′′ 0,′′ qn k 1 is a cyclic optimal ( )-Grassmannian Gray code. − − n, k; q to C1′′, again we choose equivalence-class representatives, v ,..., v , where we make sure Proof: We start by showing that the subspaces in the code 1,0′′ 1,′′ qn k 1 − − are all distinct. We first note that the subspaces in ∗ are distinct from those in , since all the former intersectCWn 1 [v′′ n k ] [v′′ ] = ∅, ′ − 0,q 1 C0′′ 1,0 C1′′ C − − ∩ 6 in a (k 1)-dimensional subspace, while all the latter intersect n 1 − i.e., that the last equivalence class chosen for C0′′, and the first W − in a k-dimensional subspace. To continue, the subspaces equivalence class chosen for C , have a non-empty intersection. of are distinct by virtue of being a Grassmannian Gray 1′′ C′ C′ 4

code. Finally, we show that the subspaces of ∗ are distinct. of length 1 containing the full vector space, and the trivial Assume C space of dimension 0, respectively. C′′ v′′ = C′′ v′′ . We can get a lower bound on the number of distinct i1 ⊕ i1,j1 i2 ⊕ i2,j2 D E D E (n, k; q)-Grassmannian Gray codes that result from this con- Then struction, thus getting a lower bound on the number of such C = C v Wn 1 codes in general. The counting requires the following lemma. i′′1 i′′1 i′′1,j1 − ⊕ ∩ n 1 n 1  D E n 1 Lemma 9. Let W − and W − be as in lemma 5, and let = Ci′′ vi′′,j W − = Ci′′ . n 1 2 ⊕ 2 2 ∩ 2 C1, C2 W − be two (k 1)-dimensional subspaces such ⊂ − n n 1  D E that dim(C1 C2) = k 2. Then for any v1 W W − , Since ′′ is a Grassmannian Gray code, we must have i1 = i2. ∩ − ∈ \ C there exist exactly q distinct subspaces of the form C2 v2 , We thus have n n 1 ⊕ h i for some v2 W W − , such that C v = C v . ∈ \ i′′1 i′′1,j1 i′′1 i′′1,j2 ⊕ ⊕ dim ((C1 v1 ) (C2 v2 )) = k 1. D E D E ⊕ h i ∩ ⊕ h i − Since the vectors v′′ ,..., v′′ n k were chosen from dis- i1,0 i ,q 1 Proof: Let w , w ,..., w be a basis for C C . Let 1 − − 1 2 k 2 1 2 tinct equivalence classes, we again must have j1 = j2. Hence, us further denote − ∩ all the subspaces of are distinct. C Next, we show that any two subspaces which adjacent in C1 = w1,..., wk 2, u1 , h − i the list, intersect in a (k 1)-dimensional subspace. This is C2 = w1,..., wk 2, u2 . − h − i certainly true for adjacent subspaces in ′ since they form an C Given v Wn Wn 1, in order to obtain a subspace W (n 1, k; q)-Grassmannian Gray code. For ∗ we have 1 ∈ \ − 2 ⊕ − C v2 with the desired intersection dimension we must choose h i n n 1 C′′ v′′ C′′ v′′ = C′′ v2 W W − such that the equation i ⊕ i,j ∩ i ⊕ i,j+1 i ∈ \  D E  D E k 2 k 2 and so the intersection is (k 1)-dimensional. Furthermore, − − ∑ α w + αu + βv = ∑ γ w + γu + δv , and intersect in a − -dimensional subspace, since i i 1 1 i i 2 2 Ci′′ Ci′′+1 (k 2) i=1 i=1 they come from a (n 1, k −1; q)-Grassmannian Gray code. Since, by construction,− − holds for some choice of scalar coefficients αi, γi, α, β, γ, δ GF(q), with β = 0. We thus choose ∈ 6 [v′′ n k ] [v′′ ] = ∅, i,q 1 Ci′′ i+1,0 Ci′′+1 k 2 − − ∩ 6 1 − we have v2 = ∑ (αi γi)wi + αu1 γu2 + βv1. δ i=1 − −

dim Ci′′ v′′ n k Ci′′+1 vi′′+1,0 = k 1. Since multiplying v by a scalar does not change the ⊕ i,q − 1 ∩ ⊕ − 2 − subspace C v , we may conveniently choose δ = β 1. Let , , and ℓ,D be as in (1).E We can also easily  verify that at 2 2 − i j Hence, ⊕ h i the insertion points of ′ into ∗ we have C C k 2 − α γ α γ v = ∑ i − i w + u u + v . dim Ciq∗ n k+ℓ Cj′+1 = k 1, 2 i 1 2 1 − ∩ − i=1 β β − β   dim C∗ n k ℓ Cj′ = k 1, Finally, we note that adding a vector from to does not iq − + +1 ∩ − C2 v   change the subspace C v . We may therefore eliminate and thus, all adjacent subspaces in the sequence are also 2 ⊕ h 2i any linear combination of w1,..., wk 2, u2 from v. By denot- adjacent in the graph q(n, k). This also proves the code is − cyclic. G ing ǫ = α/β, we are left with choosing Finally, to show that the code is optimal we need to show v2 = v1 + ǫu1, that it contains all the k-dimensional subspaces of Wn. Since and there are exactly choices for ( ) which result in ′ and ′′ are optimal we have q ǫ GF q C C distinct subspaces as required. ∈ n k = ′ + q − ′′ We are now ready to state the lower bound on the number |C| C C n 1 n k n 1 n n of distinct (n, k; q)-Grassmannian Gray codes resulting from = − + q − − = = W . Construction A. We note that codes which are cyclic shifts of k q k 1 q k q | |    −    one another are still counted as distinct codes. Theorem 10. The number of distinct (n, k; q)-Grassmannian > 6 6 Theorem 8. For every n 1 and 0 k n there exists a Gray codes resulting from Construction A is lower bounded by cyclic optimal (n, k; q)-Grassmannian Gray code. (n i j) n k k i+j 1 n−k− i [ − ] − − Proof: Because of the recursive nature of Construction − i 1 i j 1 q A, the only thing we need to prove is that the basis for ∏ ∏ (q 1)q − q 1 !q − . i=1 j=1 − − ! the recursion exists. This is trivially true since (n, n; q)-    Grassmannian Gray codes and (n,0; q)-Grassmannian Gray Proof: Let us denote the number of (n, k; q)- codes which are cyclic and optimal are the unique sequence Grassmannian Gray codes by T(n, k; q). If either k = n or 5 k = 0, then T(n, k; q) = 1, which agrees with the claimed Assume M is a k n of rank k in reduced row lower bound. Let us therefore consider the case of 0 < k < n. echelon form, k 6 n. We× denote the set of k indices of columns During the construction process, we first choose an (n containing leading coefficients as Λ(M) 0,1,..., n 1 . 1, k 1; q)-code, which can be done in T(n 1, k 1; q−) We apply the following simple recursive⊆ transformation{ −τ }to − − − ways. We then need to choose the vectors vi′′,j to obtain M: If k = 0 then τ(M) is the degenerate empty matrix with 0 rows. Otherwise, assume k > 1. If the last column of M is the subspaces Ci′′ vi′′,j . For i = 0 we can arrange the ⊕ all zeros, then τ(M)=[τ(M∗) 0k 1], where M∗ is the k n k n k | × × q − subspaces in qD − E! ways. For subsequent values of (n 1) matrix obtained from M by deleting the last column. − i, 1 6 i 6 [n 1]  2, we can choose the first subspace If the last column of M is not all zeros, let i be the index of k−1 q − − the first row from the bottom which does not contain a zero in C v in one of q ways, according to Lemma 9. The i′′ ⊕ i′′,0 the last column. We multiply the ith row by a scalar such that rest ofD theE subspaces may be chosen arbitrarily in any one its last entry is 1. We then subtract suitable scalar multiples of of qn k 1 ! ways. Finally, for i = [n 1] 1, both the the ith row from other rows of M so that the resulting matrix − k−1 q − − − first subspace and last subspace are chosen from a set of M′ has a single non-zero entry in the last column (a 1 located q subspaces. At the worst case, we can choose them both in the ith row). We then delete the ith row and the last column in one of q(q 1) ways, and the rest of the subspaces in to get the (k 1) (n 1) matrix M′′. We recursively take − × − n k − τ(M ), append a column of 0’s to its right, and re-insert the q − 2 !. ′′ − ith column which we previously removed. The result is defined We then choose an (n 1, k; q)-code, which can be done   as τ(M). in T(n 1, k; q) ways. We− rotate and insert it into the code − constructed so far. However, since we already count cyclic Example 11. Let M be the 3 5 reduced row echelon form shifts of codes as distinct, we shall assume we do not rotate matrix × it, to avoid over-counting. We, thus, only have to choose where 10301 n k to insert it, in one of q − 1 ways. M = 01204 , −   Combining all of the above, we reach the recursion, 00012 T(n, k; q) > T(n 1, k 1; q)T(n 1, k; q)   − − − · where the entries are from GF(5). We then have [n 1] n k 1 n k k−1 q (q 1)q − − q − 1 !q − . 11000 · − − τ(M) = 02410 Solving the recursion, with the base cases of T(n, n; q) = 1   00031 and T(n,0; q) = 1, gives the desired lower bound.   ✷ B. Algorithms It is easily seen that τ(M) is in row echelon form, but not We now describe algorithms related to Grassmannian Gray in reduced row echelon form, i.e., the leading coefficient of codes. The algorithms we consider are: each row is non-zero (but not necessarily 1), the entries below 1) Encoding – Finding the ith element in the code. a leading coefficient are 0 (but not necessarily 0 above it), 2) Decoding – Finding the index in the list of a given and the leading coefficient of each row is strictly to the right element of the code. of the leading coefficient of the previous row. We note that We will specialize Construction A to allow for simpler algo- Λ(M) = Λ(τ(M)). rithms. Thus, for a k-dimensional subspace Wk, and the unique We require some more notation. Throughout this section we reduced row echelon form matrix M whose rows form a k denote by ei the ith standard unit vector, i.e., the vector all of basis for W , we shall call τ(M) the canonical matrix whose entries are 0 except for the ith one being 1. The length representation of Wk. To avoid excessive notation we shall of the vector will be implied by the context. The entries of a refer to both the subspace and its canonical matrix as Wk. We length n vector will be indexed by 0,1,..., n 1. The n n say Wk is simple if identity matrix will be denoted by I , and the n− n all-zero× n 1 × 2 k matrix by 0 . W = [Ik 0n k] . n1 n2 | − A k-dimensional× subspace Wk of an n-dimensional space We now start with specializing Construction A. First, during can be represented by a k n matrix whose rows form a basis the construction we require a choice of Wn and Wn 1. We for Wk. Many choices for× such a matrix exist, and we shall be − choose both to be simple subspaces. interested in a unique one. We will first describe the reduced Next, in the construction we have ′′ = C′′,..., C′′ , and row echelon form matrix, which is known to be unique, and C 0 P′′ 1 for each C ,a (k 1)-dimensional subspace of Wn 1,− we find then transform it to obtain our representation. i′′ − − qn k vectors from Wn Wn 1, denoted v ,..., v . In a reduced row echelon form matrix, the leading coeffi- − − i′′,0 i′′,qn k 1 \ − − cient of each row is 1, and it is the only non-zero element in We make this choice explicit: let Ci′′ be a (k 1) (n 1) < < −< × − its column. Furthermore, the leading coefficient of each row canonical matrix. Let 0 6 ri,0 ri,1 ri,n k 1 6 ···Λ − − is strictly to the right of the leading coefficient of the previous n 2 be the elements in 0,1,..., n 2 (Ci′′). We note that− is not in the subspace{ , for− all} \ℓ. For an integer row. eri,ℓ Ci′′ 6

n k 0 6 j 6 q − 1, let [j]ℓ denote its ℓth digit when written in where base q, i.e., − n k 1 1 n 1 n 1 − − ℓ i = m − + 1 mod − j = ∑ [j]ℓq , n k $ q − − k q !% k 1 q ℓ=0    −  n 1 n k where [j]ℓ 0,1,..., q 1 . For convenience, we also de- j = m − + 1 mod q − ∈ { − } − k note the elements of GF(q) as α0, α1,..., αq 1, in some fixed  q ! order, where ρ( ) gives the reverse mapping,− i.e., ρ(α ) = i. n k 1 · i − − We now choose vi′′,j = en 1 + ∑ α[j]ℓ eri,ℓ . − ℓ=0 n k 1 − − vi′′,j = en 1 + ∑ α[j]ℓ eri,ℓ . We also note, that in the last case, where the vector v is − ℓ i′′,j =0 appended as another row to the generating matrix, the vector In Construction A, when inserting a shifted version of ′, is inserted between the correct rows such that the resulting n k C a parameter 0 6 ℓ 6 q − 2 is chosen. We shall call this matrix is canonical. parameter the insertion offset−. In this instance, we will always The decoding function, choose ℓ = 0. Finally, we say a cyclic optimal (n, k; q)-Grassmannian Wn n n,k;q : 0,1,..., 1 , Gray code, = C0, C1,..., CP 1, is simple, if C0 is simple, D k → k − C −   (  q ) and C0 CP 1 is simple. ∩ − is defined as the reverse of the encoding function, i.e., Lemma 12. Let ′ be a simple cyclic optimal (n 1, k; q)- Grassmannian GrayC code, and be a simple cyclic− opti- C′′ mal (n 1, k 1; q)-Grassmannian Gray code. Let = n,k;q n,k;q(m) = m, − − C D E C0, C1,..., CP 1 be the cyclic optimal (n, k; q)-Grassmannian   Gray code created− by Construction A, with an insertion offset for all 0 6 m 6 [n] 1. k q − ℓ = 0. Then its shifted version, To describe the decoding function we need some preparation work. Assume the input to the decoding function is a k- = C1, C2,..., CP 1, C0, k C − dimensional subspace W , which will also denote a canonical k is a simple cyclic optimal (n, k; q)-Grassmannian Gray code. matrix whose row span is W . n 1 k n 1 Since W − is simple, checking whether W W − Proof: The fact that is a cyclic optimal (n, k; q)-code k⊆ C amounts to checking whether the last column of W contains is trivial. It remains to prove the code is simple. Let us denote k n 1 only 0’s. If this is not the case, then dim(W W − ) = k 1, and by construction there is a unique row∩ with a non- ′ = C0′ , C1′ ,..., CP′ 1, − C ′− zero entry in the last coordinate. We denote this row v′′, ′′ = C0′′, C1′′,..., CP′′ 1. and its last coordinate must be 1. Furthermore, we remove C ′′− this row and the last column from Wk and denote the re- Since ′ is simple, we have that C0′ is simple, and that C0′ k 1 C ∩ sulting canonical matrix by W − . Finally, like before, let C′ is simple. The latter intersection determines where ′ is P′ 1 6 < < < 6 − n k C 0 r0 r1 rn k 1 n 2 be elements of inserted in ∗, i.e., between the q − subspaces derived from ··· k 1 − − − C 0,1,..., n 2 Λ(W − ). the simple (k 1)-dimensional space. Since ′′ is also simple, { − } \ − n k C With this notation we can now easily find that it is inserted in the first set of q − subspaces derived from C . By using an insertion offset ℓ = 0, we have that C = C , 0′′ 1 0′ 0 k = 0 or k = n, and that C C = C . Thus, is simple. 1 ∩ 0 0′′ C k k k n 1 We are now in a position to state simple encoding and n,k;q(W ) =  n 1,k;q(W ) W W − , (2) D D − ⊆ decoding functions. The encoding function i otherwise,

n Wn where  : 0,1,..., 1 , En,k;q k − → k (  q )   n 1 n k k 1 maps an index m to the the mth subspace in the (n, k; q)- i = − + q − n 1,k 1;q(W − ) 1 k ·D − − − Grassmannian Gray code constructed above. Using the  q observations so far, we canC easily state that n k 1 − − ℓ n k n 1 + ∑ ρ erℓ v′′ q mod q − − . ℓ= · ! k 1 q! [Ik 0k (n k)] k = 0 or k = n, 0  −  | × −  [ (m) 0 ] m 6 [n 1] 1,  n 1,k;q k 1 −k q k n 1 n,k;q(m) =  E − | × − We also note that in the case of W W − , when applying E  n 1,k 1;q(i) 0(k 1) 1 k ⊆ k  − − otherwise, n 1,k;q to W we remove the last column of W , which is  E | − × D − " vi′′,j # an all-zero column.    7

C. Complexity Analysis shown in [28], from this Gaussian coefficient we may derive [n 1] and [n 1] by k−1 q −k q The goal of this section is to bound the number of operations − required to perform the encoding and decoding procedures n n 1 qn 1 described in the previous section. = − − , (3) k k 1 · qk 1 For our convenience, we assume throughout this section  q  − q − n n 1 qn 1 that integers are represented in base q. Thus, multiplying and = − − , (4) dividing by q amount to simple shift operations on the list of k k · qn k 1  q  q − − digits. with additional O(M[nk]) operations. Another simplification is enabled by the following lemma. As we examine the algorithm as given in (2), even though it is presented as a recursive algorithm, it is a tail recursion, and Lemma 13. Let = C , C ,..., C be an (n, k; q)- 0 1 P 1 so, may be considered as an iterative process. At the beginning Grassmannian GrayC code. Then the dual code,− of each iteration we check the last column of the matrix to see if it is all 0’s. This takes O(k) time. ⊥ = C0⊥, C1⊥,..., CP⊥ 1, C − For the second case of (2), when Wk Wn 1, we delete ⊆ − is an (n, n k; q)-Grassmannian Gray code. If is cyclic, then the last column, taking O(k) time. For the third case of (2), we − C need to compute [n 1] and [n 1] from [n] , taking ( [ ]) so is ⊥. Also, if is optimal, then so is ⊥. −k q k−1 q k q O M nk C C C operations. Multiplication by− q amounts to a simple shift Proof: Obviously dim(C ) = n k for all i. Since i⊥ − operation, and addition and subtraction of numbers with nk (C⊥)⊥ = Ci, the elements of ⊥ are all distinct. To verify digits takes time. We note that finding the numbers i C O(nk) rℓ that adjacent elements in ⊥ are also adjacent in q(n, n k) for 6 ℓ 6 n k is easily seen to take at most O(n) C G − 0 1 we use simple linear algebra. For all i, time. Deleting a− row− and a column takes O(n) time. Finally, we note that the sole purpose of the modulo operation is to n 1 Ci⊥ Ci⊥+1 = (Ci + Ci+1)⊥ . transform a possible outcome into n k[ ] which 1 q − k−1 q 1 ∩ − − − may be done in O(nk) time (since we have already computed Since dim(C C ) = k 1, we have i i+1 [n 1] ). The total number of operations for the last case of the ∩ − k−1 q − dim(Ci + Ci+1) = dim(Ci) + dim(Ci+1) decoding procedure is therefore bounded by O(M[nk]). Since the total number of rounds is at most n, the entire algorithm dim(Ci Ci+1) − ∩ may be run in time O(M[nk]n). The same analysis holds for = k + 1. the encoding algorithm. It then follows that Theorem 14. The computation complexity of the encoding and decoding algorithms is O(M[nk]n). dim(C⊥ C⊥ ) = n dim (C + C )⊥ = n k 1, i ∩ i+1 − i i+1 − − The complexity of the algorithms from [28] is the same as those presented in this work. However, the algorithms here also hence, C⊥ and C⊥ are adjacent in q(n, n k). If we take i i+1 G − provide a Gray ordering of the subspaces. We also mention all indices modulo P, then is cyclic if is cyclic. Finally, ⊥ [22], in which only a decoding algorithm was suggested, with- [n] = [ n ] implies that C is optimal ifC is optimal. k q n k q C⊥ C out Gray coding, achieving complexity of O(M[n2] log n). − 6 In light of Lemma 13, we will assume throughout that 2k We can, however, improve the complexity of the decoding n, and in particular, that n k = Θ(n). − procedure for a certain asymptotic range of k by changing An important ingredient in the analysis is the complexity of the way we compute (2). We start by changing the way we multiplying two numbers, each with m digits. We denote this compute the Gaussian coefficients. By definition, number as M[m]. Using the Sch¨onhage-Strassen algorithm we n n 1 n k+1 have M[m] = O(m log m log log m) (for example, see [18]). n (q 1)(q − 1) ... (q − 1) = − − − . We can alternatively use the more recent algorithm due to k (qk 1)(qk 1 1) ... (q 1)  q − F¨urer [12], for which M[m] = O(m log m2log∗ m). We also − − − Our strategy to compute this value is to compute separately note that division of two numbers with m digits each also the numerator and denominator, and then perform division. requires O(M[m]) operations [18]. To compute the numerator, we partition the parentheses into We now turn to the analysis of the decoding algorithm. We k pairs and compute their product, partition the k/2 results into observe that all the integers involved require at most nk digits pairs, and so on. For ease of presentation we can assume k to represent. As a first step, we compute [n] . It was shown in k q is a power of to avoid rounding, and this has no effect on 1 2 [28] that the complexity of this is O(M[nk]k) . As was also the overall complexity. Initially, each of the numbers in the numerator may be represented by n digits in base q. Thus, the 1 To be more precise, it was shown in [28] that computing n 1 takes [ −k ]q total number of operations to compute the numerator is O(kn(n k) log n log log n) operations. To facilitate a comparison with the − complexity analysis we perform, and by taking n k = Θ(n) due to Lemma log k k nk log k M[2i 1n] 13, we may rewrite the result of [28] as O(M−[nk]k). We will implicitly [ i 1 ] = − 6 [ ] ∑ i M 2 − n ∑ i 1 M nk/2 log k, perform this translation whenever comparing with [28], and later, with [22]. i=1 2 2 i=1 2 − n 8 where the last inequality is due to the fact that M[m]/m Theorem 17. There are no optimal (n; q)-subspace Gray codes is a non-decreasing function. The same analysis applies to (not necessarily cyclic) when n > 2 is even, except for n = 2 the denominator. Finally, we need to divide the numerator and q = 2. and denominator, each with at most nk digits, thus requiring Proof: The proof is similar to that of Theorem 16. Again, additional ( [ ]) operations. It follows that computing O M nk let n = 2m, m > 1, and assume to the contrary such a code [n] requires O(M[nk] log k). k q exists, and = C0, C1,..., CP 1. By the definition of the The analysis of the remaining part of the algorithm is nearly code,C every timeC an m-dimensional− subspace appears in the the same. The only difference is that we do not use (3) and sequence, it is followed by an (m + 1)-dimensional subspace (4) at every iteration. Instead, whenever we find ourselves or an (m 1)-dimensional subspace, except if it is the last in in the third case of (2) we compute the necessary Gaussian the sequence.− Since the code is optimal, all subspaces appear coefficients from scratch. We now make the crucial observation and so we must have that the algorithm takes at most n iterations, at most k of which 2m 2m 2m take the third case of (2). Thus, the total number of operations + > 1. (6) m + 1 m 1 m − for a decoding procedure is O(M[nk]k log k).  q  − q  q Theorem 15. The decoding algorithm may be run using However, by the proof of Theorem 16 we already know that O(M[nk]k log k) operations. 2m 2m 2m + < . m + 1 m 1 m We note that when k log k = o(n) (for example, when  q  − q  q 1 ǫ k = O(n − ) for some 0 < ǫ < 1) the decoding algorithm Thus, the only way for (6) to hold is that we presented outperforms the decoding algorithm of [28], 2m 2m 2m including the O(n2k2) decoding algorithm of [28] for the + = 1. m + 1 m 1 m − smaller range of k < log n log log n. Furthermore, when  q  − q  q k = o(√n), the decoding algorithm we presented outperforms Using (5), we therefore need the decoding algorithm of [22]. 2m 2qm 2 (7) = 1 + m+1 −m . m q q 2q + 1 IV. SUBSPACE GRAY CODES   − When q > 4, and for all m > 1, we have This section is devoted to study of subspace Gray codes. Unlike optimal Grassmannian Gray codes, which exist for all 0 < 2qm 2 < qm+1 2qm + 1, parameters, the case of subspace Gray codes appears to be − − and so the RHS of (7) is not an integer. more complicated. We begin with nonexistence results, and When , for similar reasons, the RHS of (7) is not an then continue to constructing subspace Gray code for a limited q = 3 integer except when , but then set of cases. m = 1 2 2 31 2 = 4 = 2 = 1 + · − . 1 6 32 2 31 + 1 A. Nonexistence Results  3 − · The next two theorems show that for half of the parameter Finally, when q = 2, (7) becomes space, optimal subspace Gray codes (cyclic or not) do not 2m = 2m+1 1. exist. m −  2 Theorem 16. There are no cyclic optimal (n; q)-subspace Gray We observe that codes when n > 2 is even, over any finite field GF(q). 2m [2m] ! = 2 > m [m] ![m] ! Proof: Let n = 2m, m 1. Assume to the contrary such  2 2 2 2m 2m 1 m+1 a code exists, and = C0, C1,..., CP 1. By the definition (2 1)(2 − 1) ... (2 1) C C − = of the code, every time an m-dimensional subspace appears in m− m 1− 1 − (2 1)(2 − 1) ... (2 1) the sequence, it is followed (perhaps cyclically) by an (m + 1)- − − − 22m 1 22m 2 2m dimensional subspace or an -dimensional subspace. > − − (m 1) 2 m · m 1 ·····1 Since the code is optimal, all subspaces− appear and so we 2 2 − 2 m(m 1·) ····· must have = 2 − . 2m 2m 2m For m > 3 we have + > . m + 1 m 1 m m(m 1) m+1 q q q 2 − > 2 1.    −    − However, Thus, to complete the proof we only need to check the case 2m 2m of , for which we find that m+1 m = 2 [ m ]q [ m ]q 1 q 1 = = − > 1, (5) 4 [ 2m ] + [ 2m ] 2[ 2m ] 2 · qm 1 = 35 = 7 = 23 1. m+1 q m 1 q m 1 q − 2 6 − − −  2 for all q > 2. 9

We note that there does indeed exist an optimal non-cyclic noted in [7], if gcd(n, m) = 1 then the size of any equivalence n (2;2)-subspace Gray code: class is [1]q, and in particular, does not depend of m. Etzion proved the following two theorems, which will be = (1,0) , (0,0) , (0,1) , (0,1), (1,0) , (1,1) . C h i h i h i h i h i the starting point for our next construction. n B. Constructions Theorem 20. [7] Let n = 2m + 1 and let W be an n- dimensional vector space over GF(q), with α GF(q) a prim- We now turn to the question of whether cyclic optimal itive element. Assume = X , Y , X , Y ,...,∈X , Y is a -subspace Gray codes exist when is odd. The answer 0 0 1 1 s 1 s 1 (n; q) n sequence of distinct necklacesL representatives such− that − is trivial when n = 1. We also answer this in the positive for the cases of n = 3,5 by using the q-analog solution to Wn Wn X Y , the middle-level problem given in [7]. We first describe the i ∈ m i ∈ m + 1     q-analog of the middle-level problem, and then show how a and solution there gives a cyclic optimal subspace Gray code. n X Y Y X . Let n = 2m + 1 be an odd positive integer, and let W be i ⊂ i i ⊃ i+1 a vector space over GF(q). We consider the following graph ℓ ℓ n n n If α X0 Ys 1 with gcd( , [ ] ) = 1, then W W ⊂ − 1 q q(2m + 1): the vertex set of the graph is [ m ] [m+1], M ∪ n and two vertices W1 and W2 are connected by an edge iff ℓ ℓ [ ] 1 ℓ = , α , α2 ,..., α 1 q− , W W or W W . An (n; q)-subspace Gray code for   1 ⊂ 2 2 ⊂ 1 C L L L L the middle levels is a in q(n), and it is is a cyclic (n; q)-subspace Gray code for the middle levels. cyclic if it is a Hamiltonian circuit. M Etzion [7] proved the following theorem: Theorem 21. [7] For any q, a power of a prime, and n = 5, there exists a sequence as in Theorem 20, resulting in a cyclic Theorem 18. [7] For any q, a power of a prime, there exists a optimal (5; q)-subspace Gray code for the middle levels. cyclic optimal (3; q)-subspace Gray code for the middle levels. While Theorem 20 refers to subspaces in the middle levels, Using Theorem 18, we can prove the following theorem. it can be easily generalized. Theorem 19. For any q, a powerof a prime,there exists a cyclic Theorem 22. Let Wn be an n-dimensional vector space over optimal (3; q)-subspace Gray code. GF(q), and let α GF(q) be a primitive element. Assume ∈ Proof: Let ′ be the code guaranteed by Theorem 18, = X0, X1,..., Xs 1 is a path in q(n) visiting only repre- C sentativesL of distinct− necklaces. If allP the visited necklaces are ′ = C0, C1,..., CP 1, ℓ C ′− of equal size N, α X0 and Xs 1 are adjacent in q(n), and − P where gcd(ℓ, N) = 1, then 3 3 2 P′ = + = 2(q + q + 1). ℓ 2ℓ (N 1)ℓ 1 2 = , α , α ,..., α − ,  q  q C L L L L is a cyclic -subspace Gray code. We note that P′ is even. Since this code contains all the (n; q) subspaces in the middle levels, the only two vertices of Proof: It can be easily verified that all adjacent elements (3) not covered are W3, the entire space, and W0, the 0- Pq in are adjacent in q(n) (including the first and last one), dimensional trivial subspace. andC since all necklacesP are of equal size, all the elements of Since is cyclic, let us assume, without loss of generality, C′ are distinct. that dim(C0) = 1. We now pick an arbitrary odd integer C We are now in a position to state and prove a construction 1 6 i 6 P 3, and construct the sequence, ′ − for (5; q)-subspace Gray codes. 0 3 = W , C0, C1,..., Ci, W , CP 1, CP 2,..., Ci+1. Theorem 23. For any , a powerof a prime,there existsa cyclic C ′− ′− q We contend is a cyclic optimal (3; q)-subspace Gray code. optimal (5; q)-subspace Gray code. C Trivially, contains all the subspaces of W3 exactly once. 5 C Proof: Let W be a 5-dimensional vector space over Furthermore, since originally dim(Ci) = 1 iff i is even, and GF(q). Since 5 is prime, the sizes of necklaces of dimensions dim(Ci) = 2 iff i is odd, the resulting sequence is indeed a 5 1 through 4 are all the same and equal to [1]q. In particular, cyclic subspace Gray code. this means that there is exactly one necklace of dimension 1, For the construction of (5; q)-subspace Gray codes we and exactly one necklace of dimension 4. require a more in-depth view of Etzion’s construction from [7]. Let n Let W1 and W2 be two m-dimensional subspaces of W over = X0, Y0, X1, Y1,..., Xs 1, Ys 1, some finite field GF(q). We say W1 and W2 are equivalent if L − − there exists some α GF(q) such that be a sequence of necklaces representatives, dim(X ) = 2, ∈ i dim(Y ) = 3, as in Theorem 21, where W = αW = αw w W . i 1 2 { | ∈ 2} 5 5 5 5 It is easy to see that this is indeed an equivalence relation, and s = = = q2 + 1 > 2. 2 1 3 1 the equivalence classes were called necklaces in [7]. As also  q,  q  q,  q 10

We construct by reversing the order of Y and X , and V. CONCLUSION L′ 0 1 inserting two new necklaces, We studied optimal Gray codes for subspaces in two set- tings: the Grassmann graph, and the projective-space graph. ′ = X0, X0 X1, X1, Y0, Y0 + Y1, Y1,..., Xs 1, Ys 1. L ∩ − − In the first case we were able to construct cyclic optimal Gray codes for all parameters using a recursive construction. Since , while = , ( ) = ( ) = X0, X1 Y0 X0 X1 dim X0 dim X1 In addition, simple recursive encoding and decoding functions , and ⊂ , we must6 have 2 dim(Y0) = 3 were provided. These algorithm induce an enumerative-coding scheme, which is at least as efficient as known schemes, and dim(X X ) = 1. 0 ∩ 1 for certain parameters, surpasses them. Furthermore, Y , Y X , and Y = Y , hence In the case of the projective-space graph, it was shown 0 1 ⊃ 1 0 6 1 that there are no optimal Gray codes (cyclic or not) in the projective-space graph of even dimension. For odd dimensions, dim(Y0 + Y1) = dim(Y0) + dim(Y1) dim(Y0 Y1) = 4. − ∩ we were able to show a construction for dimensions 3 and , which are derived from constructions for the middle-levels The sequence ′ clearly satisfies the requirements of The- 5 L problem of the same dimension. orem 22. Let ′ be the cyclic (5; q)-subspace Gray code C Two related open questions arise: the first is whether there constructed in Theorem 22 using ′. It is easily seen that L 5 5 exist cyclic optimal subspace Gray codes for all even dimen- ′ contains all of the subspaces of W except for W and WC 0, the trivial 0-dimensional subspace. We use a series of sions. The second questions, is whether a reverse connection sub-sequence reversals, similar to the above reversal, to make exists which derives optimal codes for the middle-levels prob- room to insert W0 and W5. lem from a subspace Gray code. Even in 3 dimensions the answer to the latter is not clear. The code ′ is comprised of sub-sequence blocks of the iℓ C form α ′, L ACKNOWLEDGMENTS 5 ℓ ℓ 2ℓ [1] 1 ′ = ′, α ′, α ′,..., α q− ′. The author would like to thank Tuvi Etzion for valuable C L L L   L discussions which contributed to the content of this paper. The There are 5 such blocks, each of length 2 . author would also like to thank Muriel M´edard for hosting him [1]q s + 2 = q + 3 ℓ We now zoom in on the first two blocks, and α . First, at MIT during his sabbatical. L′ L′ in the block ′, we reverse the order of the 3rd, 4th, and 5th elements, thusL obtaining REFERENCES [1] M. Braun, T. Etzion, P. R. J. Osterg˚ard,¨ A. Vardy, and A. Wassermann, ′′ = X0, X0 X1, Y0 + Y1, Y0, X1, Y1,..., Xs 1, Ys 1. “Existence of q-analogs of Steiner systems,” Apr. 2013. [Online]. L ∩ − − Available: http://arxiv.org/pdf/1304.1462v2 ℓ ℓ [2] C. C. Chang, H. Y. Chen, and C. Y. Chen, “Symbolic Gray code as a We do the same in α and obtain α . We note that except L′ L′′ data allocation scheme for two-disc systems,” Comput. J., vol. 35, pp. for X0 X1 and Y0 + Y1, any two adjacent elements in the 299–305, 1992. ∩ [3] M. Chen and K. G. Shin, “Subcube allocation and task migration in sequence are also adjacent in q(n). P ℓ machines,” IEEE Trans. Comput., vol. 39, pp. 1146–1155, Next, in the combined two blocks ′′, α ′′, we reverse the 1990. L L [4] T. Cover, “Enumerative source encoding,” IEEE Trans. Inform. Theory, sequence of elements starting from Y0 + Y1 and ending with ℓ vol. 19, no. 1, pp. 73–77, Jan. 1973. α (X X ), and then insert W5 and W0 to obtain 0 ∩ 1 [5] P. Diaconis and S. Holmes, “Gray codes for randomization procedures,” Stat. Comput., vol. 4, pp. 287–302, 1994. 0 ℓ ℓ ∗ = X0, X0 X1, W , α (X0 X1), α X0, [6] E. En Gad, M. Langberg, M. Schwartz, and J. Bruck, “Constant-weight L ∩ ∩ Gray codes for local rank modulation,” IEEE Trans. Inform. Theory, Ys 1, Xs 1, Ys 2, Xs 2 ..., Y2, X2, vol. 57, no. 11, pp. 7431–7442, Nov. 2011. − − − − 5 ℓ ℓ [7] T. Etzion, “The q-analog of the middle levels problem,” Mar. 2013. Y1, X1, Y0, Y0 + Y1, W , α (Y0 + Y1), α Y0, [Online]. Available: http://arxiv.org/pdf/1303.7110v1 ℓ ℓ ℓ ℓ [8] T. Etzion and N. Silberstein, “Error-correcting codes in projective space α X1, α Y1,..., α Xs 1, α Ys 1. − − via rank-metric codes and Ferrers diagrams,” IEEE Trans. Inform. The- ory, vol. 55, no. 7, pp. 2909–2919, Jul. 2009. It is now easy to verify that ∗ describes a path in q(n), [9] T. Etzion and A. Vardy, “Error-correcting codes in projective space,” L P IEEE Trans. Inform. Theory, vol. 57, no. 2, pp. 1165–1173, Feb. 2011. and that replacing the first two blocks in ′ with ∗ gives C L [10] C. Faloutsos, “Gray codes for partial match and range queries,” IEEE Trans. Software Eng., vol. 14, pp. 1381–1393, 1988. 5 ℓ 2ℓ 3ℓ [1] 1 [11] P. Frankl and R. M. Wilson, “The Erd¨os-Ko-Rado theorem for vector = ∗, α ′, α ′,..., α q− ′, C L L L   L spaces,” J. Combin. Theory Ser. A, vol. 43, pp. 228–236, 1986. [12] M. F¨urer, “Faster integer multiplication,” SIAM J. Comput., vol. 39, pp. which is indeed a cyclic optimal (5; q)-subspace Gray code. 979–1005, Sep. 2009. [13] M. Gadouleau and Z. Yan, “Constant-rank codes and their connection to constant-dimension codes,” IEEE Trans. Inform. Theory, vol. 56, no. 7, We remark in passing that the choices for which sub- pp. 3207–3216, Jul. 2010. sequences to reverse in the proof, were made specific for [14] ——, “Packing and covering properties of subspace codes for error ease of presentation. A similar more general construction can control in random linear network coding,” IEEE Trans. Inform. Theory, vol. 56, no. 5, pp. 2097–2108, May 2010. be described, in which the reversal process allows for more [15] M. Gardner, “The curious properties of the Gray code and how it can choices of reversal positions. be used to solve puzzles,” Scientif. Amer., vol. 227, pp. 106–109, 1972. 11

[16] F. Gray, “Pulse code communication,” March 1953, U.S. Patent 2632058. [17] A. Jiang, R. Mateescu, M. Schwartz, and J. Bruck, “Rank modulation for flash memories,” IEEE Trans. Inform. Theory, vol. 55, no. 6, pp. 2659–2673, Jun. 2009. [18] D. E. Knuth, The Art of Computer Programming Volume 2: Seminumer- ical Algorithms. Addison Wesley, Reading, MA, 3rd ed., 1997. [19] R. Koetter and F. R. Kschischang, “Coding for errors and erasures in random network coding,” IEEE Trans. Inform. Theory, vol. 54, pp. 3579–3591, Aug. 2008. [20] R. M. Losee, “A Gray code based ordering for documents on shelves: classification for browsing and retrieval,” J. Amer. Soc. Inform. Sci., vol. 43, pp. 312–322, 1992. [21] J. M. Ludman, “Gray codes generation for MPSK signals,” IEEE Trans. Communications, vol. COM-29, pp. 1519–1522, 1981. [22] Y. Medvedeva, “Fast enumeration for Grassmannian space,” in Pro- ceedings of the 2012 IEEE International Symposium on Problems of Redundancy in Information and Control Systems, St. Petersburg, Russia, Sep. 2012, pp. 48–52. [23] D. Richards, “Data compression and Gray-code sorting,” Information Processing Letters, vol. 22, pp. 201–205, 1986. [24] J. Robinson and M. Cohn, “Counting seqeuences,” IEEE Trans. Comput., vol. C-30, pp. 17–23, May 1981. [25] C. D. Savage, “A survey of combinatorial Gray codes,” SIAM Rev., vol. 39, no. 4, pp. 605–629, Dec. 1997. [26] M. Schwartz and T. Etzion, “The structure of single-track Gray codes,” IEEE Trans. Inform. Theory, vol. 45, no. 7, pp. 2383–2396, Nov. 1999. [27] ——, “Codes and anticodes in the Grassman graph,” J. Combin. Theory Ser. A, vol. 97, no. 1, pp. 27–42, Jan. 2002. [28] N. Silberstein and T. Etzion, “Enumerative coding for Grassmannian space,” IEEE Trans. Inform. Theory, vol. 57, no. 1, pp. 365–374, Jan. 2011. [29] D. Silva and F. R. Kschischang, “On metric for error correction in network coding,” IEEE Trans. Inform. Theory, vol. 55, no. 12, pp. 5479– 5490, Dec. 2009. [30] D. Silva, F. R. Kschischang, and R. Koetter, “A rank-metric approach to error control in random network coding,” IEEE Trans. Inform. Theory, vol. 54, no. 9, pp. 3951–3967, Sep. 2008. [31] V. Skachek, “Recursive code construction for random networks,” IEEE Trans. Inform. Theory, vol. 56, no. 3, pp. 1378–1382, Mar. 2010. [32] J. H. van Lint and R. M. Wilson, A Course in Combinatorics, 2nd Edition. Cambridge Univ. Press, 2001. [33] S. T. Xia and F. W. Fu, “Johnson type bounds on constant dimension codes,” Designs, Codes and Cryptography, vol. 50, pp. 163–172, 2009. [34] E. Yaakobi, M. Schwartz, M. Langberg, and J. Bruck, “Sequence reconstruction for Grassmann graphs and ,” in Proceedings of the 2013 IEEE International Symposium on Information Theory (ISIT2013), Istanbul, Turkey, Jul. 2013. [35] Y. Yehezkeally and M. Schwartz, “Snake-in-the-box codes for rank modulation,” IEEE Trans. Inform. Theory, vol. 58, no. 8, pp. 5471– 5483, Aug. 2012.