5D Library › Najia Hexagram Encoding and Qimen Dunjia Combinatorial Engines · 中文

Preface: The Combinatorics of Two Divination Engines

Note

This is not divination, nor advice on timing or any other decision; please read this first. This book studies the mathematical structure of the rules for dressing a six-line hexagram with najia and for setting up a time-family Qimen Dunjia chart: group actions on binary vectors, modular arithmetic and cosets, calendar calculation, permutation groups and combinatorial counts. The rules are taken from traditional divination, but the book neither claims nor tests that any reading comes true; Chapter 8 gives a plan for a test, not the result of one. All data are generated by the programs printed in the book.

Najia six-line divination and Qimen Dunjia are the two most “engineered” of the divinatory arts: the first dresses the sixty-four hexagrams with stems, branches, six relatives, six spirits and void branches; the second turns a double-hour into an arrangement on three turning plates. Both are deterministic algorithms on finite sets and can be written in full as programs. Once written, one can ask: what structure lies inside the rules? Which verses follow from a few numbers? How often do different calendar and school conventions give the same moment different charts?

The book continues Volume 62 (Luoshu and rotating plates as permutations) and Volume 64 (the hexagrams as the Boolean cube), and recalls them only where they overlap. Like the other books of 5D Library, it tries first to refute, then sets bounds, and reports negative results as they are.

What the book contains

Chapter 1 writes Jing Fang’s eight palaces as pure hexagrams XOR eight masks, and the najia as a closed form generated by three numbers per trigram. Chapter 2 computes how the six relatives fall on the 384 lines, how the six spirits start, and the coset structure of the void branches. Chapter 3 writes the 72 bureau numbers of the solar terms in closed form and compares the split-supplement and intercalation calendars hour by hour. Chapter 4 writes the earth plate as a dihedral group and the heaven plate as a rotation of the eight outer palaces. Chapter 5 adds the human and spirit plates, counts the charts that actually occur, and finds the permutation group the plate moves generate. Chapter 6 computes how often the named patterns — punishment, tomb, fu yin, fan yin — occur, how far conventions disagree about them, and how they change from one double-hour to the next. Chapter 7 reads the Jing shi yizhuan and the Rhapsody of the Old Fisherman. Chapter 8 gives a budget of conventions and a pre-registered matching test.

Claims corrected after checking

  1. The eight palaces are pure hexagrams XOR eight masks, and the world line is fixed by upper XOR lower. The 64 hexagrams fall into exactly 8 palaces; the XOR of upper and lower trigrams tells a hexagram’s generation, and the codes of the first six generations form a Gray code (p01). The najia table is generated by three numbers per trigram: starting branch, direction and stem (p02).
  2. The six spirits are not “the day stem modulo 6”. They start by the element of the day stem, with the two earth stems wu and ji split, so the way ten stems map onto six starting spirits is not a residue modulo 6 (p04).
  3. The void branches are the complement of a coset. Each decade of ten days pairs with only ten branches, and the two left over are void; the six decades’ void pairs share out the twelve branches without overlap (p04).
  4. Hidden spirits are the rule, not the exception. 44 of the 64 hexagrams lack at least one of the six relatives (p03).
  5. The seventy-two bureau numbers come from eight starting palaces and two step rules, and 1,080 is 18 bureaus times 60 double-hours. The 72 numbers of the verse follow entirely from a closed form (p05, p14).
  6. The split-supplement and intercalation calendars give different bureaus for about three double-hours in ten. Over every double-hour from 2000 to 2029, the bureau differs in 0.3067 of them, and even the dun (yin or yang) in 0.0219 (p06).
  7. The earth plate is a dihedral group; the plate moves generate the whole symmetric group, but charts use only 72 arrangements. Every yin earth plate is a yang plate turned half way round (p07, p10); the 1,080 bureau-hours give only 727 distinct combinations of the three plates (p09).
  8. Fu yin is far commoner than the “jia hours”. The heaven plate is in fu yin for 0.2222 of bureau-hours, more than twice the 0.1000 of jia hours (p08).
  9. The three printed tomb rules disagree about a sizeable share of charts. Pairwise disagreement lies between 0.1944 and 0.4046 (p11); the verse of the five non-meeting hours lists only the first solution of its formula (p12).

How to read the boxes

Marked boxes separate published evidence, runnable Python calculations (16 programs, standard library only, each run when the book is built with its real output printed beneath it), classical sources, notes and the author’s hypotheses; every hypothesis states what result would show it wrong. To keep the code whole in print, the programs write hexagram names, stems, branches, stars, doors and spirits in pinyin or English abbreviations.

Disclosure

The author uses the works of 5D Library, including this book, as the methodological basis of his community courses, the 5D Ascension Cards (Dimensional Shift Card Decks) and the Yafu AI knowledge base, and develops and runs paid online reading software and services built on traditional divinatory symbol systems (najia six-line divination, Qimen Dunjia charts, four pillars, Zi Wei Dou Shu, chart matching and date selection); the models of this book are the mathematical basis of those programs’ algorithms, so he has a direct commercial interest in its subject. The book promotes no software, course, card deck or service, uses no user data from the author’s businesses, and accepts no sponsorship. All its models are offered for mathematical study and teaching only and constitute no promise that any reading comes true and no advice on timing or any other decision. The test in Chapter 8 must be carried out with pre-registered code by an independent analyst who has no financial relationship with the author and does not know where the readings came from, and its results will be published whether positive or negative.

Fan, Y. (2026). Najia Hexagram Encoding and Qimen Dunjia Combinatorial Engines: Eight-Palace Group Actions, Sexagenary Void Cosets, Split-Supplement versus Intercalation Divergences and Nine-Palace Rotor Permutations [纳甲装卦与奇门遁甲排盘的组合计算] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090182 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).