The Evolution of the Heavenly Stems and Earthly Branches and the Transformation of Dun Jia: A Unified Mathematical Metaphysical Study of the Information Capacity in Bazi and Qimen Dunjia
This paper systematically investigates the information-carrying capacity of Bazi (Eight Characters) and Qimen Dunjia (Mystical Gates) as divination systems, starting from the mathematical structure of Taiji, Liangyi, Sixiang, and Bagua in the *Book of Changes*. By analyzing the classical mathematical foundations such as Yin-Yang, Five Phases, the River Chart, and the Luo Script, it aims to provide a unified perspective for measuring and comparing the information density of these two divination arts.

Chapter 3: The Origin of Qimen Dunjia: An Encoding System for Military Strategy and the Heavenly Way
Section 1: The Origin of the Nine Palaces and the Number of the Luo Writing
The spatial foundation of Qimen Dunjia is the Nine Palaces (Jiǔ Gōng). The Nine Palaces originate from the Luo Writing.
The Xici Zhuan states:
"The River produced a chart, Luo produced writing; the Sages took them as models." (Hé chū tú, Luò chū shū, shèngrén zé zhī.)
The arrangement of the Nine Numbers of the Luo Writing:
4 9 2
3 5 7
8 1 6
This is a third-order magic square, where the sum of numbers in every row, column, and main diagonal is fifteen.
The names of the Nine Palaces, according to pre-Qin documents like the Lüshi Chunqiu, Records of Origin (You Shi Lan), relate to the concept of eight directions plus the center. The Nine Palaces correspond to the Eight Trigrams plus the Central Palace:
- Kan (One Palace, North)
- Kun (Two Palace, Southwest)
- Zhen (Three Palace, East)
- Xun (Four Palace, Southeast)
- Zhong (Five Palace, Center)
- Qian (Six Palace, Northwest)
- Dui (Seven Palace, West)
- Gen (Eight Palace, Northeast)
- Li (Nine Palace, South)
This assignment of the Eight Trigrams to the Nine Palaces perfectly matches the numbers of the Luo Writing—Kan trigram in the northern first palace, Kun in the southwestern second palace... Li in the southern ninth palace.
Mathematical characteristics of the Nine Palaces:
- Magic Square Property: Rows, columns, and diagonals all sum to fifteen—this implies that the numerical relationship among the three palaces on any line is "balanced," and the information distribution is uniform.
- Symmetry: Opposite palace numbers sum to ten (1+9, 2+8, 3+7, 4+6)—this implicitly agrees with Yin/Yang symmetry.
- Centrality: Five resides in the center, being half the sum of all diagonals—this is the numerical expression of "Center."
- Rotational Invariance: The Luo Writing has four rotational transformations (0°, 90°, 180°, 270°), forming the cyclic group $C_4$.
The information capacity of the Nine Palaces is based on nine positions $\times$ the content that can be placed in each position = capacity determined by the richness of the content placed.
Section 2: The Origin of the Three Curiosities and Six Instruments
The core symbolic system of Qimen Dunjia includes the "Three Curiosities" (Sān Qí) and the "Six Instruments" (Liù Yí):
Three Curiosities: Yi (乙), Bing (丙), Ding (丁) Six Instruments: Wu (戊), Ji (己), Geng (庚), Xin (辛), Ren (壬), Gui (癸)
Totaling nine Heavenly Stems (Jia 甲 is not used because Jia is the commander, hidden beneath the Six Instruments, hence "Dunjia" or "Escaping Jia").
The method of Jia Hiding:
- Jia Zi hides under Wu.
- Jia Xu hides under Ji.
- Jia Shen hides under Geng.
- Jia Wu hides under Xin.
- Jia Chen hides under Ren.
- Jia Yin hides under Gui.
These six Jia (Jia Zi, Jia Xu, Jia Shen, Jia Wu, Jia Chen, Jia Yin), which are the six leaders of the Sixty Jiazi cycle, are collectively called the "Six Jia." Each of the Six Jia hides under one Instrument, meaning the Six Instruments are the "incarnations" of the Six Jia.
Why must Jia "hide"$20 The Zuo Zhuan, Duke Xuan Year 3 records:
"The position of the Son of Heaven cannot be vacant." (Tiānzǐ zhī wèi, bùkě kuàng yě.)
Jia, the head of the Ten Stems, is like the Son of Heaven. The Son of Heaven does not personally lead the troops but entrusts the generals to carry out his orders—this is the symbolic basis for "Dunjia." Jia hides and does not appear, using the Three Curiosities and Six Instruments as vanguards, like the Son of Heaven hidden in the deep palace dispatching his generals.
From an information science perspective, "hiding" (dùn) means "hiding information"—the information of Jia is not directly presented but expressed indirectly through the Instrument under which it hides. This adds a layer to the system's information hierarchy: the surface information (the Stems displayed by the Six Instruments) and the deep information (the identity of the Jia hidden by the Six Instruments) form a dual-layer encoding, causing the same symbol to carry a double meaning.
The character Qí in the Three Curiosities means "unusual" or "surprise troops." The Guanzi, Minor Officials Chapter (Yòu Guān) states:
"Govern the state with the Orthodox (zhèng); employ troops with the Unusual (qí)." (Yǐ zhèng zhì guó, yǐ qí yòng bīng.)
Laozi, Chapter 67 (in common editions Chapter 57) also states:
"Governing the state with the Orthodox, employing troops with the Unusual, conquering the world without action." (Yǐ zhèng zhì guó, yǐ qí yòng bīng, yǐ wú shì qǔ tiānxià.)
The Three Curiosities are the surprise troops of military strategy. Yi, Bing, and Ding have a special auspicious status in Qimen Dunjia—any palace occupied by the Three Curiosities generally indicates advantage.
Information dimensions of the Three Curiosities and Six Instruments:
- Five Phase and Yin/Yang attributes of the Stems.
- Special identity (Curiosity or Instrument).
- The identity of the Jia hidden by the Instrument (which of the Six Jia).
- The relationship among the Three Curiosities and Six Instruments.
Section 3: The Origin of the Eight Gates
Qimen Dunjia has eight "Gates" (Mén):
Open Gate (Kāimén), Rest Gate (Xiūmén), Life Gate (Shēngmén), Hurt Gate (Shāngmén), Block Gate (Dùmén), Scene Gate (Jǐngmén), Death Gate (Sǐmén), Shock Gate (Jīngmén).
The Eight Gates are assigned to the Eight Palaces (the Central Palace has no gate, temporarily assigned to the Kun Two Palace or Gen Eight Palace).
Meanings of the Eight Gates:
- Open Gate (Qian Six Palace): Initiation, opening.
- Rest Gate (Kan One Palace): Rest, ease.
- Life Gate (Gen Eight Palace): Growth, generation.
- Hurt Gate (Zhen Three Palace): Harm, damage.
- Block Gate (Xun Four Palace): Blockage, sealing off.
- Scene Gate (Li Nine Palace): Scenery, brightness.
- Death Gate (Kun Two Palace): Extinction, ending.
- Shock Gate (Dui Seven Palace): Fear, shock.
Among the Eight Gates, the Open, Rest, and Life Gates are auspicious; the Hurt, Block, and Scene Gates are neutral (some classify Scene Gate as inauspicious; views vary). The Death and Shock Gates are inauspicious.
Information dimensions of the Eight Gates:
- Auspicious/Inauspicious attribute.
- Five Phase attribute (determined by the Palace it occupies).
- Directional attribute (one of the eight directions).
- Temporal attribute (changes with the rotation of the chart).
- Combinational relationship with other symbols (Stars, Spirits, Curiosities/Instruments).
Why establish "Gates"$21 Gates are the pivots of entry and exit. Chapter 1 of the Laozi states:
"Nameless is the beginning of Heaven and Earth; named is the Mother of the myriad things. Thus, constantly without desire, one contemplates their mystery; constantly with desire, one contemplates their manifestations. These two spring from the same source but differ in name; united they are called darkness. Darkness within darkness, the gateway to all mystery." (Wú míng tiāndì zhī shǐ, yǒumíng wànwù zhī mǔ. Gù cháng wú yù yǐ guān qí miào, cháng yǒu yù yǐ guān qí jiǎo. Cǐ liǎng zhě tóng chū ér yì míng, tóng wèi zhī xuán, xuán zhī yòu xuán, zhòng miào zhī mén.)
"The gateway to all mystery" (zhòng miào zhī mén)—the Gate refers to the crucial point for accessing profound principles. Qimen Dunjia is named after "Gate" precisely because it captures the meaning of "pivot." On the human level, the Eight Gates represent the direction and manner of human action—open when needed, rest when needed, generate when needed, block when needed—this is the information of decision-making.
Section 4: The Origin of the Nine Stars
Qimen Dunjia has nine "Stars" (Xīng):
Heavenly Canopy Star (Tiānpéng), Heavenly Root Star (Tiānrúi), Heavenly Rush Star (Tiānchōng), Heavenly Assistant Star (Tiānfǔ), Heavenly Fowl Star (Tiānqín), Heavenly Heart Star (Tiānxīn), Heavenly Pillar Star (Tiānzhù), Heavenly任 Star (Tiānrèn), Heavenly Hero Star (Tiānyīng).
Each of the Nine Stars resides in one Palace:
- Tianpeng (Kan One Palace)
- Tianrui (Kun Two Palace)
- Tianchong (Zhen Three Palace)
- Tianfu (Xun Four Palace)
- Tianqin (Zhong Five Palace)
- Tianxin (Qian Six Palace)
- Tianzhu (Dui Seven Palace)
- Tianren (Gen Eight Palace)
- Tianying (Li Nine Palace)
The names of the Nine Stars are related to the Nine Stars of the Big Dipper. The Seven Stars of the Big Dipper plus the two hidden stars, Left Assistant and Right Auxiliary, combine to make Nine Stars. The Big Dipper held a supreme position in pre-Qin astronomical beliefs.
The Heguanzi, Circular Flow Chapter states:
"When the handle of the Dipper points East, the world enters Spring. When the handle points South, the world enters Summer. When the handle points West, the world enters Autumn. When the handle points North, the world enters Winter." (Dǒu bǐng dōng zhǐ, tiānxià jiē chūn. Dǒu bǐng nán zhǐ, tiānxià jiē xià. Dǒu bǐng xī zhǐ, tiānxià jiē qiū. Dǒu bǐng běi zhǐ, tiānxià jiē dōng.)
The Big Dipper is the pivot of Heaven. Taking the Nine Stars of the Big Dipper as elements of the "Heaven Plate" (Tiānpán) of Qimen Dunjia captures the meaning that the Big Dipper governs the movement of Heaven.
Information dimensions of the Nine Stars:
- Auspicious/Inauspicious attribute.
- Five Phase attribute.
- Original Palace position.
- Position after rotation.
- Combinational relationship with Gates, Curiosities/Instruments, and Spirits.
Auspiciousness of the Nine Stars: Tianxin, Tianren, Tianqin, Tianfu are auspicious stars; Tianchong is neutral (or slightly auspicious); Tianpeng, Tianrui, Tianzhu, Tianying are inauspicious stars.
Section 5: The Origin of the Eight Spirits
Qimen Dunjia has eight "Spirits" (Shén):
Value Symbol (Zhífù), Coiled Serpent (Téngshé), Great Yin (Tàiyīn), Six Harmony (Liùhé), White Tiger (also called Gou Chen 勾陈), Black Tortoise (also called Zhu Que 朱雀), Nine Earths (Jiǔdì), Nine Heavens (Jiǔtiān).
The origin of the Eight Spirits is closely related to ancient astronomical beliefs and the system of "Auspicious and Inauspicious Markers" (Shénshā) derived from Yin and Yang and the Five Phases.
The Zuo Zhuan, Duke Xi Year 5 records the words of the diviner Yan:
"A child's rhyme says: 'On the day of Bing, the Dragon's Tail sets; the uniform vestments are grand; they seize the banner of Guo. The Partridge is blazing, the Heavenly Commander is powerful; fire forms an army in the middle; the Duke of Guo will flee.'"
Terms like "Dragon's Tail" and "Heavenly Commander" reflect the pre-Qin tradition of using astronomical constellations to predict human affairs. The Eight Spirits of Qimen Dunjia inherit this tradition, transforming the astronomical "Spirits" into the arcane "Spirits."
Information dimensions of the Eight Spirits:
- Auspicious/Inauspicious attribute.
- Yin/Yang attribute.
- Intrinsic characteristics (Zhifu governs nobility, Tengshe governs startling changes, Taiyin governs concealment...).
- Palace occupied.
- Combinational relationship with Gates, Stars, Curiosities/Instruments.
Section 6: The Complete Chart Structure of Qimen Dunjia
A single chart in Qimen Dunjia is formed by the superposition of the following layers:
1. Earth Plate (Dìpán, Fixed) Nine Palaces $\times$ Fixed Curiosities/Instruments (The Earth Plate Curiosities/Instruments are determined by the Bureau number, but once set, they do not move).
2. Heaven Plate (Tiānpán, Rotating) Nine Stars + Heaven Plate Curiosities/Instruments (Rotate with the Star carried by the Value Symbol).
3. Man Plate (Rénpán, Rotating) Eight Gates (Rotate with the Gate carried by the Value Embodiment).
4. Spirit Plate (Shénpán, Rotating) Eight Spirits (Rotate with the Value Symbol).
Thus, in a single Qimen Dunjia chart, each palace simultaneously carries four layers of information:
- Earth Plate Curiosities/Instruments (Bottom layer)
- Heaven Plate Star + Heaven Plate Curiosities/Instruments (Second layer)
- Man Plate Gate (Third layer)
- Spirit Plate Spirit (Fourth layer)
Adding the inherent information of the palace itself (Trigram attribute, Five Phase attribute, etc.), each palace is effectively an "information pillar"—vertically superimposed with multiple encodings.
Nine Palaces $\times$ Four Layers of Information = The total information volume of one chart.
This preliminary structure already reveals the information complexity of Qimen Dunjia far exceeds that of ordinary arcane arts. A detailed mathematical comparison will be made in the following sections.
Section 7: Setting the Bureau Number: Eighteen Bureaus for Yin and Yang Escapes
The number of Bureaus in Qimen Dunjia is $18 + 18 = 36$ Bureaus (some argue for repetition; the number of independent bureaus is fewer).
Yang Bureau (Yáng Dùn): Nine Bureaus (from Winter Solstice onwards, Bureaus One to Nine). Yin Bureau (Yīn Dùn): Nine Bureaus (from Summer Solstice onwards, Bureaus Nine down to One).
The establishment of these 18 Bureaus is closely related to the 24 Solar Terms and the 72 Five-Day Periods (Hòu).
Each Solar Term (15 days) is divided into three Yuan periods (Upper, Middle, Lower Yuan), each Yuan lasting 5 days. $24$ Solar Terms $\times 3$ Yuans $= 72$ divisions, corresponding to the 72 Hòu.
Yang Bureau Nine $\times$ Upper/Middle/Lower Yuan $= 27$ Yuan divisions (though in practice, only a portion of these $3 \times 9 = 27$ five-day segments are used). Yin Bureau Nine $\times$ Upper/Middle/Lower Yuan $= 27$ Yuan divisions.
Totaling 54 Yuan divisions$22 The mathematical relationships here are complex and require careful tracing.
In practice, the method for setting the Qimen chart is: Starting from the Yang Bureau from the Winter Solstice, progressing sequentially according to the Yuan period and Solar Term. Starting from the Yin Bureau (Nine) from the Summer Solstice, progressing sequentially.
A new Yuan begins every five days, and the same Bureau is used within that Yuan—but the chart for every shí chén (double-hour) is different (because the Value Symbol rotates with the shí chén). Thus, the information variation in Qimen Dunjia is reflected not only in the "Bureau" level but also in the "Time" level.
Within one Bureau, the chart for each of the 12 shí chén forming a day is different. In fact, one five-day Yuan (60 shí chén) produces 60 different charts.
The mathematics here is crucial:
There are approximately 72 Yuan divisions in a year (5 days each), with 60 shí chén per Yuan. $72 \times 60 = 4,320$ different shí chén charts.
However, because there are 18 Bureaus (Yang Nine + Yin Nine), and each Bureau has variations depending on the shí chén, the actual number of unique charts needs a more precise calculation.
In the mathematical comparison section later, we will analyze this in detail.