Manuscript Offprint
arXiv:2610.33676Extremal diagonal-coherent binary codes: shortened Hamming cores, deep holes, and the 64 I-Ching hexagrams
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Each of the 64 hexagrams of the I-Ching, or Book of Changes, is a stack of six Yin-Yang lines and is therefore a binary vector of length 6; the eight hexagrams formed by repeating a single trigram span a doubled-trigram subspace . We ask which binary [6, 3, 3] codes are compatible with this trigram structure. We show that a [6, 3, 3] code meets in at most four codewords, that the four are then forced to be the doubled trigrams Earth, Fire, Wind and Lake, and that exactly two codes attain this bound: the shortened Hamming code and its dual. Since has covering radius 2, its eight codewords, their radius-one balls, and its eight deep holes together reconstruct all 64 hexagrams. In general, we call a binary code of length with diagonal-coherent if it contains the half of the diagonal subspace coming from even-weight vectors — the largest part of that subspace a single-error-correcting code can contain — and extremal if its dimension is as large as possible. For and , we determine the number of extremal diagonal-coherent codes with parameters , show that diagonal coherence entails no loss of redundancy, and determine their minimum distances. We also put these codes in a normal form, determine their hulls, and show that each has covering radius 2 with exactly deep-hole cosets. Finally we propose three open problems.
Keywords covering radius, deep hole, diagonal-coherent code, hexagrams, Hamming code, hull, I-Ching, quasi-perfect code
MSC 94B05, 01A25, 94B65, 94B75
1 Introduction
The I-Ching (Yijing, Book of Changes) [14] consists of two historically distinct layers. The older layer, the Zhouyi, is a divination manual comprising, for each of the 64 hexagrams, a short hexagram statement together with six line statements; on linguistic and historical grounds it is generally dated to the Western Zhou, around the ninth century BCE [12, 10]. The younger layer is a set of ten commentaries known as the Ten Wings, among them the influential Xici zhuan (Great Commentary), composed over the Warring States and early Han periods, roughly the fourth to second centuries BCE. It is this second layer that supplies the cosmological vocabulary of Yin and Yang and that turned a manual of divination into a philosophical classic [13].
Each of the 64 hexagrams of the I-Ching is a stack of six Yin-Yang lines. Writing 0 for a broken Yin line and 1 for a solid Yang line identifies the hexagram set with the binary vector space
This identification of hexagrams with binary vectors of length 6 has a documented origin. Leibniz [11] described his binary arithmetic to Joachim Bouvet in a letter of 15 February 1701; Bouvet, then at the Kangxi court in Beijing, recognised the correspondence with the Xiantian diagram and replied on 4 November 1701, enclosing a woodcut of Shao Yong's arrangement [9]. The letter reached Leibniz only on 1 April 1703, and within days he submitted to the Paris Academy his Explication de l'arithmétique binaire, whose title explicitly advertises that binary numeration "gives the sense of the ancient Chinese figures of Fohy(Fuxi)" [6].
Even though such a nice connection was known since Leibniz, there have been only a few papers on mathematical structures of the 64 hexagrams. In 1975, Goldenberg [2] gave an elementary algebraic treatment of the I-Ching for non-mathematicians. Recently, Hu et al. [4] noticed that the system of I-Ching can be represented by the tables with dyadic groups of 4 bigrams, 8 trigrams and 64 hexagrams, which were believed to be fundamental archetypes of the Nature. The ancient Chinese could not have known about the genetic code of protein sequences of amino acids: in particular, the genetic code is constructed on DNA molecules using 4 nitrogenous bases, 16 doublets, and 64 triplets. Hence the authors [4] described the usage of dyadic groups related to the hexagrams as a foundation of the bio-mathematical doctrine of the geno-logic code. Li [7] introduced a novel computational perspective based on two's complement format of a negative integer to reinterpret the mathematical essence of the I Ching hexagrams and the topological mapping between the Fuxi Square and Circular Diagrams.
In this paper we show that coding theory provides an efficient way of understanding the 64 hexagrams. More precisely, we show that at most four of the eight doubled-trigram hexagrams can lie in a binary [6, 3, 3] code, that the four are then forced to be
and that exactly two codes attain this bound: the shortened Hamming code and its dual. For each of these two codes, the eight codewords, the balls of radius one around them, and the eight deep holes together account for all 64 hexagrams.
We then generalize this picture from hexagrams to stacks of 2m lines. We call a binary code of length 2m with diagonal-coherent if it contains the half of the diagonal subspace coming from even-weight vectors — the largest part of that subspace a single-error-correcting code can contain — and extremal if its dimension is as large as possible. For and , we determine the number of extremal diagonal-coherent binary codes with parameters which by definition contains , the image under the doubling map of the even-weight code ; Requiring it costs nothing: the dimension is already the largest possible for any binary code of length 2m with minimum distance at least 3.
We also determine the minimum distances of these codes: they are always 3 or 4, and the value 4 occurs precisely when m is a power of 2. Even then it is exceptional — we obtain a closed formula for the number of such codes (Proposition 6.14), which gives for instance out of , and out of . We give these codes in a normal form, determine their hulls, and show that each has covering radius 2 with exactly deep-hole cosets.
The paper consists of six sections. In Section 2, we give a structural background of I-Ching. In Section 3, we begin with basic definitions of coding theory. Section 4 constructs the core and proves the uniqueness statement above. In Section 5, we find the eight deep holes so that the 64 hexagrams can be described by and the deep holes. Finally, Section 6 considers the generalization of Section 4 by describing codes coherent with a diagonal subspace, together with three open problems.
2.1 Lines, trigrams, and hexagrams
The atomic symbol is a line of which there are two kinds: a broken Yin line and an unbroken Yang line. Three lines stacked vertically form a trigram, and six form a hexagram; lines are counted from the bottom upward, so that position 1 is the lowest line and position 6 the highest. There are trigrams and hexagrams, and every hexagram decomposes uniquely into a lower trigram (positions 1, 2, 3) and an upper trigram (positions 4, 5, 6); the 64 hexagrams are correspondingly the ordered pairs of trigrams. Each trigram carries a name and a canonical natural image:
| Name | Image | Trigrams | Doubled-trigram hexagrams |
|---|---|---|---|
| Qian | Heaven | 111 | 111111 |
| Dui | Lake | 110 | 110110 |
| Li | Fire | 101 | 101101 |
| Zhen | Thunder | 100 | 100100 |
| Xun | Wind | 011 | 011011 |
| Kan | Water | 010 | 010010 |
| Gen | Mountain | 001 | 001001 |
| Kun | Earth | 000 | 000000 |
Here the binary column already uses the encoding fixed in Section 1, namely Yin = 0 and Yang = 1, with the bottom line written first. A hexagram is named by its two trigram images; for instance Fire over Water is the hexagram called Wei Ji (“Before Completion”); note that the traditional name lists the upper trigram first, so in our encoding, which writes the lower trigram first, this is 010101 — Water below, Fire above.
2.2 Divination and the notion of change
The name Book of Changes refers to a procedure, not merely to a text. In the classical yarrow-stalk method — and in the simpler three-coin method that later displaced it — each of the six lines is generated independently, and the outcome distinguishes four cases rather than two: a line is Yin or Yang, and additionally stable or changing. A consultation therefore returns not one hexagram but two: the hexagram obtained by reading the lines as drawn, and a second hexagram obtained from it by flipping exactly the changing lines.
This is the point at which the tradition itself already performs the operation that the present paper formalises. If denotes the first hexagram and the set of changing lines, then the second hexagram is
where is the characteristic vector of and addition is componentwise modulo 2. In other words, divinatory change is translation in , and the number of changing lines is the Hamming distance .
2.3 Classical relations between hexagrams
Traditional hermeneutics singles out two operations relating one hexagram to another; they are involutions of and are used repeatedly below.
-
Complementation (cuo): every line is exchanged for its opposite. In binary terms .
-
Overturning (zong): the hexagram is read upside down, so that position i is exchanged with position 7 - i. This is the coordinate reversal . Exactly eight hexagrams are unchanged by it, namely the palindromic ones.
Complementation and overturning commute and generate a Klein four-group acting on the 64 hexagrams; this action governs the pairing structure of the traditional King Wen sequence. That the dual of our central code is realised by overturning rather than by an arbitrary coordinate permutation is the content of Section 4.2.
3 Preliminaries
We refer to [5], [8] for basic facts from Coding Theory.
Let be a finite field with two elements 0 and 1. A linear code of length n over is an -linear subspace
The Hamming weight of a vector is , and the Hamming distance between two vectors is . The minimum distance of a code is
If and the minimum Hamming distance of is , then has parameters . The covering radius of a set is
equivalently, is the least for which the balls of radius centred at the points of cover . Following [1], we say that covers with radius when .
A matrix is a parity-check matrix for if
The dimension is then
The dual code is
where
If , then is the row space of .
A linear code is self-dual if and self-orthogonal if . A linear code is isodual if there exists a permutation such that . It is easy to see that a self-dual code is an isodual code, but not the converse.
4 A shortened-Hamming core with I-Ching structure
In this section, we describe the 64 hexagrams in terms of a symmetric binary [6, 3, 3] code; its deep holes are treated in Section 5. This gives a new way to visualize the 64 hexagrams.
4.1 A binary code
We now describe a particularly symmetric binary code that can be used as a central set of 8 hexagrams. Note that this code is equivalent to the shortened Hamming code and is distance-optimal .
We use the convention that a hexagram is a vector
where the first three coordinates form the lower trigram and the last three coordinates form the upper trigram. Thus a doubled-trigram hexagram has the form
Consider the binary linear code generated by
Equivalently, has generator matrix
Remark 4.1. It is easy to see that .
Proposition 4.2. The code is a binary linear code.
Proof. The three generator rows are linearly independent, so . The eight codewords are
The nonzero weights are 3 or 4. Hence the minimum distance is
Therefore has parameters .
5
☐
Since , the radius-one balls around the codewords of are disjoint. Equivalently, if
then the seven sets
are pairwise disjoint. Hence they cover
of the 64 hexagrams.
The remaining 8 hexagrams form a single coset. For this choice of , the missing coset is
Explicitly,
Thus the full binary hexagram space decomposes as
On the other hand, since
we may take
Thus the whole space of 64 hexagrams has the compact coset description
Equivalently,
4.2 Uniqueness of the trigram-coherent core
The code of Proposition 4.2 was written down explicitly, and one may reasonably ask whether the I-Ching features it exhibits are an artifact of that particular choice. They are not. In this subsection we show that and its dual are the only binary [6,3,3] codes that are compatible with the trigram decomposition, in the precise sense of containing the largest possible number of doubled-trigram hexagrams. The proof is elementary and requires no computer search.
Throughout, a hexagram is a vector , the first three coordinates forming the lower trigram and the last three the upper trigram, and we write accordingly. Define the doubled-trigram subspace
whose eight elements are exactly the eight hexagrams built from a single trigram repeated twice, and the coordinate reversal
which is the I-Ching overturning (zong) operation. Finally put
the doubled tetrad {Earth, Fire, Wind, Lake}.
Definition 4.3. A binary code is trigram-coherent if is as large as possible among all binary codes.
In the terminology of Section 6, a trigram-coherent code is precisely an extremal diagonal-coherent code of length 6 (Definition 6.4).
We first bound . Write
for the even- and odd-weight cosets in , so that is the even-weight subspace and .
Lemma 4.4. Let be a subgroup containing no vector of Hamming weight 1. Then , and if and only if .
Proof. If then contains 100, which is excluded. Suppose . Then for a nonzero linear functional with , and avoids the three weight-one vectors if and only if for , that is, if and only if . Hence is the unique such subgroup of dimension 2, and no subgroup of larger order qualifies.
Proposition 4.5. Let be a binary code. Then
and equality holds if and only if . In particular a trigram-coherent code contains exactly four doubled trigrams, namely the tetrad .
Proof. The map , , is a group isomorphism and satisfies . Consequently has Hamming weight 2 precisely when .
Now is a subgroup of , so is a subgroup of . Since , the code contains no nonzero vector of weight 2, hence contains no vector of weight 1. By Lemma 4.4, with equality if and only if , and .
Thus the maximum in Definition 4.3 is 4, and every trigram-coherent code contains H. The next theorem shows that this forces the code completely.
Theorem 4.6. There are exactly two binary codes containing H, namely
Equivalently, and are the only trigram-coherent binary codes, and they satisfy .
Proof. Let be a code with . Since and , we have for some with . Writing , the nontrivial coset is
and, because the nonzero words of H have weight 4, the condition is equivalent to
Note that for the element runs over the coset , whose weights are if and if . We distinguish four cases according to the parities of and .
Case 1: . Since we have . Choosing in (1) gives . But has weight 2, contradicting (1).
Case 2: , . Choosing gives . As has weight 1 or 3, this forces , i.e., . Conversely, if then for every we have , the componentwise complement, whence
so (1) holds and . There are four admissible choices , but they all determine the same code: if and , , then with , so . Taking gives and
hence .
Case 3: , . Symmetrically , and taking gives and
hence .
Case 4: . For both and lie in and therefore have weight 1 or 3. Hence (1) holds for a given if and only if or , that is, if and only if . This set has at most two elements, whereas , so (1) fails for some .
Cases 2 and 3 exhaust the possibilities, giving exactly the two codes stated. Both contain , and .
Corollary 4.7. The overturning interchanges the two trigram-coherent [6,3,3] codes:
Consequently the unordered pair , and hence the tetrad , is canonically attached to the trigram decomposition of : it is determined by the parameters together with the requirement of trigram coherence, with no further choice involved. In particular, is an isodual code which is not self-dual, the permutation realising the isoduality being the overturning .
Proof. The first assertion is clear since sends the generators of into . The second follows since is an involution. Alternatively, preserves both the parameters [6, 3, 3] and the subspace , so it permutes the set of trigram-coherent codes, which by Theorem 4.6 has exactly two elements; since is not self-dual, cannot fix .
Remark 4.8. An exhaustive computation in Magma/Python confirms Theorem 4.6 and places it in context. There are exactly 30 binary [6,3,3] codes in ; they form a single orbit under the coordinate group , so all of them are equivalent to the shortened Hamming code and share the weight enumerator , and each has a stabiliser of order in . Of these 30 codes, exactly 2 contain , namely and . Equivalence therefore says nothing about the present question: what singles out and is not the abstract code but its position relative to the fixed trigram splitting , which the group does not preserve.
Remark 4.9 (I-Ching reading). Proposition 4.5 says that the eight doubled-trigram hexagrams cannot all be accommodated by a single-error-correcting core: at most four of them may coexist in a [6,3,3] code, and the four that can are forced to be
{ Earth, Fire, Wind, Lake },
because these are exactly the doubled trigrams with of even weight. The complementary tetrad is excluded for a structural reason: each of 001001, 010010, 100100 has Hamming weight 2, so no minimum-distance-3 code can contain it, while 111111 lies at distance 2 from . Thus these four hexagrams are pushed into the deep-hole coset . Thus the splitting of the eight doubled trigrams into a coded tetrad and a deep-hole tetrad is not a feature of one convenient example: it is the only splitting the parameters allow.
5 Deep holes for
Recall that the distance from a vector to the code is
The covering radius of is
A vector x is called a deep hole of if
The following is the case of the classical fact [8, p.533] that shortened Hamming codes are nearly perfect, and so quasi-perfect.
Proposition 5.1. , that is, is quasi-perfect. The set of deep holes of is
Proof. For the code , the first seven cosets
consist precisely of the vectors at distance 0 or 1 from . Since , they are disjoint and the coset leader of ( ) has weight 1. They cover 56 vectors. The remaining coset is
whose coset leader has weight 2 since all the cosets of weight 1 are given above. Hence every vector in has distance exactly 2 from . Therefore
The shortened-Hamming core and its deep-hole coset
Hexagram convention:
bottom line = first bit;
top line = sixth bit;
solid line,
broken.

: deep-hole coset distance 2 from
Inner core :
(doubled trigrams)
Figure 1: Eight core hexagrams set in the center with the eight orange circled deep holes set outside. Within , the four blue circled hexagrams form a [6, 2, 4] code and the four green circled hexagrams form its coset.
Consequently,
is exactly the set of deep holes of .
In particular, the deep holes are
.
The code contains the four doubled-trigram hexagrams
000000, 101101, 011011, 110110.
These correspond to
Earth/Earth, Fire/Fire, Wind/Wind, Lake/Lake.
Thus contains the doubled-trigram tetrad
{Earth, Fire, Wind, Lake}.
The missing coset contains the complementary doubled-trigram tetrad
111111, 010010, 001001, 100100,
corresponding to
Heaven/Heaven, Water/Water, Mountain/Mountain, Thunder/Thunder.
Hence contains the complementary tetrad
{Heaven, Water, Mountain, Thunder}.
We visualize and its deep-hole coset in Figure 1. The blue circled hexagrams are generated by 101101, 011011 to form a diamond while the green circled hexagrams are obtained by adding 000111 to the blue circled hexagrams to form a square. Each orange circled hexagram has exactly three hexagrams in blue or green circles at distance exactly 2. It is interesting to note that each orange circled hexagram is complementary to a unique hexagram in blue or green circle because 111111 is another coset representative of .
Proposition 5.2. Let . Then
a binary [6, 4, 2] code with weight enumerator and covering radius . Thus alone does not cover with radius one — it misses exactly the eight deep holes — while adjoining the deep-hole coset yields a code that does.
Proof. Since and , we have , so ; this set has 16 elements and is a subspace because and therefore . The identity is standard, and by Theorem 4.6, so . The weight enumerator follows by inspection of the sixteen codewords. Every lies within distance 1 of because if this is clear, and otherwise by Proposition 5.1, so . Hence , and since . Therefore, , as desired.
Remark 5.3. Now is the common self-orthogonal core fixed by both dualization and the overturning ; the sole asymmetry between and its dual is the exchange of the single non-doubled generator , itself an overturning pair. In particular, the isoduality of is realised by a genuine -Ching symmetry — reading hexagrams upside down — and not merely by an abstract coordinate permutation.
6 Codes coherent with a diagonal subspace
The uniqueness statement of Section 4.2 concerns a single code of length 6. In this section we show that it is the case of a general phenomenon. Throughout, is an integer and we work in , whose coordinates are split into a first and a second block of length .
We write for a binary linear code of length , dimension and minimum distance exactly , and when only the inequality is asserted. The distinction matters here: the codes we characterise are those with , and some of them turn out to have minimum distance 4 (Corollary 6.11).
6.1 The diagonal subspace and a general bound
Definition 6.1. The doubling map is the injective linear map
and its image is the diagonal subspace of . Clearly and
For , the diagonal subspace is the doubled-trigram subspace (Section 4.2), and is the map sending a trigram to the hexagram obtained by repeating it.
The following observation reduces the question “how much of can a code of minimum distance contain?” to a standard code-parameter problem one dimension down. Write for the largest dimension of a binary linear code of length and minimum distance at least .
Proposition 6.2. Let be a linear code with . Then
is a binary linear code of length m with . Consequently
Proof. Since is an injective linear map and is a subspace of , the preimage is a subspace of and . Let be nonzero. Then is a nonzero codeword of , so , and by (2) this reads , i.e., . As is an integer, . Hence and .
We now specialise to , the case of single-error-correcting codes, where and the bound becomes completely explicit. Let
denote the even-weight code, an code.
Corollary 6.3. Let be a linear code with . Then
and equality holds if and only if .
Proof. By Proposition 6.2, has , i.e., contains no vector of weight 1. A binary code of length and dimension is all of and contains such a vector, so . If then for a nonzero linear functional , and avoids the weight-one vectors if and only if for every , that is, if and only if . Hence is the unique possibility, and .
Definition 6.4. A binary linear code with is diagonal-coherent if it attains the bound of Corollary 6.3, that is, if . We call extremal if in addition its dimension is as large as possible.
6.2 Existence at optimal redundancy
Requiring diagonal coherence is a strong constraint: it prescribes a subcode of dimension inside a code of length . It is therefore not obvious that a diagonal-coherent code can also be optimal as an error-correcting code. We show that it always can, and that the constraint in fact costs nothing.
Recall that for binary codes of length with the sphere-packing bound forces the redundancy to satisfy , and that this is attained by shortened Hamming codes. We write
for the resulting optimal redundancy, and note for later use that the minimality of is equivalent to the two-sided estimate
Lemma 6.5. Let . Then and
Proof. A vector satisfies , so if and only if . The dual of the even-weight code is the repetition code, , which gives the stated description; the dimension count is .
Theorem 6.6. Let and set and . Then there exists a binary code containing . In other words, the maximum dimension of a diagonal-coherent code of length equals the maximum dimension of any binary code of length with minimum distance at least 3: diagonal coherence entails no loss of redundancy.
Proof. Put . A code of length satisfies and if and only if is contained in and the columns of a generator matrix of — equivalently, of a parity-check matrix of — are pairwise distinct and nonzero.
Let have dimension and let be an matrix whose rows form a basis of . By Lemma 6.5 the -th row has the form . Set
Then the columns of M are exactly
Let be the quotient map. The columns (5) are pairwise distinct and nonzero if and only if
Indeed, is needed to separate from ; distinctness of the is exactly the condition that no two of the 2m columns coincide; and says , i.e. neither nor vanishes.
The quotient has nonzero elements, so (6) can be satisfied if and only if
Since is even and is odd, the inequality is equivalent to . Hence the least for which (6) is solvable is exactly .
It remains to check that a solution with really produces a code of dimension , i.e., that has rank . Choose the to be distinct nonzero elements of and lift them arbitrarily. Any proper subspace of the -dimensional quotient contains at most nonzero elements; from (4) we have , hence , so the distinct nonzero elements cannot lie in a proper subspace and therefore span . Together with this shows that the columns of span , so rank and has dimension and . Finally because , and equality then holds by Corollary 6.3.
6.3 Enumeration
The proof of Theorem 6.6 is constructive enough to count the extremal codes exactly.
Theorem 6.7. Let , , and let denote the number of extremal diagonal-coherent codes, that is, the number of binary codes containing . Then
the denominator being .
Proof. By the proof of Theorem 6.6, such codes correspond bijectively to subspaces of dimension satisfying (6), and a choice of basis of is the same as a tuple
subject to (6). The number of such tuples is
since may be any nonzero vector, the images form an ordered sequence of distinct nonzero elements of a group of order , and each has exactly two preimages.
Two tuples determine the same subspace precisely when they are related by a change of basis, i.e., by the natural action of ,
This action is free: if fixes then fixes and every , and these vectors span (as shown at the end of the proof of Theorem 6.6), so is the identity. Hence the number of subspaces, and therefore of codes, is the number of tuples divided by .
6.4 The minimum distances of the extremal diagonal-coherent codes
An extremal diagonal-coherent code has by definition, but not necessarily . It turns out that the possible values of are governed by a fact about all binary codes of minimal redundancy, in which the diagonal plays no role; we prove that first and then specialise.
Recall that a subset of an abelian group is sum-free if for all with .
Lemma 6.8. Let be sum-free. Then , and equality holds if and only if for some subgroup of index 2; equivalently, for a nonzero linear functional .
Proof. Fix . For we have by sum-freeness, and since . Hence and are disjoint subsets of , giving , that is, .
Suppose . Then the above inclusion is an equality, so . Adjoining the element to both sides gives for every . Consequently for all , whence . Let . Then , so is a union of cosets of ; for a fixed and for every , , thus and since , we have , proving . So and has index 2.
Finally forces . The converse is immediate: if then , so is sum-free of size .
The following is essentially folklore — it is equivalent to the classical description of maximal sum-free sets in elementary abelian 2-groups — but we include a short self-contained proof, since it is the equality case that we shall need in Corollary 6.11.
Theorem 6.9. Let and let be the minimal redundancy of a binary code of length with minimum distance at least 3. Then the largest minimum distance of a binary code is
Moreover, when the codes attaining are exactly the extended Hamming codes , unique up to a permutation of the coordinates.
Proof. Let be a binary code and let be a parity-check matrix, an matrix of rank with column set . Then if and only if the columns are pairwise distinct and nonzero, and, given that, if and only if no three distinct columns sum to 0, i.e., if and only if is a sum-free subset of .
Suppose . By Lemma 6.8, ; combined with the lower estimate of (4) this forces . Since (4) confines to the interval , whose only power of 2 is , the condition is the same as being a power of 2. The equality case of Lemma 6.8 further gives for a nonzero functional ; after a change of basis this is the standard parity-check matrix of the extended Hamming code of length , whence the uniqueness assertion. This code has and no more: since we may pick distinct , and then because , while ; these four distinct columns sum to 0.
Conversely, if then taking as the column set produces a rank-r matrix, and the corresponding code has by the above.
Finally, for every in the range (4) a shortened Hamming code realises , so when is not a power of 2.
Remark 6.10. The minimality of in Theorem 6.9 cannot be dropped. For and — one more than the minimal value — choose as columns any 10 of the 16 vectors of an affine hyperplane . No three of them sum to 0, so the resulting code is a [10, 5, 4] code although 10 is not a power of 2. What Theorem 6.9 asserts is that this freedom disappears once the redundancy is pushed down to .
Corollary 6.11. Let and put , and let be an extremal diagonal-coherent code of length 2m.
(i) If , then ; in particular m is a power of 2, and moreover and is an extended Hamming code with parameters .
(ii) Conversely, if m is a power of 2, then at least one extremal diagonal-coherent code of length 2m attains d = 4. Not all of them need do so: for m = 4 exactly two of the extremal codes have d = 4, the remaining eight having d = 3 (Proposition 6.14).
(iii) If m is not a power of 2, then .
Proof. By Definition 6.4 and Theorem 6.6, the code has length , minimum distance and dimension , so its redundancy is exactly the minimal value ; and gives . Theorem 6.9 therefore applies to and yields , where if is a power of 2 and otherwise.
(i) If then , so and ; the uniqueness clause of Theorem 6.9 identifies as an extended Hamming code . Since forces , we get , a power of 2.
(iii) If is not a power of 2, neither is , so ; together with this gives .
(ii) Let with , so that . Choose a nonzero linear functional on and set , so that and . Since , we may choose . Then , so translation by is a fixed-point-free involution of and partitions into pairs . Pick one representative from each pair. The data satisfies (6): by choice; would mean , contradicting that distinct represent distinct pairs; and because while . By the proof of Theorem 6.6 these data produce an extremal diagonal-coherent code of length whose parity-check columns (5) are exactly the elements of . As for , no two elements of sum to a third, i.e., is sum-free; by the proof of Theorem 6.9 this says , whence by (i). The count for is Proposition 6.14 below.
Corollary 6.12. Let , let , and let be an extremal diagonal-coherent code of length 2m whose minimum distance is the largest occurring among such codes, that is, if is a power of 2 and otherwise. Then is optimal in both of the following senses.
(i) Distance-optimal: no binary code has minimum distance larger than .
(ii) Dimension-optimal: no binary code of length 2m with minimum distance at least has dimension larger than .
Consequently the starred entries of the minimum-distance column of Table 1 record optimal parameters, and for m = 3 this recovers the distance-optimality of noted in Section 4.
Proof. By Definition 6.4 and Theorem 6.6, C is a binary code, and .
(i) Theorem 6.9, applied with , states that the largest minimum distance of a binary code is , equal to 4 when is a power of 2 and to 3 otherwise. Since is a power of 2 if and only if is, Corollary 6.11 says exactly that attains .
(ii) Suppose first , and let be a binary code of length with and redundancy . The sphere-packing bound gives , so by (3) and .
Suppose now , so that by Corollary 6.11, and let be a binary code of length with and redundancy . Let be a parity-check matrix of , of rank , and let be its set of columns. As in the proof of Theorem 6.9, forces the columns to be pairwise distinct and nonzero with no three of them summing to 0; that is, is a sum-free subset of of size . Lemma 6.8 gives , and therefore yields , i.e., .
Remark 6.13. When m is a power of 2, the other extremal diagonal-coherent codes are not distance-optimal: for m = 4 the eight codes with d = 3 have parameters [8, 4, 3], whereas the two extended Hamming codes show that parameters [8, 4, 4] exist. Thus diagonal coherence alone does not force optimality of the minimum distance; what Corollary 6.12 says is that the best minimum distance available under diagonal coherence is already the best available without it.
Proposition 6.14. Let and , so that and . Then the number of extremal diagonal-coherent codes of length 2m with minimum distance 4 is
all remaining extremal codes having minimum distance 3. In particular
Proof. By the proofs of Theorems 6.6 and 6.7, the extremal diagonal-coherent codes of length 2m correspond bijectively to the orbits of the free -action on the set of tuples satisfying (6), the code attached to having as parity-check columns the set
By the proof of Theorem 6.9, the code has if and only if is sum-free, and since the equality case of Lemma 6.8 applies: this holds if and only if for some nonzero linear functional on . By Corollary 6.11(i) such a code has exactly.
It remains to count the tuples with of this form. The functional is determined by and may be chosen in ways. Given , both and lie in , so ; as this leaves choices of . Given and , translation by partitions into pairs , and a tuple with is precisely an ordered choice of one representative from each pair: there are ways to choose the representatives and ways to order them. Each tuple so obtained satisfies (6), by the verification carried out in the proof of Corollary 6.11(ii). Hence the number of admissible tuples is .
Finally the -action preserves this set of tuples, since , and it is free; dividing by gives the stated formula. The three displayed values are obtained by substituting .
6.5 Normal forms for the extremal diagonal-coherent codes
Proposition 6.15. Let and . For an matrix over with columns and a vector put
(i) If are pairwise distinct and nonzero, then has rank and is an extremal diagonal-coherent code of length .
(ii) Conversely, every extremal diagonal-coherent code of length 2m equals for some such A and some .
(iii) if and only if is sum-free in , and otherwise. In particular does not depend on .
Proof. Write . The columns of are
so they are of the shape (5) with this e, and condition (6) reads exactly: pairwise distinct and nonzero.
(i) The column set contains and , hence contains in its span. Modulo the columns give ; a proper subspace of has at most nonzero elements, while (4) gives , i.e. , so the span . Hence the columns span and rank . The proof of Theorem 6.6 now shows that has dimension , satisfies and contains .
(ii) Let be extremal diagonal-coherent and let be a parity-check matrix whose rows form a basis of , with associated data as in the proof of Theorem 6.6. Since there is with . Replacing by does not change the row space, hence not the code; and the -th column of is while its -th column is . Thus with , and (6) makes the distinct and nonzero.
(iii) As a set the columns of are , which does not depend on ; call it . By the proof of Theorem 6.9, if and only if is sum-free. Let be distinct. If then and , because . If then lies in precisely when . Hence is sum-free if and only if is. Since by Theorem 6.9, the remaining case gives .
Remark 6.16. Proposition 6.15(iii) reproves Corollary 6.11: a sum-free subset of has at most elements by Lemma 6.8, while as above, so forces , that is . It also gives a second route to Theorem 6.7: there are choices of and of , and the matrices and define the same code exactly when they differ by an element of the stabiliser of in , a subgroup of index .
Corollary 6.17. Let and , and let be the binary expansion of for ; this is legitimate because by (4). Then
is the parity-check matrix of an extremal diagonal-coherent code. Indeed , so is not sum-free and Proposition 6.15(iii) applies.
Remark 6.18. For m = 3 we have r = 3 and runs through all of , so
Taking makes equal to the matrix of Section 4. Here it serves as a parity-check matrix, so the resulting code is rather than itself; taking replaces the last row by 111000 and yields . The eight values of therefore produce only these two codes, in accordance with .
6.6 Hulls of the extremal diagonal-coherent codes
Recall that the hull of a linear code is ; it measures how far is from being self-dual at one extreme and linear complementary dual at the other. For the code of Section 4 we found (Theorem 4.6). The normal form of Proposition 6.15 determines the hull in general.
Theorem 6.19. Let , , and let be an extremal diagonal-coherent code written in the normal form (8). Let be the row space of , an code, and put
the sum of the columns of A. Then exactly one of the following holds.
(i) If , then and .
(ii) If and is odd, then and .
(iii) If and is even, then , that is, , and .
In cases (i) and (ii) the hull is contained in the diagonal subspace . In all cases , so no extremal diagonal-coherent code is linear complementary dual.
Proof. Write and let be the rows of . Since rank by Proposition 6.15(i), the map is an isomorphism from onto , and lies in if and only if . Hence it restricts to an isomorphism , and .
We compute . For the corresponding rows of are and , whose inner product is : the doubled rows are pairwise orthogonal and self-orthogonal. Writing for the all-one vector of length and , the inner product of with the last row is , and the last row has inner product with itself. Therefore
The -th entry of is , so .
If , then has rank 2 and its kernel consists of the with and . For such the corresponding codeword is with , and , so the condition on says exactly . This gives (i), the dimension being because when .
If and is odd, the only constraint is , giving of dimension . If and is even then , so has dimension .
Finally forces , whence .
Corollary 6.20. Suppose , the case treated in Corollary 6.24 below. Then the columns of A are all the nonzero vectors of , so is the simplex code with parameters ; moreover and m is odd. Hence every extremal diagonal-coherent code of length has
For this is Hull() = , since the simplex code of length 3 is the even-weight code ; for it gives the doubled [7, 3, 4] simplex code inside .
Remark 6.21. For case (i) or (ii) of Theorem 6.19 applies to every extremal code with , and the hull dimension is constant for each in Table 1: it equals 2, 2, 2, 2 for , and 3 for . This is an accident of the small values of involved. For and , for instance, is the sum of the 7 - omitted nonzero vectors of and is therefore never 0. At , where , both regimes occur among the codes with : choosing with gives dim Hull( ) = 3, while a set of eight nonzero vectors of summing to 0 but not sum-free — for example written as binary expansions — gives dim Hull( ) = 5 and .
6.7 Deep holes for an extremal diagonal-coherent code
Section 5 described the 64 hexagrams as the codewords of , their radius-one balls, and a single coset of deep holes. That description generalises to every m, and the number of deep holes turns out not to depend on which extremal code is chosen.
Proposition 6.22. Let , let , and let be an extremal diagonal-coherent code of length 2m. Then , so is quasi-perfect, and the deep holes of are the union of exactly
cosets of C, each of size ; hence C has deep holes. In particular this number depends only on m, and not on the choice of C among the extremal codes.
Proof. Let be a parity-check matrix of and let be its set of columns, so that and the elements of are pairwise distinct because . For a syndrome the coset of with syndrome has coset leaders of weight , the least number of elements of summing to ; thus .
We have only for , and exactly for the 2m elements of . Since is odd and greater than 1, it is not a power of 2, so the minimality of gives ; hence at least one syndrome has and .
Conversely let and suppose . Then and are disjoint subsets of of size each, so ; but (4) gives , i.e. . Hence . As we get , that is , contrary to the choice of . Therefore : there is with , and shows . Thus .
Consequently the syndromes split into one with , exactly with , and the remaining with ; the last are precisely the deep-hole cosets. Each coset of has elements.
Remark 6.23. The picture of Section 5, in which the deep holes form a single coset, occurs exactly when , that is — precisely the case treated in Corollary 6.24, where the extremal codes are Hamming codes shortened at one coordinate. For this is , the
| length, dimension | minimum distances occurring | deep-hole cosets | |||
|---|---|---|---|---|---|
Table 1: Parameters , the number of extremal diagonal-coherent codes, and the number of deep-hole cosets of each of them (Proposition 6.22); every such coset has elements. Here means that the minimum distance is optimal by Corollary 6.12.
hexagram case, and for it is . So the clean decomposition of into the eight balls around and one deep-hole coset is not typical of general : it reflects the fact that the code is a singly shortened Hamming code.
The minimum-distance column in Table 1 is consistent with Corollary 6.11, whose multiplicities are given by Proposition 6.14: the value 4 occurs exactly in the rows , where is a power of 2. The counts for and for have been confirmed by exhaustive computer search in Magma/Python.
6.8 Specialisations
Corollary 6.24. Suppose , so that and the bound (7) is met with equality. Then every extremal diagonal-coherent code is a Hamming code of length shortened at a single coordinate, namely the coordinate whose parity-check column is the vector of (5); in particular it has parameters with minimum distance exactly 3, and
Proof. When the elements exhaust the nonzero elements of , so the columns (5) are exactly the nonzero vectors of other than . A parity-check matrix whose columns are all nonzero vectors of defines the Hamming code of length ; deleting the column shortens it. The minimum distance is 3 and not 4 by Corollary 6.11, since is not a power of 2 for .
Remark 6.25. It is natural to ask how restrictive diagonal coherence really is: is every optimal code, , diagonal-coherent? Since containing is not preserved by coordinate permutations, the question must be read up to equivalence, and in that form it has a clean answer. Let be the set of the parity-check columns of such a code . Comparing with the normal form (8), we see that is equivalent to a diagonal-coherent code if and only if
for (9) lets one split into the pairs demanded by (5), and conversely the column set of is invariant under . Equivalently, the complement , which has elements and contains 0, must be invariant under some nonzero translation.
In the situation of Corollary 6.24, where , we have for a single nonzero , and holds automatically. Hence every optimal code is equivalent to a diagonal-coherent one: for these lengths diagonal coherence is no restriction at all. This covers the hexagram case , and quantifies the observation of Remark 4.8 that what distinguishes is not the abstract code but its position relative to the trigram splitting.
For , however, and one may choose with trivial translation stabiliser, so optimal codes that are equivalent to no diagonal-coherent code exist. For the obstruction is visible at once: is translation-invariant only if , so omitting three linearly independent columns, say , produces an optimal code that is not equivalent to any diagonal-coherent code. A computer search shows that the codes fall into four equivalence classes of which only one satisfies (9), and the codes into two classes of which only one does; for and there is a single class and (9) holds, in accordance with the previous paragraph.
Corollary 6.26 (the case ). For we have and . The two extremal diagonal-coherent codes are the [6,3,3] codes
they satisfy , and they are interchanged by the coordinate reversal . This recovers Theorem 4.6.
Remark 6.27. Three conditions that are easy to conflate should be kept apart.
(i) Minimum distance 4 is attained exactly when m is a power of 2, by Corollary 6.11; this is an infinite family , the codes being extended Hamming codes.
(ii) The dimension is half the length, i.e. , exactly when , which holds only for and .
(iii) Some extremal code is self-dual, which requires both (i) and (ii) and therefore happens only for m = 4: of the extremal codes exactly two are self-dual, and these are the extended Hamming [8, 4, 4] codes.
Thus at m = 3 the extremal codes form a dual pair exchanged by an involution of the coordinates, whereas at m = 4 the dual pair degenerates to a self-dual code. It would be of interest to know whether this dichotomy has a uniform explanation.
Remark 6.28. For m = 3 the diagonal subspace consists of the eight doubled-trigram hexagrams of the I-Ching, and Corollary 6.3 says that at most four of them can lie in a single-error-correcting code, the four being forced to be those with even. The general statement is therefore that a diagonal-coherent code sees exactly the “even half” of the diagonal, for every m.
6.9 Open problems
Remark 6.29. Within Definition 6.4 the minimum-distance question is completely settled and nothing remains open. An extremal diagonal-coherent code has redundancy exactly , so Theorem 6.9 applies: its minimum distance is 3, or 4, the latter occurring only when m is a power of 2, and then only for some of the codes (Proposition 6.14). No value can occur at that redundancy. The genuinely open questions concern the bound of Proposition 6.2 for the other values of d, where the relevant optimal dimension is not but the much smaller optimum associated with that d; this is Problem 6.30.
Problem 6.30. The bound of Proposition 6.2 is a different inequality for each . Call with -diagonal-coherent if it attains that bound, i.e., if , and let denote the largest dimension of a binary code of length with minimum distance at least . Is there, for every and every , a -diagonal-coherent code of dimension ? Theorem 6.6 answers this affirmatively for , where .
The first case beyond is already instructive. For we have , so the bound involves , itself a Hamming-type quantity. Taking and the Hamming [7,4,3] code , the doubled code has dimension and weights 6 and 8, so it is 5-diagonal-coherent, and a computer search produces codes of length 14 and minimum distance 5 containing whose dimension equals by [3]. Decide whether this “no loss” behaviour persists in general, and characterise the extremal -diagonal-coherent codes.
Problem 6.31. For let , , so that . The argument of Proposition 6.2 yields for any with . Develop the analogue of Theorem 6.6 in this setting, and identify the codes attaining the bound.
Problem 6.32. Over the diagonal still satisfies , so Proposition 6.2 holds verbatim. For the relevant quantity is again the largest dimension of an code, namely , but the codes attaining it are no longer unique when . Determine the -ary analogues of Theorems 6.6 and 6.7, and of Corollary 6.11. Note that Theorem 6.9 is genuinely binary: over the columns of a parity-check matrix are only required to be pairwise linearly independent, and the sum-free argument of Lemma 6.8 has no immediate analogue.
References
[1] G. Cohen, I. Honkala, S. Litsyn, and A. Lobstein, Covering Codes, North-Holland Mathematical Library, vol. 54. Amsterdam: Elsevier, 1997.
[2] D. S. Goldenberg, The Algebra of the I Ching and its Philosophical Implications. Journal of Chinese Philosophy, 2(2), 149-179, (1975).
[3] M. Grassl, “Bounds on the minimum distance of linear codes and quantum codes,” Online available at http://www.codetables.de. Accessed on 2026-08-06.
[4] Z. Hu, S. V. Petoukhov, and E. S. Petukhova, “I-Ching, dyadic groups of binary numbers and the geno-logic coding in living bodies,” Progress in Biophysics and Molecular Biology, vol. 131, pp. 354–368, 2017.
[5] W. C. Huffman and V. Pless, Fundamentals of Error-Correcting Codes, Cambridge University Press, 2003.
[6] G. W. Leibniz, “Explication de l’arithmétique binaire, qui se sert des seuls caractères 0 & 1; avec des remarques sur son utilité, & sur ce qu’elle donne le sens des anciennes figures chinoises de Fohy,” Mémoires de l’Académie Royale des Sciences, 1703, pp. 85–89.
[7] Y. Li, The Mathematical Structure of the I Ching's Sixty-Four Hexagrams: A Reinterpretation Based on Two's Complement Systems (April 07, 2026). Available at SSRN: https://ssrn.com/abstract=6534259
[8] F. J. MacWilliams and N. J. A. Sloane, The Theory of Error-Correcting Codes, North-Holland, 1977.
[9] B. S. Nielsen, A Companion to Yi Jing Numerology and Cosmology, London: RoutledgeCurzon, 2003.
[10] R. Rutt, The Book of Changes (Zhouyi): A Bronze Age Document, Richmond: Curzon Press, 1996.
[11] J. A. Ryan, “Leibniz’s binary system and Shao Yong’s Yijing,” Philosophy East and West, vol. 46, no. 1, pp. 59–90, 1996.
[12] E. L. Shaughnessy, I Ching: The Classic of Changes, New York: Ballantine Books, 1997.
[13] R. J. Smith, Fathoming the Cosmos and Ordering the World: The Yijing and Its Evolution in China, Charlottesville: University of Virginia Press, 2008.
[14] R. Wilhelm and C. F. Baynes, The I Ching, or Book of Changes, 3rd ed., Bollingen Series XIX, Princeton: Princeton University Press, 1967.