1 Introduction

For any positive integer \(s\ge 1\), let \({\mathbb {Z}}_{2^s}\) be the ring of integers modulo \(2^s\) and \({\mathbb {Z}}_{2^s}^n\) be the set of all n-tuples over \({\mathbb {Z}}_{2^s}\). A binary code of length n is a non-empty subset of \({\mathbb {Z}}_2^n\), and it is linear if it is a subspace of \({\mathbb {Z}}_2^n\). Similarly, a \({\mathbb {Z}}_{2^s}\)-additive code is a subgroup of \({\mathbb {Z}}_{2^s}^n \), which is also called linear code over \({\mathbb {Z}}_{2^s}\), and in case \(s=2\) it is called quaternary linear code. In addition, a linear code is termed cyclic, if a cyclic shift of any codeword is a codeword.

There are different Gray maps from \({\mathbb {Z}}_{2^s}\) to \({\mathbb {Z}}_2^{2^{s-1}}\), see for instance [5, 13]. One of them is Carlet’s Gray map \(\Phi :{\mathbb {Z}}_{2^{s}}\longrightarrow {\mathbb {Z}}_2^{2^{s-1}}\) defined as \(\Phi (u)=(u_{s-1},\ldots ,u_{s-1})+(u_{0},\ldots ,u_{s-2})Y\), where \(u=\sum _{i=0}^{s-1}2^{i}u_{i}\in {\mathbb {Z}}_{2^s} \) \((u_{i}\in {\mathbb {Z}}_2)\) and Y is a matrix of size \((s-1)\times 2^{s-1}\) which columns are the elements of \({\mathbb {Z}}_2^{s-1}\), \((u_{s-1},\ldots ,u_{s-1})\) and \((u_{0},\ldots ,u_{s-2})Y\) are vectors of length \(2^{s-1},\) see [3]. In this paper, we focus on the special case \(s=3\) (i.e., \( {\mathbb {Z}}_{8}\)). Therefore, if \(s=3\), then \(\Phi :{\mathbb {Z}}_8\longrightarrow {\mathbb {Z}}_2^4\) is with \(0\rightarrow 0000, 1\rightarrow 0101, 2\rightarrow 0011, 3\rightarrow 0110, 4\rightarrow 1111, 5\rightarrow 1010, 6\rightarrow 1100, 7\rightarrow 1001\). In general, the Gray map \(\Phi \) has been generalized for finite chain rings, see for instance [11, 15]. Throughout this paper, we write "Gray image" instead of “Carlet’s Gray image” for simplicity.

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

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

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

$$\begin{aligned} U \odot V=\{{{\textbf {u}}} \odot {{\textbf {v}}} :\ {{\textbf {u}}} \in U, {{\textbf {v}}} \in V \}. \end{aligned}$$

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 \(k\times n\) matrix G over \({\mathbb {Z}}_{8}\) is called a generator matrix of \({\mathcal {C}}\) if the rows of G generate \({\mathcal {C}}\) and no proper subset of the rows of G generates \({\mathcal {C}}\). As stated in [2, 9], any linear code \({\mathcal {C}}\) of length n over \({\mathbb {Z}}_{8}\) has a generator matrix which is permutation equivalent to a matrix of the form

$$\begin{aligned} G=\left( \begin{matrix} I_{\delta _{0}}&{}A_{0,1}&{}A_{0,2}&{}A_{0,3}\\ 0&{}2I_{\delta _{1}}&{}2A_{1,2}&{}2A_{1,3}\\ 0&{}0&{}4I_{\delta _{2}}&{}4A_{2,3} \end{matrix}\right) , \end{aligned}$$

where the matrices \(A_{1,2}\), \(A_{1,3}\) and \(A_{2,3}\) are binary matrices. The matrix G is said to be in standard form and such a code \({\mathcal {C}}\) is called of type \(\{\delta _{0}, \delta _{1}, \delta _{2}\}\), for more details, see [1, 5, 6].

Let \({\mathcal {C}}\) be a linear code over \({\mathbb {Z}}_{8}\). 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 [10, 17], it has been given some necessary and sufficient conditions for which the binary Gray image of a quaternary linear code is linear. Specifically, if G is a generator matrix of a linear code \({\mathcal {C}}\) over \({\mathbb {Z}}_{4}\) and \(\{{\mathbf {v}}_{j}\}_{j=1}^{\delta }\) are the rows of order four in G, then the Gray image of \({\mathcal {C}}\) (i.e., \(\Phi ({\mathcal {C}})\)) is a binary linear code if and only if \( 2({\mathbf {v}}_{j}*{\mathbf {v}}_{k}) \in {\mathcal {C}}\), for all jk satisfying \(1\le j<k\le \delta \). 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}).\) Also, by applying the operation "\(\odot \)" on \({\mathbb {Z}}_{8}\), a necessary and sufficient condition for linearity \(\Phi ({\mathcal {C}})\) has been stated, as follows:

Proposition 1.1

[16, Theorem 4.13] Let \({\mathcal {C}}\) be a linear code over \({\mathbb {Z}}_{8}\). Then \(\Phi {({\mathcal {C}})}\) is a binary linear code if and only if \(2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\), for all \({\mathbf {u}}, {\mathbf {v}}\in {\mathcal {C}}\).

The linearity problem has been studied for the family of Hadamard linear codes over \({\mathbb {Z}}_{8}\), see [7, 8]. Moreover, in [18] Wolfmann determined all cyclic codes of odd length over \({\mathbb {Z}}_4\) whose Gray images are linear.

Let \({\mathcal {C}}\) be a linear code of length n over \({\mathbb {Z}}_8\) of type \(\{\delta _{0}, \delta _{1}, \delta _{2}\}\), hence \(\mid {\mathcal {C}}\mid =2^{3\delta _{0}+2\delta _{1}+\delta _{2}}\). To determine the linearity of \(\Phi ({\mathcal {C}})\) using the above proposition, it should be investigated \(2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\) (for all \({\mathbf {u}} , {\mathbf {v}}\in {\mathcal {C}}\)), which the number of calculations is equal to \({\mid {\mathcal {C}}\mid }^2 -\left( {\begin{array}{c}\mid {\mathcal {C}}\mid \\ 2\end{array}}\right) =2^{6\delta _{0}+4\delta _{1}+2\delta _{2}-1}+ 2^{3\delta _{0}+2\delta _{1}+\delta _{2}-1}\), by not considering the elements of order 2, the number of calculations is reduced at most to \(2^{6\delta _{0}+4\delta _{1}-1}+ 2^{3\delta _{0}+2\delta _{1}-1}\). Our aim in this paper is to significantly reduce the number of calculations. To do this, using the rows of the generator matrix of \({\mathcal {C}}\), we introduce a set \({\mathcal {S}}\) with \(\mid {\mathcal {S}} \mid \le \frac{\delta _{0}(\delta _{0}+3)}{2}+\delta _{1}\) and show that \(\Phi ({\mathcal {C}})\) is linear if and only if for every \({\mathbf {u}}, {\mathbf {v}}\in {\mathcal {S}}\), \(2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\). Thus the number of calculations is at most equal to \(\left( {\begin{array}{c}\frac{\delta _{0}(\delta _{0}+3)}{2}+\delta _{1}\\ 2\end{array}}\right) \). In this way, the calculations are much less of the method used in Proposition 1.1. Also, we generalize Wolfmann’s idea for a cyclic code of odd length over \({\mathbb {Z}}_{8}\) and give a condition on the generator polynomial of this code whose Gray image is linear. The paper is organized as follows. The linearity of Gray image of a linear code of length n over \({\mathbb {Z}}_{8}\) using its generator matrix is investigated in Sect. 2. In Sect. 3, we give a condition on the generator polynomial of a cyclic code of odd length over \({\mathbb {Z}}_{8}\) which its Gray image is linear. In Sect. 4, some examples of linear and cyclic codes are presented whose Gray images are linear or non-linear.

2 Gray image of linear codes over \({\mathbb {Z}}_{8}\)

In general, if \({\mathcal {C}}\) is a linear code of length n over \({\mathbb {Z}}_{8}\), \(\Phi ({\mathcal {C}})\) may not be a linear code. In this section, we will present a method using the generator matrix \({\mathcal {C}}\) that can be used to check the linearity or non-linearity of \(\Phi ({\mathcal {C}})\). To do this, we first express the following lemma. This lemma specifies some relations between two operations "\( \odot \)" and "\(\circledast \)" over \({\mathbb {Z}}_{8}\) which will be used to prove the main results related to the linearity of \(\Phi ({\mathcal {C}})\) given in the next theorem.

Lemma 2.1

Let \(u,v,w,z\in {{\mathbb {Z}}_{8}} \). Then

  1. (i)

    \(2((u\circledast v)\odot w)=2(2(u \odot v)\odot w)\).

  2. (ii)

    \(2((u + v)\odot w)=2(u\odot w) + 2(v\odot w) + 2(2(u\odot v)\odot w)\).

  3. (iii)

    \(2(((u+v)\circledast w)\odot z)=2(2(u\odot w)\odot z)+2(2(v\odot w)\odot z)\).

Proof

Suppose the binary expansions of u, v, w and z over \({\mathbb {Z}}_{8}\) as follows:

$$\begin{aligned} u&=u_{0}+2u_{1}+4u_{2},\\ v&=v_{0}+2v_{1}+4v_{2},\\ w&=w_{0}+2w_{1}+4w_{2},\\ z&=z_{0}+2z_{1}+4z_{2}. \end{aligned}$$

Based on the rational sum between u and v, we have:

$$\begin{aligned} u+v=(u_{0}\oplus v_{0})+2(u_{1}\oplus v_{1}\oplus u_{0}v_{0})+4(u_{2}\oplus v_{2}\oplus u_{0}v_{0}(u_{1}\oplus v_{1})\oplus u_{1}v_{1}). \end{aligned}$$
(I)
  1. (i)

    Clearly, \( (u\circledast v)\odot w=2(u_{0}v_{0})w_{1}+4((u_{0}v_{0}(u_{1}\oplus v_{1})\oplus u_{1}v_{1})w_{2}) \). Multiplying both sides of the equation by 2, we obtain

    $$\begin{aligned} 2((u\circledast v)\odot w)=4(u_{0}v_{0})w_{1}=4(u\odot v)\odot 2w=2(2(u\odot v)\odot w). \end{aligned}$$
  2. (ii)

    By (I), we have:

    $$\begin{aligned} (u+v)\odot w=u\odot w+v\odot w+(u\circledast v)\odot w. \end{aligned}$$

    Multiplying both sides of the above equation by 2, we obtain

    $$\begin{aligned} 2((u + v)\odot w)=2(u\odot w) + 2(v\odot w) + 2(2(u\odot v)\odot w). \end{aligned}$$
  3. (iii)

    By (I), \( (u+v)\circledast w \) is equal to

    $$\begin{aligned} 2(u_{0}\oplus v_{0})w_{0}+4((u_{0}\oplus v_{0})w_{0}(u_{1}\oplus v_{1}\oplus u_{0}v_{0}\oplus w_{1})\oplus (u_{1}\oplus v_{1}\oplus u_{0}v_{0})w_{1}), \end{aligned}$$

    so \(((u+v)\circledast w)\odot z \) is equal to

    $$\begin{aligned} 2((u_{0}\oplus v_{0})w_{0})z_{1})+4(((u_{0}\oplus v_{0})w_{0}(u_{1}\oplus v_{1}\oplus u_{0}v_{0}\oplus w_{1})\oplus (u_{1}\oplus v_{1}\oplus u_{0}v_{0})w_{1})z_{2}), \end{aligned}$$

    multiplying the above expression by 2, we obtain

    $$\begin{aligned} 2(((u+v)\circledast w)\odot z)=4((u_{0}\oplus v_{0})w_{0}z_{1})=2(2(u\odot w)\odot z)+2(2(v\odot w)\odot z). \end{aligned}$$

\(\square \)

Let \({\mathcal {C}}\) be a linear code of length n over \({\mathbb {Z}}_{8}\). Let\({\mathcal {R}}=\{{\mathbf {r}}_{\lambda }\}_{{\lambda } \in {\Lambda }}\)be the rows of the generator matrix (in standard form) of \({\mathcal {C}}\). We define

$$\begin{aligned} {\mathcal {R}}_1&=\{ {\mathbf {r}}_{\lambda } \in {\mathcal {R}}: \ \mathrm{ord}({\mathbf {r}}_{\lambda })=8 \},\\ {\mathcal {R}}_2&=\{ {\mathbf {r}}_{\lambda } \in {\mathcal {R}}: \ \mathrm{ord}({\mathbf {r}}_{\lambda })=4 \},\\ {\mathcal {R}}_3&=\{ {\mathbf {r}}_{\lambda } \in {\mathcal {R}}: \ \mathrm{ord}({\mathbf {r}}_{\lambda })=2 \}. \end{aligned}$$

Now put \({\mathcal {S}}={\mathcal {R}}_1 \cup {\mathcal {R}}_2 \cup \{2({\mathbf {r}}_{\lambda } \odot {\mathbf {r}}_{\lambda '}): \ {{\mathbf {r}}_{\lambda }, {\mathbf {r}}_{\lambda '} }\in {\mathcal {R}}_1 \}\). Note that \(\delta _0=\mid {\mathcal {R}}_1 \mid \), \(\delta _1=\mid {\mathcal {R}}_2 \mid \), and \(\delta _2=\mid {\mathcal {R}}_3 \mid \). Therefore \(\mid {\mathcal {S}} \mid \le 2\delta _0+\delta _1+\genfrac(){0.0pt}1{\delta _0}{2}=\frac{\delta _{0}(\delta _{0}+3)}{2}+\delta _{1}\). Using the definition of set \({\mathcal {S}}\), the necessary and sufficient condition for linearity \(\Phi {({\mathcal {C}})}\) can be stated in the following theorem.

Theorem 2.1

Under the conditions stated in the above, the following statements are equivalent.

  1. (i)

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

  2. (ii)

    For all \( {{\mathbf {u}},{\mathbf {v}}}\in {\mathcal {S}} \), \( {2({\mathbf {u}}\odot {\mathbf {v}})}\in {{\mathcal {C}}}\).

Proof

\((i)\Rightarrow (ii)\) it follows immediately from Proposition 1.1.

\((ii)\Rightarrow (i)\) By Proposition 1.1, it is enough to show that \( 2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\), for all \( {\mathbf {u}},{\mathbf {v}}\in {\mathcal {C}}\). First note that for every \( {{\mathbf {u}},{\mathbf {v}}} \in {\mathcal {C}}\), \({\mathbf {u}} \odot {\mathbf {v}}={\mathbf {v}} \odot {\mathbf {u}}\) and \({\mathbf {u}} \odot {\mathbf {u}}= {\mathbf {u}}\). Also, if \( {\mathbf {u}}\) or \({\mathbf {v}}\) belongs to \({\mathcal {R}}_2 \cup {\mathcal {R}}_3\), then the order of \(2({\mathbf {u}} \odot {\mathbf {v}}) \) is at most 2. Therefore, without loss of the generality, we can assume that

$$\begin{aligned} {\mathcal {S}}={\mathcal {R}} \cup \{2({\mathbf {r}}_{\lambda } \odot {\mathbf {r}}_{\lambda '}): {\mathbf {r}}_{\lambda }, {\mathbf {r}}_{\lambda '} \in {\mathcal {R}} \}. \end{aligned}$$

Let \( {\mathbf {u}},{\mathbf {v}}\) be two arbitrary elements in \({\mathcal {C}}\). There are \({\mathbf {r}}_{\lambda _{1}},\ldots ,{\mathbf {r}}_{\lambda _{t}}, {\mathbf {r}}_{\lambda '_{1}},\ldots ,{\mathbf {r}}_{\lambda '_{s}} \in {\mathcal {R}}\) (not necessarily distinct) such that \({\mathbf {u}}={\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}\) and \({\mathbf {v}}={\mathbf {r}}_{\lambda '_{1}}+\cdots +{\mathbf {r}}_{\lambda '_{s}}\). We consider two cases.

  1. Case 1:

    \(s=1\). This means that \({\mathbf {v}} \in {\mathcal {R}}\). By induction on t, we show that \(2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\). By hypothesis, for \(t=1\) it is trivial. For \(t=2\), by Lemma 2.1 part (ii),

    $$\begin{aligned} 2({\mathbf {u}}\odot {\mathbf {v}})=2(({\mathbf {r}}_{\lambda _{1}}+{\mathbf {r}}_{\lambda _{2}})\odot {\mathbf {v}})=2({\mathbf {r}}_{\lambda _{1}}\odot {\mathbf {v}})+2({\mathbf {r}}_{\lambda _{2}}\odot {\mathbf {v}})+2(2({\mathbf {r}}_{\lambda _{1}}\odot {\mathbf {r}}_{\lambda _{2}})\odot {\mathbf {v}}) \in {\mathcal {C}}. \end{aligned}$$

    Assume the induction hypothesis holds for \(t=k\), i.e.,

    $$\begin{aligned} 2({\mathbf {u}}\odot {\mathbf {v}})=2(({\mathbf {r}}_{\lambda _{1}}+{\mathbf {r}}_{\lambda _{2}}+\cdots +{\mathbf {r}}_{\lambda _{k}})\odot {\mathbf {v}})\in {\mathcal {C}}. \end{aligned}$$

    For \(t=k+1\), we have:

    $$\begin{aligned} 2({\mathbf {u}}\odot {\mathbf {v}})&=2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{k}}+{\mathbf {r}}_{\lambda _{k+1}}) \odot {\mathbf {v}})\\&=2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{k}})\odot {\mathbf {v}})+2({\mathbf {r}}_{\lambda _{k+1}}\odot {\mathbf {v}})\\&+2((({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{k}})\circledast {\mathbf {r}} _{\lambda _{k+1}})\odot {\mathbf {v}}). \end{aligned}$$

    So, it is enough to prove that \(2((({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{k}})\circledast {\mathbf {r}}_{\lambda _{k+1}})\odot {\mathbf {v}})\in {\mathcal {C}}\). To do this, we show

    $$\begin{aligned} \begin{aligned} 2((({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{k}})\circledast {\mathbf {r}}_{\lambda _{k+1}})\odot {\mathbf {v}})=\sum _{\alpha =1}^{k}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{k+1}})\odot {\mathbf {v}})\in {\mathcal {C}}. \end{aligned} \end{aligned}$$
    (II)

    To prove (II), we apply induction on k. For \(k=1\), by Lemma 2.1 part (i),

    $$\begin{aligned} 2(({\mathbf {r}}_{\lambda _{1}}\circledast {\mathbf {r}}_{\lambda _{2}})\odot {\mathbf {v}})=2(2({\mathbf {r}}_{\lambda _{1}}\odot {\mathbf {r}}_{\lambda _{2}})\odot {\mathbf {v}}) \in {\mathcal {C}}. \end{aligned}$$

    For \(k=2\), by Lemma 2.1 part (iii),

    $$\begin{aligned} 2((({\mathbf {r}}_{\lambda _{1}}+{\mathbf {r}}_{\lambda _{2}})\circledast {\mathbf {r}}_{\lambda _{3}})\odot {\mathbf {v}})= 2(2({\mathbf {r}}_{\lambda _{1}}\odot {\mathbf {r}}_{\lambda _{3}})\odot {\mathbf {v}})+2(2({\mathbf {r}}_{\lambda _{2}}\odot {\mathbf {r}}_{\lambda _{3}})\odot {\mathbf {v}})\in {\mathcal {C}}. \end{aligned}$$

    Assume that the induction hypothesis holds for \(k=m\). For \(k=m+1\), by Lemma 2.1 part (iii),

    $$\begin{aligned} \begin{aligned} 2((({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}}+{\mathbf {r}}_{\lambda _{m+1}})\circledast {\mathbf {r}}_{\lambda _{m+2}})\odot {\mathbf {v}}) =&2(2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}})\odot {\mathbf {r}}_{\lambda _{m+2}})\odot {\mathbf {v}})\\ {}&+2(2({\mathbf {r}}_{\lambda _{m+1}}\odot {\mathbf {r}}_{\lambda _{m+2}})\odot {\mathbf {v}}). \end{aligned} \end{aligned}$$

    On the other hand, by Lemma 2.1 part (i),

    $$\begin{aligned} 2(2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}})\odot {\mathbf {r}}_{\lambda _{m+2}})\odot {\mathbf {v}})=2((({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{m}})\circledast {\mathbf {r}}_{\lambda _{m+2}})\odot {\mathbf {v}}). \end{aligned}$$

    Now by the induction hypothesis, we deduce that

    $$\begin{aligned} \begin{aligned} 2((({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{m}} +{\mathbf {r}}_{\lambda _{m+1}})\circledast {\mathbf {r}}_{\lambda _{m+2}})\odot {\mathbf {v}})=\sum _{\alpha =1}^{m+1}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{m+2}})\odot {\mathbf {v}}). \end{aligned} \end{aligned}$$

    Therefore, \(2({\mathbf {u}}\odot {\mathbf {v}})=2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{k}}+{\mathbf {r}}_{\lambda _{k+1}}) \odot {\mathbf {v}})\in {\mathcal {C}}.\)

  2. Case 2:

    \(s >1\). For \(s=2\), we have:

    $$\begin{aligned} \begin{aligned} 2({\mathbf {u}}\odot {\mathbf {v}})&=2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}+{\mathbf {r}}_{\lambda '_{2}}))\\ {}&=2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})\odot {\mathbf {r}}_{\lambda '_{1}}) \\&\quad +2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})\odot {\mathbf {r}}_{\lambda '_{2}})+2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}})). \end{aligned} \end{aligned}$$

    Thus, it is enough to prove that, \(2(({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))\in {\mathcal {C}}\). For this purpose we show that

    $$\begin{aligned} \begin{aligned} 2(({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))&=\sum _{\alpha =1}^{t}2({\mathbf {r}}_{\lambda _{\alpha }}\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}}))\\ {}&\quad +\sum _{1\le \alpha < \beta \le t}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{\beta }})\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}})). \end{aligned} \end{aligned}$$
    (III)

    We prove (III) by induction on t. For \(t=1 \), it obtains from Lemma 2.1 part (i). For \(t=2\), by Lemma 2.1 parts (i) and (ii), \(2(({\mathbf {r}}_{\lambda _{1}}+{\mathbf {r}}_{\lambda _{2}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))\) is equal to

    $$\begin{aligned} 2({\mathbf {r}}_{\lambda _{1}}\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}}))+2({\mathbf {r}}_{\lambda _{2}}\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}}))+2(2({\mathbf {r}}_{\lambda _{1}}\odot {\mathbf {r}}_{\lambda _{2}})\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}})). \end{aligned}$$

    Assume that the induction hypothesis holds for \(t=m\). It follows from Lemma 2.1 part (ii),

    $$\begin{aligned} \begin{aligned}&2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}}+{\mathbf {r}}_{\lambda _{m+1}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))=2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))\\&\qquad \quad +2({\mathbf {r}}_{\lambda _{m+1}}\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))\\&\qquad \quad +2((({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}})\circledast {\mathbf {r}}_{\lambda _{m+1}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}})). \end{aligned} \end{aligned}$$

    Applying (II), with \({\mathbf {v}}={\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}\), it implies that

    $$\begin{aligned} 2((({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}})\circledast {\mathbf {r}}_{\lambda _{m+1}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))=\sum _{\alpha =1}^{m}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{m+1}})\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}})). \end{aligned}$$

    Consequently,

    $$\begin{aligned} \begin{aligned}&2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{m}}+{\mathbf {r}}_{\lambda _{m+1}})\odot ({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{2}}))=\sum _{\alpha =1}^{m+1}2({\mathbf {r}}_{\lambda _{\alpha }}\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}}))\\&\qquad \quad + \sum _{1\le \alpha < \beta \le m+1} 2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{\beta }})\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{2}})). \end{aligned} \end{aligned}$$

    Hence, (III) holds. Therefore, \(2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\). Now suppose for \(s=k\), \(2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\). For \(s=k+1\), we have:

    $$\begin{aligned} \begin{aligned} 2({\mathbf {u}}\odot {\mathbf {v}})&=2(({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}+\cdots + {\mathbf {r}}_{\lambda '_{k}}+{\mathbf {r}}_{\lambda '_{k+1}}))\\&=2(({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}+\cdots +{\mathbf {r}}_{\lambda '_{k}}))\\&\quad +2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})\odot {\mathbf {r}}_{\lambda '_{k+1}})\\&\quad +2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})\odot (({\mathbf {r}}_{\lambda '_{1}}+\cdots +{\mathbf {r}}_{\lambda '_{k}})\circledast {\mathbf {r}}_{\lambda '_{k+1}})). \end{aligned} \end{aligned}$$

    Inasmuch as \(2(({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}+\cdots +{\mathbf {r}}_{\lambda '_{k}}))\) and \(2(({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})\odot {\mathbf {r}}_{\lambda '_{k+1}})\) both belong to \({\mathcal {C}}\), it remains to prove \(2((({\mathbf {r}}_{\lambda '_{1}}+\cdots +{\mathbf {r}}_{\lambda '_{k}})\circledast {\mathbf {r}}_{\lambda '_{k+1}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))\in {\mathcal {C}}\). To this purpose, by induction on k, we show that

    $$\begin{aligned} \begin{aligned}&2((({\mathbf {r}}_{\lambda '_{1}}+\cdots + {\mathbf {r}}_{\lambda '_{k}})\circledast {\mathbf {r}}_{\lambda '_{k+1}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))=\sum _{\gamma =1}^{k} (\sum _{\alpha =1 }^{t} 2({\mathbf {r}}_{\lambda _{\alpha }}\odot 2({\mathbf {r}}_{\lambda '_{\gamma }}\odot {\mathbf {r}}_{\lambda '_{k+1}})))\\&\qquad \quad +\sum _{\gamma =1}^{k} (\sum _{1\le \alpha <\beta \le t} 2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{\beta }})\odot 2({\mathbf {r}}_{\lambda '_{\gamma }}\odot {\mathbf {r}}_{\lambda '_{k+1}}))). \end{aligned} \end{aligned}$$

    By (III), it is true for \(k=1\). For \(k=2\), from Lemma 2.1 parts (i) and (iii), we have:

    $$\begin{aligned} \begin{aligned} 2((({\mathbf {r}}_{\lambda '_{1}}+{\mathbf {r}}_{\lambda '_{2}})\circledast {\mathbf {r}}_{\lambda '_{3}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))&= 2(2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{3}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))\\ {}&\quad +2(2({\mathbf {r}}_{\lambda '_{2}}\odot {\mathbf {r}}_{\lambda '_{3}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))\\ {}&= 2(({\mathbf {r}}_{\lambda '_{1}}\circledast {\mathbf {r}}_{\lambda '_{3}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))\\ {}&\quad +2(({\mathbf {r}}_{\lambda '_{2}}\circledast {\mathbf {r}}_{\lambda '_{3}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})). \end{aligned} \end{aligned}$$

    Thus, (III) implies that

    $$\begin{aligned} 2((({\mathbf {r}}_{\lambda '_{1}}+{\mathbf {r}}_{\lambda '_{2}})\circledast {\mathbf {r}}_{\lambda '_{3}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))&=\sum _{\alpha =1}^{t}2({\mathbf {r}}_{\lambda _{\alpha }}\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{3}}))\\ {}&\quad +\sum _{1\le \alpha<\beta \le t}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{\beta }})\odot 2({\mathbf {r}}_{\lambda '_{1}}\odot {\mathbf {r}}_{\lambda '_{3}}))\\ {}&\quad +\sum _{\alpha =1}^{t}2({\mathbf {r}}_{\lambda _{\alpha }}\odot 2({\mathbf {r}}_{\lambda '_{2}}\odot {\mathbf {r}}_{\lambda '_{3}}))\\ {}&\quad +\sum _{1\le \alpha <\beta \le t}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{\beta }})\odot 2({\mathbf {r}}_{\lambda '_{2}}\odot {\mathbf {r}}_{\lambda '_{3}})). \end{aligned}$$

    Assume that the induction hypothesis holds for \(k=m-1\). For \(k=m\), by Lemma 2.1 parts (i) and (iii), \( 2((({\mathbf {r}}_{\lambda '_{1}}+\cdots +{\mathbf {r}}_{\lambda '_{m-1}}+ {\mathbf {r}}_{\lambda '_{m}})\circledast {\mathbf {r}}_{\lambda '_{m+1}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))\) is equal to

    $$\begin{aligned}&2(({\mathbf {r}}_{\lambda '_{1}}+\cdots +{\mathbf {r}}_{\lambda '_{m-1}})\circledast {\mathbf {r}}_{\lambda '_{m+1}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))\\&\quad +2(({\mathbf {r}}_{\lambda '_{m}}\circledast {\mathbf {r}}_{\lambda '_{m+1}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}})). \end{aligned}$$

    Now from the induction hypothesis and (III), we deduce that

    $$\begin{aligned}&2((({\mathbf {r}}_{\lambda '_{1}}+\cdots + {\mathbf {r}}_{\lambda '_{m}})\circledast {\mathbf {r}}_{\lambda '_{m+1}})\odot ({\mathbf {r}}_{\lambda _{1}}+\cdots +{\mathbf {r}}_{\lambda _{t}}))=\sum _{\gamma =1}^{m-1}(\sum _{\alpha =1}^{t}2({\mathbf {r}}_{\lambda _{\alpha }}\odot 2({\mathbf {r}}_{\lambda '_{\gamma }}\odot {\mathbf {r}}_{\lambda '_{m+1}})))\\&\qquad \quad +\sum _{\gamma =1}^{m-1}(\sum _{1\le \alpha<\beta \le t}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{\beta }})\odot 2({\mathbf {r}}_{\lambda '_{\gamma }}\odot {\mathbf {r}}_{\lambda '_{m+1}})))\\&\qquad \quad +\sum _{\alpha =1}^{t}2({\mathbf {r}}_{\lambda _{\alpha }}\odot 2({\mathbf {r}}_{\lambda '_{m}}\odot {\mathbf {r}}_{\lambda '_{m+1}}))\\&\qquad \quad +\sum _{1\le \alpha <\beta \le t}2(2({\mathbf {r}}_{\lambda _{\alpha }}\odot {\mathbf {r}}_{\lambda _{\beta }})\odot 2({\mathbf {r}}_{\lambda '_{m}}\odot {\mathbf {r}}_{\lambda '_{m+1}})). \end{aligned}$$

    Consequently,

    $$\begin{aligned} 2({\mathbf {u}}\odot {\mathbf {v}})=2(({\mathbf {r}}_{\lambda _{1}}+\cdots + {\mathbf {r}}_{\lambda _{t}})\odot ({\mathbf {r}}_{\lambda '_{1}}+\cdots + {\mathbf {r}}_{\lambda '_{k}}+{\mathbf {r}}_{\lambda '_{k+1}}))\in {\mathcal {C}}. \end{aligned}$$

\(\square \)

3 Gray image of cyclic codes over \({\mathbb {Z}}_{8}\)

All cyclic codes of odd length over \({\mathbb {Z}}_{4}\) whose Gray images are linear were determined by Wolfmann (see [18]). In this section, we generalize Wolfmann’s idea for these codes of odd length n over \({\mathbb {Z}}_{8}\). 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, \(R_{3,n}\) denote the quotient ring \(\frac{{\mathbb {Z}}_{8}[x]}{\langle x^{n}-1\rangle }\) and the elements of \(R_{3,n}\) will be identified with polynomials over \({\mathbb {Z}}_{8}\) of degree \(\leqslant n-1\). For simplicity, we set \(f(x):=f\), where \(f(x) \in R_{3,n}\). An n-tuple \((c_0,c_1, \ldots , c_{n-1})\) in \({\mathbb {Z}}_{8}\) will be identified with the element \(c_0+c_{1}x+ \ldots +c_{n-1}x^{n-1}\) of \(R_{3,n}\). It is known that a cyclic code \({\mathcal {C}}\) corresponds to an ideal of \(R_{3,n}\). 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 \({\mathbb {Z}}_{8}\). 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 3.1

[12, Theorem 3.4] Let \({\mathcal {C}}\) be a cyclic code of odd length n over \({\mathbb {Z}}_{8}\). Then there exist a collection of pairwise-coprime polynomials \(f_0, f_1, f_2, f_3\) (possibly equal to 1) such that \(f_0f_3f_2f_1=x^{n}-1\) and \({\mathcal {C}}\) is generated by \(\{\hat{f}_3, 2\hat{f}_{2}, 2^{2}\hat{f}_1\}\), where for \(1 \le i \le 3\), \(\hat{f}_i\) denote the product of all \(f_j\) expect \(f_i\); i.e.,

$$\begin{aligned} {\mathcal {C}}=\langle \hat{f}_3, 2\hat{f}_{2}, 2^{2}\hat{f}_1 \rangle . \end{aligned}$$

Lemma 3.1

Under the conditions stated in Proposition 3.1, we have:

  1. (i)

    \({\mathcal {C}}=\langle f_0f_1f_2, 2f_0f_1, 4f_0 \rangle =\langle f_0f_1f_2+2f_0f_1+4f_0 \rangle \).

  2. (ii)

    \({\mathcal {C}} \cap 2R_{3,n} = \langle 2f_0f_1, 4f_0 \rangle =\langle 2f_0f_1+ 4f_0 \rangle \).

Proof

(i) By Proposition 3.1, \({\mathcal {C}}= \langle f_0f_1f_2, 2f_0f_1f_3, 4f_0f_2f_3 \rangle \) and \(x^n-1=f_0f_3f_2f_1\). Set \({\mathcal {C}}'=\langle f_0f_1f_2, 2f_0f_1, 4f_0 \rangle \). Clearly \({\mathcal {C}} \subseteq {\mathcal {C}}'\). Inasmuch as gcd\((f_2, f_3)=1\), thus there exist \(s_2\) and \(s_3 \in {\mathbb {Z}}_8[x]\) such that

$$\begin{aligned} s_2f_2+s_3f_3=1. \end{aligned}$$

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

$$\begin{aligned} 2f_0f_1=2s_2f_0f_1f_2+2s_3f_0f_1f_3 \in {\mathcal {C}}. \end{aligned}$$

As the same way, gcd\((f_1, f_2f_3)=1\), hence there exist \(s_1\) and \(s_{2,3} \in {\mathbb {Z}}_{8}[x]\) such that

$$\begin{aligned} s_1f_1+s_{2,3}f_2f_3=1. \end{aligned}$$

Multiplying the above equation by \(4f_0\), we obtain

$$\begin{aligned} 4f_0=4s_1f_0f_1+4s_{2,3}f_0f_2f_3 \in {\mathcal {C}}. \end{aligned}$$

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= f_0f_1f_2+ 2f_0f_1+ 4f_0\). Inasmuch as for distinct values \(1 \le i,j,k \le 3\), \(f_if_j\) and \(f_k\) are coprime, then we have:

$$\begin{aligned} r_{i,j}f_if_j+r_kf_k=1, \end{aligned}$$

for some \(r_{i,j}, r_k \in {\mathbb {Z}}_{8}[x]\). Now we obtain

$$\begin{aligned} 1&=(r_{1,2}f_1f_2+r_3f_3)(r_{1,3}f_1f_3+r_2f_2)(r_{2,3}f_2f_3+r_1f_1) \\&=(r_{1,2}r_{1,3}r_{2,3}f_1f_2f_3+r_{1,2}r_2r_{2,3}f_{2}^2+r_{1,3}r_3r_{2,3}f_{3}^2+r_{1,2}r_{1,3}r_1f_{1}^2+r_1r_2r_3)f_1f_2f_3\\&\quad +r_{2,3}r_2r_3f_{2}^2f_{3}^2+r_{1,2}r_1r_2f_{1}^2f_{2}^2+r_{1,3}r_1r_3f_{1}^2f_{3}^2 \\&=s_0f_1f_2f_3+s_1f_2f_3+s_2f_1f_2+s_3f_1f_3, \end{aligned}$$

for some \(s_0,s_1,s_2,s_3 \in {\mathbb {Z}}_{8}[x]\). Multiplying the above equation by \(4f_0\), we conclude

$$\begin{aligned} 4f_0=4s_1f_0f_2f_3+4s_2f_0f_1f_2+4s_3f_0f_1f_3=g(s_1f_2f_3)+g(4s_2)+g(2s_3f_3) \in \langle g \rangle . \end{aligned}$$

Moreover, multiplying the above equation by \(2f_0f_1\), we deduce

$$\begin{aligned} 2f_0f_1=2s_2f_0f_{1}^2f_2+2s_3f_0f_{1}^2f_3=(2g-4f_0f_1)s_2f_1+(g-4f_0)s_3f_1f_3 \in \langle g \rangle . \end{aligned}$$

Furthermore, \(f_0f_1f_2=g-2f_0f_1 -4 f_0 \in \langle g \rangle \). Consequently, \({\mathcal {C}} = \langle g \rangle \).

(ii) For the first equality, it is easy to see that (\(\supseteq \)) holds. Now suppose that \(b \in {\mathcal {C}} \cap 2R_{3,n}\). So, there exist \(r \in R_{3,n}\) such that

$$\begin{aligned} b=rf_0f_1f_2+ 2rf_0f_1+ 4rf_0. \end{aligned}$$

Therefore, there exists \(r' \in R_{3,n}\) such that \(r=2r'\). Hence, we have:

$$\begin{aligned} b=2r'f_0f_1f_2+ 4r'f_0f_1 \in \langle 2f_0f_1, 4f_0 \rangle . \end{aligned}$$

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

The proof of the last equality is similar to Part (ii). \(\square \)

Remark 3.1

The elements of \({\mathbb {Z}}_{8}\) can be expressed in the form \(c_{0}+2c_{1}+4c_2\), where for \(0\leqslant i\leqslant 2\), \( c_{i} \in \{0,1\}\). The natural epimorphism \(\sim :{\mathbb {Z}}_{8} \rightarrow {\mathbb {Z}}_{4}\) is defined by \(c_0+2c_1+4c_2 \rightarrow c_0+2c_1\) can be extended to a ring epimorphism from \({\mathbb {Z}}_8[x]\) to \({\mathbb {Z}}_{4}[x]\) as following:

$$\begin{aligned} \sim :{\mathbb {Z}}_{8}[x]&\rightarrow {\mathbb {Z}}_{4}[x]\\ {a}(x)=a_0+a_1x+\cdots +a_nx^n&\mapsto \tilde{a}(x)= \tilde{a}_0+\tilde{a}_1x+\cdots +\tilde{a}_nx^n. \end{aligned}$$

One can see that if \(a(x) \in {\mathbb {Z}}_8[x]\), then \(2a(x)=2 \tilde{a}(x)\).

Similarly, we can also have the natural epimorphism

$$\begin{aligned} -: {\mathbb {Z}}_{8}[x]&\rightarrow {\mathbb {F}}_2[x]\\ b(x)=b_0+b_1x+\cdots +b_nx^n&\mapsto \bar{b}(x)=\bar{b}_0+\bar{b}_1x+\cdots +\bar{b}_nx^n. \end{aligned}$$

Remark 3.2

Let n be odd, \({\mathbb {F}}_2\) be the finite field of order 2, \({\mathbb {F}}_{2^t}\) be the splitting field of \(x^{n}-1\) over \({\mathbb {F}}_2\) and \(\mathrm{GR}(2^2, 2^{t})\) be the Galois ring of characteristic 4 with residue field \({\mathbb {F}}_{2^t}\). Let \(\beta \) be a primitive nth root in \({\mathbb {F}}_{2^t}\). We define the generalized Mattson–Solomon transform as the function \({\mathcal {T}} :\mathrm{GR}(2^2, 2^{t})/\langle x^{n}-1 \rangle \longrightarrow \mathrm{GR}(2^2, 2^{t})/\langle x^{n}-1 \rangle \) such that

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

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

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

Lemma 3.2

Let \(A(x), B(x) \in R_{2,n}\), then \(2{\mathcal {T}}^{-1}(A(x)\odot B(x))=2{\mathcal {T}}^{-1}(A(x)){\mathcal {T}}^{-1}(B(x))\).

Proof

Let \(A(x)=A_0+A_1x+ \cdots +A_{n-1}x^{n-1}\) and \(B(x)=B_0+B_1x+ \cdots +B_{n-1}x^{n-1}\). Hence,

$$\begin{aligned} A(x) \odot B(x)=(A_0 \odot B_0)+(A_1 \odot B_1) x+ \cdots +(A_{n-1} \odot B_{n-1}) x^{n-1}. \end{aligned}$$

Since for any \(u,v \in {\mathbb {Z}}_4\), \(2(u \odot v)=2uv\), we have:

$$\begin{aligned} 2(A(x) \odot B(x))=2(A_0 B_0+A_1 B_1 x+ \cdots +A_{n-1}B_{n-1} x^{n-1})=2(A(x) *B(x)). \end{aligned}$$

Therefore, using a method similar to the proof of [14, Theorem22], we obtain

$$\begin{aligned} 2{\mathcal {T}}^{-1}(A(x) \odot B(x))=2{\mathcal {T}}^{-1}(A(x) *B(x))=2{\mathcal {T}}^{-1}(A(x)){\mathcal {T}}^{-1}(B(x)). \end{aligned}$$

\(\square \)

In the following theorem \(g= f_0f_1f_2+2f_0f_1+4f_0\) and \(d=f_0f_1\). Also, \(\tilde{f}_3\otimes \tilde{f}_3\) is the divisor of \(x^n-1\) in \({\mathbb {Z}}_{4}[x]\) whose roots are the \(\beta ^i\beta ^j\) such that \(\beta ^i\) and \(\beta ^j\) are roots of \(\tilde{f_3}\).

Theorem 3.1

Let \({\mathcal {C}}=\langle g \rangle \) be a cyclic code of odd length n over \({\mathbb {Z}}_{8}\). Let \(\tilde{h}\) be such that

$$\begin{aligned} x^n-1=(\tilde{f}_3\otimes \tilde{f}_3)\tilde{h} \end{aligned}$$

in \({\mathbb {Z}}_{4}[x]\). The following statements are equivalent.

  1. (i)

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

  2. (ii)

    \(\tilde{d}\) divides \(\tilde{h}\) in \({\mathbb {Z}}_{4}[x]\).

Proof

\((i)\Rightarrow (ii)\) If deg(\(\tilde{f}_3\))=0, then \(\tilde{f}_3=1\). Hence, obviously \(\tilde{d}\) divides \(\tilde{h}\). Suppose deg(\(\tilde{f}_3 ) > 0.\) There exists \(0 \le j \le n-1\) such that \(\tilde{f}_{3}(\beta ^{j})=0\). Define

$$\begin{aligned} K=\{k:\ (\tilde{f}_3\otimes \tilde{f}_3)(\beta ^{k})=0, \ 0 \le k \le n-1\ \} \end{aligned}$$

and

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

Clearly \(2j\in K\), so \(J(k)\ne \emptyset \). Assume that \(k \in K\) and \(j \in J(k)\). Inasmuch as

$$\begin{aligned} x^n-1=\tilde{d}\tilde{f_2}\tilde{f_3}=(\tilde{f}_3\otimes \tilde{f}_3)\tilde{h}, \end{aligned}$$

then \(\tilde{h}(\beta ^{k})\), \(\tilde{d}(\beta ^{j})\) and \(\tilde{d}(\beta ^{k-j})\) are non-zero. So, it is enough to show that \(\tilde{d}(\beta ^{k})\ne 0\). Let us consider \(A_{j}(k)=\tilde{d}(\beta ^{j})\tilde{d}(\beta ^{k-j})\) and \(S_{k}(x)=\sum _{j \in J(k)}A_{j}(k)x^{j}\). Note that \(\bar{A}_{j}(k) \ne 0\) in \({\mathbb {F}}_{2^t}\), hence \(2A_{j}(k) \ne 0\) in \(GR(2^t, 2^{3t})\) and this follows that \(2S_{k}(x) \) is non-zero in \(GR(2^t, 2^{3t})[x]\). Since the degree of \(S_{k}(x)\) is at most \(n-1\), there exists \(0 \le m \le n-1\) such that \(S_{k}(\beta ^{m})\ne 0\); i.e., \(2S_{k}(\beta ^{m})\) is a non-zero element of \(GR(2^t, 2^{3t})\). Applying the hypothesis and Proposition 1.1, we have \(2(d \odot x^{m}d) \in {\mathcal {C}}\). Hence,

$$\begin{aligned} 2(d \odot x^{m}d) \in {\mathcal {C}}\cap 2R_{3,n}=\langle 2f_{0}f_{1}+4f_0\rangle . \end{aligned}$$

Thus, there exists \({\lambda }_{m} \in R_{3,n}\) such that \( 2({d} \odot x^{m}{d})=2{\lambda }_{m}(f_{0}f_{1}+2f_0)\). This implies that \( 2(\tilde{d} \odot x^{m}\tilde{d})=2\tilde{\lambda }_{m}\tilde{d} \), in \(R_{2,n}\). Applying Lemma 3.2, we obtain

$$\begin{aligned} 2{{\mathcal {T}}^{-1}}(\tilde{\lambda }_{m}\tilde{d})={\mathcal {T}}^{-1}(2\tilde{\lambda }_{m}\tilde{d})={\mathcal {T}}^{-1}(2(\tilde{d} \odot x^{m}\tilde{d}))=2{\mathcal {T}}^{-1}(\tilde{d}){\mathcal {T}}^{-1}(x^{m}\tilde{d}). \end{aligned}$$

Therefore,

$$\begin{aligned} \begin{aligned} 2\sum _{k \in K}\tilde{\lambda }_{m}(\beta ^{k})\tilde{d}(\beta ^{k})x^{k}&=2\sum _{i=0}^{n-1}\tilde{d}(\beta ^{i})x^{i}\sum _{j=0}^{n-1}x^{m}(\beta ^{j})\tilde{d}(\beta ^{j})x^{j}\\&=2\sum _{\tilde{f}_3(\beta ^{i})=0}\tilde{d}(\beta ^{i})x^{i}\sum _{\tilde{f}_3(\beta ^{j})=0}(\beta ^{m})^{j}\tilde{d}(\beta ^{j})x^{j}\\&=2\sum _{(\tilde{f}_3\otimes \tilde{f}_3)(\beta ^{k})=0}(\sum _{i+j=k}\tilde{d}(\beta ^{i})\tilde{d}(\beta ^{j})(\beta ^{mj}))x^{k}\\&=\sum _{k \in K}(\sum _{j \in J(k)}2\tilde{d}(\beta ^{k-j})\tilde{d}(\beta ^{j})(\beta ^{m})^{j})x^{k}\\&=\sum _{k \in K}(\sum _{j \in J(k)}2A_{j}(k)(\beta ^{m})^{j})x^{k}. \end{aligned} \end{aligned}$$

Consequently, \(2\tilde{\lambda }_{m}(\beta ^{k})\tilde{d}(\beta ^{k})\ne 0\) and this means that \(\tilde{d}(\beta ^{k})\ne 0\).

\((ii)\Rightarrow (i)\) First we show that \(\langle 2\tilde{g}\rangle \odot \langle 2\tilde{g}\rangle \subseteq \langle 2\tilde{h}\rangle \) in \(R_{2,n}\). Let \(\tilde{s}=\tilde{m}_{1}\tilde{g}\odot \tilde{m}_2\tilde{g}\) be in \(\langle \tilde{g}\rangle \odot \langle \tilde{g}\rangle \), where \(m_1,m_2 \in R_{3,n}\).

Using Lemma 3.2, we get

$$\begin{aligned} {\mathcal {T}}^{-1}(2\tilde{s})={{\mathcal {T}}}^{-1}(2(\tilde{m}_1\tilde{g}\odot \tilde{m}_2\tilde{g})) =2{\mathcal {T}}^{-1}(\tilde{m}_1\tilde{g}\odot \tilde{m}_2\tilde{g}) =2{\mathcal {T}}^{-1}(\tilde{m}_1\tilde{g}){\mathcal {T}}^{-1}(\tilde{m}_2\tilde{g}). \end{aligned}$$

Hence,

$$\begin{aligned} \sum _{k=0}^{n-1}2\tilde{s}(\beta ^{k})x^{k}&=2\sum _{i=0}^{n-1}\tilde{m}_1(\beta ^{i})\tilde{g}(\beta ^{i})x^{i}\sum _{j=0}^{n-1}\tilde{m}_2(\beta ^{j})\tilde{g}(\beta ^{j})x^{j}\\&=2\sum _{\tilde{f}_3(\beta ^{i})=0}\tilde{m}_1(\beta ^{i})\tilde{g}(\beta ^{i})x^{i}\sum _{\tilde{f}_3(\beta ^{j})=0}\tilde{m}_2(\beta ^{j})\tilde{g}(\beta ^{j})x^{j}\\&=\sum _{(\tilde{f}_3\otimes \tilde{f}_3)(\beta ^{k})=0}(\sum _{i+j=k}2\tilde{m}_1(\beta ^{i})\tilde{m}_2(\beta ^{j})\tilde{g}(\beta ^{i})\tilde{g}(\beta ^{j}))x^{k}. \end{aligned}$$

If \(2\tilde{s}(\beta ^{k}) \ne 0\) then \((\tilde{f}_3\otimes \tilde{f}_3)(\beta ^{k})=0\), so \(2\tilde{h}(\beta ^{k}) \ne 0 \). This means that \(2\tilde{s}\) belongs to \(\langle \tilde{2h}\rangle \). Hence, by the hypothesis, we deduce that \(\langle 2\tilde{g}\rangle \odot \langle 2\tilde{g}\rangle \subseteq \langle 2\tilde{h}\rangle \subseteq \langle 2\tilde{d}\rangle \). According to Proposition 1.1, it is enough to show \(2(m_{1}g\odot m_{2}g)\in {\mathcal {C}}\), for all \( m_{1},m_{2}\in R_{3,n}\). By the above, there exists \(\tilde{r}\in R_{2,n}\) such that \(2(\tilde{m}_1\tilde{g}\odot \tilde{m}_2\tilde{g})=2\tilde{r}\tilde{d}\). Therefore, from Remark 3.1,

$$\begin{aligned} 2(m_{1}g\odot m_{2}g)=2(\tilde{m}_1\tilde{g}\odot \tilde{m}_2\tilde{g}) =2\tilde{r}\tilde{d} =2rd \in {\mathcal {C}}. \end{aligned}$$

\(\square \)

4 Examples

Example 4.1

Let \({\mathcal {C}}\) be a linear code of length 4 over \({\mathbb {Z}}_{8}\) with generator matrix

$$\begin{aligned} G=\left( \begin{matrix} {\mathbf {r}}_{1}\\ {\mathbf {r}}_{2}\\ {\mathbf {r}}_{3}\\ {\mathbf {r}}_{4} \end{matrix}\right) =\left( \begin{matrix} 1&{}0&{}0&{}6\\ 0&{}1&{}0&{}1\\ 0&{}0&{}1&{}1\\ 0&{}0&{}0&{}2 \end{matrix}\right) . \end{aligned}$$

Here \({\mathcal {R}}_1=\{{{\textbf {r}}}_1, {{\textbf {r}}}_2, {{\textbf {r}}}_3\}\), \({\mathcal {R}}_2=\{{{\textbf {r}}}_4\}\), and \({\mathcal {R}}_3=\emptyset \). Hence, \( {\mathcal {S}}=\{1006, 0101, 0011, 0002, 2004, 0202, 0022,0000\}\). It is easy to check that \( 2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}} \), for all \({\mathbf {u}},{\mathbf {v}}\in {\mathcal {S}}\). Therefore, Theorem 2.1 implies that \(\Phi ({\mathcal {C}})\) is linear. Note that the number of calculations is equal to \(\left( {\begin{array}{c}8\\ 2\end{array}}\right) \), while by using Proposition 1.1, the number of calculations is equal to \(2^{21}+2^{10}=2098176\).

Example 4.2

Let \({\mathcal {C}}\) be a linear code of length 10 over \({\mathbb {Z}}_{8}\) with generator matrix

$$\begin{aligned} G=\left( \begin{matrix} {\mathbf {r}}_{1}\\ {\mathbf {r}}_{2}\\ {\mathbf {r}}_{3}\\ {\mathbf {r}}_{4}\\ {\mathbf {r}}_{5}\\ {\mathbf {r}}_{6}\\ {\mathbf {r}}_{7} \end{matrix}\right) =\left( \begin{matrix} 1&{}0&{}0&{}2&{}0&{}0&{}1&{}1&{}1&{}0\\ 0&{}1&{}0&{}1&{}0&{}0&{}3&{}2&{}1&{}0\\ 0&{}0&{}1&{}6&{}0&{}0&{}3&{}0&{}1&{}1\\ 0&{}0&{}0&{}2&{}0&{}0&{}0&{}2&{}2&{}2\\ 0&{}0&{}0&{}0&{}2&{}2&{}0&{}0&{}0&{}0\\ 0&{}0&{}0&{}0&{}0&{}4&{}0&{}0&{}0&{}0\\ 0&{}0&{}0&{}0&{}0&{}0&{}4&{}0&{}4&{}0 \end{matrix}\right) . \end{aligned}$$

Here \({\mathcal {R}}_1=\{{{\textbf {r}}}_1, {{\textbf {r}}}_2, {{\textbf {r}}}_3\}\), \({\mathcal {R}}_2=\{{{\textbf {r}}}_4, {{\textbf {r}}}_5\}\), and \({\mathcal {R}}_3=\{{{\textbf {r}}}_6, {{\textbf {r}}}_7\}\). Hence, \( {\mathcal {S}}=\{1002001110, 0101003210,0016003011, 0002000222, 0000220000, 2004002220, 0202006420, 0024006022, 0000002020, 0004002020, 0000006020\}\). Since \(2((0002000222)\odot (0000006020))=0000000040\notin {\mathcal {C}}\), therefore Theorem 2.1 implies that \(\Phi ({\mathcal {C}})\) is nonlinear.

Example 4.3

Over \({\mathbb {Z}}_8\), we have:

$$\begin{aligned} x^{7}-1=(x-1)(x^3+6x^2+5x-1)(x^3+3x^2+2x-1)=f_0f_1f_2f_3, \end{aligned}$$

where \(f_0=x-1\), \(f_1=x^3+6x^2+5x-1\), \(f_2=x^3+3x^2+2x-1\), and \(f_3=1\). Observe that \(f_0\), \(f_1\), \(f_2\) and \(f_3\) are pairwise-coprime. Let \({\mathcal {C}}\) be a cyclic code of length 7 over \({\mathbb {Z}}_8\) generated by polynomial \(g=f_0f_1f_2+2f_0f_1+4f_0\). Obviously, \(\tilde{h}=x^n-1\), so \(\tilde{d}=\tilde{f_0}\tilde{f_1}\) divides \(\tilde{h}\) in \({\mathbb {Z}}_{4}[x]\). Hence, Theorem 3.1 implies that \(\Phi ({\mathcal {C}})\) is linear. It is noted that this example has been investigated using Proposition 1.1 in [16, Page112].

Example 4.4

Let p be an odd prime and \(p \equiv \pm 1\) (mod 8). Let \({\mathcal {Q}}_p\) and \({\mathcal {N}}_p\) be the sets of non-zero quadratic residues and quadratic non-residues modulo p, respectively. Over \({\mathbb {F}}_2\), we have:

$$\begin{aligned} x^p-1=(x-1)g_{_{Q}}(x)g_{_{N}}(x), \end{aligned}$$

where \(g_{_{Q}}(x)={ \displaystyle \prod _{i \in {\mathcal {Q}}_p} (x- \beta ^i)} \), \(g_{_{N}}(x)={ \displaystyle \prod _{i \in {\mathcal {N}}_p} (x- \beta ^i)} \) and \(\beta \) is a primitive pth root. Suppose that \(f_0\) and \(f_3\) are Hensel-lifting \(g_{_{Q}}(x)\) and \((x-1)g_{_{N}}(x)\) to \({\mathbb {Z}}_8\), respectively. Let \({\mathcal {C}}\) be a cyclic code of length p over \({\mathbb {Z}}_8\) generated by the polynomial \(g=f_0f_1f_2+2f_0f_1+4f_0\), where \(f_1=f_2=1\). Suppose that \(T=\{i+j:\ \tilde{f}_{3}(\beta ^{i})=\tilde{f}_{3}(\beta ^{j}) = 0 , \ 0 \le i, j \le n-1\ \}\). Inasmuch as \(T=\{i+j:\ i,j \in {\mathcal {N}}_p \cup \{0\} \}\), we can conclude \(|T| >p/2\) and this implies that T is not a subgroup of \({\mathbb {Z}}_p\). Therefore, there exists \(k \in T \cap {\mathcal {Q}}_p\). This means that \(\tilde{d}=\tilde{f_0}\tilde{f_1}\) is not a divisor of \(\tilde{h}\) in \({\mathbb {Z}}_{4}[x]\). Consequently, the Gray image of \({\mathcal {C}}\) is not linear.

One can see that \({\mathcal {C}}=\langle f_0 \rangle \) and it is a quadratic residue code of length p over \({\mathbb {Z}}_8\) which has been introduced in [4]. Therefore, the Gray image of a quadratic residue code over \({\mathbb {Z}}_8\) is not linear.

5 Conclusion

For a linear code \( {\mathcal {C}} \) over \({\mathbb {Z}}_8\) of type \(\{\delta _{0}, \delta _{1}, \delta _{2}\}\), by using the rows of the generator matrix (in standard form) of \({\mathcal {C}}\), we introduced a set \({\mathcal {S}}\) with \(\mid {\mathcal {S}} \mid \le \frac{\delta _{0}(\delta _{0}+3)}{2}+\delta _{1}\) and showed that binary Gray image of \({\mathcal {C}}\) is linear if and only if for every \({\mathbf {u}}, {\mathbf {v}}\in {\mathcal {S}}\), \(2({\mathbf {u}}\odot {\mathbf {v}})\in {\mathcal {C}}\). In this method, the calculations to check the linearity are much less of the method used in [16]. Also, we gave a necessary and sufficient condition whose Gray image is linear for a cyclic code of odd length over \({\mathbb {Z}}_8\) 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 \({\mathbb {Z}}_{2^s}\) (for \(s>3\)) using their generator matrix and generator polynomial, respectively.