5D Library › 纳甲装卦与奇门遁甲排盘的组合计算 · English

第二章 六亲、六神与旬空

六亲是 Z5 上的差

装卦的下一步是六亲:以本宫的五行为「我」,看每一爻地支的五行与我的生克。同我为兄弟,我生为子孙,我克为妻财,克我为官鬼,生我为父母 (Wang, n.d.)。在第 66 本的记号下,这就是 ℤ5\mathbb{Z}_5 上的差:以木 0、火 1、土 2、金 3、水 4,地支五行减去宫五行模 5,0 到 4 依次对应兄弟、子孙、妻财、官鬼、父母。

推导

# Chapter 2. Six relatives: the palace element against each line.
# Palaces and najia branches as in p01 and p02 (repeated here, since the
# programs do not import one another). The relative of a line is the
# relation of its branch's element to the palace's element in Z_5
# (wood 0, fire 1, earth 2, metal 3, water 4; "generates" is +1):
#   0 brothers (XD), +1 offspring (ZS), +2 wife-wealth (QC),
#   +3 officer-ghost (GG), +4 parents (FM).
# A hexagram that lacks a relative must borrow it as a "hidden spirit"
# (fu shen) from the pure hexagram of its palace.
TRIGRAMS = {"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)}
ELEMENT = {"Qian": 3, "Dui": 3, "Li": 1, "Zhen": 0, "Xun": 0, "Kan": 4,
           "Gen": 2, "Kun": 2}
MASKS = ((), (1,), (1, 2), (1, 2, 3), (1, 2, 3, 4), (1, 2, 3, 4, 5),
         (1, 2, 3, 5), (5,))
SHI = (6, 1, 2, 3, 4, 5, 4, 3)
START = {"Qian": 0, "Zhen": 0, "Kan": 2, "Gen": 4,
         "Kun": 7, "Xun": 1, "Li": 3, "Dui": 5}
YANG = {"Qian", "Zhen", "Kan", "Gen"}
BRANCH_ELEMENT = (4, 2, 0, 0, 2, 1, 1, 2, 3, 3, 2, 4)
CODES = ("XD", "ZS", "QC", "GG", "FM")
NAME = {v: k for k, v in TRIGRAMS.items()}

def branches(lower, upper):
    def run(t, base):
        step = 2 if t in YANG else -2
        return [(base + step * k) % 12 for k in range(3)]
    return run(lower, START[lower]) + run(upper, START[upper] + 6)

def all_hexagrams():
    for t, bits in TRIGRAMS.items():
        for g, m in enumerate(MASKS):
            h = tuple(b ^ (i + 1 in m) for i, b in enumerate(bits + bits))
            yield h, t, g

def relatives(h, palace):
    bs = branches(NAME[h[:3]], NAME[h[3:]])
    return [CODES[(BRANCH_ELEMENT[b] - ELEMENT[palace]) % 5] for b in bs]

if __name__ == "__main__":
    lines, missing, at_shi, n_kinds = {}, {}, {}, {}
    lacking = 0
    for h, palace, g in all_hexagrams():
        rel = relatives(h, palace)
        for r in rel:
            lines[r] = lines.get(r, 0) + 1
        absent = [c for c in CODES if c not in rel]
        lacking += bool(absent)
        for c in absent:
            missing[c] = missing.get(c, 0) + 1
        n_kinds[5 - len(absent)] = n_kinds.get(5 - len(absent), 0) + 1
        r = rel[SHI[g] - 1]
        at_shi[r] = at_shi.get(r, 0) + 1
    print("   {:24s}".format("relative") + "".join("{:>5s}".format(c)
                                               for c in CODES))
    for label, d in (("on all 384 lines", lines),
                     ("on the 64 world lines", at_shi),
                     ("hexagrams lacking it", missing)):
        print("   {:24s}".format(label) + "".join(
            "{:5d}".format(d.get(c, 0)) for c in CODES))
    print("   hexagrams with all five relatives: {} of 64".format(
        n_kinds.get(5, 0)))
    print("   lacking one or more: {}".format(lacking))
    print("   number of distinct relatives per hexagram: " + ", ".join(
        "{}: {}".format(k, v) for k, v in sorted(n_kinds.items())))
    print("\nReading: the 384 lines are not shared evenly among the five")
    print("relatives (offspring 58, brothers 92), and 44 of the 64")
    print("hexagrams lack at least one, so the hidden-spirit rule is not")
    print("an exception but the usual case.")
#    relative                   XD   ZS   QC   GG   FM
#    on all 384 lines           92   58   74   78   82
#    on the 64 world lines      14   12   15   13   10
#    hexagrams lacking it        6   16   16    8   10
#    hexagrams with all five relatives: 20 of 64
#    lacking one or more: 44
#    number of distinct relatives per hexagram: 3: 12, 4: 32, 5: 20
#
# Reading: the 384 lines are not shared evenly among the five
# relatives (offspring 58, brothers 92), and 44 of the 64
# hexagrams lack at least one, so the hidden-spirit rule is not
# an exception but the usual case.
384 爻中五种六亲的爻数;虚线为五种平均分配时的爻数。

384 爻在五种六亲之间分得并不均匀:兄弟 92 爻,父母 82 爻,官鬼 78 爻,妻财 74 爻,子孙只有 58 爻。更重要的是,64 卦中只有 20 卦六亲俱全,44 卦缺少至少一种(12 卦只有三种六亲,32 卦有四种)。缺少的六亲要从本宫纯卦借来作「伏神」。所以伏神不是偶尔用到的补救,而是大多数卦都要用的常规步骤。

六神:按五行起,不是模 6

六神从初爻往上排:甲乙日起青龙,丙丁日起朱雀,戊日起勾陈,己日起螣蛇,庚辛日起白虎,壬癸日起玄武。十个日干对应六个起点。

推导

# Chapter 2. Six spirits and the void branches as residues.
# Six spirits, from line 1 upward, start by the day stem: jia, yi with
# Qing Long; bing, ding Zhu Que; wu Gou Chen; ji Teng She; geng, xin
# Bai Hu; ren, gui Xuan Wu; then in the order QL ZQ GC TS BH XW.
# Void (kong wang): the sixty days fall into six decades (xun) of ten;
# each decade pairs its ten stems with ten of the twelve branches, and
# the two branches left over are void for that decade.
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
         "gui")
BRANCHES = ("zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen",
            "you", "xu", "hai")
SPIRITS = ("QL", "ZQ", "GC", "TS", "BH", "XW")
START = (0, 0, 1, 1, 2, 3, 4, 4, 5, 5)          # by day stem

def void(k):
    """The two void branches for sexagenary day k (0 = jia-zi)."""
    first = (k % 12 - k % 10 + 10) % 12
    return first, (first + 1) % 12

if __name__ == "__main__":
    cells = ["{}:{}".format(s, SPIRITS[START[i]])
             for i, s in enumerate(STEMS)]
    print("   day stem -> spirit on line 1:")
    print("     " + " ".join(cells[:5]))
    print("     " + " ".join(cells[5:]))
    print("   the start is stem mod 6: {};  it follows the element, with"
          .format(all(START[i] == i % 6 for i in range(10))))
    print("   earth split into wu and ji: {}".format(
        all(START[i] == START[i ^ 1] for i in (0, 2, 6, 8))
        and START[4] != START[5]))
    found = {}
    for k in range(60):
        cover = {(k - k % 10 + j) % 12 for j in range(10)}
        left = tuple(b for b in range(12) if b not in cover)
        assert left == tuple(sorted(void(k)))
        found.setdefault(k // 10, set()).add(left)
    for x in range(6):
        (pair,) = found[x]
        print("   decade from {}-{:5s}: void {} {}".format(
            STEMS[0], BRANCHES[(10 * x) % 12], BRANCHES[pair[0]],
            BRANCHES[pair[1]]))
    pairs = [p for x in range(6) for p in found[x]]
    print("   the six void pairs partition the twelve branches: {}".format(
        sorted(b for p in pairs for b in p) == list(range(12))))
    print("   void pair = (branch - stem + 10, +11) mod 12, constant within")
    print("   each decade: checked for all 60 days")
    print("\nReading: the spirits follow the day stem's element, not the")
    print("stem modulo 6; the void branches are the two residues a decade")
    print("of the sixty-cycle misses, and the six decades miss disjoint")
    print("pairs, so every branch is void on exactly ten days in sixty.")
#    day stem -> spirit on line 1:
#      jia:QL yi:QL bing:ZQ ding:ZQ wu:GC
#      ji:TS geng:BH xin:BH ren:XW gui:XW
#    the start is stem mod 6: False;  it follows the element, with
#    earth split into wu and ji: True
#    decade from jia-zi   : void xu hai
#    decade from jia-xu   : void shen you
#    decade from jia-shen : void wu wei
#    decade from jia-wu   : void chen si
#    decade from jia-chen : void yin mao
#    decade from jia-yin  : void zi chou
#    the six void pairs partition the twelve branches: True
#    void pair = (branch - stem + 10, +11) mod 12, constant within
#    each decade: checked for all 60 days
#
# Reading: the spirits follow the day stem's element, not the
# stem modulo 6; the void branches are the two residues a decade
# of the sixty-cycle misses, and the six decades miss disjoint
# pairs, so every branch is void on exactly ten days in sixty.

程序先说明这一对应不是「日干模 6」:按五行,木、火、金、水各两干共用一个起点,唯独土的戊、己分为勾陈与螣蛇两个起点,凑足六个。这是一个以五行为主、在土上分裂的映射。

旬空:陪集的补

六十甲子分为六旬,每旬十天。一旬的十个天干依次配上十个连续的地支,十二地支中剩下两个,就是这一旬的空亡。程序验证:对第 kk 天(甲子为 0),空亡的第一个地支是 (kmod⁡12−kmod⁡10+10)mod⁡12(k \bmod 12 – k \bmod 10 + 10) \bmod 12,第二个是它的下一位;在一旬之内这个值不变。六旬的空亡依次为戌亥、申酉、午未、辰巳、寅卯、子丑,恰好不重叠地分完十二地支。所以每个地支在六十天中恰有十天为空,即六分之一。

注

结构上的含义。 旬空是六十甲子这个循环群的结构,不是额外的规则:一旬是 ℤ60\mathbb{Z}_{60} 中连续十个元素,它们的地支是 ℤ12\mathbb{Z}_{12} 中连续的十个余数,空亡就是剩下的两个。

小结

六亲是地支五行与宫五行在 ℤ5\mathbb{Z}_5 上的差。384 爻中子孙最少、兄弟最多;64 卦中 44 卦缺少至少一种六亲,伏神是常态。六神按日干五行起,土分戊己,不是模 6 的余数。旬空是每旬十个连续地支之外的两个余数,六旬的空亡恰好分完十二地支。

参考文献

Wang, Hongxu. n.d. Bushi Zhengzong [the Orthodox Lineage of Divination]. In Chinese; Qing Dynasty.

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