5D Library › Six-Dimensional Hypercube Walks, Hexagram Mutation Markov Chains and Modular Star-Palace Lattices · 中文

Chapter 7. The Number of the Great Expansion, the Before-Heaven Diagrams and the Origins of the Zi Wei Dou Shu

Why read these sources here

Every rule in the first six chapters has a textual source: the yarrow method comes from the Appended Statements and Zhu Xi’s Divination Procedure, the rules for moving lines from Zhu Xi’s Introduction to the Study of the Changes, the binary order of the hexagrams from Shao Yong’s Before-Heaven diagrams, and the star-placement verses from Zi Wei Dou Shu literature attributed to Chen Tuan. This chapter returns to these texts, checks the statements the models rely on, and marks where reading becomes interpretation.

The number of the great expansion

Source text

Appended Statements, part one

大衍之數五十,其用四十有九。分而為二以象兩,掛一以象三,揲之以四以象四時,歸奇於扐以象閏;五歲再閏,故再扐而後掛。 “The number of the great expansion is fifty, of which forty-nine are used. They are divided in two to represent the two; one is hung up to represent the three; they are counted off by fours to represent the four seasons; the remainder is put between the fingers to represent the intercalary month. There are two intercalary months in five years, so the putting-aside is done twice before the next hanging.”

(Lynn 1994; Wilhelm 1967)

All the calculations of Chapter 2 come from this passage: fifty less one, divide in two, hang one, count by fours, put the remainder aside. The Appended Statements give each step a symbolic meaning (the two modes, the three powers, the four seasons, the intercalary month) but say nothing about the probability of any step. That old yang is three times as likely as old yin is a mathematical consequence of the procedure, not something the text says; Chapter 2 also showed that the ratio holds only for natural ways of splitting. Zhu Xi set the procedure out as a ritual at the head of his Original Meaning of the Zhouyi, the Divination Procedure, and discussed the stalk numbers and the reading of changes in his Introduction to the Study of the Changes (Zhu Xi 2002; Smith 2008).

Note

Checking the text. The quotation from the Appended Statements above is the usual text and has been checked against a punctuated edition. The rules of the Divination Procedure and of “Examining the changes” are paraphrased in this book from their usual summary, not quoted.

The Before-Heaven diagrams are binary

Shao Yong (1011-1077) arranged the sixty-four hexagrams in a sequence and in an eight-by-eight square, beginning with Qian and ending with Kun; later generations called these the Before-Heaven diagrams. The fourteenth program checks the sequence.

Calculation

# Chapter 7. Shao Yong's "Before Heaven" order is counting in binary.
# Shao Yong (1011-1077) arranged the 64 hexagrams in a sequence and in a
# square of 8 x 8, starting from Qian and ending with Kun. Read each
# hexagram as a six-digit binary number with yang = 1, yin = 0 and the
# BOTTOM line as the highest digit: the sequence is then 63, 62, ..., 0,
# and the trigram order Qian Dui Li Zhen Xun Kan Gen Kun is 7, 6, ..., 0.
# This is the observation Bouvet sent to Leibniz in 1701. The program
# checks it from the received sequence (listed by King Wen number) and the
# trigram table, and compares the King Wen order with the binary values.
TRI = {"qian": (1, 1, 1), "dui": (1, 1, 0), "li": (1, 0, 1),
       "zhen": (1, 0, 0), "xun": (0, 1, 1), "kan": (0, 1, 0),
       "gen": (0, 0, 1), "kun": (0, 0, 0)}         # bottom line first
KING_WEN = [                                   # upper, lower for 1..64
    "qian qian", "kun kun", "kan zhen", "gen kan",
    "kan qian", "qian kan", "kun kan", "kan kun",
    "xun qian", "qian dui", "kun qian", "qian kun",
    "qian li", "li qian", "kun gen", "zhen kun",
    "dui zhen", "gen xun", "kun dui", "xun kun",
    "li zhen", "gen li", "gen kun", "kun zhen",
    "qian zhen", "gen qian", "gen zhen", "dui xun",
    "kan kan", "li li", "dui gen", "zhen xun",
    "qian gen", "zhen qian", "li kun", "kun li",
    "xun li", "li dui", "kan gen", "zhen kan",
    "gen dui", "xun zhen", "dui qian", "qian xun",
    "dui kun", "kun xun", "dui kan", "kan xun",
    "dui li", "li xun", "zhen zhen", "gen gen",
    "xun gen", "zhen dui", "zhen li", "li gen",
    "xun xun", "dui dui", "xun kan", "kan dui",
    "xun dui", "zhen gen", "kan li", "li kan",
]

XIANTIAN = [                    # King Wen numbers in Shao Yong's order
    1, 43, 14, 34, 9, 5, 26, 11, 10, 58, 38, 54, 61, 60, 41, 19,
    13, 49, 30, 55, 37, 63, 22, 36, 25, 17, 21, 51, 42, 3, 27, 24,
    44, 28, 50, 32, 57, 48, 18, 46, 6, 47, 64, 40, 59, 29, 4, 7,
    33, 31, 56, 62, 53, 39, 52, 15, 12, 45, 35, 16, 20, 8, 23, 2,
]


def bits(n):
    upper, lower = KING_WEN[n - 1].split()
    return TRI[lower] + TRI[upper]

def value(h):                     # bottom line is the highest digit
    return sum(b << (5 - i) for i, b in enumerate(h))

def spearman(x, y):
    n = len(x)
    rx = {v: i for i, v in enumerate(sorted(x))}
    ry = {v: i for i, v in enumerate(sorted(y))}
    d = sum((rx[a] - ry[b]) ** 2 for a, b in zip(x, y))
    return 1 - 6 * d / (n * (n * n - 1))

if __name__ == "__main__":
    vals = [value(bits(n)) for n in XIANTIAN]
    print("   values along Shao Yong's sequence: {} ... {}".format(
        vals[:6], vals[-3:]))
    print("   sequence is 63, 62, ..., 0: {}".format(
        vals == list(range(63, -1, -1))))
    order = "qian dui li zhen xun kan gen kun".split()
    print("   trigram order values: {}".format(
        [sum(b << (2 - i) for i, b in enumerate(TRI[t])) for t in order]))
    square = [[value(TRI[lo] + TRI[up]) for lo in order] for up in order]
    print("   8 x 8 square, first row (upper Qian): {}".format(square[0]))
    kw_vals = [value(bits(n)) for n in range(1, 65)]
    print("   rank correlation of King Wen order with binary value:"
          " {:+.3f}".format(spearman(list(range(64)), kw_vals)))
    print("\nReading: Shao Yong's sequence and square are exactly binary")
    print("counting, read from the bottom line. The received King Wen order")
    print("is a different principle altogether: pairs by reversal and")
    print("complement (p01 of Chapter 1), with no trend in binary value.")
#    values along Shao Yong's sequence: [63, 62, 61, 60, 59, 58] ... [2, 1, 0]
#    sequence is 63, 62, ..., 0: True
#    trigram order values: [7, 6, 5, 4, 3, 2, 1, 0]
#    8 x 8 square, first row (upper Qian): [63, 55, 47, 39, 31, 23, 15, 7]
#    rank correlation of King Wen order with binary value: -0.004
#
# Reading: Shao Yong's sequence and square are exactly binary
# counting, read from the bottom line. The received King Wen order
# is a different principle altogether: pairs by reversal and
# complement (p01 of Chapter 1), with no trend in binary value.

Reading each hexagram with yang as 1 and yin as 0 and the bottom line as the highest digit, Shao Yong’s sequence is exactly 63, 62 … 0; the Before-Heaven order of the trigrams, Qian, Dui, Li, Zhen, Xun, Kan, Gen, Kun, is exactly 7 down to 0; and each row of the square pairs one upper trigram with the eight lower ones. In other words, the Before-Heaven diagrams are six-digit binary counting.

Evidence

Bouvet and Leibniz. In 1701 the Jesuit Joachim Bouvet, in China, sent Shao Yong’s diagrams to Leibniz; in his Explanation of Binary Arithmetic, published in 1703, Leibniz pointed out that they agree with his binary notation (Leibniz 1703; Perkins 2004). This is a correct observation about structure; it does not show that Shao Yong used binary arithmetic, nor that binary numbers have any divinatory meaning.

The received King Wen order follows a different principle altogether: the program shows a rank correlation of −0.004 with binary value, almost zero; Chapter 1 showed that its principle is pairing by reversal and complement.

The origins of the Zi Wei Dou Shu

Note

Attribution and date. Zi Wei Dou Shu is traditionally attributed to Chen Tuan (Xiyi) of the late Five Dynasties and early Song. An early text that can be dated is the three-juan Zi Wei Dou Shu in the Ming Supplement to the Daoist Canon of the Wanli era, author unknown (Anonymous 1607); the Complete Book of Zi Wei Dou Shu in circulation today is a later compilation. The placement verses of Chapter 5 follow the chart rules in common use today and are checked against known values in the usual placement tables. The placement verses and the rule for starting the flowing months have been checked against the edition relied on; schools differ in details (the handling of intercalary months, how the flowing months start).

Hypothesis · not established

The author’s interpretation (not established): the main-star structure of Zi Wei Dou Shu — one star placed by a division with a parity correction, one star its reflection, the rest fixed translations — shows a designer at home with modular arithmetic and symmetry, and can be read alongside the congruence calculations of calendrical astronomy of the same period. What would show the reading to be inapt: evidence that the rules accumulated step by step as rules of thumb with no unified arithmetical design, in which case the reading is only a modern reconstruction.

Summary

The number of the great expansion in the Appended Statements gives every step of the yarrow method but no probabilities; the three-to-one ratio is a mathematical consequence of the procedure. Shao Yong’s Before-Heaven diagrams are six-digit binary counting read from the bottom line, a structure pointed out by Bouvet and Leibniz between 1701 and 1703; the King Wen order is almost uncorrelated with binary value. Zi Wei Dou Shu is attributed to Chen Tuan, and an early datable text appears in the Ming Daoist canon; the book’s placement rules follow common practice, with the points that need checking against an edition marked.

References

Anonymous. 1607. Ziwei Doushu [Zi Wei Dou Shu], 3 Juan, in the Wanli Supplement to the Daoist Canon (Wanli Xu Daozang). In Chinese; Author Unknown, Traditionally Attributed to Chen Tuan.
Leibniz, Gottfried Wilhelm. 1703. “Explication de l’arithmétique Binaire.” Histoire de l’Académie Royale Des Sciences, Avec Les Mémoires de Mathématique et de Physique, 85–89.
Lynn, Richard John. 1994. The Classic of Changes: A New Translation of the i Ching as Interpreted by Wang Bi. Columbia University Press.
Perkins, Franklin. 2004. Leibniz and China: A Commerce of Light. Cambridge University Press.
Smith, Richard J. 2008. Fathoming the Cosmos and Ordering the World: The Yijing (i Ching, or Classic of Changes) and Its Evolution in China. University of Virginia Press.
Wilhelm, Richard. 1967. The i Ching or Book of Changes. 3rd ed. Translated by Cary F. Baynes. Princeton University Press.
Zhu Xi. 2002. Introduction to the Study of the Classic of Change (i-Hsueh Ch’i-Meng). Translated by Joseph A. Adler. Global Scholarly Publications.

Fan, Y. (2026). Six-Dimensional Hypercube Walks, Hexagram Mutation Markov Chains and Modular Star-Palace Lattices: Boolean Cube Spectral Gaps, Yarrow-versus-Coin Probability Biases and Twelve-Palace Dihedral Projections [六维超立方体游走、卦变马尔可夫链与模运算星宫晶格] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090176 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).