Kernels and ranks of cyclic and negacyclic quaternary codes

We study the rank and kernel of Z4\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathbb {Z}}_4$$\end{document} cyclic codes of odd length n and give bounds on the size of the kernel and the rank. Given that a cyclic code of odd length is of the form C=⟨fh,2fg⟩\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { C}= \langle fh, 2fg \rangle $$\end{document}, where fgh=xn-1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$fgh=x^n-1$$\end{document}, we show that ⟨2f⟩⊆K(C)⊆C\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\langle 2f \rangle \subseteq \mathcal { K}(\mathcal { C}) \subseteq \mathcal { C}$$\end{document} and C⊆R(C)⊆⟨fh,2g⟩\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { C}\subseteq \mathcal { R}(\mathcal { C}) \subseteq \langle fh, 2g \rangle $$\end{document} where K(C)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { K}(\mathcal { C}) $$\end{document} is the preimage of the binary kernel and R(C)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { R}(\mathcal { C})$$\end{document} is the preimage of the space generated by the image of C\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { C}$$\end{document}. Additionally, we show that both K(C)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { K}(\mathcal { C})$$\end{document} and R(C)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { R}(\mathcal { C})$$\end{document} are cyclic codes and determine K(C)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { K}(\mathcal { C})$$\end{document} and R(C)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal { R}(\mathcal { C})$$\end{document} in numerous cases. We conclude by using these results to determine the case for negacyclic codes as well.

Any linear Z 4 -code C is permutation-equivalent to a code with generator matrix of the form: where A and C are matrices over F 2 and B is a matrix over Z 4 . It follows that |C| = 2 2δ+γ and in this case we say that C is of type 4 δ 2 γ . This generator matrix is said to be in standard form. We say that a quaternary non-zero vector v is of order 2 if v + v = 0 and of order 4 if it is not of order 2 and v + v + v + v = 0. The Hamming weight of any vector u ∈ F n 2 , denoted by w H (u), is the number of non-zero coordinates of u. Given two binary vectors u, v ∈ F n 2 , the Hamming distance between u and v is d(u, v) = w H (u, v) and it is the number of coordinates in which they differ. The Lee weights of 0, 1, 2, 3 ∈ Z 4 are 0, 1, 2, 1 respectively, and the Lee weight of u ∈ Z n 4 , w L (u), is the rational sum of the Lee weights of its components. If u, v ∈ Z n 4 , then the Lee distance between u and v is d L (u, v) = w L (u − v).
Denote by φ the standard Gray map φ : Z 4 → F 2 2 that is defined by 0 → 00, 1 → 01, 2 → 11, 3 → 10. We extend this map to Z n 4 → F 2n 2 by applying it coordinatewise. The map is a non-linear distance preserving map. If C ⊆ Z n 4 is a quaternary code with minimum distance d, then φ(C) ⊆ F 2n 2 is a binary code with the same minimum distance. This map was used in [9] to show that certain non-linear binary codes had a Z 4 structure.
We take the standard inner-product, namely [v, w] = v i w i . For a linear code C over any alphabet, define its dual code as C ⊥ = {w | [w, v] = 0, ∀v ∈ C}. The code C ⊥ is a linear code whether or not C is.
We say that a code C over any alphabet is cyclic if We say that C is quasi-cyclic of index k if π k (C) = C and k is the least integer satisfying this equation. As usual we associate cyclic codes over a ring R with ideals in R[x]/ x n − 1 and negacyclic codes with ideals in R[x]/ x n + 1 , where the vector c = (c 0 , c 1 , . . . , c n−1 ) corresponds to the polynomial c(x) = c 0 + c 1 x + c 2 x 2 + · · · + c n−1 x n−1 . Throughout this paper, we will write c intead of c(x) when we refer to the polynomial. Moreover, when we say that a quaternary code is cyclic we are assuming that the code is linear. However, when we say a binary code is quasi-cyclic we are not assuming that it is linear.
In [10], Pless and Qian describe cyclic codes over Z 4 building on the earlier work of Calderbank and Sloane in [5] who studied cyclic codes over Z p e and the p-adic integers. The following fundamental theorem can be found in [10]. From the definition of the type of a quaternary cyclic code, if C = f h, 2 f g is a quaternary cyclic code of type 4 δ 2 γ , we have that δ = deg(g) and γ = deg(h).
Recall that (x n − 1) = (x − 1)(x n−1 + x n−2 + · · · + x + 1). This means that x − 1 and x n−1 + x n−2 + · · · + x + 1 are always divisors of x n − 1. For the remainder of the paper we assume that n is odd. This is because if n is odd there is a unique factorization of x n − 1 into basic irreducible polynomials over the binary field. Then, using Hensel's lift, we have a unique factorization into basic irreducible pairwise coprime polynomials. Cyclic and negacyclic codes have also been studied for even lengths, see [1][2][3]6]. However, the description of the ideals is quite different for even lengths because the factorization of x n − 1 is not unique in these cases.
For u ∈ Z 4 [x], we denote by u ∈ F 2 [x] the polynomial obtained by considering the coefficients of u modulo 2. Note that if u is a divisor of . Let β be a primitive root of unity over F 2 and u|(x n − 1). We define as the polynomial whose roots are β i+ j such that β i , β j are roots of u.
Let C be a Z 4 cyclic code. The following theorem proved in [12] determines the linearity of φ(C) in terms of the generator polynomials of C.
The following properties are equivalent.
Corollary 1 Let C = f h, 2 f g be a quaternary cyclic code, where f gh = x n − 1.
We make the standard definition of the kernel of a binary code and introduce notation for its quaternary preimage.
If C is a binary code, define its kernel to be ker It is well known that the kernel of a binary code is the intersection of all maximal linear subspaces and that the code is the union of cosets of the kernel; see [7,8] for details.
Let C be a binary, not necessarily linear code. We denote by C the linear binary code generated by the vectors in C. We shall say that rank(C) = dim( C ). For a quaternary code C we shall also say that rank(C) = rank(φ(C)).
The following appears in [7].
Lemma 1 Let C be a quaternary linear code. Then, R(C) and K(C) are quaternary linear codes satisfying In [7,8], various bounds are put on the rank and size of the kernel for arbitrary quaternary codes. In this work, these bounds are significantly refined for the cyclic case. Moreover, we show that, unlike the general case, it is not true that the intermediate dimensions for the rank and kernel between the bounds can be achieved for some code.
Both in the case of the rank and in the case of the dimension of the kernel, we will study subcodes of quaternary cyclic codes that are also quaternary cyclic. We will use the following theorem that relates the generator polynomials of a quaternary cyclic code and its quaternary cyclic subcodes.
This gives that f divides f h and f divides 2 f g. Then since h and g are coprime, then f divides f .

Kernels of cyclic codes
In this section, we shall examine the kernel of quaternary cyclic codes.
The following is well known, see [9], and follows from the fact that The following is immediate from the definitions. It is well known that φ(C) can be expressed as the union of cosets of ker(φ(C), specifically where v i is either 0 or any of the order 4 vectors in C that are not in K(C). That is, φ(C) is the union of cosets of the kernel. The coset leaders are precisely the images of those order 4 vectors which are not in the kernel. By the action of π 2 , the quasi-cyclic shift sends coset to coset fixing only the kernel. We already know that the kernel K(C) of any quaternary linear code is a quaternary linear code. The next theorem will show that K(C) is cyclic when C is cyclic.
Theorem 4 Let C be a quaternary cyclic code. Then K(C) is a quaternary cyclic code.
Proof Let C be a quaternary cyclic code. Since K(C) is linear, we only have to check that π(v) ∈ K(C), for v ∈ K(C); that is, 2π(v) * w ∈ C, for all w ∈ C.
Since K(C) is a quaternary cyclic code, we can write the kernel as The following theorem puts a minimal size on the kernel of the code. When the size of the kernel of a code is the minimal size, we say that the kernel is a minimum. First note that from Lemma 2 all order 2 codewords are in the kernel. In the case of a quaternary cyclic code C = f h, 2 f g , the subgroup of order 2 codewords is 2 f h, 2 f g . Moreover, since gcd(h, g) = 1, we have that 2 f h, 2 f g = 2 f and therefore, 2 f ⊆ K(C).

Theorem 5
Let C = f h, 2 f g be a quaternary cyclic code of odd length. If K(C) is a minimum then K(C) = 2 f and |K(C)| = 2 n−deg( f ) . Hence the minimum size of K(C) is Then invoke Theorem 1, with g = 1, f = f and h = x n −1 f , and we have the result. We can use this theorem to put a lower bound on the size of the kernel. The upper bound is reached when the code is linear, and we say that the kernel is a maximum. We can then establish an upper and a lower bound on the size of the kernel in the following corollary.

Corollary 2 Let C be a quaternary cyclic code of odd length then
It follows that Proof The lower bound follows from Theorem 5 and the upper bound follows from Theorem 1 given that |C| = 4 deg(g) 2 deg(h) .
Equation (3) simply rephrases this in terms of the degrees of the generating polynomials. According to Theorems 1 and 5, the kernel of a quaternary cyclic code C is a minimum if K(C) = 2 f and it is a maximum if φ(C) is linear and K(C) = C. Of course, it is possible that the lower bound can equal the upper bound; for example, if C = 2 f then the kernel is both the maximum and the minimum. In this case we prefer to say that the kernel has maximum size, since maximum size indicates that the image is a linear binary code.
In the general linear case, we can find quaternary linear codes of length n and all possible values for the kernel as in the following theorem.
Theorem 6 [7] There exists a quaternary linear code C of length n and type 4 δ 2 γ with ker As it was mentioned in the introduction, this is not true for quaternary cyclic codes. We will establish some properties for the kernel of a quaternary cyclic code and we will give some conditions for its dimension. After that, we can begin to describe the kernel of a cyclic code in various cases.
We know that K(C) = f h , 2 f g . The following theorem proves that, in fact, K(C) = f h , 2 f g .
As it was mentioned in the introduction, the kernel of a binary code is the intersection of all maximal linear subspaces. Therefore, if C 1 , C 2 , . . . C r are all the maximal subcodes of a quaternary linear code C such that φ(C i ) is a linear subcode of φ(C), for 1 ≤ i ≤ r , then We will see in Proposition 1 the relation between the generator polynomials of the kernel and the generators polynomials of the maximal subcodes C i . First we need the following Lemma.
Proof First we will prove that f lcm( Using the same argument for C 2 we obtain the inclusion.
Finally, we will prove the other inclusion. Since C 1 ⊆ C 1 ∩ C 2 , we have by Therorem 3 and the results follows.

Proposition 1
Let C = f h, 2 f g be a quaternary cyclic code of odd length. Let C 1 , C 2 , . . . C r be all the maximal subcodes of a C such that φ(C i ) is a linear subcode of φ(C). Therefore Then, by aplying the same argument as in the proof of Theorem 7, we have that f i = f . Item 2 is obteined by extending Lemma 4 to C 1 ∩ · · · ∩ C r .
Let 1 denote the all-one vector. Note that 1 corresponds to the polynomial x n−1 + x n−2 + · · · + x + 1. The following lemma was proven in a different way in [4].
Lemma 5 Let C be a quaternary code. If 1 ∈ C then 1 ∈ K(C).
Proof We have that 2 · 1 * v = 2v ∈ C for all vectors v in C. By Lemma 2, this gives that if the all-one vector is in the code C then it is in the kernel K(C).
Note that the proof of this lemma applies to any vector over Z 4 that consists entirely of units.
Since we have that 2 f ∈ K(C), if 1 ∈ K(C), then we have that the size of the kernel is not a minimum; that is dim(ker(φ(C))) ≥ γ + δ + 1.
With the following theorem and corollary we shall see when the size is exactly γ + δ + 1.
Proof First we note that deg(g) + deg(h) is the minimum dimension of the kernel, and all order 2 codewords are in the kernel by Theorem 5. If v ∈ K(C) then all n cyclic shifts of v are in K(C) since K(C) is a cyclic code. But n − deg(v) cyclic shifts are linearly independent over Z 4 , adding n − deg(v) to the dimension of the binary kernel (noting that the order 2 codewords were already in K(C)).
Proof Since the minimal kernel contains all order 2 codewords, to increase the dimension by one a unique order 4 vector v must be added. By Theorem 8, this vector must increase the dimension by n − deg(v) where v is the polynomial corresponding to the vector v. However, the only polynomial divisor of x n − 1 with degree n − 1 is the polynomial x n−1 + x n−2 + · · · + x + 1.
Finally, the possible values on the size of the kernel depends on the degree of the polynomials dividing g.

Theorem 9
Let C = f h, 2 f g be a quaternary cyclic code of odd length. Then, there exists k dividing g such that K(C) = f hk, 2 f g k .
Proof From Theorem 7, we have that But not all the possible kernels are realized as shown in the following theorem.
Theorem 10 Let C = f h, 2 f g be a quaternary cyclic code of odd length with kernel , and there exists j ∈ {1, . . . , r } such that g does not divide g j . We have that ( g j ⊗ g j ) divides h j g j by Theorem 2.
by Therorem 2, the image under the Gray map of the code linear, which is a contradiction with the fact that C j is a maximal subcode with linear image under the Gray map.

Example 1 Consider the case when
The next corollary describes the situation when (x − 1) divides g, but may not be equal to g.

Corollary 5
Let C = f h, 2 f g be a quaternary cyclic code of odd length. If (x − 1) divides g then 1 ∈ K(C) and so K(C) is not the minimum.
Proof If (x − 1) divides g then f h divides x n−1 + x n−2 + · · · + x + 1. Hence the all-one vector is in the code and therefore 1 ∈ K(C) by Lemma 5. But 1 is not in 2 f h, 2 f g since it is an order 4 vector and therefore K(C) is not the minimum. As an example, let n = 3, then x 3 − 1 = (x − 1)(x 2 + x + 1). If f = x 2 + x + 1, g = x − 1 and h = 1, then C = x 2 + x + 1 is generated by the all-one vector and this vector is in the kernel by Lemma 5, so C = K(C) and φ(C) is linear.
It is not true that if f is not in the kernel then the kernel is a minimum. For example, consider n = 9 and x 9 − 1 = (x − 1)(x 2 + x + 1)(x 6 + x 3 + 1). If we take f = x 6 + x 3 + 1, h = 1, and g = x 3 −1 then C = x 6 +x 3 +1 and the kernel does not contain f = x 6 +x 3 +1 but does contains the all-one vector. Hence the kernel is not a minimum by Lemma 5. In fact, in this case the dimension of ker(φ(C)) is the minimum plus 1.
If h = 1, we have that C = x − 1 . Then the generator matrix of the code in standard form is: ⎛ Let v i be the i-th row of the matrix. Then using Lemma 2, for arbitrary rows of this matrix v i , v j we have 2v i * v j = (0, 0, . . . , 0, 2) which is not in C. Let u be an order 4 vector. We can write u = u + 2ū, If, on the other hand, there is no j which is not in A then 2u = (2, 2, 2, . . . , 2, 0). Hence, 2u * v 1 = (2, 0, 0, . . . , 0) which is not in C. Then there is no order 4 vector in the kernel. Therefore, K(C) = 2(x − 1) and the kernel is a minimum.

Classification of the kernels for some factorizations of x n − 1
In this section, we will take into account the factorization of x n − 1. Specifically, we shall examine the following cases. The first case is when the polynomial x n−1 + x n−2 +· · ·+ x + 1 is irreducible; that is, there are just two factors in the factorization of x n − 1. Then, we look at the case when there are three factors and in particular when this occurs for length n = p 2 , where p a prime.
If the polynomial x n−1 + x n−2 + · · · + x + 1 is irreducible then the factorization of x n − 1 is and there are 3 2 = 9 possible codes. Applying Theorem 12 to this case we get the following corollary which determines the dimension of the kernel for all nine codes.

Corollary 6
Let C = f h, 2 f g be a quaternary cyclic code of odd length. If x n−1 + x n−2 + · · · + x + 1 is irreducible over Z 4 , then if g = x n−1 + x n−2 + · · · + x + 1, f = x − 1 and h = 1 the kernel is a minimum and in all other cases K(C) = C and the image is linear.
For example, for n ≤ 30, the polynomial x n−1 + x n−2 + · · · + x + 1 is irreducible for n = 3, 5, 11, 13, 19, 29. Hence for these values of n, when g = x n−1 + x n−2 + · · · + x + 1 and h = 1, the kernel is a minimum, and in all other cases we have that the image is a linear code.
Let n = pq, p, q integers. Then (1+x p +x 2 p +· · ·+x (q−1) p )(x p −1) = x qp −1 = x n −1. Hence these two polynomials divide x n − 1. We shall examine the case when f h is the first polynomial. Notice that x p − 1 has further factors. These cases shall be examined later.
Theorem 13 Let C = f h, 2 f g be a quaternary cyclic code of odd length. Let n = pq, p, q integers. If f h = (1 + x p + x 2 p + · · · + x (q−1) p ) then K(C) = C.
Proof The matrix given by taking p cyclic shifts of the f h, i.e. π i ( f h) for i = 0, 1, 2, . . . , p − 1, is in standard form. That is, the identity matrix is in the first p coordinates. These are the vectors of order 4 in the generator matrix of the code. The generator matrix in the standard form also has other order 2 vectors which are not relevant to this proof. Then if we take 2v * w for any of these vectors we have 0 or 2v which are in the code. Hence, the code C satisfies K(C) = C.
We now consider the further factorization of x p − 1.

Theorem 14
Let C = f h, 2 f g be a quaternary cyclic code of odd length. If for some integer s we have that s divides n and f h = x s−1 + · · · + x + 1, then dim(ker(φ(C))) ≥ γ + δ + 1, that is, the kernel is not a minimum.
This gives that 1 ∈ C and 1 ∈ K(C) by Lemma 5. This gives the result.

Theorem 15
If there are exactly three monic irreducible factors of x n −1, n odd, then n = p or n = p 2 where p > 2 is a prime. If there are exactly two monic irreducible factors of x n − 1 then n = p.
Proof If n = st with s = t then x − 1, x + x s + x 2s + · · · + x (t−1)s , x + x t + x 2t + · · · + x (s−1)t , 1 + x + x 2 + · · · + x s , and 1 + x + x 2 + · · · + x t are all distinct factors of x n − 1 as we have shown previously. Hence the only time you can have three factors is when n = p or n = p 2 , where p is a prime. If n = p 2 , then x − 1, x + x p + x 2 p + · · · + x ( p−1) p and 1 + x + x 2 + · · · + x p are factors, hence if there are only two factors then n is a prime.
We have seen in Theorem 15 that if we have three factors in the decomposition of x n − 1 then n = p or p 2 . We will see some properties for these cases in general and we will give the complete classification for the case n = p 2 .
Theorem 16 Let x n − 1 = (x − 1)ab, where a and b are irreducible polynomials. Let C be a quaternary cyclic code of odd length with C = a, (x − 1)ab = a . Then either K(C) = C and φ(C) is linear, or dim(φ(C)) = γ + δ + 1.
Remark If n = p 2 , p prime, and x n − 1 = (x − 1)ab with a = 1 + x + · · · + x p−1 and b = 1 + x p + · · · + x ( p−1) p , then the only self-dual Z 4 -cyclic code of length n is C = 2 . This is because the code C is self-dual if and only if f h + 2 f = g * h * + 2g * (see [11]); that is, h = ±h * and f = ±g * , where h * and g * are the reciprocal polynomials of h and g respectively. Hence, the only option is h = x n −1, f = g = 1. This is not true if n = p. In the case n = 7, for example, we have that and the Z 4 -cyclic codes C 1 = (x − 1)a, 2ab and C 2 = (x − 1)b, 2ba are both self-dual, for a = (3 + 2x + 3x 2 + x 3 ) and b = (3 + x + 2x 2 + x 3 ) since a = −b * . Moreover, C 1 and C 2 are equivalent and, therefore the dimensions of the kernels coincide.
From now on, we will consider the case n = p 2 odd, p > 2 prime and (x−1) n = (x−1)ab, for a = 1 + x + x 2 + · · · + x p−1 and b = 1 + x p + x 2 p + · · · + x ( p−1) p . We will completely determine the kernel in this case for all possible values of f, g and h.
Theorem 17 Let C = f h, 2 f g be a quaternary cyclic code of odd length n = p 2 and x n − 1 = (x − 1)ab where a and b are irreducible polynomials. Set h = 1. If f = a, then Consider h = 1 and f = a. Then C = a, 2(1 + x + · · · + x n−1 ) . Note that 2a π(a) / ∈ C and hence a / ∈ K(C) and K(C) = C. Moreover, 1 + x + · · · + x n−1 = a + π p (a) + · · · + π p−1 (a) =∈ C. Hence, by Lemma 5, 1 + x + · · · + x n−1 ∈ K(C). Since a = f h divides f h and f h divides 1 + x + · · · + x n−1 = ab, we have that h = 1 or h = b. If h = 1, then K(C) = C that is not possible. Therefore, h = b and K(C) = 1 + x + · · · + x n−1 , 2ab . Now consider h = 1 and f = b. Then C = b, 2(1 + x + · · · + x n−1 ) . Note that for all i, 2b π i (b) is either 0 or 2b and, in both cases, it belongs to C. Hence b ∈ K(C) and K(C) = C. Let v be the vector corresponding to x p −1. Since p > 2, we have that 2v π p (v) = π p (2, 0, . . . , 0) that belongs to C if and only if (1, 0, . . . , 0) belongs to C, due to the fact that C is free, where a free code is a code isomorphic to Z k 4 for some k. In this case, we have that 1 + x + · · · + x n−1 is in C that is not possible. Hence, π p (2, 0, . . . , 0) is not in the code and K(C) = C. Therefore, the kernel is a minimum.

Theorem 18 Let
. . .  (010 . . . 010 . . . 0 . . . 010 . . . 0) also belongs to the code which is not true by the form of the generator matrix. Hence, 2v π(v) / ∈ C and v is not in the kernel, so the kernel is a minimum.

Theorem 19
Let C = f h, 2 f g be a quaternary cyclic code of odd length n = p 2 and x n − 1 = (x −1)ab where a and b are irreducible polynomials. Set g = a. If f = b then K(C) = C and the kernel is a maximum. If f = x − 1 then K(C) = 2 f and the kernel is a minimum.
Proof Let v be the vector corresponding to f h = (x −1)b. Then we have 2v * π j (v) is either 0, 2 f h or a cyclic shift of the vector corresponding to 2b. We note that 0 and 2 f h are both in the code. So if 2b is in the code then the kernel is a maximum. If not then it is easy to see that no linear combination of the order 4 vectors is in the kernel and hence the kernel is a minimum.
Then since x − 1 and a are relatively prime, we have that 2b ∈ 2b(x − 1), 2ba . Hence, in this case we have that C = K(C).
Hence, in this case we have that K(C) = 2 f and is a minimum.
Theorem 20 Let C = f h, 2 f g be a quaternary cyclic code of odd length n = p 2 and x n − 1 = (x − 1)ab where a and b are irreducible polynomials. Set g = b. If f, h = 1 then K(C) = 2 f and the kernel is a minimum.
Proof Let v be the vector corresponding to f h. Then we have 2v * π j (v) is either 0 or a cyclic shift of the vector corresponding to 2b. Moreover, we can see that any linear combination w of order 4 vectors has a vector w such that 2w * w is a cyclic shift of the vector corresponding to 2b.
In both cases we have that 2b is not in the code, because neither a nor (x − 1) divides b.
In the following theorem, we will summarize all the cases when n = p 2 and x n − 1 has three factors.

Theorem 21
Let C = f h, 2 f g be a quaternary cyclic code of length n = p 2 and x n − 1 = (x − 1)ab where a and b are irreducible polynomials. Then K(C) is either the minimum 2 f , the maximum C or 1 + x + x 2 + · · · + x n−1 , 2 f . That is, we have that the dimension of ker(φ(C)) is either γ + δ, γ + 2δ or γ + δ + 1.
Proof Let x n − 1 = (x − 1)ab, where a and b are the irreducible polynomials defined before. We will check all the possibilities for f, g, h, f gh = x n − 1 and we determine, in each case if the kernel is the maximum, dimension γ + 2δ; the minimum, dimension γ + δ or it has dimension γ + δ + 1.
• If g = 1 or g = x − 1, then K(C) = C and the kernel is a maximum by Corollary 1. For the remainder assume g = 1, x − 1. • If f = 1 then we know that K(C) = C by Corollary 1.
• Set f = a. If h = 1, then we apply Theorem 17 and K(C) = 1+x +x 2 +· · ·+x n−1 , 2 f g ; that is, the dimension of the kernel is γ +δ+1. If h = x −1, then g = b and, by Theorem 20 the kernel is a minimum. If h = b or h = b(x − 1), then g = 1 or x − 1 and it has been determined before. • Set f = b. If h = 1, then we apply Theorem 17 and K(C) = C; that is, the kernel is a maximum. If h = x − 1, then g = a and, by Theorem 20 the kernel is also a maximum. If h = a or h = a(x − 1), then g = 1 or x − 1 and it has been determined before. • If f = x − 1 and g = a or g = b, then by Theorems 19 and 20 the kernel is a minimum.
If g = ab, then by Theorem 12, the kernel is also a minimum. 1)a, or f = (x − 1)b and g = 1, x − 1. Then by Theorem 18 the kernel is a maximum in the case p = 2 and it is a minimum otherwise.
Theorem 18 • If f = ab, then necessarily g = 1 or x − 1 and of f = x n − 1, then g = 1. In all the cases, the kernel has been determined before.
In Table 1, we can completely determine all possible kernels from the last theorem when n = p 2 and there are only three irreducible factors of x n − 1. A * in the table indicates that it takes on all possible values. In this case there are 27 cyclic codes represented in the table. We consider p > 2.

Ranks of cyclic codes
In this section, we shall describe the quaternary code R(C) and its binary image which is φ(C) . It is immediate that if K(C) = C then R(C) = C since φ(C) = φ(C). We begin with a lemma.

Lemma 6 Let C be a quaternary cyclic code. Then φ(C) is a quasi-cyclic code of index 2.
Proof Let {v i } be a set of vectors in C = φ(C), then if v = α i v i then α i π 2 (v i ) ∈ C and α i π 2 (v i ) = π 2 (v). Hence the code is quasi-cyclic of index 2.
Note that we are not asserting that the binary image is linear, only that it is held invariant by the action of π 2 .
Theorem 22 Let C be a quaternary cyclic code, then R(C) is a quaternary cyclic code.
Proof By Lemma 1 we have that R(C) is linear. By Lemma 6 we have that φ(C) is quasicyclic of index 2, hence R(C) is a linear quaternary cyclic code.
In general, we have that R(C) = f h , 2 f g for some f , h , g satisfying f g h = x n − 1.
The following lemma can be found in [8,9]. Note that C has a binary linear image if and only if 2v i v j ∈ C for any i, j ∈ {1, . . . , δ}. Since R(C) is, by definition, the minimum quaternary linear code containig C whose binary image is linear, then we can easily obtain the following corollary.

Corollary 7
Let C = f h, 2 f g be a quaternary cyclic code of odd lenth. Then R(C) = C, 2v * π(v), . . . , 2v * π s (v) where v is the vector corresponding to f h and s = n − deg( f h) − 1.
Theorem 23 Let C be a quaternary cyclic code of odd length, with C = f h, 2 f g . Then there exits a polynomial r dividing f such that R(C) = f h, 2 f r g . Proof Let C = f h, 2 f g and R(C) = f h , 2 f g . By Corollary 7, we have that C and R(C) have the same number of order 4 vectors. Since C ⊆ R(C) we have that f h = f h . Then f hg = f h g = x n − 1 which gives that g = g . Finally, we have that f divides f by Theorem 3 and hence there exists a polynomial r such that f r = f . Therefore, f h , 2 f g = f h, 2 f r g . We can use these results to find a maximum for R(C).
Theorem 24 Let C be a quaternary cyclic code of odd length.
Note that C has linear image by Corollary 1. Then Hence, since C is the maximum code that R(C) can be, we have that the dimension can go up at most by deg( f ).
In general, we have that Theorem 25 Let C be a quaternary cyclic code of odd length with is not linear and f is irreducible then R(C) = f, 2g .
Proof We know by Theorem 23, that R(C) = f h, 2 f r g for some r dividing f . But since f is irreducible, we have that r = 1 or r = f . If r = f then the image is linear. Therefore, Notice that this theorem completely determines all possible cases when n = p 2 and x n − 1 = (x − 1)(1 + x 2 + · · · + x p−1 )(1 + x p + x 2 p + · · · + x ( p−1) p ) and all factors are irreducible, since the only cases where the image is not linear have f irreducible. Hence, we know the rank for every code in Table 1.
In all other cases, R(C) = C.
Proof By Corollary 6, we have that the only case when φ(C) is not linear is when g = x n−1 + x n−2 + · · · + x + 1, f = x − 1 and h = 1. In this case, it is easy to see that R(C) = x − 1, 2(1 + x + · · · + x n−1 ) . This code has a linear image by Corollary 6 and is formed by adding 2v * π(v) where v is the vector corresponding to x − 1.

Kernels and ranks of negacyclic codes
We begin our study of negacyclic codes with a theorem that is similar to Theorem 4.
Theorem 27 Let C be a negacyclic code over Z 4 . Then K(C) is a negacyclic code.
Proof The proof follows similarly to the proof of Theorem 4, replacing π with σ.
For odd n we have a bijective correspondence between cyclic codes and negacyclic codes using the following map: where μ(c(x)) = c(−x). Notice that from this bijective correspondence the role played by the all-one vector is now played by the vector (1, 3, 1, 3, 1, 3, . . . , 1). It is still true that if this vector is in the code, then 2 (1, 3, 1, 3, 1, 3, . . . , 1) * v = 2v and hence in the code. So that if this vector is in the code then this vector is in the kernel. The same can be said for any vector whose coordinates are all ±1.
We have similar theorems for the rank.
Proof Consider the binary code φ(C) and the binary code φ(μ(C)). The second binary code is formed from the first by simply permuting the two coordinates corresponding to odd powered monomials. Let this action be given by τ . Then τ (φ(C)) = φ(μ(C)). It is immediate that τ ( φ(C) ) = φ(μ(C)) . Then by considering the inverse image under φ we have the result.
Theorem 30 Let C be a quaternary negacyclic code then R(C) is a negacyclic code.
Proof If C is a quaternary negacyclic code then C = μ(C ) for some quaternary cyclic code. Then by Theorem 29, R(C) = μ(R(C )). Since C is cyclic, we have that R(C) is cyclic by Theorem 22. Then μ(R(C)) is negacyclic and we have the result.
Given Theorems 28 and 29, we see that the case for negacyclic codes is determined by the case for cyclic codes.

Examples
We shall look at the rank and the kernel for some small values of n. For n = 3, 5, 11, 13, we have seen that the polynomial x n−1 + x n−2 + · · · + x + 1 is irreducible, so these cases are trivial as described in Corollary 6 and Theorem 26.
In the cases n = 7, 9, 17, the polynomial x n − 1 factors into three irreducible polynomials and the different values for the dimension of the kernel belong to {γ + δ, γ + δ + 1, γ + 2δ}. We completely describe the case n = 9 at Table 1. We add the results for the case n = 7 in the following tables. In the first table, the codes are linear; that is the dimension of the kernel is γ + 2δ. In the second table the dimension of the kernel is the minimum possible; that is, γ + δ. Finally, there are two cases where the dimension of the kernel is γ + δ + 1.
is irreducible so we can invoke Corollary 6. The cases for n = 7 and n = 9 are similar. However, at n = 15 there are codes for which this is not true. In the next example we shall show cases where the dimension of the kernel is neither the minimum, maximum, nor the minimum plus 1. But rather where it goes up by the degree of a factor of g.