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

Chapter 6. How Often the Patterns Occur, How Conventions Disagree, and Neighbouring Hours

Punishment and tomb

Qimen judgement relies heavily on “patterns”: a given symbol falling on a given palace. On the heaven plate the two most used kinds are the “six yi punish” (wu on Zhen 3, ji on Kun 2, geng on Gen 8, xin on Li 9, ren on Xun 4, gui on Xun 4) and the “three qi in the tomb”. Common books give the tomb rule in at least three ways: the usual “yi on Kun, bing on Qian, ding on Gen”; “yin and yang share life and death”, with ding entombed with bing in xu (Qian 6); and “yang dies where yin is born”, with yi entombed in xu (Qian 6). The next program counts these patterns over all 1,080 bureau-hours.

Calculation

# Chapter 6. How often the named patterns occur, and under which rules.
# Heaven plate as in p08: each outer star carries the earth-plate symbol
# of its home palace round the ring; the centre's symbol rides with Rui.
# Patterns read on the heaven plate (palace numbers):
#   "six yi punish" (ji xing): wu on 3, ji on 2, geng on 8, xin on 9,
#     ren on 4, gui on 4;
#   "three qi in the tomb" (ru mu), three printed conventions:
#     common      yi on 2, bing on 6, ding on 8
#     same-life   yi on 2, bing on 6, ding on 6  (yin and yang stems
#                 share their tomb)
#     yang-dies   yi on 6, bing on 6, ding on 8  (yin stems take the
#                 tomb of the opposite cycle)
SYMBOLS = ("wu", "ji", "geng", "xin", "ren", "gui", "ding", "bing", "yi")
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
         "gui")
RING = (1, 8, 3, 4, 9, 2, 7, 6)
LEADER = ("wu", "ji", "geng", "xin", "ren", "gui")
PUNISH = {"wu": 3, "ji": 2, "geng": 8, "xin": 9, "ren": 4, "gui": 4}
TOMB = {"common": {"yi": 2, "bing": 6, "ding": 8},
        "same-life": {"yi": 2, "bing": 6, "ding": 6},
        "yang-dies": {"yi": 6, "bing": 6, "ding": 8}}

def nine(x):
    return (x - 1) % 9 + 1

def outer(p):
    return 2 if p == 5 else p

def heaven(b, yang, k):
    e = {s: nine(b + i) if yang else nine(b - i)
         for i, s in enumerate(SYMBOLS)}
    lead, stem = LEADER[k // 10], STEMS[k % 10]
    r = (RING.index(outer(e[lead if stem == "jia" else stem]))
         - RING.index(outer(e[lead]))) % 8
    where = {}
    for s, p in e.items():
        src = 2 if p == 5 else p
        where[s] = RING[(RING.index(src) + r) % 8]
    return where

def flags(where):
    punish = any(where[s] == p for s, p in PUNISH.items())
    tomb = {c: any(where[s] == p for s, p in t.items())
            for c, t in TOMB.items()}
    return punish, tomb

if __name__ == "__main__":
    rows = [flags(heaven(b, y, k)) for b in range(1, 10) for y in (1, 0)
            for k in range(60)]
    n = len(rows)
    print("   {:,d} bureau-hours".format(n))
    print("   six yi punish somewhere on the heaven plate: {:.4f}".format(
        sum(p for p, _ in rows) / n))
    for c in TOMB:
        print("   a qi in the tomb, {:9s} rule: {:.4f}".format(
            c, sum(t[c] for _, t in rows) / n))
    names = list(TOMB)
    for i in range(3):
        for j in range(i + 1, 3):
            d = sum(t[names[i]] != t[names[j]] for _, t in rows) / n
            print("   tomb verdict differs, {} vs {}: {:.4f}".format(
                names[i], names[j], d))
    print("\nReading: some 'punishment' is on the heaven plate in more")
    print("than half of all charts and a qi is in a tomb in about a third.")
    print("The three printed tomb rules disagree about a given chart for")
    print("between a fifth and two fifths of all bureau-hours.")
#    1,080 bureau-hours
#    six yi punish somewhere on the heaven plate: 0.5296
#    a qi in the tomb, common    rule: 0.3426
#    a qi in the tomb, same-life rule: 0.3361
#    a qi in the tomb, yang-dies rule: 0.3315
#    tomb verdict differs, common vs same-life: 0.2102
#    tomb verdict differs, common vs yang-dies: 0.1944
#    tomb verdict differs, same-life vs yang-dies: 0.4046
#
# Reading: some 'punishment' is on the heaven plate in more
# than half of all charts and a qi is in a tomb in about a third.
# The three printed tomb rules disagree about a given chart for
# between a fifth and two fifths of all bureau-hours.
Share of bureau-hours with a punishment or a qi in the tomb on the heaven plate (tomb under three rules).

Some “six yi punish” is on the heaven plate in 0.5296 of bureau-hours, more than half; a qi is in the tomb in 0.3426, 0.3361 and 0.3315 under the three rules, about a third each. Similar frequencies do not mean similar verdicts: for the same bureau-hour the three rules disagree, pair by pair, in 0.2102, 0.1944 and 0.4046 of cases. Whether a given chart “has a qi in the tomb” gets the opposite answer from another book with a chance of one in five to two in five.

How Tian Qin is handled. In the program the stem of the central palace five, carried by Tian Qin, turns together with Tian Rui and is counted in the clash and tomb tallies like any other.

The five non-meeting hours: verse and formula

The “five non-meeting hours” are the double-hours whose stem controls the day stem with the same polarity (the seven-killings relation). By the five-rats formula of Volume 66 the hour stem is 2×(day stemmod⁡5)+hour branch2 \times (\text{day stem} \bmod 5) + \text{hour branch} modulo 10, and the seven-killings stem is the day stem plus 6; solving this congruence gives each day’s non-meeting hours.

Calculation

# Chapter 6. The "five non-meeting hours" from the five-rats formula.
# An hour is "non-meeting" when its stem controls the day stem with the
# same polarity (the seven-killings relation): hour stem = day stem + 6
# (mod 10). With the hour stem 2 (D mod 5) + h (mod 10) for branch h,
# this is solvable in h for every day, and twice when the stem returns
# at the hai and xu hours. The verse as usually printed lists one hour
# per day stem.
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
         "gui")
BRANCHES = ("zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen",
            "you", "xu", "hai")
VERSE = ("geng-wu", "xin-si", "ren-chen", "gui-mao", "jia-yin", "yi-chou",
         "bing-zi", "ding-you", "wu-shen", "ji-wei")

def hours_of(d):
    return ["{}-{}".format(STEMS[(2 * (d % 5) + h) % 10], BRANCHES[h])
            for h in range(12)]

if __name__ == "__main__":
    total = 0
    for d in range(10):
        bad = [x for x in hours_of(d) if x.split("-")[0] == STEMS[(d + 6)
                                                                  % 10]]
        total += len(bad)
        mark = "" if bad == [VERSE[d]] else "   <- verse lists {}".format(
            VERSE[d])
        print("   {:4s} day: {}{}".format(STEMS[d], " ".join(bad), mark))
    print("   non-meeting hours among 10 x 12 = 120 day-hours: {} = {:.4f}"
          .format(total, total / 120))
    print("\nReading: the verse is the five-rats formula solved for the")
    print("seven-killings stem; it lists the first solution only. On ji")
    print("and geng days the same stem comes round again in the xu or hai")
    print("hour, so the formula gives a second non-meeting hour that the")
    print("verse omits.")
#    jia  day: geng-wu
#    yi   day: xin-si
#    bing day: ren-chen
#    ding day: gui-mao
#    wu   day: jia-yin
#    ji   day: yi-chou yi-hai   <- verse lists yi-chou
#    geng day: bing-zi bing-xu   <- verse lists bing-zi
#    xin  day: ding-you
#    ren  day: wu-shen
#    gui  day: ji-wei
#    non-meeting hours among 10 x 12 = 120 day-hours: 12 = 0.1000
#
# Reading: the verse is the five-rats formula solved for the
# seven-killings stem; it lists the first solution only. On ji
# and geng days the same stem comes round again in the xu or hai
# hour, so the formula gives a second non-meeting hour that the
# verse omits.

The solutions agree with the usual verse (“on a jia day geng-wu, on a yi day xin-si …”) day by day, with two exceptions: on ji and geng days the same stem comes round again in the xu or hai hour, so the formula gives a second non-meeting hour (yi-hai on ji days, bing-xu on geng days) that the verse does not list. Of the 120 combinations of day stem and hour branch, 12 are non-meeting hours, 0.1000.

Neighbouring hours

Volume 66 showed how timing errors affect the four pillars. For Qimen the question is: within one bureau, how different are the charts of two neighbouring double-hours in their patterns?

Calculation

# Chapter 6. One double-hour of timing error: does the chart change?
# For every bureau-hour k (0-59) the heaven plate (p08, p11) is compared
# with the next hour k + 1 of the same bureau. We count how often the
# fu yin flag, the "punishment" flag and the common-rule "tomb" flag
# change, i.e. how much a reading built on these flags depends on which
# side of a double-hour boundary a birth or a question falls.
SYMBOLS = ("wu", "ji", "geng", "xin", "ren", "gui", "ding", "bing", "yi")
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
         "gui")
RING = (1, 8, 3, 4, 9, 2, 7, 6)
LEADER = ("wu", "ji", "geng", "xin", "ren", "gui")
PUNISH = {"wu": 3, "ji": 2, "geng": 8, "xin": 9, "ren": 4, "gui": 4}
TOMB = {"yi": 2, "bing": 6, "ding": 8}

def nine(x):
    return (x - 1) % 9 + 1

def outer(p):
    return 2 if p == 5 else p

def chart(b, yang, k):
    e = {s: nine(b + i) if yang else nine(b - i)
         for i, s in enumerate(SYMBOLS)}
    lead, stem = LEADER[k // 10], STEMS[k % 10]
    r = (RING.index(outer(e[lead if stem == "jia" else stem]))
         - RING.index(outer(e[lead]))) % 8
    where = {s: RING[(RING.index(outer(p)) + r) % 8] for s, p in e.items()}
    return (r == 0,
            any(where[s] == p for s, p in PUNISH.items()),
            any(where[s] == p for s, p in TOMB.items()))

if __name__ == "__main__":
    changes = [0, 0, 0]
    pairs = 0
    for b in range(1, 10):
        for y in (1, 0):
            for k in range(59):
                a, c = chart(b, y, k), chart(b, y, k + 1)
                pairs += 1
                for i in range(3):
                    changes[i] += a[i] != c[i]
    for name, c in zip(("fu yin", "punishment", "tomb (common)"), changes):
        print("   {:14s} flag changes between neighbouring hours: {:.4f}"
              .format(name, c / pairs))
    print("   (over {:,d} pairs of neighbouring bureau-hours)".format(pairs))
    print("\nReading: each of these flags changes between one double-hour")
    print("and the next for two fifths to more than half of all pairs, so")
    print("a reading built on them depends heavily on exact timing.")
#    fu yin         flag changes between neighbouring hours: 0.4030
#    punishment     flag changes between neighbouring hours: 0.5499
#    tomb (common)  flag changes between neighbouring hours: 0.4840
#    (over 1,062 pairs of neighbouring bureau-hours)
#
# Reading: each of these flags changes between one double-hour
# and the next for two fifths to more than half of all pairs, so
# a reading built on them depends heavily on exact timing.

Of the 1,062 pairs of neighbouring double-hours within a bureau, the fu yin flag changes in 0.4030, the punishment flag in 0.5499 and the tomb flag (usual rule) in 0.4840. A judgement built on these patterns is highly sensitive to the boundary of the double-hour: if the moment of the chart lies near a boundary, the chart of the neighbouring double-hour should be read as well.

Summary

A punishment is on the heaven plate in more than half of all bureau-hours, a qi in the tomb in about a third; the three common tomb rules disagree about the same chart, pair by pair, in 0.1944 to 0.4046 of cases. The five non-meeting hours are the solutions of the five-rats formula, and the verse omits the second solution on ji and geng days. Between neighbouring double-hours, the fu yin, punishment and tomb flags change in two fifths to more than half of all pairs.

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).