1 Introduction

For any positive integer \(s\ge 1\), let \(\mathbb {Z}_{2^s}\) be the ring of integers modulo \(2^s\). A Galois ring is defined to be a finite commutative ring R with identity 1 such that the set of zero divisors of R with 0 added is a principal ideal \(\langle p\rangle \) for some prime number p. A polynomial over \(\mathbb {Z}_{2^s}\) is called basic irreducible if its reduction modulo 2 is irreducible over \(\mathbb {F}_2\), and it is monic if its leading coefficient is 1. Let h(x) be a monic basic irreducible polynomial of degree \(m>0\) over \(\mathbb {Z}_{2^s}\). It is known that the residue class ring \(\frac{\mathbb {Z}_{2^s}[x]}{\langle h(x) \rangle }\) is a Galois ring of characteristic \(2^s\) and cardinality \(2^{sm}\), and is denoted by \(GR(2^s,m)\). Also, it is local ring with maximal ideal \(\mathfrak {m}=\langle 2 \rangle \). Furthermore, any ideal of \(GR(2^s,m)\) is of the form \(\langle 2^i \rangle \) for \(1 \le i \le s\), and there is a chain of ideals: \(GR(2^s,m)=\langle 1 \rangle \supset \langle 2 \rangle \supset \cdots \supset \langle 2^{s}\rangle =\{0\}\). In this paper, we focus on the special case \(s=2\) (i.e., GR(4, m)). Throughout this paper, we denote GR(4, m) by R. The residue classes \(a_0+a_1x+\cdots +a_{m-1}x^{m-1}+\langle h(x) \rangle \), where \(a_0, a_1,\ldots ,a_{m-1}\in \mathbb {Z}_4\), are all the distinct elements of R. The natural homomorphism \(\bar{}: \mathbb {Z}_4\longrightarrow \mathbb {F}_2\) is defined by \(c_0+2c_1\longmapsto c_0\), can be extended to a ring epimorphism from \(\mathbb {Z}_4[x]\) to \(\mathbb {F}_2[x]\) as following:

$$\begin{aligned} \bar{~}: \mathbb {Z}_4[x]&\longrightarrow \mathbb {F}_2[x]\\ a_0+a_1x+\cdots +a_nx^n&\longmapsto \bar{a}_0+\bar{a}_1x+\cdots +\bar{a}_nx^n, \nonumber \end{aligned}$$
(1)

therefore the ring homomorphism (1) induces a ring homomorphism

$$\begin{aligned} R&\longrightarrow \frac{\mathbb {F}_{2}[x]}{\langle \bar{h}(x)\rangle }\\ a_0+a_1x+\cdots +a_nx^n+\langle h(x)\rangle&\longmapsto \bar{a}_0+\bar{a}_1x+\cdots +\bar{a}_nx^n+\langle \bar{h}(x)\rangle , \nonumber \end{aligned}$$
(2)

which will also be denoted by \(\bar{~}\). Write \(\xi = x + \langle h(x)\rangle \), then \(h(\xi )=0\), and \(\xi \) is also of order \(2^{m}-1\). Every element of R can be written uniquely in the following form

$$\begin{aligned} a_0 + a_1 \xi + \cdots + a_{m-1} \xi ^{m-1},\quad a_{i}\in \mathbb {Z}_{4}\ (0\le i \le m-1), \end{aligned}$$
(3)

and \(R = \mathbb {Z}_{4}[\xi ]\). The representation (3) is called the additive representation of the elements of the Galois ring R. Denote the image of \(\xi \) under the map (2) by \(\bar{\xi }\), then \(\bar{\xi }=x+\langle \bar{h}(x)\rangle ,\bar{h}(\bar{\xi })=0 \), and \(\frac{\mathbb {F}_{2}[x]}{\langle \bar{h}(x)\rangle }=\mathbb {F}_{2}[\bar{\xi }]\simeq \mathbb {F}_{2^m}\). Moreover, \( \frac{R}{\langle 2 \rangle }\simeq \mathbb {F}_{2^m} \). Let \(\tau = \{0,1,\ldots ,\xi ^{2^{m}-2}\}\), known as Teichmüller set. Then any element \(c\in R\) can be written uniquely as

$$\begin{aligned} c = a + 2b, \quad (a,b\in \tau ). \end{aligned}$$
(4)

The representation (4) is called the 2-adic representation of the element \(c\in R\), and we denote by \([c]=[a, b]\), see [12, 16,17,18]. Note that, we do not make distinction between the field \(\mathbb {F}_{2^m}\) and the \(\tau \). A code of length n over \(\mathbb {F}_{2^m}\) is a non-empty subset of \(\mathbb {F}_{2^m}^n\), and it called linear if it is a subspace of \(\mathbb {F}_{2^m}^n\). A code of length n is linear over R if it is a R-submodule of \(R^n\). In addition, a linear code is called cyclic, if a cyclic shift of any codeword is a codeword.

For any \(u\in \mathbb {Z}_{4}\), the 2-adic expansion of \(u=u_{0}+2u_{1}\) is denoted by \([u]=[u_{0},u_{1}]\), where \(u_{0},u_{1}\in \mathbb {F}_2\). As stated in [15], three operations “\( \odot \)”, “\(\oplus \)”and “\(\circledast \)”are introduced as follows; if \( u, v\in {\mathbb {Z}_{4}} \), \([u]=[u_{0}, u_{1}]\) and \([v]=[v_{0}, v_{1}]\), then

$$\begin{aligned} u\odot v&=u_{0}v_{0}+2u_{1}v_{1},\\ u\oplus v&=u_{0}\oplus v_{0}+ 2(u_{1}\oplus v_{1}),\\ u\circledast v&=2u_{0}v_{0}. \end{aligned}$$

Note that \(u\circledast v\) has been denoted by \((0,\zeta _1)\) in [15]. It is easy to see that \(u+v=u\oplus v \oplus (u\circledast v)\), \(u\odot v=v\odot u\), \(u\oplus u=0\) and \(u\odot u=u\). The vectors in \( \mathbb {Z}_{4}^{n}\) are written in the form \((u^{1}, u^{2},\ldots , u^{n})\), where \(u^{i}\in \mathbb {Z}_{4}\) and \([u^{i}]=[u_{0}^{i}, u_{1}^{i}]\), for all \(i=1,\ldots ,n\). The application of the operation “\(\odot \)”on \(\mathbb {Z}_{4}\) to \(\mathbb {Z}_{4}^n\) is extended in the natural way; that is, if \(\varvec{u}=(u^{1}, u^{2},\ldots , u^{n}), \varvec{v}=(v^{1}, v^{2},\ldots , v^{n})\in \mathbb {Z}_{4}^n\), then \(\varvec{u} \odot \varvec{v}=(u^{1} \odot v^{1}, u^{2} \odot v^{2}, \ldots , u^{n}\odot v^{n})\). Recall that for each \(\varvec{u}=(u^1, \ldots , u^n)\) and \( \varvec{v}=(v^1, \ldots , v^n)\) belong to \( \mathbb {Z}_{4}^n\), \(\varvec{u} *\varvec{v}=(u^{1}v^{1},\ldots ,u^{n}v^{n})\), and \(2(\varvec{u}*\varvec{v})=2(\varvec{u}\odot \varvec{v})\). Also, if U and V are two subsets of \(\mathbb {Z}_{4}^n\), then

$$\begin{aligned} U *V =\{\varvec{u} *\varvec{v} :\ \varvec{u} \in U, \varvec{v} \in V \}. \end{aligned}$$
(5)

A vector \(\varvec{c}\in R^{n}\) is written in the form \((c^1, c^2, \ldots , c^n)\), where \(c^{i}\in R\), and \([c^{i}]=[a^i, b^i]\) \((a^i, b^i\in \mathbb {F}_{2^m})\), for all \(i=1,2,\ldots ,n\).

Unlike linear codes over finite fields, linear codes over rings do not have a basis, but there exists a generator matrix for these codes. A matrix \(\mathcal {G}\) is called a generator matrix for \(\mathcal {C}\) if the rows of \(\mathcal {G}\) span \(\mathcal {C}\) and none of them can be written as a linear combination of the other rows of \(\mathcal {G}\). A linear code of length n over R is permutation equivalent to a code whose generator matrix \(\mathcal {G}\) has the form

$$\begin{aligned} \mathcal {G}=\left( \begin{matrix} I_{k_0}&{}A&{}B\\ 0&{}2I_{k_1}&{}2C \end{matrix}\right) , \end{aligned}$$

where A and C have entries only from \(\tau \), and B has entries from R, see [7].

There are different Gray maps from \(\mathbb {Z}_{2^s}\) to \(\mathbb {Z}_2^{2^{s-1}}\), see for instance [1, 2, 10]. One of them is Homogeneous Gray map which has been generalized for finite chain rings [8, 14]. Let \(\mathcal {C}\) be a linear code of length n over R and let \(\Phi \) be Homogeneous Gray map on \(R^n\). In general, \(\Phi (\mathcal {C})\) does not need to be linear. One of the interesting topics in algebraic coding theory is to see under what conditions the image of this code is linear or non-linear. In [6, 18], it has been given some necessary and sufficient conditions for which the binary Gray image of a quaternary linear code is linear. Specifically, if \( \mathcal {G} \) is a generator matrix of a linear code \(\mathcal {C}\) over \(\mathbb {Z}_{4}\) and \(\{\varvec{v}_{j}\}_{j=1}^{k_0}\) are the rows of order four in \(\mathcal {G}\), then, \(\Phi (\mathcal {C})\) is a binary linear code if and only if \( 2(\varvec{v}_{t}*\varvec{v}_{l}) \in \mathcal {C}\), for all tl satisfying \(1\le t<l\le k_0\). In [15] by applying the operation “\(\odot \)”on \(\mathbb {Z}_{2^s}\), a necessary and sufficient condition for linearity \(\Phi (\mathcal {C})\) has been stated. The linearity problem has been studied for the family of Hadamard linear codes over \(\mathbb {Z}_{8}\) and \(\mathbb {Z}_{2^s}\), see [4, 5]. Moreover, Wolfmann [19] determined all cyclic codes of odd length over \(\mathbb {Z}_4\) whose Gray images are linear. In [3], we investigated the linearity of the Gray image of a linear code and a linear cyclic code of odd length over \(\mathbb {Z}_8\) using their generator matrix and generator polynomial, respectively. Also, the necessary and sufficient conditions are given for which the Gray image of a linear code defined over the Galois ring \(GR(p^2,m)\) to be linear [11]. The paper is organized as follows. In Section 2, the Homogeneous Gray image over finite chain rings is introduced. The linearity of Gray image of a linear code of length n over R is investigated in Section 3. In Section 4, we give a condition on the generator polynomial of a linear cyclic code of odd length over R which its Gray image is linear.

2 Preliminaries

A finite commutative ring with identity \(1\ne 0\) is called a finite chain ring if its ideals are linearly ordered by inclusion. It is well known that it is a local ring. Let S be a finite chain ring and \(\mathfrak {m}=\langle \gamma \rangle \) be the unique maximal ideal of S. Since S is finite, so, there exist the number i such that \(\langle \gamma ^i\rangle =\{0\}\). Let s be the minimal number such that \(\langle \gamma ^s\rangle =\{0\}\). Therefore, s is called the nilpotency index of \(\gamma \), see [8, 13, 14]. Suppose that the residue field \(\frac{S}{\langle \gamma \rangle }\) is \(\mathbb {F}_{p^m}\), where p is a prime. For every \(r\in S\), there are unique \(a_0(r),a_1(r),\ldots ,a_{s-1}(r)\in \mathbb {F}_{p^m}\) such that \(r=a_0(r)+a_1(r)\gamma +\cdots +a_{s-1}(r)\gamma ^{s-1}\). Thus, each element \(\varvec{r} \in S^n\) can be written uniquely as

$$ \varvec{r}=a_0(\varvec{r})+a_1(\varvec{r})\gamma +\cdots +a_{s-1}(\varvec{r})\gamma ^{s-1}, $$

where \(a_i(\varvec{r})=(r_{i,0},r_{i,1},\ldots ,r_{i,n-1})\in \mathbb {F}_{p^m}^n\), for every \(0\le i\le {s-1}\). In [8], for a finite chain ring S, the Homogeneous Gray map from \(S^n\) to \(\mathbb {F}_{p^m}^{p^{m(s-1)}n}\) is defined as follows.

Let \(\alpha \) be a fixed primitive element of \(\mathbb {F}_{p^m}\). An element \(\alpha _{\epsilon }\in \mathbb {F}_{p^m}\) corresponding to \(\epsilon \in \mathbb {Z}_{p^m}\) is given by

$$ \alpha _\epsilon :=\xi _0(\epsilon )+\xi _1(\epsilon )\alpha +\cdots +\xi _{m-1}(\epsilon )\alpha ^{m-1}, $$

if the p-adic representation of \(\epsilon \) is

$$ \epsilon =\xi _0(\epsilon )+\xi _1(\epsilon )p+\cdots +\xi _{m-1}(\epsilon )p^{m-1}, $$

where \(\xi _i(\epsilon )\in \{0,1, \ldots ,p-1\}\), for every \(0 \le i \le m-1\).

Likewise, each \(\omega \in \mathbb {Z}_{p^{m(s-1)}}\) is viewed uniquely as the \(p^m\)-adic representation

$$ \omega =\bar{\xi }_0(\omega )+\bar{\xi }_1(\omega )p^m +\cdots +\bar{\xi }_{s-2}(\omega )p^{m(s-2)}, $$

where \(\bar{\xi }_i(\omega )\in \{0,1,\ldots ,p^{m}-1\}\), for every \(0\le i\le s-2\). Define the Homogeneous Gray map \(\Phi : S^n\longrightarrow \mathbb {F}_{p^m}^{p^{m(s-1)}n} \) by \(\Phi (\varvec{r})=(\varvec{b}_0,\varvec{b}_1,\ldots ,\varvec{b}_{p^{m(s-1)}-1}),\) for all \(\varvec{r}=a_0(\varvec{r})+a_1(\varvec{r})\gamma +\cdots +a_{s-1}(\varvec{r})\gamma ^{s-1}\in S^n\), where

$$ \varvec{b}_{\omega p^{m}+\epsilon }=\alpha _\epsilon \widetilde{a_0(\varvec{r})}+\sum _{l=1}^{s-2}\alpha _{\bar{\xi }_{l-1}(\omega )}\widetilde{a_{l}(\varvec{r})}+\widetilde{a_{s-1}(\varvec{r})}, $$

for all \(0\le \omega \le p^{m(s-2)}-1\) and \(0\le \epsilon \le p^{m}-1\), and \(\widetilde{a_i(\varvec{r})}=(\widetilde{r_{i,0}},\widetilde{r_{i,1}},\ldots ,\widetilde{r_{i,n-1}})\), where \(\widetilde{~} :S\longrightarrow \mathbb {F}_{p^m}^n\) is the canonical map. It is easy to see that \(\Phi \) is injective. The Homogeneous Gray map \(\Phi : S^n\longrightarrow \mathbb {F}_{p^m}^{p^{m(s-1)}n} \) can be written in the following form

$$\begin{aligned} \Phi (\varvec{r})=[\varvec{r}]\mathcal {\mathcal {A}}=[\widetilde{a_0(\varvec{r})}, \widetilde{a_1(\varvec{r})}, \ldots , \widetilde{a_{s-2}(\varvec{r})}, \widetilde{a_{s-1}(\varvec{r})}]\mathcal {\mathcal {A}}, \end{aligned}$$
(6)

where

$$\begin{aligned} \mathcal {A}\!=\!\left( \begin{matrix} \alpha _0&{}\cdots &{}\alpha _{p^{m}-1}&{}\alpha _0&{}\cdots &{}\alpha _{p^{m}-1}&{}\cdots &{}\cdots &{}\alpha _0&{}\cdots \\ \alpha _{\bar{\xi }_{0}(0)}&{}\cdots &{}\alpha _{\bar{\xi }_{0}(0)}&{}\alpha _{\bar{\xi }_{0}(1)}&{}\cdots &{}\alpha _{\bar{\xi }_{0}(1)}&{}\cdots &{}\cdots &{}\alpha _{\bar{\xi }_{0}(p^{m(s-2)}-1)}&{}\cdots \\ \alpha _{\bar{\xi }_{1}(0)}&{}\cdots &{}\alpha _{\bar{\xi }_{1}(0)}&{}\alpha _{\bar{\xi }_{1}(1)}&{}\cdots &{}\alpha _{\bar{\xi }_{1}(1)}&{}\cdots &{}\cdots &{}\alpha _{\bar{\xi }_{1}(p^{m(s-2)}-1)}&{}\cdots \\ \vdots &{}\vdots &{}\vdots &{}\vdots &{}\vdots &{}\vdots &{}\vdots &{}\vdots &{}\vdots &{}\vdots \\ \alpha _{\bar{\xi }_{s-3}(0)}&{}\cdots &{}\alpha _{\bar{\xi }_{s-3}(0)}&{}\alpha _{\bar{\xi }_{s-3}(1)}&{}\cdots &{}\alpha _{\bar{\xi }_{s-3}(1)}&{}\cdots &{}\cdots &{}\alpha _{\bar{\xi }_{s-3}(p^{m(s-2)}-1)}&{}\cdots \\ 1&{}\cdots &{}1&{}1&{}\cdots &{}1&{}\cdots &{}\cdots &{}1&{}\cdots \end{matrix}\quad \begin{matrix} \alpha _{{p^m}-1}\\ \alpha _{\bar{\xi }_{0}(p^{m(s-2)}-1)}\\ \alpha _{\bar{\xi }_{1}(p^{m(s-2)}-1)}\\ \vdots \\ \alpha _{\bar{\xi }_{s-3}(p^{m(s-2)}-1)}\\ 1 \end{matrix} \right) ._{s\times p^{m(s-1)}} \end{aligned}$$

For example,

  • Consider \(S=\mathbb {Z}_{27}\). So, the Gray map \(\Phi \) for every \(\varvec{r}\in \mathbb {Z}_{27}^n\) is defined from \(\mathbb {Z}_{27}^{n}\) to \(\mathbb {F}_{3}^{9n}\) by \(\Phi (\varvec{r})=[\varvec{r}]\mathcal {A}=[\widetilde{a_0(\varvec{r})}, \widetilde{a_1(\varvec{r})}, \widetilde{a_2(\varvec{r})}]\mathcal {A}\). It is easy to see that

    $$ \mathcal {A}={\left( \begin{matrix} 0&{}1&{}2&{}0&{}1&{}2&{}0&{}1&{}2\\ 0&{}0&{}0&{}1&{}1&{}1&{}2&{}2&{}2\\ 1&{}1&{}1&{}1&{}1&{}1&{}1&{}1&{}1 \end{matrix}\right) .}_{3\times 9} $$
  • Consider \(S=GR(4,2)\). Thus, the Gray map \(\Phi \) for every \(\varvec{r}\in GR(4,2)^n\) is defined from \(GR(4,2)^{n}\) to \(\mathbb {F}_{4}^{4n}\) by \(\Phi (\varvec{r})=[\varvec{r}]\mathcal {A}=[\widetilde{a_0(\varvec{r})}, \widetilde{a_1(\varvec{r})}]\mathcal {A}\). It is easy to check that

    $$ \mathcal {A}={\left( \begin{matrix} 0&{}1&{}\xi &{}1+\xi \\ 1&{}1&{}1&{}1 \end{matrix}\right) .}_{2\times 4} $$

3 Gray images of linear codes over R

In this section, we will present a method that can be used to check the linearity or non-linearity of \(\Phi (\mathcal {C})\). The following two definitions will be useful for the proof of the main result of this section.

Definition 1

Let \(a=a_{0}+a_{1}\bar{\xi }+\cdots +a_{m-1}\bar{\xi }^{m-1}\) and \( b= b_{0}+b_{1}\bar{\xi }+\cdots +b_{m-1}\bar{\xi }^{m-1}\) belong to \(\mathbb {F}_{2^{m}}\), where \(a_0,a_1,\ldots ,a_{m-1}\), \( b_0,b_1,\ldots ,b_{m-1}\in \mathbb {F}_2\). We define

$$\begin{aligned} a\odot b&=a_{0}b_{0}+a_{1}b_{1}\bar{\xi }+\cdots +a_{m-1}b_{m-1}\bar{\xi }^{m-1},\\ a\oplus b&=a_{0}\oplus b_{0}+(a_{1}\oplus b_{1})\bar{\xi }+\cdots +(a_{m-1}\oplus b_{m-1})\bar{\xi }^{m-1}. \end{aligned}$$

One can see that \(a\odot b=b\odot a\), \(a\odot a=a\), and \(a\oplus a=0\). We extend the application of the operations “\(\odot \)”and “\(\oplus \)”on \(\mathbb {F}_{2^{m}}\) to \(\mathbb {F}_{2^{m}}^{n}\) in the natural way; that is, if \(\varvec{a}=(u^{1}, u^{2},\ldots , u^{n}), \varvec{b}=(v^{1}, v^{2},\ldots , v^{n})\in \mathbb {F}_{2^{m}}^{n}\), then \(\varvec{a} \odot \varvec{b}=(u^{1} \odot v^{1}, u^{2} \odot v^{2}, \ldots , u^{n}\odot v^{n})\), \(\varvec{a} \oplus \varvec{b}=(u^1\oplus v^1, u^2\oplus v^2,\ldots ,u^n\oplus v^n)\).

Definition 2

Let \(c=a_0+a_1\xi +\cdots +a_{m-1}{\xi }^{m-1}\) and \(c'=a'_0+a'_1\xi +\cdots +a'_{m-1}{\xi }^{m-1}\) belong to R, where \(a_i=a_{i0}+2a_{i1},a'_i=a'_{i0}+2a'_{i1}\in \mathbb {Z}_4\) for \(i=0,\ldots ,m-1\). We define

$$\begin{aligned} c\odot c'&=a_0\odot a'_0+(a_1\odot a'_1)\xi +\cdots +(a_{m-1}\odot a'_{m-1}){\xi }^{m-1},\\ c\oplus c'&=a_0\oplus a'_0+(a_1\oplus a'_1)\xi +\cdots +(a_{m-1}\oplus a'_{m-1}){\xi }^{m-1},\\ c\circledast c'&=2(a_{00}a'_{00}+a_{10}a'_{10}\xi +\cdots +a_{m-10}a'_{m-10}\xi ^{m-1}). \end{aligned}$$

It is easy to see that \(c\odot c'=c'\odot c\) and \(c\odot c=c\). The operations “\(\odot \)”, “\(\oplus \)”and “\(\circledast \)”can be extended to \(R^n\) in an obvious way; in other words, for \(\varvec{c}=(u^{1}, u^{2},\ldots , u^{n}), \varvec{c'}=(v^{1}, v^{2},\ldots , v^{n})\in R^n\), we have \(\varvec{c} \odot \varvec{c'}=(u^{1} \odot v^{1}, u^{2} \odot v^{2}, \ldots , u^{n}\odot v^{n})\), \(\varvec{c} \oplus \varvec{c'}=(u^1\oplus v^1, u^2\oplus v^2,\ldots ,u^n\oplus v^n)\) and \(\varvec{c}\circledast \varvec{c'}=(u^1\circledast v^1,\ldots ,u^n\circledast v^n)\). Furthermore, if U and V are two subsets of \(R^n\), we define \(U *V\) as (5).

Lemma 3.1

For all \(\varvec{X}, \varvec{Y}\in R^n\), we have \(\Phi (\varvec{X}+\varvec{Y})=\Phi (\varvec{X})\oplus \Phi (\varvec{Y})\oplus \Phi (\varvec{X}\circledast \varvec{Y})\).

Proof

It is enough to prove for the case \(n=1\). Let XY be two arbitrary elements in R. There are \(a_0,\ldots ,a_{m-1},a'_0,\ldots ,a'_{m-1}\in \mathbb {Z}_4\) such that \(X=a_0+a_1\xi +\cdots +a_{m-1}{\xi }^{m-1}\) and \( Y=a'_0+a'_1\xi +\cdots +a'_{m-1}{\xi }^{m-1}\), where \(a_i=a_{i0}+2a_{i1}\) and \(a'_i=a'_{i0}+2a'_{i1}\), for \(i=0,\ldots ,m-1\). Note that, for every \(u,v\in \mathbb {Z}_4\), \(u+ v=u\oplus v\oplus (u\circledast v)\). So,

$$\begin{aligned} X+Y&=(a_0+a_1\xi +\cdots +a_{m-1}{\xi }^{m-1})+(a'_0+a'_1\xi +\cdots +a'_{m-1}{\xi }^{m-1})\\&=((a_{00}+2a_{01})+(a_{10}+2a_{11})\xi +\cdots +(a_{m-10}+2a_{m-11})\xi ^{m-1})\\&\quad +((a'_{00}+2a'_{01})+(a'_{10}+2a'_{11})\xi +\cdots +(a'_{m-10}+2a'_{m-11})\xi ^{m-1})\\&= ((a_{00}+2a_{01})+(a'_{00}+2a'_{01}))+((a_{10}+2a_{11})+(a'_{10}+2a'_{11}))\xi +\\&\quad \cdots +((a_{m-10}+2a_{m-11})+(a'_{m-10}+2a'_{m-11}))\xi ^{m-1}\\&=((a_{00}+a'_{00})+2(a_{01}+a'_{01}))+((a_{10}+a'_{10})+2(a_{11}+a'_{11}))\xi +\\&\quad \cdots +((a_{m-10}+a'_{m-10})+2(a_{m-11}+a'_{m-11}))\xi ^{m-1}\\&\quad +2(a_{00}a'_{00}+a_{10}a'_{10}\xi +\cdots +a_{m-10}a'_{m-10}\xi ^{m-1})\\&=X\oplus Y\oplus (X\circledast Y). \end{aligned}$$

Therefore, \([X+Y]=[X]\oplus [Y]\oplus [X\circledast Y]\), but then \([X+Y]\mathcal {A}=[X]\mathcal {A}\oplus [Y]\mathcal {A}\oplus [X\circledast Y]\mathcal {A}\). Consequently, \(\Phi (X+Y)=\Phi (X)\oplus \Phi (Y)\oplus \Phi (X\circledast Y)\).\(\square \)

Note that for \(\varvec{X}, \varvec{Y}\) belong to \(R^n\), \(\varvec{X}\circledast \varvec{Y}=2(\varvec{X}\odot \varvec{Y})\). Equivalently, we have

$$\begin{aligned} \Phi (\varvec{X}+\varvec{Y})=\Phi (\varvec{X})\oplus \Phi (\varvec{Y})\oplus \Phi (2(\varvec{X}\odot \varvec{Y})). \end{aligned}$$
(7)

Proposition 3.1

Let \(\varvec{X}, \varvec{Y} \in R^n\). Then \(\Phi (\varvec{X}+\varvec{Y}+2(\varvec{X}\odot \varvec{Y}))=\Phi (\varvec{X})\oplus \Phi (\varvec{Y})\).

Proof

The proof follows from (7).\(\square \)

Let \(\mathcal {C}\) be a linear code of length n over R, in the following theorem, we state the necessary and sufficient condition for the linearity of \(\Phi (\mathcal {C})\).

Theorem 3.1

Let \(\mathcal {C}\) be a linear code of length n over R. Then, \(\Phi (\mathcal {C})\) is a linear code if and only if \(2(\varvec{X} \odot \varvec{Y})\in \mathcal {C}\), for all \(\varvec{X},\varvec{Y}\in \mathcal {C}\).

Proof

By Proposition 3.1, we have \(\Phi (\varvec{X}+\varvec{Y}+2(\varvec{X}\odot \varvec{Y}))=\Phi (\varvec{X})\oplus \Phi (\varvec{Y})\). Therefore, we deduce that \(\Phi (\varvec{X})\oplus \Phi (\varvec{Y})\in \Phi (\mathcal {C})\) if and only if \(\Phi (\varvec{X}+\varvec{Y}+2(\varvec{X}\odot \varvec{Y}))\in \Phi (\mathcal {C})\) for all \(\varvec{X},\varvec{Y}\in \mathcal {C}\). So, the results follows.\(\square \)

Theorems 5 of [6] and \(4.13 (s=2)\) of [15] can be concluded from the above theorem.

Corollary 3.1

Let \(\mathcal {C}\) be a code of length n over R, and \(\varvec{X}_1,\ldots ,\varvec{X}_r\) be a set of generators of \(\mathcal {C}\). Then, \(\Phi (\mathcal {C})\) is linear if and only if \(2(\varvec{X}_{t}\odot \varvec{X}_{l})\in \mathcal {C}\) for all tl satisfying \(1\le t< l\le r\). In particular, if \(\mathcal {G}\) is a generator matrix of a linear code \(\mathcal {C}\) and \(\{\varvec{v}_j\}_{j=1}^{k_0}\) are the row vectors of order four in \(\mathcal {G}\). Thus, \(\Phi (\mathcal {C})\) is linear if and only if \(2(\varvec{v}_{t}\odot \varvec{v}_{l})\in \mathcal {C}\) for all tl satisfying \(1\le t< l\le k_0\).

Example 3.1

Let \(R=GR(4,2)=\mathbb {Z}_4[\xi ]\), where \(h(\xi )=0\) and \(h(x)=x^2+x+1\) is a basic irreducible polynomial over \(\mathbb {Z}_{4}\). Suppose that \(\mathcal {C}\) be a linear code of length 7 over R with generator matrix

$$ \mathcal {G}=\left( \begin{array}{c} \varvec{v}_1\\ \varvec{v}_2\\ \varvec{v}_3\\ \varvec{v}_4\\ \varvec{u} \end{array}\right) =\left( \begin{array}{ccccccc} 1&{}0&{}0&{}0&{}\xi &{}0&{}3\\ 0&{}1&{}0&{}0&{}0&{}2&{}2\xi \\ 0&{}0&{}1&{}0&{}1&{}\xi &{}0\\ 0&{}0&{}0&{}1&{}\xi &{}0&{}1\\ 0&{}0&{}0&{}0&{}2&{}2\xi &{}2 \end{array}\right) . $$

Since \(2(\varvec{v}_{1}\odot \varvec{v}_{4})\notin \mathcal {C}\), thus Theorem 3.1 implies that \(\Phi (\mathcal {C})\) is nonlinear.

Example 3.2

Suppose that \(R=GR(4,2)=\mathbb {Z}_4[\xi ]\), where \(h(\xi )=0\) and \(h(x)=x^2+x+1\) is a basic irreducible polynomial over \(\mathbb {Z}_{4}\). Let \(\mathcal {C}\) be a linear code of length 6 over R with generator matrix

$$ \mathcal {G}=\left( \begin{array}{c} \varvec{v}_1\\ \varvec{v}_2\\ \varvec{v}_3 \end{array}\right) =\left( \begin{array}{cccccc} 1&{}0&{}0&{}\xi &{}0&{}2\\ 0&{}1&{}0&{}0&{}1&{}2\xi \\ 0&{}0&{}1&{}1&{}\xi &{}1 \end{array}\right) . $$

It is to check that \(2(\varvec{v}_{1}\odot \varvec{v}_{2})\), \(2(\varvec{v}_{1}\odot \varvec{v}_{3})\) and \(2(\varvec{v}_{2}\odot \varvec{v}_{3})\) belong to \( \mathcal {C}\), so Theorem 3.1 implies that \(\Phi (\mathcal {C})\) is linear.

4 Gray images of linear cyclic codes over R

Generators for cyclic \(\mathbb {Z}_4\)-codes have been studied by Kanwar and López in [9]. Also, all cyclic codes of odd length over \(\mathbb {Z}_{4}\) whose Gray images are linear were determined by Wolfmann, see [19]. In this section, we generalize Wolfmann’s idea for these codes of odd length n over the Galois ring R. So, throughout this section, we let n be odd. Recall that a linear code \(\mathcal {C}\) of length n is called cyclic, if \(c=(c_0, c_1, \ldots , c_{n-1}) \in \mathcal {C}\) implies that \((c_{n-1}, c_0, \ldots , c_{n-2}) \in \mathcal {C}\). As is customary, \(\mathcal {R}\) denote the quotient ring \(\frac{R[x]}{\langle x^{n}-1\rangle }\) and the elements of \(\mathcal {R}\) will be identified with polynomials over R of degree \(\leqslant n-1\). For simplicity, we write a polynomial f(x) as f, where \(f(x) \in \mathcal {R}\). We represent any n-tuple \((c_0,c_1, \ldots , c_{n-1}) \in R^n\) by the residue class of the polynomial \(c_0+c_{1}x+ \dots +c_{n-1}x^{n-1}\) over R mod \(x^n-1\). It is known that a cyclic code \(\mathcal {C}\) corresponds to an ideal of \(\mathcal {R}\). We start this section with a lemma where we discuss the structure of the polynomial generator of the cyclic code of odd length n over R. This lemma will play a crucial role in the linearity of \(\Phi (\mathcal {C})\). Before we go on, we need to state the following well-known proposition.

Proposition 4.1

[16] Let \(\mathcal {C}\) be a cyclic code of odd length n over the Galois ring R. Then there is a unique set of pairwaise coprime monic polynomials \(g_{0},g_{1}, g_{2}\) over R (possibly, some of them are equal to 1) such that \(g_{0}g_{2} g_{1}=x^{n}-1\) in R[x] and \(\mathcal {C}=<\hat{g}_2, 2\hat{g}_1>\), where \(\hat{g}_{i}=\prod _{i\ne j}g_{j}\).

Lemma 4.1

Under the conditions stated in Proposition 4.1, we have:

  1. (i)

    \(\mathcal {C}=\langle g_0g_1,2g_0 \rangle =\langle g_0g_1+2g_0 \rangle \).

  2. (ii)

    \(\mathcal {C} \cap 2\mathcal {R} = \langle 2g_0 \rangle \).

Proof

(i) By Proposition 4.1, \(\mathcal {C}= \langle g_0g_1, 2g_0g_2 \rangle \) and \(x^n-1=g_0g_2g_1\). Set \(\mathcal {C}'=\langle g_0g_1, 2g_0 \rangle \). Clearly \(\mathcal {C} \subseteq \mathcal {C}'\). Inasmuch as gcd\((g_1, g_2)=1\), thus there exist \(s_1\) and \(s_2 \in R[x]\) such that

$$ s_1g_1+s_2g_2=1. $$

Multiplying the above equation by \(2g_0\), we obtain

$$ 2g_0=2s_1g_0g_1+2s_2g_0g_2 \in \mathcal {C}. $$

This means that \(\mathcal {C}' \subseteq \mathcal {C}\); i.e., \(\mathcal {C}' = \mathcal {C}\).

For the last equality, it is enough to show that \(\mathcal {C} \subseteq \langle g \rangle \), where \(g=g_0g_1+2g_0\). Inasmuch as gcd\((g_1, g_2)=1\), thus there exist \(r_1\) and \(r_2 \in R[x]\) such that

$$ r_1g_1+r_2g_2=1. $$

Multiplying the above equation by \(2g_0\), we conclude

$$ 2g_0=2r_1g_0g_1+2r_2g_0g_2=g(2r_1)+g(r_2g_2) \in \langle g \rangle . $$

Furthermore, \(g_0g_1= g-2g_0 \in \langle g \rangle \). Consequently, \(\mathcal {C}=\langle g \rangle \).

(ii) It is easy to see that \((\supseteq )\) holds. Now suppose that \(b \in \mathcal {C} \cap 2\mathcal {R}\). So, there exist \(r \in \mathcal {R}\) such that

$$ b= rg_0g_1+2rg_0. $$

Therefore, there exists \(r' \in \mathcal {R}\) such that \(r=2r'\). Hence, we have

$$ b=2r'g_0g_1 \in \langle 2g_0 \rangle . $$

Consequently, \((\subseteq )\) also holds.\(\square \)

Remark 4.1

The elements of Galois ring R can be expressed in the form \(a+2b\), where \(a,b \in \tau \). The natural epimorphism \(\bar{~}: R \longrightarrow \mathbb {F}_{2^m}\) is defined by \(a+2b \longmapsto a\) can be extended to a ring epimorphism from R[x] to \(\mathbb {F}_{2^m}[x]\) as following:

$$\begin{aligned} \bar{~}: R[x]&\longrightarrow \mathbb {F}_{2^m}[x]\\ a(x)+2b(x)&\longmapsto a(x). \end{aligned}$$

One can see that if \(a(x) \in R[x]\), then \(2a(x)=2 \bar{a}(x)\).

Lemma 4.2

Let \(\mathcal {C}\) be a cyclic code of odd length n over the Galois ring R. Then \(\Phi (\mathcal {C})\) is a linear code if and only if \(\langle \bar{g}_0\bar{g}_1 \rangle *\langle \bar{g}_0\bar{g}_1 \rangle \subset \langle \bar{g}_0 \rangle \).

Proof

By Theorem 3.1\(\Phi (\mathcal {C})\) is a linear code if and only if

$$ 2(\bar{\varvec{X}}*\bar{\varvec{Y}})=2(\varvec{X} *\varvec{Y})=2(\varvec{X} \odot \varvec{Y}) \in \mathcal {C}, $$

for all \(\varvec{X},\varvec{Y}\in \mathcal {C}\). The translation in terms of polynomial representations gives that \(\Phi (\mathcal {C})\) is a linear code if and only if \(2(\bar{m}_1\bar{g} *\bar{m}_2\bar{g}) \in \mathcal {C}\), for all \(m_1, m_2 \in \mathcal {R}\), where \(g=g_0g_1+2g_0\) is the generator of \(\mathcal {C}\). Since \(\bar{g}= \bar{g}_0\bar{g}_1\), the condition from Lemma 4.1 becomes \(2(\bar{m}_1\bar{g}_0\bar{g}_1 *\bar{m}_2\bar{g}_0\bar{g}_1) \in \mathcal {C} \cap 2\mathcal {R} = \langle 2g_0 \rangle \), for all \(m_1, m_2 \in \mathcal {R}\). Therefore the above condition is equivalent to \(\bar{m}_1\bar{g}_0\bar{g}_1 *\bar{m}_2\bar{g}_0\bar{g}_1 \in \langle \bar{g}_0 \rangle \), for all \(m_1, m_2 \in \mathcal {R}\), which is the expected result.\(\square \)

Remark 4.2

Let n be odd, \(\mathbb {F}_{2^m}\) be the finite field of order \(2^m\), \(\mathbb {F}_{2^{mt}}\) be the splitting field of \(x^{n}-1\) over \(\mathbb {F}_{2^m}\). Let \(\beta \) be a primitive nth root in \(\mathbb {F}_{{2^m}^t}\). We define the generalized Mattson-Solomon transform as the function \(\mathcal {T} : \mathbb {F}_{{2^m}^t}[x]/\langle x^{n}-1 \rangle \longrightarrow \mathbb {F}_{{2^m}^t}[x]/\langle x^{n}-1 \rangle \) such that

$$ A(x)=\mathcal {T}({a}(x))=\sum _{k=0}^{n-1}{a}(\beta ^{-k})x^k. $$

It is easy to see that \(\mathcal {T}\) is a bijection. The inverse transformation is given by

$$ a(x)=\mathcal {T}^{-1}(A(x))=\sum _{k=0}^{n-1}A(\beta ^{k})x^k. $$

Lemma 4.3

Let \(a(x), b(x) \in \mathbb {F}_{{2^m}^t}[x]/\langle x^{n}-1 \rangle \), then \(\mathcal {T}(a(x) b(x))=\mathcal {T}(a(x))*\mathcal {T}(b(x))\).

In the following, \(g=g_0g_1+2g_0\) and \(\bar{g}_2\otimes \bar{g}_2\) is the divisor of \(x^n-1\) in \(\mathbb {F}_{2^m}[x]\) whose roots are the \(\beta ^i\beta ^j\) such that \(\beta ^i\) and \(\beta ^j\) are roots of \(\bar{g}_2\).

Lemma 4.4

Let \(\bar{d}\) and \(\bar{g}_2\) be in \(\mathbb {F}_{2^m}[x]\) such that \(x^{n}-1=\bar{d}\bar{g}_2\), with n odd. Let \(\bar{e}\) be such that \(x^{n}-1=(\bar{g}_2\otimes \bar{g}_2)\bar{e}\). Then \(\langle \bar{d} \rangle *\langle \bar{d} \rangle \subset \langle \bar{e} \rangle \).

Proof

Let \(\bar{s}=\bar{m}_1\bar{d} *\bar{m}_2\bar{d}\) be in \(\langle \bar{d} \rangle *\langle \bar{d} \rangle \). Using the inverse Mattson-Solomon transform we obtain \(\sum _{k=0}^{n-1}\bar{s}(\beta ^{k})x^{k}=\sum _{i=0}^{n-1}\bar{m}_1(\beta ^{i})\bar{d}(\beta ^{i})x^{i}\sum _{j=0}^{n-1}\bar{m}_2(\beta ^{j})\bar{d}(\beta ^{j})x^{j}\). Since \(\bar{d}(\beta ^t) \ne 0\) if and only if \(\bar{g}_2(\beta ^t)= 0\) then the right side of the previous equality is \(\sum _{\bar{g}_2(\beta ^i)=0}\bar{m}_1(\beta ^{i})\bar{d}(\beta ^{i})x^{i}\sum _{\bar{g}_2(\beta ^j)=0}\bar{m}_2(\beta ^{j})\bar{d}(\beta ^{j})x^{j}\). Consequently, \(\sum _{k=0}^{n-1}\bar{s}(\beta ^{k})x^{k}= \sum _{(\bar{g}_2\otimes \bar{g}_2)(\beta ^k)=0}\sum _{i+j=k}\bar{m}_1(\beta ^{i})\bar{d}(\beta ^{i})\bar{m}_2(\beta ^{j})\bar{d}(\beta ^{j})x^{k}\). It follows that if \(\bar{s}(\beta ^{k}) \ne 0\) then \((\bar{g}_2\otimes \bar{g}_2)(\beta ^k)=0\) or, equivalently, if \(\bar{e}(\beta ^k)=0\) then \(\bar{s}(\beta ^{k})= 0\). This means that \(\bar{e}\) divides \(\bar{s}\) and, therefore, \(\bar{s}\) belongs to \(\langle \bar{e} \rangle \).

Theorem 4.1

Let \(\mathcal {C}=\langle g \rangle \) be a cyclic code of odd length n over the Galois ring R, where \(g=g_0g_1+2g_0\) with \(x^{n}-1=g_{0}g_{2} g_{1}\). Let \(\bar{e}\) be such that

$$\begin{aligned} x^n-1=(\bar{g}_2\otimes \bar{g}_2)\bar{e} \end{aligned}$$

in \(\mathbb {F}_{2^m}[x]\). The following statements are equivalent.

  1. (i)

    \(\Phi (\mathcal {C})\) is linear.

  2. (ii)

    \(\bar{g}_0\) divides \(\bar{e}\) in \(\mathbb {F}_{2^m}[x]\).

Proof

\((i)\Rightarrow (ii)\) If \(\bar{g}_0=1\) or \(\bar{g}_2=1\), then obviously \(\bar{g}_0\) divides \(\bar{e}\). From now on \(\bar{g}_0 \ne 1\) and \(\bar{g}_2 \ne 1\). Define

$$\begin{aligned} K=\{k:\ (\bar{g}_2\otimes \bar{g}_2)(\beta ^{k})=0, \ 0 \le k \le n-1\ \} \end{aligned}$$

and

$$\begin{aligned} J(k)=\{j:\ \bar{g}_{2}(\beta ^{j})= \bar{g}_{2}(\beta ^{k-j})=0, \ 0 \le j \le n-1\ \}. \end{aligned}$$

Since \(\bar{g}_2 \ne 1\) then \(K \ne \emptyset \) and if \(k \in K\) then \(J(k) \ne \emptyset \). Following Lemma 4.2, for every integer m, \(0 \le m \le n-1\), there exists \(\bar{\lambda }_m\) such that \( \bar{g}_0\bar{g}_1 *x^{m} \bar{g}_0\bar{g}_1= \bar{\lambda }_m \bar{g}_0\). Using the Mattson-Solomon transform with \(\bar{d}= \bar{g}_0\bar{g}_1\) we find \(\sum _{k \in K}(\sum _{j \in J(k)}A_{j}(k)(\beta ^m)^j)x^k=\sum _{k \in K}\bar{\lambda }_m(\beta ^k)\bar{g}_0(\beta ^k)x^k\), with \(A_{j}(k)=\bar{d}(\beta ^j)\bar{d}(\beta ^{k-j})\). Let k be in K and let us consider \(S_{k}(X)=\sum _{j \in J(k)}A_{j}(k)X^{j}\). From the definitions of K and J(k), we have \(A_j(k) \ne 0\) for every \(k \in K\) and every \(j \in J(k)\) and, therefore, \(S_k(x)\) is not zero. The degree of \(S_k(x)\) is at most \(n-1\) which also is the maximum number of roots of \(S_k(x)\). Consequently, there exists m, \(0 \le m \le n-1\) such that \(S_k(\beta ^m) \ne 0\). It follows that \(\bar{\lambda }_m(\beta ^k)\bar{g}_0(\beta ^k) \ne 0\) and, therefore, \(\bar{g}_0(\beta ^k) \ne 0\). We deduce that \((\bar{g}_2\otimes \bar{g}_2)(\beta ^k) = 0\) implies \(\bar{g}_0(\beta ^k) \ne 0\) or, equivalently, \(\bar{g}_0(\beta ^k)=0\) implies \((\bar{g}_2\otimes \bar{g}_2)(\beta ^k) \ne 0\). In other word, if \(\bar{g}_0(\beta ^k)=0\) then \(\bar{e}(\beta ^k)=0\) which means that \(\bar{g}_0\) divides \(\bar{e}\).

\((ii)\Rightarrow (i)\) If \(\bar{g}_0\) divides \(\bar{e}\) then \(\langle \bar{e} \rangle \subset \langle \bar{g}_0 \rangle \). Applying Lemma 4.4 with \(\bar{d}=\bar{g}_0\bar{g}_1\) we show that the condition of Lemma 4.2 is satisfied and, therefore, \(\Phi (\mathcal {C})\) ia a linear code.\(\square \)

Corollary 4.1

Let \(\mathcal {C}=\langle g \rangle \) be a cyclic code of odd length n over the Galois ring R, where \(x^n-1=g_0g_2g_1\).

  1. (i)

    If \(g_0=1\), then \(\Phi (\mathcal {C})\) is linear.

  2. (ii)

    If \(g_2=1\), then \(\Phi (\mathcal {C})\) is linear.

  3. (iii)

    If \(g_2=x-1\), then \(\Phi (\mathcal {C})\) is linear.

Example 4.1

Let \(R=GR(4,2) = \mathbb {Z}_4[\xi ]\), where \(h(\xi )=0\) and \(h=x^2+x+1\) is a basic irreducible polynomial over \(\mathbb {Z}_4\). In R[x], \(x^{3}-1=g_{0}g_{2} g_{1}\), where \(g_0=x-1\), \(g_1=x-\xi \) and \(g_2=x-\xi ^2\). Let \(\mathcal {C}\) be a cyclic code of length 3 over R generated by polynomial \(g=g_0g_1+2g_0\). Obviously, \(\bar{g}_0\) divides \(\bar{e}= (x-1)(x-\bar{\xi }^2)\) in \(\mathbb {F}_{4}[x]\). Hence, Theorem 4.1 implies that \(\Phi (\mathcal {C})\) is linear.

Example 4.2

Let \(R=GR(4,2) = \mathbb {Z}_4[\xi ]\), where \(h(\xi )=0\) and \(h(x)=x^2+x+1\) is a basic irreducible polynomial over \(\mathbb {Z}_4\). In R[x], \(x^{7}-1=g_{0}g_{2} g_{1}\), where \(g_0 = x^3 - x^2 + 2x - 1\), \(g_1 = x^3 + 2x^2 + x - 1\) and \(g_2 = x - 1\). Let \(\mathcal {C}\) be a cyclic code of length 7 over R generated by polynomial \(g=g_0g_1+2g_0\). It is easy to see that \(\bar{g}_0\) divides \(\bar{e}=(x^3-x^2-1)(x^3+x-1) \) in \(\mathbb {F}_{4}[x]\). Therefore, Theorem 4.1 implies that \(\Phi (\mathcal {C})\) is linear.

5 Conclusion

For a linear code \(\mathcal {C}\) of arbitrary length n over R, we showed that Gray image of \(\mathcal {C}\) is linear if and only if for every \(\varvec{X},\varvec{Y}\in \mathcal {C}\), \(2(\varvec{X} \odot \varvec{Y})\in \mathcal {C}\). In addition, we gave a necessary and sufficient condition whose Gray image is linear for a cyclic code of odd length over R by using the generator polynomial of this code. As a future research, it would be interesting to check the linearity of the Gray image of a linear code and a cyclic code over \(GR(2^s,m)\) (for \(s > 2\)) using their generator matrix and generator polynomial, respectively. As mentioned in [19], an open problem is check the linearity of the Gray image of a cyclic code over \(\mathbb {Z}_4\) of even length by using its generator polynomials.This problem can be studied for the Galois ring GR(4, m) too.