Coding and Bounds for Partially Defective Memory Cells

This paper considers coding for so-called partially stuck (defect) memory cells. Such memory cells can only store partial information as some of their levels cannot be used fully due to, e.g., wearout. First, we present new constructions that are able to mask $u$ partially stuck cells while correcting at the same time $t$ random errors. The process of"masking"determines a word whose entries coincide with writable levels at the (partially) stuck cells. For $u>1$ and alphabet size $q>2$, our new constructions improve upon the required redundancy of known constructions for $t=0$, and require less redundancy for masking partially stuck cells than former works required for masking fully stuck cells (which cannot store any information). Second, we show that treating some of the partially stuck cells as erroneous cells can decrease the required redundancy for some parameters. Lastly, we derive Singleton-like, sphere-packing-like, and Gilbert--Varshamov-like bounds. Numerical comparisons state that our constructions match the Gilbert--Varshamov-like bounds for several code parameters, e.g., BCH codes that contain all-one word by our first construction.

levels.For multi-level PCMs, the case in which the partially stuck level s = 1 is particularly important since this means that a cell can reach all crystalline sub-states, but cannot reach the amorphous state.
Figure 1 depicts the general idea of reliable and (partially) defective memory cells.It shows two different cell level representations: Representation 1 forms the binary extension filed F 2 4 and Representation 2 forms the set of integers modulo q = 4, i.e., Z/4Z.

No value can be stored
The value that cell can store ∈ F 2 2 The value that cell can store ∈ Z/4Z In the stuck scenario as shown in case (B), the defective cells can store only the exact stuck level s.Case (C) is more flexible (partially defective scenario).
Partially stuck cells at level s ≥ 1 can store level s or higher.

A. Related Work
Coding for memories with stuck cells, also known as defectcorrecting codes for memories with defects, dates back to the 1970s, cf. the work by Kuznetsov and Tsybakov [6].They proposed binary defect-correcting codes in finite and asymptotic regimes whose required redundancy is at least the number of defects.Later works [7]- [19] investigated the problem of defective cells under various aspects: binary and non-binary, only defect-correcting coding and error-and-defectcorrecting coding, and finite and asymptotic length analysis.
In binary defect-correcting coding models, e.g.[8], [10]- [12], [15]- [17], the authors dealt with masking stuck cells without considering additional substitution errors.In these studies, it is unclear if the proposed constructions are optimal in terms of their required redundancy.The works [9], [13], [14] considered masking stuck memory cells while at the same time correcting potential random errors.In [13], socalled partitioned cyclic code and partitioned BCH codes were proposed for this task.
The asymptotic model of stuck-cell-masking codes also received considerable attention in the previously mentioned papers.Moreover, there is work devoted to asymptotically optimal codes for a fixed number of defects [18] or for a number of defects proportional to the codeword length [19].The proposed constructions, for example [19,Section 4] and its extended version in [19,Section 5] that can additionally correct substitution errors, show that u check symbols are sufficient for masking u defects.However, they use codes with a property that is not well studied in coding theory.Therefore, we do not dwell on [18] and [19], and also our goal is to obtain code constructions for finite code length n.
The recent work [5] considers partially stuck memory cells (see Figure 1.C), and improves upon the redundancy necessary for masking compared to all prior works for classical stuck cells.However, the paper does not consider error correction in addition to masking.

B. Our Contribution
In this paper, we consider the problem of combined error correction and masking of partially stuck cells.Compared to the conventional stuck-cell case in [13], we reduce the redundancy necessary for masking, similar to the results in [5], and even reduce further compared to [5, Construction 5].
If cells are partially stuck at level 1, we can simply use a (q−1)-ary error correcting code as mentioned in [5,Section III].However, this approach could require too much redundancy if a cell is partially stuck at different levels rather than 1.For instance, using (q − s)-ary codes for 2 ≤ s ≤ q − 1 reduces the cardinality of the code because exempting s out of the available q levels is quite expensive.Further, for relatively few partially stuck-at-1 cells, even a (q − 1)-ary error correcting code is not a competitor to our constructions (cf. Figure 6).Therefore, considering sophisticated coding schemes is favorable.
We provide code constructions for any number of partially stuck cells; see Table III for an overview of our constructions and their required redundancies.For the error-free case, where only masking is necessary, our redundancies coincide with those from [5] or are even smaller.
Our paper also investigates a technique where the encoder, after a first masking step, introduces errors at some partially stuck positions of a codeword in order to satisfy the stuckat constraints.The decoder uses part of the error-correcting capability to correct these introduced errors.
We also derive bounds on our code constructions, namely a Singleton-type, sphere-packing-type, and Gilbert-Varshamovtype bounds.We provide a numerical analysis by comparing our code constructions and the derived bounds with other trivial codes and known limits.
Our focus is on long codes over small alphabets, i.e., the code length n is larger than the field size q.Otherwise, one could instead mask by a code of length n < q (by using, e.g., [20]).
The remainder of the paper is arranged as follows.In Section II, we provide notations and define the models of joint errors and partially defective cells examined in this study.Our code constructions along with their encoding and decoding algorithms are presented in Section III and IV.Section V generalizes the previous constructions to mask partially stuck cells at any arbitrary level and correct errors additionally.
Section VI investigates exchanging error correction capability toward more partially stuck cells masking possibility.Upperand lower-like bounds on our constructions are derived in Section VII and VIII, respectively.In Section IX, we provide numerical and analytical comparisons.Finally, Section X concludes this work.
As usual, an [n, k, d] q code is a linear code over F q of length n, dimension k and minimum (Hamming) distance d.The (Hamming) weight wt(x) of a vector x ∈ F n q equals its number of non-zero entries.
We fix throughout the paper a total ordering "≥" of the elements of F q such that a ≥ 1 ≥ 0 for all a ∈ F q \ {0}.So 0 is the smallest element in F q , and 1 is the next smallest element in F q .We extend the ordering on F q to F n q : for x = (x 0 , . . ., x n−1 ) ∈ F n q and y = (y 0 , . . ., y n−1 ) ∈ F n q , we say that x ≥ y if and only if In order to simplify notation, we sometimes identify x ∈ F q with the number of field elements not larger than x, that is, with the integer q − |{y ∈ F q | x ≥ y}|.The meaning of x will be clear from the context.Figure 1 depicts the two representations that are equivalent in this sense.Finally, we denote the q-ary entropy function by h q , that is h q (0) = 0, h q (1) = log q (q − 1), and h q (x) = −x log q (x)

B. Definitions
1) Defect and Partially Defect Cells: A cell is called defect (stuck at level s), if it can only store the value s.A cell is called partially defect (partially stuck at level s), if it can only store values which are at least s.Note that a cell that is partially defect at level 0 is a non-defect cell which can store any of the q levels and a cell that is partially defect at level q − 1 is a (fully) defect cell.
2) (Σ, t)-PSMC: For Σ ⊂ F n q and non-negative integer t, a q-ary (Σ, t)-partially-stuck-at-masking code C of length n and size M is a coding scheme consisting of a message set M of size M , an encoder E and a decoder D.
The encoder E is a mapping from M × Σ to For each (m, s) ∈ M × Σ and each e ∈ F n q such that wt(e) ≤ t and E(m, s) + e ≥ s, it holds that D(E(m, s) + e) = m.
3) (u, 1, t) PSMC: A q-ary (u, 1, t) PSMC of length n and cardinality M is a q-ary (Σ, t) PSMC of length n and size M where In this special case, the partially stuck-at condition means that the output of the encoder is non-zero at each position of the support φ of s.

A. Code Construction
In this section, we present a coding scheme over F q that can mask up to q − 1 partially stuck cells and additionally can correct errors.We adapt the construction from [5], which allows to mask up to q − 1 partially-stuck-at-1 (s i = 1 for all i) cells with only a single redundancy symbol, but cannot correct any substitution errors.
Construction 1. Assume that there is an [n, k, d] q code C with a k × n generator matrix of the form , and 1 is the all-one vector of length .Encoder and decoder are shown in Algorithm 1 and Algorithm 2.
) PSMC of length n and cardinality q k−1 .

Algorithm 1: Encoding
Input: Algorithm 2: Decoding Input: Proof.To mask the partially-stuck-at-1 positions, the codeword has to fulfill: Since | φ | < q, there is at least one value v ∈ F q such that w i = v, for all i ∈ φ.Thus, The decoder (Algorithm 2) gets y, which is c corrupted by at most d−1 2 substitution errors.The decoder of C can correct these errors and obtain c.
Due to the structure of G, the first position of c equals −v.Hence, we can compute ŵ = w (cf.Algorithm 2) and m = m.Corollary 1.If there is an [n, k, d] q code containing a word of weight n, then there is a q-ary (q − 1, 1, d−1

2
) PSMC of length n and size q k−1 .
To obtain a cyclic code, similar to [13, Theorem 2], we can adapt Algorithms 1 and 2 of Construction 1 to directly operate on the generator polynomial of the code, which may be beneficial in practice.We present this variant in Appendix A. For instance, any cyclic code whose generator polynomial is a divisor of g 0 (x) = 1+x+x 2 +• • •+x n−1 contains the all-one codeword.For BCH codes, this is the case if the defining set of the code does not contain 0. This gives an explicit family of codes whose parameters, for a specific choice of cyclotomic cosets, can be bounded by standard bounds on the minimum distance of cyclic codes such as the BCH bound.

B. Comparison to the Conventional Stuck-Cell Scenario
Theorem 1 combines [13, Theorem 1] and [5,Theorem 4] to provide a code construction that can mask partially stuck cells and correct errors.The required redundancy is a single symbol for masking plus the redundancy for the code generated by the upper part of G, needed for the error correction.In comparison, [13, Theorem 1] requires at least redundancy symbols to mask u stuck cells, where the inequality follows directly from the Singleton bound.
In the following, we present Tables I and II to compare ternary cyclic codes of length n = 8 for masking partially stuck cells to masking stuck cells [13], both with error correction.
The tables show that masking partially stuck cells requires less redundancy than masking stuck cells, both with and without additional error correction.The reason is that there is only one forbidden value in each partially stuck-at-1 cell, while there are q − 1 forbidden values in each stuck at cell.

C. Remarks on Construction 1
Remark 1.The special case of Theorem 1 with n < q was used in [20] for constructing a (q − 1)-ary error-correcting code from a q-ary Reed-Solomon code, which can be of interest if q − 1 is not the power of a prime.
Remark 2. The code constructions in Theorem 1 and 17 also work over the ring of integers modulo q (Z/qZ) in which q is not necessarily a prime power, similar to the construction for u < q in [5].
Remark 3.According to [5,Construction 3], it is possible to further decrease the required redundancy for masking u partially-stuck-at-1 cells to 1 − log q q u+1 .We can use the same strategy here.Let z = ( q u+1 ) .We choose disjoint sets A 1 , A 2 , .., A z of size u + 1 in F q .As additional information, the encoder picks j ∈ {1, 2, . . ., z}.In Step 2 of Algorithm 1, it selects v from A j .As the decoder acquires v, it can obtain j as well.
The masking technique in the previous section only guarantees successful masking up to a number of q − 1 partially stuck-at-1 cells.In this section, we present techniques to mask more than q − 1 cells.
Depending on the values of the stored information in the partially stuck positions, Construction 1 may be able to mask more than q − 1 cells.In Section IV-A, we determine the probability that masking is possible for fixed partially stuck cell positions and randomly chosen information vectors.
Next, we propose two code constructions for simultaneous masking and error correction when q ≤ u < n.One is based on the masking-only construction in [5, Construction 4] and the other is based on [5, Section VI], which are able to mask

Cardinality
Overall

Cardinality
Overall Redundancy u t The defining set Dc by (17) u ≥ q partially stuck positions, but cannot correct any errors.We generalize these constructions to be able to cope with errors.The latter construction may lead to larger code dimensions for a given pair (u, t), in a similar fashion as [5, Construction 5] improves upon [5,Construction 4].Further, taking t = 0 it achieves larger codes sizes than [5,Construction 5] if the all-one word is in the code.

A. Probabilistic Masking
We determine the probability that masking is possible for u ≥ q partially stuck-at 1 cells stuck positions with the code constructions in Theorem 1 and Theorem 17 are used.This probabilistic masking approach enables us to use the memory cells with a certain probability even if there are more than q − 1 partially stuck cells.
Theorem 2. Let G be as in Construction 1, and let φ ⊂ [n] have size u.If the columns of G indexed by the elements in φ are linearly independent, a uniformly drawn message from F k−1 q results in a word c with c i = 0 for all i ∈ φ with probability Proof.An appropriate value for v in Step 2 in Algorithm 1 cannot be found if and only if {w i | i ∈ φ} = F q which is true if and only f : φ → F q defined by f w (i) = w i is a surjection.As is well-known (see e.g [21, Example 10.2], the number of surjections from a set of size u to a set of size q equals q−1 i=0 As the columns of G are independent, the vector w restricted to φ is distributed uniformly on F u q , and hence a word is not masked with probability equal to the expression from (3) divided by q u .
The following example illustrates that the probability that masking is successful can be quite large.
Example 1.Let q = 3, n = 8, n − k = 0.The probability to mask u = n − 1 partially stuck-at-1 memory cells is P(3, 7) = 0.17.This ratio is 0.77 if u = q and clearly it is The assumption in Theorem 2 that the columns of G indexed by the partially stuck positions are linearly independent is fulfilled for most codes with high probability if For dependent columns, it becomes harder to count the number of intermediate codewords w that do not cover the entire alphabet since w i for all i ∈ φ is not uniformly distributed over F u q .
B. Code Construction over F q for Masking Up to q + d 0 − 3

Partially Stuck Cells
We recall that [5,Construction 4] can mask more than q − 1 partially stuck-at-1 cells and it is a generalization of the allone vector construction [5,Theorem 4].Hence, replacing the 1 n vector in Theorem 1 by a parity-check matrix as in [5,Construction 4] allows masking of q or more partially stuck-at 1 cells, and correct t errors.
Construction 2. Suppose that there is an [n, k, d] q code C with a k × n generator matrix of the following form: where H 0 ∈ F l×n q is a parity-check matrix of an [n, n − l, d 0 ] code C 0 .Encoder and decoder are shown in Algorithm 3 and Algorithm 4.

2
) PSMC of length n and cardinality q k−l .
Proof.Let φ ⊂ [n] have size u ≤ q+d 0 −3.Algorithm 3 finds z = {z 0 , z 1 , . . ., z l−1 } similar to [5,Theorem 7] instead of only finding v value as demonstrated in Algorithm 1. Then the proof is exactly the same as in [5,Theorem 8] for the masking part.In short, the authors in the proof of [5,Theorem 7] subdivides the code length n into l block lengths of sizes at most q − 1.Hence, as each block contains at most q − 1 Algorithm 3: Encoding Input: and ẑ ∈ F l q such that ĉ = mG 1 + ẑH 0 .Output: Message vector m ∈ F k−l q constraints, then in a corresponding block there is at least Then [5,Theorem 8] reduces l such that an appropriate z ∈ F l q still exists as any u − q + 2 ≤ d 0 − 1 of H 0 labeled by u are linearly independent.The error correction part of the proof follows the proof of Theorem 1.
The gain of Theorem 3 in the number of partially stuck cells that can be masked comes at the cost of larger redundancy.However, the redundancy is still smaller than the redundancy of the construction for masking stuck-at cells and error correction in [13].In particular, let C be an [n, k, d ≥ 2t + 1] code containing an [n, l] q subcode C 0 for which C ⊥ 0 has minimum distance d 0 .With Theorem 3, we obtain a (d 0 +q−3, 1, d−1 2 ) PSMC of length n and cardinality q k−l .The construction in [13] yields a coding scheme with equal cardinality, allowing for masking up to d 0 −1 fully stuck cells and correcting d−1 2 errors.Hence, exactly q − 2 more cells that are partially stuck at levels 1 than classical stuck cells can be masked.

C. Code Construction over
We generalize [5, Section VI] to be able to cope with errors.Unlike [5, Section VI] that could be over any prime power q, the following code construction works over the finite field F q where q = 2 µ in order to describe a 2 µary partially stuck cells code construction.This is because binary subfiled subcodes that are required in this construction are not linear subspace for codes over any prime power q.We denote by where Encoder and decoder are shown in Algorithm 5 and Algorithm 6.
Algorithm 5: Encoding (m; m ; φ) Input: , where , where c is a valid output of Algorithm 5 and e is an error of Hamming weight at most t.
We first show the existence of z from Step 1.For each i ∈ φ, we have that x i = 0, so there are exactly two elements As H 0 is the parity check matrix of a code with minimum distance d 0 , any d 0 − 1 columns of H 0 are independent, so an appropriate γ exists.Now we show that c i = 0 for all i ∈ φ.
Decoding: As c ∈ C, ĉ = c.As G has full rank, and it holds that a = m + γ, m = m and ẑ = z.As m ∈ F l and γ ∈ F l 2 , we can retrieve m = m from a = m + γ.
We show next two minor extensions on Theorem 4 for the special case that x is the all-one vector.Proposition 1.If x is the all-one vector in Theorem 4, then the coding scheme in Construction 3 can be modified to produce a 2 µ -ary Hence, there is a z 0 ∈ F such that w + z 0 1 has at most d 0 − 1 binary entries, and we can encode where ζ ∈ {0, 1} is an additional message bit so that the cardinality from Theorem 4 is doubled.As z 0 ∈ F and ζ ∈ {0, 1}, the pair (z 0 , ζ) can be retrieved from z 0 + ζ.

Proof. In Step 1 of Algorithm 5, the encoder determines
the existence of such a z is proved as in the proof of Theorem 3. Next, the encoder determines γ ∈ {0, 1} l and γ and has no zeros in the positions of φ.
In decoding, from c both (m + γ) and m can be retrieved, and so, as m ∈ F l and γ ∈ {0, 1} l , m can be retrieved as well.
Proposition 1 doubles the size of the PSMC as compared to Theorem 4 (by using ζ as additional message bit), while masking the same number of partially stuck-at-errors and correcting the same number of substitution errors.Theorem 4.A, as compared to Theorem 4, results in a PSMC of the same size and error correction capabilities, but increases the number of cells that can be masked from Now, we show an example using nested BCH codes, allowing to store more symbols compared to Theorem 4 for the same code parameters.
As 1 ∈ C\C ⊥ 0 , the code C has a generator matrix of the form given in Construction 3, namely where H 0 is a generator matrix for C ⊥ 0 and G 1 has 12 − 4 − 1 = 7 rows.The code C 0 = (C ⊥ 0 ) ⊥ is equivalent to the [15,11] 2 BCH code with zeros α 7 , α 11 , α 13 and α 14 .As this BCH code has two consecutive zeros, its minimum distance (and hence the minimum distance of C 0 ) is at least 3.
Finally, we note that application of Theorem 3 to C yields a (4, 1, 1) PSMCs of size 4 8 , which has worse parameters than the three PSMC mentioned before.
Example 3 clearly shows that for the same code parameters, Construction 3, Proposition 1 and Construction 3.A significantly improve upon Construction 2.
We summarize in Table III our constructions and compare them with some of the previous works, namely with the construction for masking classical stuck cells in [13] and constructions for partially stuck cells without errors in [5].
So far, we have considered the important case for s i = 1 for all i ∈ φ.In this section, we present error correction and masking codes constructions that can mask partially stuck cells at any level s i and correct errors additionally.

A. Generalization of Theorem 1
Here, we give only the main theorem without adding the exact encoding and decoding processes because it follows directly as a consequence of Construction 1.
Assume there is an [n, k, d] q code C of a generator matrix as specified in Theorem 1. Then there exists a (Σ, d−1

2
) PSMC over F q of length n and cardinality q k−1 .
Proof.We follow the generalization for the masking partially stuck at any arbitrary levels in [5, Theorem 10].Hence, for s ∈ Σ, we modify Step 2 in Algorithm 1 such that w i −v ≥ s i for all i ∈ [n].Such a v exists as each cell partially stuck at level s i excludes s i values for v, and n−1 i=0 s i < q.The rest of the encoding steps and the decoding process are analogous to Algorithms 1 and 2. As the output from the encoding process is a codeword, we can correct d−1 2 errors.

B. Generalization of Construction 2
In the following, we generalize Construction 2 to arbitrary s stuck levels.
then the coding scheme in Construction 2 can be modified to produce a (Σ, t) PSMC of length n and size q k−l .Proof.To avoid cumbersome notation, we assume without loss of generality that where I d0−2 is the identity matrix of size d 0 − 2, 0 denotes the . As T is invertible, and any d 0 − 1 columns of H 0 are independent, any d 0 − 1 columns of Y are independent as well.
For 0 ≤ i ≤ l − 1, we define Clearly, L 0 , . . ., L l−1 are pairwise disjoint.Moreover, for each j ∈ {d 0 − 2, d 0 − 1, . . ., n − 1}, column j of Y is independent from the (d 0 − 2) leftmost columns of Y , and so there is an By combining (6) and the form of Y , we infer that Let w ∈ F n q be the vector to be masked, i.e. the vector after Step 1 in Algorithm 3. The encoder successively determines the coefficients ζ 0 , . . ., ζ l−1 of ζ ∈ F l q such that w + ζY ≥ s, as follows.For j ∈ [d 0 − 2], the encoder sets ζ j = s j − w j .Now let d 0 − 2 ≤ i ≤ l − 1 and assume that ζ 0 , . . ., ζ i−1 have been obtained such that It follows from combination of ( 7) and the choice of For each j ∈ L i , we define F j as Clearly, |F j | = s j as Y i,j = 0, and so j∈Li where the last inequality follows from the assumption of Σ in the proposition statement and the ordering of the components of s.Hence, j∈Li F j = F q .The encoder chooses ζ i ∈ F q \ j∈Li F j .We claim that For j ∈ L i , (9) follows from the definition of F j .For j ∈ i−1 k=0 L k , (9) follows from (8) and the fact that Y i,j = 0.By using induction on i, we infer that That is, with ζ = (ζ 0 , . . ., ζ l−1 ), we have that w + ζY ≥ s.
As Y = T H 0 , it follows that z := ζT is such that The decoding process remains as in Algorithm 4.
We give an alternative non-constructive proof for Proposition 2 in Appendix B. Remark 6.The proof of Proposition 2 shows that (d 0 − 2) cells can be set to any desired value, while the remaining (n − d 0 + 2) cells can be made to satisfy the partial stuck-at conditions, provided that the sum of the stuck-at levels in these (n − d 0 + 2) cells is less than q.
Corollary 2 (Generalization of Theorem 3).Let s ∈ F q and let Σ = {s ∈ F n q | wt(s) ≤ d 0 + q s − 3 and max{s i | i ∈ [n] ≤ s}.The coding scheme in Construction 2 is a (Σ, t) PSMC scheme of length n and size q k−l .
Hence in both cases, i∈Ψ s i ≤ q − 1.The corollary thus follows from Proposition 2. In particular, if s = 1, the corollary agrees with Theorem 3.
We do not generalize Construction 3 as it is tailored to the special case where s i = 1 for all i ∈ φ.
In the constructions shown so far, the encoder output c is a word from an error correcting code C. If c does not satisfy the partial stuck-at conditions in j positions, the encoder could modify it in these j positions to obtain a word c = c + e satisfying the partial-stuck at constrains, while wt(e ) = j.If C can correct t errors, then it still is possible to correct t − j errors in c .This observation was also made in [13,Theorem 1].The above reasoning shows that the following proposition holds.Proposition 3. If there is an (n, M ) q (u, 1, t) PSMC, then for any j with 0 ≤ j ≤ t, there is an (n, M ) q (u + j, 1, t − j) PSMC.
In the remainder of this section, we generalize the above proposition to general Σ (Theorem 6).We also provide variations on the idea of the encoder introducing errors to the result of a first encoding step in order that the final encoder output satisfies the partially stuck-at conditions.Theorem 6 (Partial Masking PSMC).Let Σ ⊂ F n q , and assume that there exists an (n, M ) q (Σ, t) PSMC C. For any j ∈ [t], there exists an (n, M ) q (Σ (j) , t − j) PSMC C j , where Proof.Let the encoder E j and the decoder D j for C j be Algorithm 7 and Algorithm 8, respectively.By definition, c ≥ s .Moreover, if Algorithm 7: Encoding Output: Codeword c .We can improve on Theorem 6 for Construction 3 giving Lemma 1.
Lemma 1.Given an [n, k, d] q code as defined in Construction 3, then for any j such that 0 We use the notation from Algorithm 5.After Step 1, w has at most u 0 = 2u 2 µ ≤ d 0 + j − 1 binary entries in the positions from φ.After Step 2, at least d 0 − 1 of these entries in c differ from 0. By setting the at most j other binary entries in the positions from φ equal to 1, the encoder introduces at most j errors, and guarantees that the partial stuck-at conditions are satisfied.
In Lemma 2, we use another approach for introducing errors in order to satisfy the stuck-at conditions.Lemma 2. Given an [n, k, d] q code containing a word of weight n, for any j with 0 ≤ j ≤ d−1
Proof.We use the notation from Construction 1.
Let φ ⊂ [n] have size u ≤ q − 1 + qj.Let x be a codeword of weight n.For each i ∈ φ, there is exactly one v ∈ F q such that w i + vx i = 0, and so As a consequence, there is v ∈ F q such that c = w + vx has most u q ≤ j entries in φ equal to zero.By setting these entries of c to a non-zero value, the encoder introduces at most j errors.As C can correct up to d−1 2 errors, it can correct these j errors and additionally up to d−1 2 − j substitution errors.
Example 4. Consider a [15, 9, 5] 4 code C containing the allone word, e.g. the BCH code with zeroes α, α 2 , α 3 , where α is a primitive element in F 16 .Let u ≤ 7 and t = 1.We use the all-one word for partial masking, ensuring that 0 occurs in at most u 4 ≤ 1 position indexed by φ.We set the codeword value in this position to 1, introducing one error.We can correct this introduced error and one additional random error as C has minimum distance 5. Hence, we have obtained a 4-ary (7, 1) PSMC of length 15 and cardinality 4 8 .
We show in Example 5 how applying Lemma 2 for Construction 3 outperforms Lemma 1.

Following
Step 2 in Algorithm 5 and since d 0 = 3, we can mask at most d 0 − 1 binary values highlighted in the vector w (φ) that leaves us, in this example, with at most 2u 2 2 − d 0 + 1 = 5 zeros that remain unmasked.
However, applying Lemma 2 instead for Construction 3 gives a better result.Choosing γ = 0 in Step 2 of Algorithm 5, we obtain c (φ) = w (φ) with ( u q = 3) zeros highlighted in blue above that we can directly trade.

Remark 7.
As the code from Construction 3 has a word of weight n, Lemma 2 implies the existence of an (u, 1, t) PSMC of cardinality q k−1 under the condition that 2(t + u q ) < d.Lemma 1 shows the existence of an (u, 1, t) PSMC of smaller cardinality, viz.q k−l , under the condition that 2(t + max(0, 2u 2 µ − d 0 + 1) < d.As a consequence, Lemma 1 can only improve on Lemma 2 if d 0 − 1 > 2u 2 µ − u 2 µ .We can generalize Lemma 2 as follows.
Lemma 3. Given an [n, k, d] q code containing a word of weight n.Let 0 ≤ j ≤ d−1

2
, and let There is a q-ary (Σ, d−1 2 − j) PSMC of length n and size q k−1 .
Proof.We use the notation from Theorem 5.For simplicity, we assume that the code contains the all-one word.We wish to choose the multiplier v ∈ F q such that c = w − v • 1 satisfies c i ≥ s i for as many indices i as possible.For each index i, there are q − s i values for v such that this inequality is met.Hence, there is a v ∈ F q such that c i ≥ s i for at least 1 q i (q − s i ) = n − 1 q i s i indices i.The encoder thus needs to introduce errors only in the at most 1 q i s i positions for which the inequality is not satisfied.Lemma 4. Assume there exists a matrix as in Proposition 2. Let 0 ≤ j ≤ d−1

2
, and let Then exists a q-ary (Σ, d−1 2 − j) PSMC of length n and size q k−l .Proof.Let s ∈ Σ.In order to simplify notation, we assume without loss of generality that n−1 i=d0−2 s i ≤ q−1+qj.We use the same argument as in the alternative proof of Proposition 2 (see Appendix B).Clearly, So we infer that for at least n − j indices i ∈ [n], Remark 8.The proof of Lemma 4 shows that the encoder output in fact can be made equal to s in the d 0 − 2 largest entries of s.In fact, it shows that the scheme allows for masking d 0 − 2 stuck-at errors, masking partial stuck errors in the remaining cells, and correcting d−1 2 − j substitution errors, provided that the sum of the stuck-at levels in the n − d 0 + 2 remaining cells is less than (j + 1)q.

V I I . U P P E R B O U N D S O N P S M C C O D E S
The output of an encoder has restrictions on the values in the partially stuck-at cells; in the other cells, it can attain all values.So the set of all encoder outputs is a poly-alphabetic code [22].To be more precise, the following proposition holds.Proposition 4. Let C be an (n, M ) q (Σ, t) partially stuck-atmasking code with encoder E. For any s ∈ Σ, let Then C s is a code with minimum distance at least 2t + 1 and |M| words, and Proof.By our error model, errors in stuck-at cells result in values still satisfying the stuck-at constraints.Therefore, t errors can be corrected if and only if C s has minimum Hamming distance at least 2t + 1.The rest of the proposition is obvious.
As a result of Proposition 4, upper bounds on the size of poly-alphabetic codes [22] are also upper bounds on the size of partially-stuck-at codes.Theorem 7. (Singleton type bound) Let C be a q-ary (Σ, t) PSMC of length n and size M .Then for any s = (s 0 , . . ., s n−1 ) ∈ Σ,

Proof. Combination of Proposition 4 and [22, Theorem 2].
Theorem 8. (Sphere-packing type bound) Let C be a q-ary (Σ, t) PSMC of length n and size M .Then for any s = (s 0 , . . ., t , the volume of a ball of radius t, satisfies where the volume V (s) r of the sphere with radius r is given by Proof.Combination of Proposition 4 and [22, Theorem 3].
Remark 9.The difference between poly-alphabetic codes and partially-stuck-at-masking codes is that in the former, the positions of stuck-at cells and the corresponding levels are known to both encoder and decoder, whereas in the latter, this information is known to the encoder only.) and our sphere-packing-like ("errors and partially stuck cells") bounds.The classical sphere-packing bound ("only errors") can read at u = 0 in our sphere-packing-like bounds curves.The chosen parameters are µ = 5 and q = 3, and n = ((q µ − 1)/(q − 1)).
Figure 2 compares our derived sphere-packing-like bound to the amount of storable information symbols for a completely reliable memory (i.e., no stuck cells, no errors that can be seen at u = 0 in the solid line) and the upper bound on the cardinality of an only-masking PSMC (only stuck cells, no errors) derived in [5] as depicted in the solid curve.At u = 0, the derived sphere-packing-type bound (dotted and dashed-dotted plots) matches the usual sphere-packing bound ("only errors") case.The more u partially stuck at cells, the less amount of storable information, i.e.only q − 1 levels can be utilized.Hence, the dotted and dashed-dotted lines are declining while u is growing.On the other hand, the more errors (e.g., t = 25 in the dashed-dotted plot), the higher overall required redundancy and the lower storable information for the aforementioned curve.
We have provided various constructions of (u, 1, t) PSMCs based on q-ary t-error correcting codes with additional properties.In this section, we first employ GV-like techniques to show the existence of (u, 1, t) PSMCs.Next, we study the asymptotic of the resulting GV bounds.
We start with a somewhat refined version of the Gilbert bound, that should be well-known, but for which we did not find an explicit reference.
Lemma 5. Let q be a prime power, and assume there is an then there is an [n, k] q code C k with minimum distance at least d that has C s as a subcode.
Proof.By induction on k.For k = s, the statement is obvious.Now let κ ≥ s and let C κ be an [n, κ] q code with minimum distance at least d that has C s as a subcode.If q κ d−1 i=0 n i (q− 1) i < q n , then the balls with radius d−1 centered at the words of C κ do not cover F n q , so there is a word x at distance at least d from all words in C κ .As shown in the proof of [23,Theorem. 5.1.8],the [n, κ + 1] q code C κ+1 spanned by C κ and x has minimum distance at least d.

1) Finite GV bound based on Lemma 2:
Theorem 9. Let q be a prime power.Let n, k, t, u be nonnegative integers such that There exists a q-ary (u, 1, t) PSMC of length n and size q k−1 .
Proof.Let C 1 be the [n, 1, n] q code generated by the all-one word.Lemma 5 implies that there is an [n, k] q code with minimum distance at least 2t + 1 that contains the all-one word.Lemma 2 shows that C k can be used to construct a PSMC with the claimed parameters.
Remark 10.GV bound from Theorem 1 is a special case of Theorem 9 for u ≤ q − 1.
2) Finite GV bound based on Construction 2: Lemma 6.Let q be a prime power, and let 1 ≤ k < n.Let E ⊂ F n q \ {0}.The fraction of [n, k] q codes with non-empty intersection with E is less than |E|/q n−k .
Proof.Let C be the set of all [n, k] q codes.Obviously, It follows from [24,Lemma 3] that Remark 11.If E has the additional property that λe ∈ E for all e ∈ E and λ ∈ F q \ {0}, then the upper bound in Lemma 6 can be reduced to |E|/(q − 1)q n−k .
Lemma 7. Let k, n, d and d ⊥ be integers such that There exists a q-ary [n, k] code C with minimum distance at least d such that C ⊥ has minimum distance at least d ⊥ .
Proof.Let C denote the set of all [n, k] q codes.By applying Lemma 6 with E = {e ∈ F n q | 1 ≤ wt(e) ≤ d − 1} and using the first condition of the lemma, we see that more than half of the codes in C have empty intersection with E, that is, have minimum distance at least d.Similarly, more than half of all q-ary [n, n − k] codes have minimum distance at least d ⊥ , and so more than half of the codes in C have a dual with minimum distance at least d ⊥ .We conclude that C contains a code with both desired properties.
Theorem 10 (Gilbert-Varshamov-like bound by Construction 2).Let q be a prime power.Suppose the positive integers u, t, n, k, l with u, t ≤ n and l < k satisfy Then there is a q-ary (u, 1, t) PSMC of length n and cardinality q k−l .
Proof.According to Lemma 7, ( 11) and ( 12) imply the existence of an [n, l] q code C 0 with minimum distance at least 2t + 1 for which the dual code has minimum distance at least u − q + 3. Lemma 5 shows that C 0 can be extended to an [n, k] q code C with minimum distance at least d.As C has a generator matrix of the form required by Construction 2, the theorem follows.
3) Finite GV bound based on Proposition 1: In this section, we give sufficient conditions for the existence of matrices satisfying the conditions of Proposition 1.We start with Lemma 8 and Lemma 9, then we prove the main theorem (Theorem 11).
Lemma 8. Let G be a k × n matrix over F q .For s ≥ 1, let Proof.The proof of Lemma 8 can be found in the appendix.Now we introduce Lemma 9 which is the binary version of Lemma 7 but with an extra restriction on the weight of the words.
Lemma 9. Let k, n, d and d ⊥ be integers such that There exists a binary [n, k] code C with minimum distance at least d without a word of weight more than n − d + 1 such that C ⊥ has minimum distance at least d ⊥ .
Proof.Similar to the proof of Lemma 7. Let C denote the set of all binary [n, k] codes.By applying Lemma 6 with , we infer that the first inequality implies that more than half of the codes in C contain no element from E. Similarly, the second inequality implies that more than half of the binary [n, n − k] codes have minimum weight at least d ⊥ , and so more than half of the codes in C have a dual with minimum distance at least d ⊥ .We conclude that there is a code in C enjoying both desired properties.
Proof.By Lemma 9, there exists a binary [n, l] code C 0 with minimum distance at least 2t + 1 for which C ⊥ 0 has minimum distance at least u 2 µ−1 + 1 with the following additional property: if H 0 ∈ F l×n 2 is a generator matrix for C 0 , then the binary code C µ with generator matrix H 0 1 has minimum distance at least 2t + 1.According to Lemma 8, the code C µ over F 2 µ with this generator matrix has minimum distance at least 2t + 1 as well.Lemma 5 implies that C µ can be extended to an [n, k] 2 µ code with minimum distance at least 2t + 1.

The [n, k] code has a generator matrix of the form
Application of Proposition 1 yields the claim.4) Finite GV bound from trivial construction: Clearly, a (q − 1)-ary code of length n with minimum distance at least 2t + 1 is a q-ary (u, 1, t) PSMC of length n.Combining this observation with the Gilbert bound for a q − 1-ary alphabet, we obtain the following.
Theorem 12. Let q ≥ 3, and let There is a q-ary (n, 1, t) PSMC of length n and cardinality M .
So far we have covered the GV-like bounds for our code constructions for finite length n.

B. Asymptotic GV Bound on PSMCs
In this section, we present the asymptotic version of the GV bounds from the previous section.That is, we provide lower bounds on the achievable rates of a q-ary (u, 1, t) PSMCs in the regime that the code length n tends to infinity, and the number u of partial stuck-at cells and the number t of random errors both grow linearly in n.
We recall the well-known following lemma that estimates the volume of a Hamming ball using the q-ary entropy function.
For sufficiently large n, there exists a q-ary ( υn , 1, τ n ) PSMC of length n and rate at least Proof.Let n be a positive integer.Write u = υn and t = τ n .Then Vol q (n, u−q + 2) ≤ Vol q (n, u).Hence, by setting l = nh q (υ) + 2 log q (2) , Lemma 10 implies that ( 12) is satisfied.Similarly, by setting it is ensured that ( 13) is satisfied.According to Theorem 10, there is a q-ary (u, 1, t) PSMC of length n and size q k−l , so with rate k − l.The choices for k and l show that the theorem is true.
Remark 12. Theorem 14 in fact holds for classical stuck-at cells instead of stuck-at-1 errors, as follows from considering the generalization of Theorem 10 in Proposition 2, i.e., Heegard's construction [13].
3) Asymptotic GV bound from Construction 3: Theorem 15 (Asymptotic Gilbert-Varshamov-like bound from Theorem 11).Let µ be a positive integer, and let υ and τ be such that For sufficiently large n there is a 2 µ -ary ( υn , 1, τ n ) PSMC of length n and rate at least Proof.For notational convenience, we set Let n be a positive integer satisfying n ≥ 7 η , and let u = υn , u 0 = u 2 µ−1 and t = τ n .We set Lemma 10 implies that ( 15) is satisfied.Moreover, as Lemma 10 implies that ( 14) is satisfied.We set Lemma 10 implies that ( 16) is satisfied.

I X . C O M PA R I S O N S
We provide different comparisons between our code constructions and the existence of the code based on Theorem 9, Theorem 10 and Theorem 11.Next, we also compare to the known limits and investigate the trade-off between masking and error-correction as described in Section VI.
A. Comparison of Theorem 9 for u ≤ q − 1 to other Bounds Figure 3 illustrates the rates of a (q −1, 1, t) PSMC obtained from Theorem 1 (applying Theorem 9 for the special case u ≤ q − 1) for n = 114, q = 7 and 0 ≤ t ≤ 56.We show how close explicit BCH codes that contains the all-one word of certain rates R and that can correct designed distances d ≥ 2t + 1 to the achieved rates from Theorem 1.We note that the solid red graph matches the dashed-dotted green plot for a few code parameters and overpasses it for t = 39.We also compare to the classical q-ary GV bound (in dashed black) as well as to reduced alphabet (q − 1)-ary GV bound (in dashed-dotted blue).To this end, we show upper bounds on the rates that can be obtained from Theorem 1 using the Griesmer bound [27], and the Ball-Blokhuis bound [28] on the size of codes containing the all-one word.
The dashed-dotted green curve shows the rates for Theorem 1 by Theorem 9 for u ≤ q − 1 in which codes that have the all-one words are considered.This curve for several code parameters matches the red line that shows how the rates of BCH codes that contain all-one word with regard to the designed distances d ≥ 2t + 1.
B. Comparison among Theorem 10, Theorem 11 and (q − 1)ary Gilbert-Varshamov bound We plot the achievable rates (R = log q (M )/n) as a function of t for different fixed values of u. Figure 4 is the resulting plot for n = 200 and q = 2 3 .It can be seen that the GV-like bound in different ranges of u and t based on Construction 2 improves upon the (q −1)-ary GV bound for u ≤ 5 as depicted in the solid red curve, and improves further (up to u ≤ 20) based on Construction 3 as shown in the dashed gray line (3rd one from above).The dashed dotted blue curve is used to see what if we map our 2 3 levels such that we avoid the subscript 0 to compare with 7 levels.It is obvious that for µ = 3, the rate loss1 resulting from using q − 1 instead of q symbols is already quite small.Note that for u = 0 the solid red curve mostly achieves the exact rates obtained from the standard 2 3 -ary GV bound for 0 ≤ t ≤ 80, and so as for the dashed red curve but for 0 ≤ t ≤ 47.On contrary, for larger t values, Table IV shows that the exchange is beneficial giving higher rates.For example, we start with C 21,41 whose R = 0.105, then applying Theorem 6 gives C 22,40 of R = 0.105 which is greater than R = 0.100 that has been obtained directly by Theorem 10 as stated in Table IV.

F. Comparisons of applications of Theorem 6, Lemma 1, Lemma 2 vs direct application of Theorem 11
For the derived GV bound based on Construction 3 obtained by Theorem 11, we demonstrate the exchange of a one error correction ability with a single masking capability of a partially stuck cell following Theorem 6 in Figure 9.The solid and dotted lines represent the rates before and after trading, respectively.We also show the exchange by Lemma 1 and Lemma 2 in which the reduction of the correctable errors by one increases u by 2 µ−1 and 2 µ , respectively.Let us discuss the following curves.For u = 19, the orange solid curve shows the rates by Theorem 11.Exchanging u + 1 and t − 1 throughout Theorem 6 obtains the orange dotted line for u + 1 = 20 which lies slightly bellow the orange solid plot.Hence, the exchange gives lower rates but provides rate R = 0.380 for t = 30 while direct application of Theorem 11 (compared to its corresponding graph which is the solid green curve at u = 20, 21, 22, 23) does not.Now, we apply Lemma 1 n log q M of GV bounds for different u, and t for n = 200 and q = 2 3 in Theorem 10.The solid plots are the rates from the derived GV-like bound and the dotted graphs are the rates after trading u + 1, t − 1 by Theorem 6. rather Theorem 6.We observe the dashed red graph for u + 2 3−1 = 23 shows the exact rates from the orange dotted curve for u + 1 = 20.Therefore, it is clear that Lemma 1 provides a gain of masking exactly 3 more cells with regard to Theorem 6.
However, if we take u = 23 directly by Theorem 11, we achieve slightly higher rates.We conclude that Theorem 11 can directly estimate the maximum possible masked u cells that can also be achieved applying Lemma 1, and can achieve slightly higher rates.However, Theorem 11 does not give rates for larger t values while Lemma 1 and Theorem 6 do that.
On the other hand, as Theorem 11 is based on Construction 3 that contains a word of weight n, Lemma 2 is applicable under the condition that 2(t + u q ) < d (cf.Remark 7).Hence, we can achieve higher rates while masking up to the same number of u cells than employing Lemma 1 or Theorem 6 as shown in the dashed-dotted curve.
For that we describe some points of Figure 9    Lemma 2 on a code obtained by Theorem 9 always provides higher code rates for the same parameters u, t (see Figure 7).n log q M of GV bounds for different u, and t for n = 200 and q = 2 3 in Theorem 11.The solid plots are the rates from the derived GV like bound and the dotted graphs are the rates after trading u + 1, t − 1 by Theorem 6.We also show the exchange by Lemma 1 and Lemma 2 in which the reduction of the correctable errors by one increases u by 2 µ−1 and 2 µ , respectively.

G. Analytical comparison of asymptotic GV-like bounds
In this section, we state the results of the analytical comparisons of the asymptotic GV bounds from Theorems 13, 14 and 15, ignoring the terms that tend to zero for increasing n.The proofs can be found in Appendix D. Proposition 5.If υ, τ and q are such that the conditions of Theorem 13 and Theorem 14 are met, then the rate guaranteed by Theorem 13 is at least equal to the code rate guaranteed by Theorem 14. Proposition 6.If υ, τ and q = 2 µ are such that the conditions of Theorem 14 and Theorem 15 are met, then the code rate guaranteed by Theorem 15 is at least equal to the code rate guaranteed by Theorem 14.
We note that the requirement 2τ < 1 2 from Theorem 15 is stricter than the requirement 2τ < 1 − 1 2 µ from Theorem 14.That is, there are pairs (τ, υ) for which Theorem 14 is applicable, but Theorem 15 is not.
As explained in Appendix D, comparison of Theorem 13 and Theorem 15 is more complicated.We have the following partial result.Proposition 7. Let υ, τ > 0 and q = 2 µ be such that the conditions of Theorem 13 and Theorem 15 are met.If υ is sufficiently small, then the rate guaranteed by Theorem 13 is larger than the rate guaranteed by Theorem 15.

X . C O N C L U S I O N
In this paper, code constructions and bounds for nonvolatile memories with partial defects have been proposed.Our constructions can handle both: partial defects (also called partially stuck cells) and random substitution errors, and require less redundancy symbols for u > 1 and q > 2 than the known constructions for stuck cells.Compared to error-free masking of partially stuck cells, our achieved code sizes coincide with those in [5], or are even larger as shown in Proposition 1.We summarize our constructions and the previous works on partially/fully stuck cells in Table III.
Further, we have shown that it can be advantageous to introduce errors in some partially stuck cells in order to satisfy the stuck-at constraints.For the general case that is applicable for all of our constructions, we have shown in Theorem 6 how to replace any 0 ≤ j ≤ t errors by j masked partially stuck cells.This theorem has been improved for Construction 3 by Lemma 1, and further enhanced by another method for introducing errors in the partially stuck locations through Lemma 2 (cf.Example 5).We gain (e.g., for j = 1) exactly 2 µ−1 and 2 µ (under the condition that 2(t + u q ) < d) additional masked partially stuck cells applying Lemma 1 and Lemma 2, respectively.So far, determining if introducing errors in partially stuck cells is advantageous or not can only be done numerically.
We also derived upper and lower limits on the size of our constructions.Our sphere-packing-like bound for the size of (Σ, t) PSMCs has been compared to the usual sphere-packing upper bound, and for the case of no errors (t = 0) to [5, Theorem 2].
We have numerically compared our Gilbert-Varshamov-type bounds, for given (u, t), to each other and to (q − 1)-ary codes.For u ≤ q − 1, Theorem 9 states the existence of (u, 1, t) PSMCs with rates that almost match the ones from the usual q-ary GV bound (shown in Figure 3).Moreover, up to u = 20 for q = 8, Figure 6 shows that application of Theorem 9 is better than using (q − 1)-ary code as mentioned in [5, Section III].On the other hand, for q = 4 and u = 10, Theorem 10 and Theorem 11 obviously require less redundancies than (q − 1)ary code as shown in Figure 5.
Figures 8 and 9 demonstrate the application of Theorem 6, Lemma 1 and Lemma 2 on (u, 1, t) PSMCs of rates that have been obtained based on Theorem 10 and Theorem 11.For some parameters (i.e.u = 16, t = 41 as shown in Table IV and u = 19, t = 31 as shown in Table V), application of Theorem 6 and Lemma 1 achieve higher code rates and more masked cells.Application Lemma 2 on a code obtained by Theorem 9 (i.e.u = 7, t = 27) provides higher code rate compared to the direct employment of Theorem 11, Theorem 6 and Lemma 1.
In the asymptotic regime of our GV-like bounds, Theorem 13 and Theorem 15 are remarkable competitors to Theorem 14.However, the analytical comparison between Theorem 13 and Theorem 15 is more complicated to decide which one is the better choice.This was also confirmed numerically via Figure 7.
This section provides an alternative of Construction 1 by generalizing the construction of [13,Theorem 2].We use the so-called partitioned cyclic codes from [13] as basic idea, but we require only a single redundancy symbol l = 1 for the masking operation similar to [5, Theorem 4 and Algorithm 3].Compared to Construction 1, Construction 4 directly implies a constructive strategy on how to choose a cyclic code of a certain minimum distance.In this appendix, we will use the following notation.If C is a cyclic code, it has a generator polynomial g(x) of degree n − k with roots in F q m , where n divides q m − 1.The defining set D c of C is the set containing the indices b of the zeros α b of the generator polynomial g(x), i.e., The minimum distance d of C can be bounded from below by the BCH bound δ or more involved bounds such as the Hartmann-Tzeng bound [29] or the Roos bound [30].
Construction 4. Let u ≤ min{n, q − 1}.Assume there is an [n, k, δ ≥ 2t + 1] q cyclic code C with a generator polynomial g(x) of degree < n − k that divides g 0 (x) : Encoder and decoder are given in Algorithms 9 and 10.
Algorithm 9: Encoding Input: , where e(x) ∈ F q [x] of degree ≤ n − 1 is the error polynomial 1 ĉ(x) ← Decode y(x) in the code generated by g(x) 2 m(x) ← ĉ(x) mod g 0 (x) Output: Message m(x) ∈ F q [x] of degree < k − 1 Proof.A cyclic code of length n contains the all-one word if and only if its generator polynomial g(x) divides g 0 (x) = 1 + x + • • • + x n−1 .Thus, Construction 4 follows directly from Theorem 1, but with different encoding and decoding algorithms.Algorithm 9 shows the encoding process for the cyclic code construction.
Step 1 in Algorithm 9 calculates w(x) of degree < n − 1.Since u < q, there is at least one v ∈ F q such that all coefficients of w(x), w i ∈ F q , are unequal to v. Therefore, after Step 3, c n−1 = −v.The requirement for masking, see ( 1) is satisfied for c(x) since c i = (w i − v) ∈ F q = 0. Algorithm 10 decodes the retrieved polynomial y(x).First, decode y(x) in the code generated by g(x).Second, the algorithm performs the unmasking process to find m(x).We obtain: ĉ(x) = m(x) • g(x) + z 0 • g 0 (x) m(x) = ŵ(x) mod g 0 (x) g(x) = m(x).
Construction 4 provides an explicit cyclic construction that can mask u < q cells and correct t errors.If we use a BCH code in Construction 4, we can bound the minimum distance of the code C by the BCH bound.This is done in Tables I and II.

B. An alternative Proof of Proposition 2
We start with Lemma 11.
Lemma 11.Let M ∈ F m×n q be such that each column of M has at least one non-zero entry.Let s ∈ F n q .For each w ∈ F n q , there is a v ∈ F m q such that i Proof.We define the set S as Clearly, there is v ∈ F m q such that i ∈ [n] w i + (vM Let i ∈ [n].As the i-th column of M has a non-zero entry, for each y ∈ F q there are exactly q m−1 vectors x ∈ F m q such that (xM ) i = y.As a consequence, v ∈ F m q | w i + (vM ) i ≥ s i = (q − s i )q m−1 , and so The lemma follows from combining (18) and (19).
We are now in a position to introduce an alternative nonconstructive proof for Proposition 2.
Let s ∈ Σ.In order to simplify notation, we assume without loss of generality that n−1 i=d0−2 s i ≤ q − 1.Let w ∈ F n q .We wish to find z ∈ F l q such that w i + (zH 0 ) i ≥ s i for many indices i.As the d 0 − 2 leftmost columns of H 0 are independent, there exists an invertible matrix T ∈ F l×l Combining this with the fact that v i = s i for all i ∈ [d 0 − 2], we infer that for all indices i ∈ [n],

C. Proof of Lemma 8
Let s ≥ 1.As F q ⊆ F q s , it is clear that d 1 ≥ d s .
To show the converse, we use the trace function T defined as T (x) = s−1 i=0 x q i .As is well-known, T is a non-trivial mapping from F q s to F q , and T (ax + by) = aT (x) + bT (y), (20) for all x, y ∈ F q s and a, b ∈ F q .We extend the trace function to vectors by applying it coordinate-wise.Let m ∈ F k q s \{0}.We choose λ ∈ F q s such that T (λ•m) = 0.As T (0) = 0, we infer that wt(mG) = wt(λ • mG) ≥ wt(T (λ • mG)).As all entries from G are in F q , it follows from (20)

D. Proofs of analytical comparisons of the asymptotic GV bounds
We will use the following lemma.
Lemma 12. Let q ≥ 2 be an integer.If 0 ≤ x, y are such that x + y ≤ 1, then h q (x + y) ≤ h q (x) + h q (y).
1) Proof of Proposition 5: Assume τ and υ are such that the conditions of Theorem 13 and Theorem 14 are satisfied, that is, such that 2τ + 2 υ q < 1 − 1 q and h q (υ) + h q (2τ ) < 1.By invoking Lemma 12, we see that h q (2τ + 2 v q ) ≤ h q (2τ ) + h q (2 • υ q ) ≤ h q (2τ ) + h q (υ), where the final inequality holds as q ≥ 2 and h q is monotonically increasing on [0, 1 − 1 q ].As a consequence, the code rate guaranteed by Theorem 13 is at least equal to the code rate guaranteed by Theorem 14.

Figure 1 .
Figure1.Illustration of reliable and (partially) defective memory cells.In this figure, there are n = 5 cells with q = 4 possible levels.The cell levels ∈ F 2 2 are mapped to (0, 1, α or 1 + α) shown in Representation 1 or ∈ Z/4Z are mapped to (0, 1, 2 or 3) shown in Representation 2. Case (A) illustrates fully reliable cells which can store any of the four values in both representations.In the stuck scenario as shown in case (B), the defective cells can store only the exact stuck level s.Case (C) is more flexible (partially defective scenario).Partially stuck cells at level s ≥ 1 can store level s or higher.

Theorem 4 .
A. If the conditions of Construction 3.A hold, then Construction 3 can be modified to produce a 2 µary (2 µ−1 d e , 1, d−1 2

Algorithm 8 :
Decoding Input: Recived y = c + e where wt(e) ≤ t − j and y ≥ s 1 Message m = D(y) Output: Message vector m In Algorithm 8, the decoder D of C is directly used for decoding C j .As y ≥ s , surely y ≥ s.Moreover, we can write y = c + (c − c + e).As shown above, wt(c − c) ≤ j, and so wt(c−c +e) ≤ t.As a consequence, D(y) = m.

25 Figure 8 .
Figure 8.The achievable rates R = 1n log q M of GV bounds for different u, and t for n = 200 and q = 2 3 in Theorem 10.The solid plots are the rates from the derived GV-like bound and the dotted graphs are the rates after trading u + 1, t − 1 by Theorem 6.

Figure 9 .
Figure 9.The achievable rates R = 1n log q M of GV bounds for different u, and t for n = 200 and q = 2 3 in Theorem 11.The solid plots are the rates from the derived GV like bound and the dotted graphs are the rates after trading u + 1, t − 1 by Theorem 6.We also show the exchange by Lemma 1 and Lemma 2 in which the reduction of the correctable errors by one increases u by 2 µ−1 and 2 µ , respectively.
by Table V.Let C u,t be a code by Theorem 11 whose rate is R given in Table V at u row and t column.Taking C 19,27 gives C 20,26 and C 23,26 with R = 0.435 applying Theorem 6 and Lemma 1, respectively.In contrary, taking C 19,31 is advantageous as there are codes (C 20,30 by Theorem 6 and C 23,30 by Lemma 1) with R = 0.380 while direct application of Theorem 11 cannot provide these codes as highlighted in green with "None".Now, we apply Lemma 2 on a code obtained by Theorem 9 for (u = 7, t = 27) to obtain the code C 15,26 of rate R = 0.465 that satisfies 2(26 + 15 8 ) < 55.The achieved rate is higher compared to C 15,26 of R = 0.460 that is directly obtained by Theorem 11, or applying Theorem 6 on C 14,27 to obtain C 15,26 of R = 0.445, or using Lemma 1 on C 11,27 to obtain C 15,26 of R = 0.456.This result does not mean that application