One extra position can cut the number of messages in a three-symbol linear code by a factor of 81
Why it matters
Suppose a message uses three symbols and every three messages must show all three symbols in at least two ninths of their positions. With a linear encoding rule, adding a position can cut the number of messages from 19,683 to 243, even if the whole code is redesigned. The worst such loss factor grows logarithmically with the length of the encoded message.
Suppose we want to label messages with strings of symbols so that we can tell any three distinct messages apart by looking at a single position. With the symbols 0, 1 and 2, a position separates the three messages if it shows a different symbol for each. How many messages can we label if every triple must be separated in at least two ninths of the positions? A longer string offers another place to separate messages, but it can also raise the number of separations we need. Knowing how the maximum number of messages grows with length does not tell us how much it can fall in one step.
For a linear code, which computes each output symbol by adding multiples of the input symbols modulo three, the maximum falls from 19,683 messages at length 9,841 to just 243 at length 9,842. That is a factor of 81 even with a complete redesign of the code. Larger losses occur at greater lengths: among all starting lengths up to N, the worst one-step loss factor grows in proportion to \log N.
Why two ninths matters
Three independent, uniformly chosen symbols are all different in six of the 27 possible ordered outcomes, a fraction of 2/9. This chance rate marks a transition for codes without any linearity restriction. Bishnoi and colleagues [1] describe how, at any fixed fraction below 2/9, the number of messages can grow exponentially with length. At any fixed fraction above it, the number stays bounded. At 2/9 itself, a bound of Bassalygo and colleagues [2] gives a maximum at most proportional to length.
For linear codes [3], write k for the number of input symbols in a message and n for the length of its encoded string. Distinct messages must give distinct strings, so the code represents 3^k messages. We call k its dimension, or rank. At length n a triple needs m(n)=\lceil 2n/9\rceil separating positions, where the brackets round up to the next integer if needed. Write L(n) for the largest number of messages in a linear code that meets this requirement. When m(n+1)=m(n), appending a zero to every string preserves every separation. A loss can occur only when the required count rises by one.
Message counts at consecutive lengths
The losses recur after lengths of the form P_a=(3^a-1)/2, where a is an integer. We compared the dimensions we could construct with upper bounds on the dimension at every length from 1 through 531,441. The bounds agreed at 1,999 lengths, giving the exact maximum there. Table 1 shows every pair P_a,P_a+1 in that range for a\ge2. Each starting count is exact. An interval means that we can attain its lower message count and can rule out counts above its upper end.
Table 1. Number of messages before and after adding one position. The loss factor is the first size divided by the second.
| Starting length | Messages at start | Messages one position later | Loss factor |
|---|---|---|---|
| 4 | 9 | 3 | 3 |
| 13 | 27 | 3 | 9 |
| 40 | 81 | 9 | 9 |
| 121 | 243 | 9 | 27 |
| 364 | 729 | 27 | 27 |
| 1,093 | 2,187 | 81 | 27 |
| 3,280 | 6,561 | 81–243 | 27–81 |
| 9,841 | 19,683 | 243 | 81 |
| 29,524 | 59,049 | 243–729 | 81–243 |
| 88,573 | 177,147 | 729–2,187 | 81–243 |
| 265,720 | 531,441 | 2,187–6,561 | 81–243 |
The same pattern holds for arbitrarily large a. At P_a the code can use all 3^a messages of dimension a. One position later, the optimum is smaller by a factor proportional to a. In symbols,
Two facts explain the worst loss up to N. First, the lengths with the large drops occur regularly enough: P_{a+1}=3P_a+1, and a grows as \log_3 P_a. Second, at every starting length we can retain enough messages to keep the loss within a constant multiple of the logarithm. We prove these facts by counting the positions that separate triples and by constructing codes that supply enough of those positions.
How the encoding determines which triples separate
Represent the rule for each position by a column c listing the coefficients of its linear combination. The output symbol for message u is the dot product u\cdot c modulo three. The matrix of all n columns is called a generator. Both messages and columns belong to \mathbb F_3^k, the space of k symbols with arithmetic modulo three. Replacing c by -c just interchanges the outputs 1 and 2, so the two columns separate the same triples. Pairing the nonzero columns this way gives P_k pairs, called directions. The dimension-k simplex code uses one column from each direction. A general code can repeat columns or use zero columns.
Subtract one message in a triple from all three to write the triple as 0,u,v. This shifts all three symbols at each position by the same amount and preserves their differences. A column separates this triple when u\cdot c and v\cdot c are opposite and nonzero. Suppose first that u,v are independent (neither is a multiple of the other). To give opposite symbols, the column must satisfy (u+v)\cdot c=0. This equation defines a hyperplane H, a space of dimension k-1. To give nonzero symbols, the column must lie outside the smaller space J in H defined by u\cdot c=0. That extra equation reduces the dimension to k-2. For k\ge2, the set H\setminus J therefore contains s_k=P_{k-1}-P_{k-2}=3^{k-2} directions. If u,v are dependent, the only possibility for distinct nonzero messages is v=-u. All 3^{k-1} directions with u\cdot c\ne0 then qualify. By using each direction once, the simplex guarantees at least s_k separations for every triple.
The same count limits what any code can achieve. Every hyperplane H and every hyperplane J inside it occur in a triple test: choose a vector x whose dot product vanishes precisely on H, choose u whose dot product within H vanishes precisely on J, and set v=x-u. If every triple needs m separations, every such H\setminus J must contain at least m columns, counting repeats. Average over all pairs H,J. By symmetry each nonzero column appears in the same fraction s_k/P_k of the tests, and a zero column appears in none. Thus
A stronger bound accounts for the number of columns each hyperplane needs before taking the average. Within H, use its nonzero columns as a generator in dimension k-1. Each nonzero linear function on H gives an encoded string by acting on these columns. The function vanishes on a hyperplane J inside H, so the string has at least m nonzero symbols from columns in H\setminus J. By linearity, the difference between strings from distinct functions also has at least m nonzero symbols. The resulting code therefore has the full dimension k-1, and any two distinct strings differ in at least m places. The ternary Griesmer bound [4] says that a linear code with this dimension and distance needs at least the number of positions given by the sum below. Each nonzero column lies in a fraction P_{k-1}/P_k of the hyperplanes. The average count in a hyperplane must meet the lower bound, so
Why one more separation reduces the dimension
At length P_a+1, every triple needs m=s_a+1 separations. Consider a candidate dimension 2\le k\le a and write r=3^{a-k}. The length and requirement become
At length 9,842, for example, rank six gives r=27. Every hyperplane would need 3,272 nonzero columns, but their mean is at most 9{,}842\cdot121/364=85{,}063/26<3{,}272. Rank five works. Repeating the rank-five simplex 81 times takes 81\cdot121=9{,}801 positions and supplies 2,187 separations. Of the remaining 41 positions, 19 suffice for a rank-five code constructed by Kurz [5] that separates every triple at least once. The last 22 positions can be padding. A direct count across all 2,362,041 triples in the assembled code gave a minimum of 2,188 separating positions. This proves that the maximum is 243 messages.
How to supply the extra separation
The same construction attains the order of the upper bound for large a. In any dimension k, a block of just 9k columns can separate every triple at least once. To prove existence, choose the columns independently and uniformly. For a fixed pair u,v from a triple translated to 0,u,v, a column separates with probability 2/9 if u,v are independent and 2/3 if v=-u. There are fewer than 9^k pairs. The expected number missed by the whole block is less than 9^k(7/9)^{9k}<1, so some block misses none.
Choose r as the least power of three at least 18a and set k=a-\log_3 r. For large a, k\ge2. Repeating the simplex r times supplies rs_k separations. The remaining (r+1)/2 positions fit the extra block. Padding to the prescribed length gives a code with 3^k>3^a/(54a) messages.
Could the loss come only from rounding up the required fraction? At lengths 3^a and 3^a+9, both counts 2n/9 are integers, yet a comparable loss occurs over those nine positions. At the first length, two rank-a simplex copies and one padding position support 3^a messages. At the second, n=2rP_k+r+9 and m=2rs_k+2. Increasing the requirement from 2rs_k by two raises the first ceiling in (2) by two and each later one by one. The sum becomes 2rP_{k-1}+k, giving 3k<r+9. As in (3), this excludes rank a for large a and bounds the optimum by O(3^a/a), meaning at most a constant times 3^a/a. For a matching lower bound, choose the same r as in the preceding construction. After 2r simplex copies, two blocks of 9k fit in the remaining r+9 positions and supply the two extra separations.
A limit on the loss at any length
In any linear code that meets the two-ninths requirement, the message count satisfies 3^k\le3n. To see why, for k\ge3 choose a nonzero column and keep only the messages that give zero there. Deleting that position leaves a code of rank k-1 with the old requirement m, since a constant position separated no surviving triple. By (1),
The key to extending an arbitrary code is to restrict its messages so that many positions become constant at once. We can then rewrite those positions without losing any separations among the surviving messages. Choose a t-dimensional subspace U uniformly from \mathbb F_3^k. Keep the messages whose dot products with all columns in U vanish; these form a space of dimension k-t. Each nonzero column belongs to U with probability (3^t-1)/(3^k-1), and a zero column always does. Averaging over choices of U and using 3^k\le3n, we find that some choice frees at least
Take the least t with 3^t\ge27k+1. If t<k, this frees at least 9k positions. Use them to insert the block that separates each triple at least once in dimension k-t, and append one zero position. Each surviving triple keeps its old separations and gains at least one, enough at length n+1. Restricting the messages costs a factor of 3^t<3(27k+1). If t\ge k, the entire starting code has fewer than 3(27k+1) messages, so the same loss bound holds. Starting with an optimal code gives L(n)/L(n+1)=O(k)=O(\log(n+1)). This is the upper bound on the worst one-step loss.
For starting lengths below 19,683 the worst factor is exactly 81. In that range 3^k\le3n<3^{10}, so k\le9. If k>4, taking t=4 frees at least 27 positions because the integer count is at least 80/3. The surviving dimension is at most five, so restricting Kurz's 19-column block to that dimension supplies the extra separation. If k\le4, the starting code itself has at most 81 messages. Thus no step in this range exceeds the loss factor attained at 9,841.
Methods for the length scan
At each length we tested integer dimensions satisfying 3^k\le3n. To bound the dimension from above we used (2). For k\ge3 we also applied (1) at length n-1 with rank k-1 and the original m, using the deletion argument above. To construct a code, we divided m by the simplex separation count s_k, writing m=qs_k+b with remainder 0\le b<s_k. After q simplex copies, we used the shorter of another simplex and b copies of a block that separates each triple at least once. We counted the dimension as attainable if the total length was at most n, filling any surplus positions by repeating a column. Rank one is always attainable by repeating the message symbol.
For dimensions two through five the blocks had lengths 4, 9, 14 and 19, respectively. The first was the rank-two simplex; the others came from the matrices in section 3 of Kurz [5]. For higher dimensions we used the 9k existence bound. We checked the five published matrices, including the three rank-four choices, by translating triples to zero and counting positions with opposite nonzero symbols for every pair of distinct nonzero messages. For the independent check at 9,842, each simplex copy used the representative of each direction whose first nonzero entry is 1. We added the rank-five block and padded with 22 copies of the last coordinate vector (the column that returns the last input symbol). We generated the strings for all 243 messages and, for each unordered triple, compared the three symbols in pairs and counted the positions where every pair differed.
The logarithmic growth law concerns the worst ratio for linear codes. Its sharp constant and the corresponding loss for unrestricted encodings remain undetermined by these bounds.
References
- A. Bishnoi et al., The generalized trifference problem.
- L. Bassalygo, M. Burmester, A. Dyachkov and G. Kabatianski, Hash codes, 1997. The bound for the ternary case is stated in the introduction to [1].
- V. Yu. Solomennikov and Yu. L. Sagalovich, On linear hash codes, 1998.
- G. Solomon and J. J. Stiffler, Algebraically punctured cyclic codes, 1965.
- S. Kurz, Trifferent codes with small lengths, 2023.