PERFECT CODES OVER NON-PRIME POWER ALPHABETS: AN APPROACH BASED ON DIOPHANTINE EQUATIONS

. The classiﬁcation of perfect codes over non-prime power alphabets has been an open problem for which there have been no new results in almost 50 years. In this paper, we show non-existence of perfect 2 − error correcting codes over q − ary alphabets for more than 170 new values of q . Our methods rely on techniques from the resolution of generalised Ramanujan–Nagell equations and from computational number theory.

1. Introduction 1.1.Background.Error correcting codes have been widely studied since the 1940s.Apart from their intrinsic mathematical interest, this is due to the fact that error correcting codes have many useful applications for information transmission and engineering.For example, in [6] the authors discuss possible applications of errorcorrecting codes to semiconductor memory, while the classical article by Shannon [26] introduced error-correcting codes as a way to transmit information over noisy channels.
While these applications are one of the main reasons why error correcting codes are studied, the developments in this paper will be theoretical.Throughout the article, we shall consider the following standard definition of an error correcting code.
Definition 1.Let q ≥ 2, e ≥ 1 be positive integers, and let Z q be a set with q elements, which we shall call the alphabet.An e−error correcting code C with Date: May 27, 2024.2010 Mathematics Subject Classification.Primary 94B65, 11D61, Secondary 11G05, 11G50, 14G05.
Key words and phrases.Error correcting codes, 2−perfect codes, Hamming bound, Ramanujan-Nagell equations, Mordell curves.parameters (n, M ) is a subset of Z n q of size M and such that any two elements w 1 , w 2 ∈ C differ in at least 2e + 1 positions.
It is a standard fact in coding theory (for example, see [12,Theorem 2.16]) that any e−error correcting code with parameters (n, M ) over an alphabet of size q satisfies the sphere packing bound or Hamming bound : (1) Let us briefly explain why this inequality holds.For this, let us define the set In order for a code to be an e−error correcting code, it follows that the sets B(w, e) and B(w ′ , e) are disjoint for w = w ′ , and therefore, we have that Since there are precisely q n elements in Z n q , inequality (1) follows.In the case where (1) is an equality, we say that the code is perfect.In other words, C is perfect if and only if n and M satisfy the following Diophantine equation: (5) M = q n e j=0 n j (q − 1) j .
Perfect codes are optimal for information transmission, in the sense that they allow for the maximum possible number of words while being able to correct e errors.In other words, perfect codes are the most expressive e−error correcting codes that are theoretically possible, and it is desirable to know whether they exist for a fixed value of q and e.
For these reasons, the classification of perfect codes was a very active topic of research in the late 20th century, and this led to the production of a vast amount of literature on the topic.The most relevant works are summarised in Table 1 and we refer the reader to [11] for a detailed survey on the history of perfect codes.

3, 4, 5
There are no perfect e−error correcting codes over a q-ary alphabet.
Best [4] 7, ≥ 9 Hong [13] 6, 8 There are no perfect e−error correcting codes over a q-ary alphabet.van Lint [20] 10 Table 1.Summary of existing results on perfect e−error correcting codes over q−ary alphabets This was proved by Tietäväinen [29], and independently by Leontiev and Zinoniev [18].Therefore, if q is a prime power, perfect codes do exist and are completely classified for any value of e ≥ 1.
However, as it is apparent from Table 1, the situation when q is not a prime power is quite different.In this case, all the existing results are negative for any values of e and q.This has led many authors to conjecture (see for example [11,Section 5]) the following: Conjecture 1.Let q ≥ 6 be a non-prime power.Then, there are no perfect error correcting codes over Z q .
In Table 1, we see that the combination of the works of Reuvers [25], Best [4] and Hong [4] successfully proves Conjecture 1 for e−error correcting codes, where e ≥ 3.For e ≤ 2, the number of results is much more scarce, and almost nonexistent for e = 1, as remarked by Heden in [11, Section 2].
For e = 2, as shown in the last rows of Table 1, the existing results are due to Reuvers [25], van Lint [20] and Bassalygo et al. [2].Together, they show that perfect 2−error correcting codes do not exist for (8) q = 6, 10, 15, 21, 22, 26, 30, 35 and q = 2 s 3 r , where r, s > 0 are positive integers.We remark that the methods used in all these papers are specific to the cases at hand and cannot be generalised to other values of q.This is probably the reason why there have been no new results in the area in more than 50 years.
Indeed, we believe that the great difficulty of dealing with the case where q is not a prime power, as well as the lack of a general methodology for these cases justifies the scarcity of literature.
To illustrate this, we note that there is a significant amount of modern articles which aim to generalise the results in Table 1 to extended codes or to different metrics, but they always treat the case when q is a prime power.For example, under this assumption Li and Xing [19] classify perfect quantum codes and Gubitosi, Portela and Qureshi [10] show analogous results for the Niederreiter-Rosenbloom-Tsfasman metric.
In conclusion, we identify a clear gap in the literature in the case e = 2, since, apart from the family studied in [2], there are only 7 values of q which are not prime powers and for which non-existence has been proved, and there have been no new results in half a century.In addition, the techniques used in the proofs cannot be generalised, which makes it difficult to extend the results to different codes or metrics.
In this paper, we address this gap in the literature by proving non-existence results for the case e = 2 and 172 new values of q, therefore substantially increasing the evidence towards Conjecture 1.In addition, our methods are theoretically valid for all values of q and the only obstructions that we encounter are of a computational nature.Consequently, it seems feasible to generalise them to other problems, and we shall comment more on this in Section 5.2.
1.2.The main results.For the rest of the paper, we let q ≥ 6 be a positive integer which is not a prime power.In this paper, we will prove new results related to the non-existence of perfect 2−error correcting codes over alphabets of size q.
Our main result is the following, which covers all but two values of q ≤ 200, as well as some values of q in the interval q ∈ [201, 600] subject to certain additional restrictions.
Theorem 2. Let q ≥ 6 be a positive integer which is not a prime power, satisfying any of the following conditions.
Then, there are no perfect 2−error correcting codes over alphabets of size q.
The values of q in the theorem are optimal given the current existing computational techniques and the methods used in this paper.We will comment more on this in Section 5.1.
The second result that we present applies to all values of q, but, instead of showing non-existence of perfect codes, it shows that there can only be finitely many perfect 2−error correcting perfect codes over a q−ary alphabet.This is consistent with Conjecture 1, albeit much weaker.Theorem 3. Let q ≥ 6 be a positive integer which is not a prime power.Then, there are at most finitely many perfect 2−error correcting codes over an alphabet of size q.
In order to prove Theorems 2 and 3, we will study the perfect code condition ( 5) with e = 2.We shall see that, for a fixed value of q, it can be reduced to a Ramanujan-Nagell type equation, which we can solve effectively with the use of several techniques from computational number theory.
The history of Ramanujan-Nagell type equations is rich and has motivated a vast amount of research in the number theory community ever since Ramanujan conjectured that the Diophantine equation ( 9) x 2 + 7 = 2 n , only had solutions for n = 3, 4, 5, 7 and 15.This was proved by Mordell in 1948 [23] and led to many researchers considering generalisations of (9).We refer the reader to [16] for a detailed survey of generalisations of the Ramanujan-Nagell equation.
In order to prove Theorems 2 and 3, we shall solve a Ramanujan-Nagell type equation.If, after resolving the equation, there are any solutions (n, M ) to ( 5), we can use Lloyd's theorem to prove that they cannot constitute a perfect code.
The organisation of this paper is as follows.In Section 2, we will reduce the Hamming bound to a Ramanujan-Nagell equation and prove Theorem 3. In Section 3, we will build upon the work of von Känel and Matschke [14] in order to obtain all solutions to the previously obtained Ramanujan-Nagell equations.In Section 4, we will show that the outstanding solutions cannot form perfect codes by using Lloyd's theorem, and therefore prove Theorem 2. In Section 5, we shall discuss complications arising from our methodology, as well as potential future lines of work.Finally, in Section 6, we will briefly summarise our findings and explain how they overcome the shortcomings in the literature.
All computations in this paper have been carried out with the use of Magma [5] code.The code is available for the reader in the author's GitHub repository (https://github.com/PJCazorla/perfect-q-ary-codes)and can be used to check the correctness of the computations.

The Hamming bound and Ramanujan-Nagell type equations
We suppose that there exists a perfect 2 error-correcting q−ary code with parameters (n, M ).In order to avoid trivial codes, we shall assume that n ≥ 5 and M ≥ 2.Then, it follows from the perfect code condition ( 5) with e = 2 that Let q 1 , . . ., q k denote the prime divisors of q.By (10), M | q n and, consequently, there is a solution (n, n 1 , . . ., n k ) ∈ Z k+1 to the Diophantine equation (11) 1 + n(q − 1) + n(n − 1) 2 (q − 1) 2 = q n1 1 . . .q n k k , with n ≥ 5 and where q ≥ 6 is fixed.Now, let us introduce some notation.Let x and D q be given by the following expressions: (12) x = 2n(q − 1) + 3 − q and D q = 8 − (q − 3) 2 .
Multiplying (11) by 8 and completing the square, we see that the existence of a perfect 2-error correcting code over a q−ary alphabet implies that there exists a solution (x, n 1 , . . ., n k ) ∈ Z k+1 to the Diophantine equation (13) x 2 + D q = 8q n1 1 . . .q n k k .Let A denote the set of positive integers supported only on {q 1 , . . ., q k }, so that ( 14) Clearly, the Diophantine equation ( 13) can be rewritten as (15) x 2 + b = cy, where x ∈ Z, y ∈ A, b = D q and c = 8.This is an example of a generalised Ramanujan-Nagell equation, as considered by von Känel and Matschke in [14].
We can immediately use their work to prove Theorem 3.
Proof of Theorem 3. By [14, Corollary K], it follows that there are at most finitely many solutions to any generalised Ramanujan-Nagell equation such as (15) and, consequently, there are at most finitely many solutions to (13), showing that there can only be finitely many perfect 2−error correcting q−ary codes for a fixed value of q.
For the convenience of the reader, we shall give a different proof of the fact that (15) has finitely many solutions.This proof will allow us to fix notation and will be insightful for our work in Section 3.
Without loss of generality, we can assume that gcd(c, q 1 . . .q k ) = 1.This is because any powers of q 1 , . . ., q k present in c can be absorbed into y without altering the number of solutions of (15).Then, we can write (16) c = c 0 c 3 1 and y = y 0 y 3 1 , where c 0 , c 1 , y 0 , y 1 ∈ Z with c 0 and y 0 cubefree.We note here that (17) c 0 y 0 ∈ {c 0 q a1 1 . . .q a k k | 0 ≤ a 1 , . . ., a k ≤ 2}.We define d and z by (18) d = c 0 y 0 and z = c 1 y 1 , so that (15) can be rewritten as Let (x, z) ∈ Z 2 be a solution to the previous equation and let (X, Y ) be given by (20) X = dz and Y = dx.
Then, (X, Y ) is an integral point on the Mordell curve By the work of Siegel [27], these curves have finitely many integral points.In addition, since the set in ( 17) is finite, there are only finitely many curves E d to consider.Consequently, there are at most finitely many solutions to (15), finishing the proof.
From the definition of x and D q given in ( 12), we note that x and D q are even precisely when q is odd.Therefore, we can define (22) x ′ = x 2 and In these cases, we can divide (13) by 4 and obtain the following equation, which, computationally, is slightly easier to solve: q and c = 2, this is another instance of a generalised Ramanujan-Nagell equation in the form of (15).We shall present an algorithm for resolving these equations in Section 3.

Resolving the Diophantine equations
As we explained in Section 2, the existence of a perfect 2−error correcting code over a q−ary alphabet implies the existence of a solution (x, y) to the generalised Ramanujan-Nagell equation (15).In this section, we shall present an algorithm to solve this type of equations.Our algorithm is based on [14, Algorithm 6.2].
As we discussed in the proof of Theorem 3, we can reduce the resolution of (15) to the determination of all integral points (X, Y ) on a finite number of Mordell curves E d .Then, by ( 16), ( 18) and ( 20), we may recover the original solutions x and y via the expressions where the product is taken over all primes p and ord p (.) denotes the standard p−adic valuation.If a S < 500, 000, we can use [14,Algorithm 4.2] to compute all integral points very efficiently.This restriction is due to the fact that the algorithm requires the computation of all elliptic curves of conductor N | a S .If a S < 500, 000, these curves have been computed by Cremona [7] and so the necessary computational effort is minimal.
In the case where a S ≥ 500, 000, our code computes the integral points by using Magma's function IntegralPoints, which is based upon the use of linear forms in complex and p-adic elliptic logarithms (for a reference, see [28]).In this case, the main computational difficulty lies in the fact that a Mordell-Weil basis for E d needs to be computed which, in general, is very hard.We introduce two tricks to mitigate this difficulty.
Firstly, we note that the question of determining the rank r of E d is highly non-trivial.However, by the work of Kolyvagin [15], we know that if the analytic rank of an elliptic curve is 0 or 1, its algebraic rank coincides with its analytic rank.Since computing the analytic rank is much easier computationally than computing the algebraic rank, there are substantial computational savings in these cases.
We also remark that if r = 0, there is no need to compute any generators to the Mordell-Weil group.Similarly, if r = 1, a generator can be found by computing Heegner points, as shown by Gross and Zagier [9].We implement these two improvements in our code.While it could seem that these are not significant for the computation, they actually help tremendously and allow us to solve many equations which would otherwise not be amenable to our techniques.
Alternatively, we could have used the work of Bennett and Ghadermarzi [3], who computed all integral points on the Mordell curves ( 26) where 0 < |k|≤ 10 7 .They use a different set of techniques, involving the resolution of cubic Thue equations.This entrails a similar level of computational complexity to our approach, and it does not introduce any substantial computational improvements.
With the presented algorithm, we are able to solve the generalised Ramanujan-Nagell equations and recover the values of n and M which could represent a perfect 2−error correcting q−ary code.This is the content of the following lemma.Lemma 3.1.Let q ≥ 6 be a positive integer which is not a prime power satisfying either of the two conditions in Theorem 2.Then, all solutions (n, M ) to (10) with n ≥ 5 are given in Table 2.
Proof.Using the algorithm that we have previously presented, we obtain all solutions (x, y) ∈ Z 2 to each of the generalised Ramanujan-Nagell equations.By (12), we can then recover n as (27) n = x + q − 3 2(q − 1) , and obtaining M is immediate from (10).All the solutions that we found are contained in Table 2. Table 2. Solutions to (10) with n ≥ 5 and q satisfying the conditions in Theorem 2.

Dealing with the outstanding solutions: Lloyd's theorem
In order to finish the proof of Theorem 2, we need to show that none of the solutions in Table 2 can be parameters for a perfect q−ary code.For this purpose, we shall use Lloyd's Theorem, which was originally proved by Lloyd [21] if q is a prime power.The general case was proved independently by Bassalygo [1], Delsarte [8] and Lenstra [17].The statement of that theorem is as follows.
Theorem 4. (Lloyd) Let n, e and q be positive integers.Suppose that there exists a perfect e−error correcting code over a q−ary alphabet with word length n.Then, the polynomial has e distinct integer zeros in the interval [1, n].
Our previous work, together with Lloyd's theorem, allow us to finish the proof of Theorem 2.
Proof of Theorem 2. Let q be a number satisfying the conditions in the theorem and suppose for contradiction that there exists a perfect 2−error correcting code over a q−ary alphabet, with parameters (n, M ).
By our discussion in Sections 2 and 3, along with Lemma 3.1, we know that the tuple (q, n, M ) is contained in one of the rows of Table 2.By Theorem 4, it follows that the polynomial L 2 (x) given by However, we check with Magma that this is not the case for any of the values of q and n in Table 2. Consequently, for all the values of q in the statement of Theorem 2, there does not exist a perfect 2−error correcting code over an alphabet of size q.

Limitations and future lines of work
In this section, we shall briefly comment on the limitations of the methodology that we present in this paper, as well as propose future lines of work and different problems which could be solved by leveraging these techniques.5.1.Limitations of our methodology.Firstly, we remark that our methods can show non-existence of perfect 2−error correcting codes for a fixed value of q, but they are not able to handle infinite families of q.The main reason why is due to the fact that the coefficient D q in (13) depends on q and it would no longer be constant.
For this reason, even if the set (17) remains finite (which could be achieved by fixing the prime divisors of q, for example), we would effectively need to obtain all integral points for a family of Mordell curves E d(q) .In this situation, the results of Siegel [27] do not apply and, consequently, it is entirely possible that there are infinitely many integral points to consider.In addition, and to the best of our knowledge, there are not any techniques that allow to determine integral points over families of elliptic curves in an effective manner.This is why we believe that, in order to prove Conjecture 1, even just for e = 2, significantly new ideas will need to be introduced.
If we fix q, we note that, in principle, all the techniques that we have presented in this paper would be applicable for any q.However, in practice, it is computationally unfeasible to resolve (13) for values of q other than those in Theorem 2.
For this reason, it is unlikely that the range of values of q can be extended much further with our methodology.This is mainly due to the fact that, despite the computational improvements that we have introduced in Section 3, we ultimately need to find a list of generators for the group E d (Q), where E d is the Mordell curve (21).As the conductor of E d grows, even finding one rational point on E d is a very hard problem and, consequently, it is impractical to compute a basis for E d (Q).
To illustrate the computational difficulties, let us consider the case q = 94 = If q has a large prime divisor p, there is a slightly different problem.In this instance, and for q large, we need to use the Magma IntegralPoints subroutine to find integral points on the Mordell curve (21).However, this relies on the use of linear forms in p−adic elliptic logarithms (see [28]) and the bounds obtained by applying this method are astronomical as p grows, which makes it impossible to find all solutions to (13).In fact, this is the main reason why we needed to exclude prime divisors larger than 13 if q ≤ 600.
Due to the high computational burden, we believe that the results that we present here cannot be significantly extended without the introduction of new algorithms to resolve the Ramanujan-Nagell equation (13).Promising results in this direction are the newly-improved estimates for linear forms in three logarithms by Mignotte and Voutier [22] and some work on the generalised Ramanujan-Nagell equation by Mutlu, Le and Soydan [24], which, if extended, could allow for a more efficient resolution of (13).5.2.Future lines of work.In this paper, we used extensively two features of perfect 2−error correcting codes: the perfect code condition (10) and the fact that Lloyd's Theorem (Theorem 4) applies.As long as these two conditions are satisfied, it seems plausible that our approach could generalise.
For instance, the methods that we present here could be used to approach perfect 2−error correcting quantum codes, by mimicking this approach and changing the perfect code condition (5) by the perfect quantum code condition: (31) M = q n e j=0 n j (q 2 − 1) j .
Li and Xing [19] classified perfect quantum codes over q−dimensional qudits, where q is a prime power.In addition, they proved an analogue of Lloyd's theorem for quantum codes.This makes the situation completely analogous to the classical case and, for this reason, it seems reasonable that the approach that we presented here would directly generalise to quantum codes.

Conclusions
The main findings of this paper are Theorems 2 and 3, where we show that perfect 2-error correcting codes over q−ary alphabets do not exist for more than 170 new values of q, and show that, for a fixed value of q, there can only be finitely many 2−error correcting perfect codes.
In previously existing literature, no values of q with more than three prime factors were considered and, in addition, the methods used were specific to the cases at hand and could not be generalised.In addition, there had been no new results in over 50 years, showing a clear gap in the literature.
In this paper, we successfully address this gap by showing non-existence of perfect codes for some values of q with four prime factors (q = 210, 330, 462) and provide a method which would theoretically apply to any fixed value of q, with the only existing problems arising from current computational technology.Our results improve the number of q for which 2−error correcting codes have been classify by more than 2,000%.
We remark that these results are also relevant from a practical point of view, since they show that, for many values of q, the optimal information transmission scheme while attempting to correct 2 errors cannot be that of perfect codes and, consequently, alternative schemes need to be considered in order to achieve the best possible codes.
In order to verify all computations carried out in this paper, we provide the reader with the Magma code available in the author's GitHub repository (accessible at https://github.com/PJCazorla/perfect-q-ary-codes),which can be used to check the correctness of Theorem 2.
Finally, we remark that our results are consistent with the existing literature in the cases where they overlap and, in addition, they support Conjecture 1, which is widely believed to be true.

( 2 )
B(w, d) = {w 2 ∈ C | w and w 2 differ in at most d positions.},where w ∈ C is fixed and d ≥ 0 is an integer.It is an easy combinatorial exercise to see that (3) |B(w, d)|= d j=0 n j (q − 1) j .

3 .
In order to compute the integral points on the Mordell curves E d , we distinguish two cases.Following [14, Section 4.1], we define a S by(25) a S = 1728 p p min{ordp(bd 2 ),2} ,