5D Library › Four-Pillar Calendrical Computation and Formal Rule Engines · 中文

Preface: A Chart Is a Program That Can Be Checked

Note

This is not fortune telling, nor advice on any decision; please read this first. This book studies the mathematical structure of the calendar calculations and judgement rules of four-pillar charts: Julian days and congruences, time conversion, error propagation, group actions, weighted graphs and agreement statistics. The rules are taken from the Ziping art, 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.

A four-pillar chart first does calendar work, turning the year, month, day and hour of birth into four pairs of stems and branches; then it judges, computing from these eight characters the ten gods, the hidden stems and the strength of the day master. The first half is astronomy and calendar calculation, with a single correct answer once the conventions are stated; the second half is a rule engine whose results depend on parameters. Both halves can be written as programs, and once written, three questions can be asked. Do different programs give the same birth different charts? Does a birth time a few minutes off change the chart? Do the parameters of different schools give the same chart opposite judgements?

The book continues Volume 37 (the modular arithmetic of the sexagenary calendar) and Volume 60 (the equation of time and the solar terms), 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 the day pillar as a residue of the Julian day and the “five tigers” and “five rats” rules as affine maps modulo 10. Chapter 2 compares three conventions for the zi hour and computes the difference between clock time and true solar time city by city. Chapter 3 computes how often a timing error changes the hour, day, month and year pillars, gives the conditional probabilities a “boundary check” needs, and shows that the starting age of the luck cycles is piecewise linear between solar terms. Chapter 4 writes the ten gods as the group ℤ5×ℤ2\mathbb{Z}_5 \times \mathbb{Z}_2 and the hidden stems as weight vectors over the five elements. Chapter 5 writes the judgement of strength as scoring on a weighted graph and measures, under three parameter sets, how far the verdicts strong, weak and “follow” agree. Chapter 6 compares two chart engines city by city and gives test vectors that any two engines can check against each other. Chapter 7 reads the Yuanhai ziping, the Sanming tonghui and the Ditian sui. Chapter 8 gives a four-step check, the sample size of an agreement study and a pre-registered matching test.

Claims corrected after checking

  1. Day and hour pillars have closed formulas. The day pillar’s index is (Julian day + 49) modulo 60; the hour stem is 2×(day stemmod⁡5)+hour branch2 \times (\text{day stem} \bmod 5) + \text{hour branch} modulo 10, matching the five-rats verse entry by entry (p01, p02).
  2. The early and late zi hours affect one birth in twenty-four, but combined with true solar time two engines disagree far more often. By clock time the three zi-hour conventions differ only between 23:00 and 24:00, 0.0417 of births (p03); if one engine reads the clock and the other true solar time, at least one pillar differs for 0.1043 of births in Shanghai and 0.6463 in Kuala Lumpur (p12).
  3. Timing errors mainly affect the hour pillar. A uniform error of up to 15 minutes either way makes the hour pillar wrong with probability 0.06250 and the day pillar with 0.00521; the month and year pillars are orders of magnitude less affected (p05).
  4. A “boundary check” can be written as a table. With an error of standard deviation 15 minutes, a birth time must lie about 25 minutes from the edge of its double-hour before the chance of a wrong hour pillar falls below 0.05; 0.412 of each double-hour falls in the zone that should be flagged (p06).
  5. The starting age of the luck cycles is a straight line between solar terms and jumps at each term. Three days count as one year, so a 30-minute error moves it by only 2.5 days; but a birth one minute either side of a term can move it by as much as 10.48 years (p07). The glosses “one day for four months, one double-hour for ten days” assume a year of 360 days (p14).
  6. The ten gods are ℤ5×ℤ2\mathbb{Z}_5 \times \mathbb{Z}_2, not a distance along the order of the stems. The table of ten gods is a Latin square that depends only on the difference of elements and on whether the polarities match (p08).
  7. Verdicts of strong and weak agree only moderately across reasonable parameters. Cohen’s κ between three parameter sets is 0.553 to 0.622 pair by pair, and all three agree on only 0.684 of charts; the share of “follow” charts lies between 0.022 and 0.121 (p10). Moving the hour by one double-hour changes the verdict for 0.127 of charts (p11).

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 stems and branches in pinyin (jia, zi and so on).

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 (four-pillar charts, six-line hexagram casting, 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 of divinatory prediction and no advice on any 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). Four-Pillar Calendrical Computation and Formal Rule Engines: Julian-Day Sexagenary Cycles, Midnight-Boundary Disagreements, Birth-Time Sensitivity Bounds and Weighted-Graph Strength Scoring [四柱排盘的历法计算与规则引擎] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090180 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).