1 Introduction

Fix a prime q. The goal is to find long Locally Recoverable Codes (also known as Locally Reparable Codes or LRC) over \(\mathbb {F}_q\) ([1,2,3, 8, 15,16,17, 20]). We do this using s layers of MDS codes in which the layers are structured in the shape of an MDS code. Our codes have not good minimum distance, but (in our opinion) they are excellent for erasures, because they have the following additional structure.

Definition 1.1

Fix positive integers s and n. Let \({\mathcal {C}}\) be a length n code. We say that \({\mathcal {C}}\) is s-recoverable or s-LRC if for each letter \(x\in \{1,\dots ,n\}\) there are codes \({\mathcal {C}}_1(x), \dots , ,{\mathcal {C}}_s(x)\}\) with each \({\mathcal {C}}_i(x)\) acting on a subset \(S_i(x)\) of \(\{1,\dots ,n\}\) and \(S_i(x)\cap S_j(x) =\{x\}\) for all \(i\ne j\). We say the \({\mathcal {C}}\) is a linear s-LRC code if all codes \({\mathcal {C}}\) and all \({\mathcal {C}}_i(x)\) are linear.

In our construction we will also get additional properties on the local codes \({\mathcal {C}}_i(x)\), \(1\le i\le s\), \(x\in \{1,\dots ,n\}\). Fix \(i\in \{1,\dots ,s\}\). All local codes \({\mathcal {C}}_i(x)\), \(x\in \{1,\dots ,n\}\) are isomorphic and in particular they have the same parameters. We call the structure \(\{{\mathcal {C}}_i(x)\}_{x\in \{1,\dots ,n\}}\) the i-th layer of the s-LRC code \({\mathcal {C}}\). The i-th layer is associated to a single code \({\mathcal {C}}_i\) with the parameters of each \({\mathcal {C}}_i\).

In some sense as an input we are also using well-known LRC codes, the case \(s=1\) corresponding to the classical case of Locally Recoverable Codes, because each codeword belongs to s local codes \({\mathcal {C}}_1,\dots ,{\mathcal {C}}_s\), and if at least one local code, say \({\mathcal {C}}_i\), has only a few erasures or errors we may correct them using only \({\mathcal {C}}_i\) (Remark 2.4). Still, these codes have only length up to \((q+1)^s\) (except a few cases for q even described in Remark 2.3). If we only take \(s=1\) we only have small, but not too small, well-known codes. For \(s\gg 0\) we get arbitrarily long codes, but at the expense of the simplicity of the codes. In any case, even for large s, the local codes have small length. Since the construction works for arbitrary linear codes \({\mathcal {C}}_1,\dots ,{\mathcal {C}}_s\) we state the result for \(s\ge 2\) arbitrary codes. We stress that the minimum distance of these codes is low, but we find that this type of long codes structured in layers may correct a huge number of erasures. Given an evaluation code \({\mathcal {C}}\) and a received word \(w\in \mathbb {F}_q^n\) we do not need to receive other letters to get the true codeword \({\tilde{w}}\) received as w (assuming there are no errors, only erasures). To get \({\tilde{w}}\) from w we may work off-line. To get linear codes with arbitrarily high length, even using only \(s=2\), it is sufficient for instance to use an AG code as one of the codes ([14, 18, 19, 21]) and use \(s-1\) smaller codes, say \(s-1\) MDS codes.

In the next theorem we speak about evaluation codes ([6, 7]). A non-degenerate linear code is an evaluation code ([21, Theorem 1.1.6]) and the converse holds, since every linear code is isomorphic to its bidual, but we consider directly the dual \({\mathcal {C}}_i\) and its minimum distance \(d_i\), because it is not easy (unless \({\mathcal {C}}_i\) is an MDS) to compute \(d_i\) only knowing the minimum distance of \({\mathcal {C}}_i^\bot \).

Theorem 1.2

Fix a prime power q, an integer \(s\ge 2\) and s linear evaluation codes \({\mathcal {C}}_1,\dots ,{\mathcal {C}}_s\) over \(\mathbb {F}_q\) with \({\mathcal {C}}_i\) an \([n_i,k_i,d_i]\) evaluation code. Set \(n:= \prod _{i=1}^{n} n_i\) and \(k:= \prod _{i=1}^{s} k_i\). Let t be the maximal non-negative integer such that

$$\begin{aligned} \frac{q^{t+1}-1}{q-1} +q^{t-1}\sqrt{q} \ge \left( {\begin{array}{c}n\\ 2\end{array}}\right) (q-1)+ \sum _{i=1}^{s} (n/n_i)\frac{q^{k_i}-1}{q-1} \end{aligned}$$
(1)

Then there exists an \([n,k-t]\) linear code over \(\mathbb {F}_q\) which corrects at least \(-1+\prod _{i=1}^{s} (d_i-1)\) erasures (assuming that no error occurs).

Remark 1.3

More precisely for each integer w such that \(0 \le w\le t\) we construct an \([n,k-w]\) evaluation code \({\mathcal {D}}_w\) which corrects at least \(-1+\prod _{i=1}^{s} (d_i-1)\) erasures (assuming that no error occurs). The code \({\mathcal {D}}_0\) is just the dual of the tensor product of the codes \({\mathcal {C}}_1^\bot ,\dots ,{\mathcal {C}}_s^\bot \), while all other codes \({\mathcal {D}}_w\) are linear projections of \({\mathcal {D}}_0\) which preserves the length, n, the structure of s-LRC code and the ability to correct at least \(-1+\prod _{i=1}^{s} (d_i-1)\) erasures (assuming that no error occurs). Suppose that for some \(x\in \{1,\dots ,n\}\) the local codes \({\mathcal {C}}_i(x)\), \(1\le i\le s\), are not sufficient to get the value of the received word at x. Call \(S\subset \{1,\dots ,n\}\) the set of all such letters x. If \(\#S\) is at most the minimum distance of the global code, then we may correct the received word.

Remark 1.4

If each \({\mathcal {C}}_i\) is an evaluation MDS cods, i.e. if \(d_i=k_i+1\), each code \({\mathcal {D}}_w\), \(0\le w\le t\), corrects \(k-1\) erasures (if no error occurs). If all but one local code, say \({\mathcal {C}}_h\), has no error or erasure and \(s\ge 2\), just assuming \(d_h\ge 2\) for all \(h\ne i\) is sufficient to correct every received word of each \({\mathcal {D}}_w\) (Remark 2.4).

2 The proof

In many papers the LRC is used with respect to disjoint supports, i.e. if we have an [nk]-code \({\mathcal {U}}\) with m local codes \({\mathcal {U}}_1,\dots ,{\mathcal {U}}_m\) we assume the existence of a partition \(I_1\sqcup \cdots \sqcup I_m\) of \(\{1,\dots .n\}\) such that each \({\mathcal {U}}_h\) has as letters the elements of \(I_h\). This is the set-up of [1, 3, 5] and of many other schemes for locally recoverable codes and we were inspired by these papers.

We follow [5, Sect. 3.1], [6, 7] and [21, Sect. 1.1.6] to use projective geometry to handle linear codes over \(\mathbb {F}_q\). Recall that there is a bijection equivalence classes of non-degenerate linear \([n,k,d]_q\) codes and the set of equivalence classes of projective \([n,k,d]_q\) systems, the latter being described by a set \(S\subset \mathbb {P}^{k-1}(\mathbb {F}_q)\) spanning \(\mathbb {P}^{k-1}(\mathbb {F}_q)\) and with cardinality n ([21, Theorem 1.1.6]). In the description of [21, Theorem 1.1.6] a dual vector space occurs and this explain our reason to call them evaluation codes, not just linear codes.

We recall that any linear code over a finite field is isomorphic to the dual of its dual and hence each linear code is equivalent to a dual code over the same field. It is also equivalent to a code constructed from a finite set \(S\subset \mathbb {P}^{k-1}(\mathbb {F}_q)\) ([5]). For a finite set \(S\subset \mathbb {P}^{k-1}(\mathbb {F}_q)\) the integer \(\#S\) is the length of the equivalent code \({\mathcal {C}}\), k is an upper bound for the integer \(k'\) such that \({\mathcal {C}}\) is an \([n,k']\) code. More precisely, \(k'-1 = \dim \langle S\rangle \), where \(\langle \ \ \rangle \) denotes the linear span. Thus \({\mathcal {C}}\) is an [nk]-code if and only if S spans \(\mathbb {P}^{k-1}(\mathbb {F}_q)\). We say that S or \(S\subset \mathbb {P}^{k-1}(\mathbb {F}_q)\) is an evaluation code. Let \(S\subset \mathbb {P}^{k-1}(\mathbb {F}_q)\) be an evaluation code. Its minimum distance is the smallest integer d such that there is \(S'\subseteq S\) such that \(\#S' =d\) and \(\dim \langle S'\rangle \le d-2\). Fix an integer \(s\ge 2\). In the set-up of evaluation codes the dual of the product \({\mathcal {C}}_1^\bot \otimes \cdots \otimes {\mathcal {C}}_s^\bot \) (or tensor product as it is known in linear algebra) of the codes \({\mathcal {C}}_i\), \(1\le i\le s\), obtained using the set \(S_i\subset \mathbb {P}^{k_i-1}(\mathbb {F}_q)\) is a code with length \(\prod _{i=1}^{s} \#S_i\) and obtained evaluating the image \(\nu (S) \subset \mathbb {P}^{k-1}(\mathbb {F}_q)\), where \(k:= \prod _{i=1}^{s} k_i\), and \(\nu : \prod _{i=1}^{s} \mathbb {P}^{k_i-1}(\mathbb {F}_q) \rightarrow \mathbb {P}^{k-1}(\mathbb {F}_q)\) is the Segre embedding ([10]). Note that for a fixed prime power q for \(s\gg 0\) the length of \({\mathcal {C}}_1\otimes \cdots \otimes {\mathcal {C}}_s\) goes to \(+\infty \).

Remark 2.1

Let \({\mathcal {C}}\) be a linear [nk]-code associated to a finite set \(S\subseteq \mathbb {P}^{k-1}(\mathbb {F}_q)\). For any \(A\subseteq S\) set \(\delta (A):= \#S -1 -\dim \langle A\rangle \). A set \(A\subseteq S\) is the support of a codeword of \({\mathcal {C}}\) if and only if \(\delta (A')< \delta (A)\) for all \(A'\subseteq A\), i.e. if and only if \(\langle B\rangle =\langle A\rangle \) for all \(B\subset A\) such that \(\#B=\#A-1\).

Take \(A\subseteq S\) such that \(\delta (A')< \delta (A)\) for all \(A'\subseteq A\). This is the case if and only if \(\langle \nu (E)\rangle =\langle \nu (A)\rangle \) for all \(E\subset A\) such that \(\#E =\#A -1\). If one of the previous equivalent conditions is satisfied we say that A (or \(\nu (A)\)) is equally dependent.

Remark 2.2

Let \({\mathcal {C}}\) be an [nkd] code over the field \(\mathbb {F}_q\). Its dual \({\mathcal {C}}^\bot \) with respect to the Hamming metric is an \([n,n-k]\)-code over \(\mathbb {F}_q\). It is complicated to know the minimum distance of \({\mathcal {C}}^\bot \), unless we know more about \({\mathcal {C}}\), but it would be the case in the following two important cases. If \({\mathcal {C}}\) is an MDS, i.e. if \(d=n-k+1\), then \({\mathcal {C}}^\bot \) is an MDS, i.e. \({\mathcal {C}}^\bot \) has minimum distance \(k+1\). Now assume that \({\mathcal {C}}\) is an AG code over a smooth genus g curve X. In this case we will not use the true minimum distance of \({\mathcal {C}}\), but only that \(d\ge n-k+1-g\) ([14, Theorem 5.2.2], [19, 21]). In this case \({\mathcal {C}}^\bot \) is a AG code over the same smooth curve X ([19, §8.1]) and hence \({\mathcal {C}}^\bot \) has minimum distance at least \(k+1-g\). In our paper we will only use \({\mathcal {C}}^\bot \) and its minimum distance \(k+1\) or its lower bound \(k+1-g\). This is the case because we use evaluation codes induced by finite sets \(S\subset \mathbb {P}^{k-1}(\mathbb {F}_q)\), where \(\#S =n\) and S spans \(\mathbb {P}^{k-1}(\mathbb {F}_q)\).

An [nkd] code \({\mathcal {C}}\) corrects \(d-1\) erasures (assuming as always in this paper that no error occurs) ([12, pp. 44-45], [13, p. 55]). Then \({\mathcal {C}}^\bot \) corrects k erasures if \({\mathcal {C}}\) is an MDS and at least \(k-g\) erasures if \({\mathcal {C}}\) is an AG code on a smooth curve of genus g.

Remark 2.3

If q is even and \(k_i=3\) for some i, we may take \(n_i=q+2\) and take as \({\mathcal {C}}_i\) an MDS code for the following reason. It was classically known the existence of a set \(S_2\subset \mathbb {P}^2(\mathbb {F}_q)\) such that \(\#S_2=q+2\) and no 3 of the point of \(S_2\) are collinear (an arc in the terminology of [9, 11]).

Remark 2.4

A linear code with minimum distance \(d>2a+b\) corrects at least a errors and b erasures. Suppose you receive a word \(\tau \) for one of the codes \({\mathcal {D}}_w\), \(0\le w\le t\), considered in Remark 1.3 and let \(\tau _i\) the part of \(\tau \) corresponding to the letters of the local code \({\mathcal {C}}_i\). Suppose that \(\tau _i\) contains at most a errors and b erasures with \(2a+b \le d_i-1\). Then we correct \(\tau _i\) using only the local code \({\mathcal {C}}_i\). Hence in the set-up of Theorem 1.2 we are allowed in each local code a small number of errors (if the local code has very few erasures), but we must correct all the errors before running the algorithm to correct the erasures, otherwise we only get garbage.

Remark 2.5

We recall that a t-blocking set of a projective space \(\mathbb {P}^r(\mathbb {F}_q)\) is a set \(B\subset \mathbb {P}^r(\mathbb {F}_q)\) such that \(B\cap V\ne \emptyset \) for all \(V\in Gr(r-t+1,r+1)(\mathbb {F}_q)\). If \(B\supseteq B'\) and \(B'\) is a t-blocking set, then B is a blocking set. Any \(W\in Gr(t+1,r+1)(\mathbb {F}_q)\) is a t-blocking set. A. Beutelspacher proved that \(\# B \ge \frac{q^{t+1}-1}{q-1} +q^{t-1}\sqrt{q}\) if B is a t-blocking set containing no \(W\in Gr(t+1,r+1)(\mathbb {F}_q)\) ( [4]). We mention that blocking sets and [4] were used for the construction of LRC in [5, 17].

Proof of Theorem 1.2:

First of all we need to prove that some \(x>0\) exists. The proof will also show that the code \({\mathcal {D}}_t\) is layered so that it may be used as an s-LRC. Set \(Y:= \prod _{i=1}^{s} \mathbb {P}^{k_i-1}\) and take \(S_i\subset \mathbb {P}^{k_i-1}(\mathbb {F}_q)\) inducing the evaluation code \({\mathcal {C}}_i\). Let \(\nu : Y \rightarrow \mathbb {P}^{k-1}\) denote the Segre embedding. Fix \(i\in \{1,\dots ,s\}\). Let \(T_i\) be the union of the \(n/n_i\) linear subspaces of \(\mathbb {P}^{k-1}(\mathbb {F}_q)\) spanned by the sets \(A_1\times \cdots \times A_s\) with \(A_i =S_i\) and \(\#A_j=1\) for all \(j\ne 0\). For any integer \(w\ge 0\) let \(Gr(w+1,k)(\mathbb {F}_q)\) denote the Grassmannian of all w-dimensional \(\mathbb {F}_q\)-linear subspaces of \(\mathbb {P}^{k-1}(\mathbb {F}_q)\). For any \(W\in Gr(w+1,k)\) let \(\ell _W: \mathbb {P}^{k-1}(\mathbb {F}_q)\setminus W \rightarrow \mathbb {P}^{k-1-w}(\mathbb {F}_q)\) denote the linear projection from W. We want to find w and \(W\in Gr(w+1,k)(\mathbb {F}_q)\) such that the linear projection from W induces an \([n,k-w-2]\) codes which corrects at least \(\delta \) errors and preserve the layered structure so that the corresponding code \({\mathcal {D}}_t\) corrects at least \(\prod _{i=1}^{s} (d_i-1)\) erasures. Fix an integer \(w\ge 0\). We want to find a w-dimensional linear subspace W such that the linear projection from w gives an \([n,k-2-w]\) code layered into s codes with the parameters of the codes \({\mathcal {C}}_1,\dots ,{\mathcal {C}}_s\). To get that the length of the code is n it is sufficient to find W such that \(W\cap S =\emptyset \) and W intersects no line spanned by two points of S.

Then we want to preserve the layers. We need that the projection \(\ell _W\) preserves the layers, i.e. it sends the linear spaces giving the layers onto same dimensional linear spaces, i.e. that \(W\cap M=\emptyset \) for all linear spaces giving the layers. We do not need that after the projection these linear spaces are different and we do not need that the images of linear spaces belonging to the same layer (which before the linear projection were disjoint) are mapped by \(\ell _W\) to disjoined linear spaces. We need that the \(\sum _{i=1}^{s} n/n_i \) linear subspace of \(\mathbb {P}^{k-1}(\mathbb {F}_q)\) used do not meet W (we do not need that their images by \(\ell _W\) are disjoint, not even that all these images are different linear subspaces).

Let \(B'\) the union of all linear spaces in the layers. For \(1\le i\le s\) there are \(n/n_i\) layers belonging to the layer corresponding to \({\mathcal {C}}_i\) and each of these linear spaces has dimension \(k_i-1\) and hence it has \(\frac{q^{k_i}-1}{q-1}\) points. Let \(B''\) be the union of the lines spanned by 2 of the points of S. Set \(B:= B'\cup B''\). \(\square \)

Claim 1: \(\#B < \left( {\begin{array}{c}n\\ 2\end{array}}\right) (q-1)+\sum _{i=1}^{s} (n/n_i)\frac{q^{k_i}-1}{q-1}\).

Proof of Claim 1: There are at most \(\left( {\begin{array}{c}n\\ 2\end{array}}\right) \) lines spanned by the points of S. Any line \(L\subset \mathbb {P}^{k-1}(\mathbb {F}_q)\) has cardinality \(q+1\). Since any line occurring in the definition of \(B''\) contains 2 points of S, \(\#B''\le \left( {\begin{array}{c}n\\ 2\end{array}}\right) (q-1)+n\). Since \(S\subset B'\), \(\#(B\setminus B') \le \left( {\begin{array}{c}n\\ 2\end{array}}\right) (q-1)\). \(B''\) is the union of \(n/n_i\) \((k_i-1)\)-dimensional linear spaces, \(1\le i\le s\). Strict inequality holds in Claim 1 because \(s\ge 2\) and linear spaces belonging to different rulings of Y meets at points defined over \(\mathbb {F}_q\).

To conclude the proof it is sufficient to find \(W\in Gr(n+1-t,n+1)(\mathbb {F}_q)\) such that \(B\cap W =\emptyset \), i.e. to prove that B is not a t-blocking set in the sense of [4].

Claim 2: B does not contain any t-dimensional linear subspace.

Proof of Claim 2: Since \(S_i\) spans \(\mathbb {P}^{k_i-1}(\mathbb {F}_q)\), the set S spans \(\mathbb {P}^{k-1}(\mathbb {F}_q)\) and hence Claim 2 follows from the inclusion \(S\subset B\).

By [4] (Remark 2.5) to conclude the proof it is sufficient to quote Claims 1 and 2. \(\square \)