5D Library › Xuankong Flying-Star Permutations, Twenty-Four-Mountain Compass Discretization and Craniofacial Ratio Metrology · 中文

Chapter 2. Sum to Ten, Three Combinations and the Conventions of Replacement

Sum to ten and three combinations

Every palace holds three numbers: the period star, the mountain star and the facing star. Several configurations valued in the tradition can be written as exact conditions. Sum to ten: in all nine palaces the period star and the facing star add to 10 (facing side), or the period star and the mountain star add to 10 (mountain side). Father-and-mother three combinations: in every palace the three numbers belong to one of the sets {1, 4, 7}, {2, 5, 8} or {3, 6, 9}. String of pearls: in every palace the three numbers are consecutive (9 counts as next to 1).

Algebraically, the sum of two charts can be the same in all palaces only if they fly in opposite directions; the sum is then 10 exactly when the two centre numbers add to 1 mod 9.

Calculation

# Chapter 2. p03: He shi and san ban gua among the 216 charts.
# Same chart rules as p02. In each of the nine palaces a chart shows
# three numbers: period star, mountain star, facing star. Patterns:
#   he shi (sum to ten), facing side: period + facing = 10 everywhere;
#   he shi, mountain side: period + mountain = 10 everywhere;
#   san ban gua (father and mother): in every palace the three numbers
#     form one of the sets {1, 4, 7}, {2, 5, 8}, {3, 6, 9};
#   lian zhu (string of pearls): in every palace the three numbers are
#     consecutive, such as 3, 4, 5 (9 counts as next to 1).
# Algebra: a sum is constant over the palaces only if the two charts
# fly in opposite directions; then it equals 10 exactly when the two
# centre numbers sum to 1 mod 9.
import collections

LOSHU = {"SE": 4, "S": 9, "SW": 2, "E": 3, "C": 5, "W": 7,
         "NE": 8, "N": 1, "NW": 6}
PALACE_OF = {v: k for k, v in LOSHU.items()}
PATH = ["C", "NW", "W", "NE", "S", "N", "SW", "E", "SE"]
OPP = {"N": "S", "S": "N", "E": "W", "W": "E", "NE": "SW", "SW": "NE",
       "NW": "SE", "SE": "NW"}
PAL_ORDER = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
MOUNTAINS = ("ren zi gui chou gen yin jia mao yi chen xun si bing wu "
             "ding wei kun shen geng you xin xu qian hai").split()

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

def fly(c, sign):
    return {p: norm(c + sign * k) for k, p in enumerate(PATH)}

def polarity(number, pos):
    cardinal = number in (1, 3, 7, 9)
    return (1, -1, -1)[pos] if cardinal else (-1, 1, 1)[pos]

def side(base, pal, pos):
    n = base[pal]
    ref = LOSHU[pal] if n == 5 else n
    return fly(n, polarity(ref, pos))

def chart(period, i):
    base = fly(period, 1)
    sit = PAL_ORDER[i // 3]
    face = OPP[sit]
    return base, side(base, sit, i % 3), side(base, face, i % 3), sit, face

def category(period, i):
    base, m, f, sit, face = chart(period, i)
    if m[sit] == period and f[face] == period:
        return "wang shan wang xiang"
    if m[face] == period and f[sit] == period:
        return "shang shan xia shui"
    if m[face] == period and f[face] == period:
        return "shuang xing hui xiang"
    return "shuang xing hui zuo"

def palaces(ch):
    base, m, f, sit, face = ch
    return [(base[p], m[p], f[p]) for p in PATH]

def he_shi(trip, k):
    return all(t[0] + t[k] == 10 for t in trip)

def san_ban(trip):
    return all(len({x % 3 for x in t}) == 1 and len(set(t)) == 3
               for t in trip)

def lian_zhu(trip):
    for t in trip:
        s = sorted(t)
        if not any({norm(a), norm(a + 1), norm(a + 2)} == set(s)
                   for a in range(1, 10)):
            return False
    return True

if __name__ == "__main__":
    cnt = collections.Counter()
    by_cat = collections.Counter()
    for p in range(1, 10):
        for i in range(24):
            trip = palaces(chart(p, i))
            for name, ok in (("he shi, facing side", he_shi(trip, 2)),
                             ("he shi, mountain side", he_shi(trip, 1)),
                             ("san ban gua", san_ban(trip)),
                             ("lian zhu", lian_zhu(trip))):
                if ok:
                    cnt[name] += 1
                    by_cat[(name, category(p, i))] += 1
    print("   pattern                  charts   share of 216")
    for name in ("he shi, facing side", "he shi, mountain side",
                 "san ban gua", "lian zhu"):
        print("   {:22s} {:8d} {:14.4f}".format(name, cnt[name],
                                               cnt[name] / 216))
    print("\n   pattern by class (only non-zero cells):")
    for (name, cat), n in sorted(by_cat.items()):
        print("     {:22s} {:22s} {:3d}".format(name, cat, n))
    print("\nReading: each pattern is rare and confined to particular")
    print("classes: he shi needs two charts flying in opposite")
    print("directions with matching centres, and san ban gua and lian")
    print("zhu occur only among the shang shan xia shui charts. These")
    print("are facts about a permutation table, not evidence about")
    print("houses.")
#    pattern                  charts   share of 216
#    he shi, facing side          12         0.0556
#    he shi, mountain side        12         0.0556
#    san ban gua                  16         0.0741
#    lian zhu                     16         0.0741
#
#    pattern by class (only non-zero cells):
#      he shi, facing side    shuang xing hui xiang    8
#      he shi, facing side    wang shan wang xiang     4
#      he shi, mountain side  shuang xing hui zuo      8
#      he shi, mountain side  wang shan wang xiang     4
#      lian zhu               shang shan xia shui     16
#      san ban gua            shang shan xia shui     16
#
# Reading: each pattern is rare and confined to particular
# classes: he shi needs two charts flying in opposite
# directions with matching centres, and san ban gua and lian
# zhu occur only among the shang shan xia shui charts. These
# are facts about a permutation table, not evidence about
# houses.

Among the 216 charts, sum to ten on the facing side and on the mountain side occur 12 times each (0.0556 each), and the father-and-mother and string-of-pearls combinations 16 times each (0.0741 each). They are confined to particular classes: facing-side sum to ten has 8 charts with double stars at the facing and 4 prosperous ones; mountain-side sum to ten has 8 with double stars at the sitting and 4 prosperous ones; both kinds of three combinations occur only among the mountain up, water down charts. These are facts about a permutation table, not evidence about houses.

Replacement charts: two conventions

When a facing lies near the edge between two mountains, many schools switch to a replacement chart: the centre number of each side chart is replaced by the “replacement star” of the corresponding mountain. This book’s replacement table: zi, gui, jia, shen give 1; kun, ren, yi, mao, wei give 2; xu, qian, hai, chen, xun, si give 6; you, xin, chou, gen, bing give 7; yin, wu, geng, ding give 9. Schools differ on how the direction of flight is fixed after replacement. The book compares two explicitly stated conventions: convention A keeps the direction of the ordinary chart; convention B uses the polarity of the replacement number’s own palace.

Calculation

# Chapter 2. p04: Replacement charts (ti gua) under two conventions.
# When a facing lies near the edge of its mountain, the replacement
# method changes the centre number of each side chart: the number n
# is replaced by the replacement star of the mountain in the same
# position within palace n (n = 5: the palace where it stands), from
#   zi gui jia shen -> 1;  kun ren yi mao wei -> 2;
#   xu qian hai chen xun si -> 6;  you xin chou gen bing -> 7;
#   yin wu geng ding -> 9.
# Texts differ on the direction of flight after replacement. Two
# stated conventions: A keeps the direction of the ordinary chart;
# B takes the polarity of the replacement number's own palace. With
# a new centre, the period star may land in neither the sitting nor
# the facing palace: class "other".
import collections

LOSHU = {"SE": 4, "S": 9, "SW": 2, "E": 3, "C": 5, "W": 7,
         "NE": 8, "N": 1, "NW": 6}
PALACE_OF = {v: k for k, v in LOSHU.items()}
PATH = ["C", "NW", "W", "NE", "S", "N", "SW", "E", "SE"]
OPP = {"N": "S", "S": "N", "E": "W", "W": "E", "NE": "SW", "SW": "NE",
       "NW": "SE", "SE": "NW"}
PAL_ORDER = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
MOUNTAINS = ("ren zi gui chou gen yin jia mao yi chen xun si bing wu "
             "ding wei kun shen geng you xin xu qian hai").split()

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

def fly(c, sign):
    return {p: norm(c + sign * k) for k, p in enumerate(PATH)}

def polarity(number, pos):
    cardinal = number in (1, 3, 7, 9)
    return (1, -1, -1)[pos] if cardinal else (-1, 1, 1)[pos]

def side(base, pal, pos):
    n = base[pal]
    ref = LOSHU[pal] if n == 5 else n
    return fly(n, polarity(ref, pos))

def chart(period, i):
    base = fly(period, 1)
    sit = PAL_ORDER[i // 3]
    face = OPP[sit]
    return base, side(base, sit, i % 3), side(base, face, i % 3), sit, face

def category(period, i):
    base, m, f, sit, face = chart(period, i)
    if m[sit] == period and f[face] == period:
        return "wang shan wang xiang"
    if m[face] == period and f[sit] == period:
        return "shang shan xia shui"
    if m[face] == period and f[face] == period:
        return "shuang xing hui xiang"
    return "shuang xing hui zuo"

TI = {}
for names, star in (("zi gui jia shen", 1), ("kun ren yi mao wei", 2),
                    ("xu qian hai chen xun si", 6),
                    ("you xin chou gen bing", 7), ("yin wu geng ding", 9)):
    for n in names.split():
        TI[n] = star

def side_ti(base, pal, pos, conv):
    n = base[pal]
    ref = LOSHU[pal] if n == 5 else n
    c = TI[MOUNTAINS[PAL_ORDER.index(PALACE_OF[ref]) * 3 + pos]]
    sign = polarity(ref, pos) if conv == "A" else polarity(c, pos)
    return fly(c, sign)

def chart_ti(period, i, conv):
    base = fly(period, 1)
    sit = PAL_ORDER[i // 3]
    face = OPP[sit]
    return (base, side_ti(base, sit, i % 3, conv),
            side_ti(base, face, i % 3, conv), sit, face)

def classify(ch, period):
    base, m, f, sit, face = ch
    if m[sit] == period and f[face] == period:
        return "wang shan wang xiang"
    if m[face] == period and f[sit] == period:
        return "shang shan xia shui"
    if m[face] == period and f[face] == period:
        return "shuang xing hui xiang"
    if m[sit] == period and f[sit] == period:
        return "shuang xing hui zuo"
    return "other"

if __name__ == "__main__":
    names = ["wang shan wang xiang", "shang shan xia shui",
             "shuang xing hui xiang", "shuang xing hui zuo", "other"]
    res, cnt, changed = {}, {}, {}
    for conv in ("A", "B"):
        cnt[conv], changed[conv] = collections.Counter(), 0
        for p in range(1, 10):
            for i in range(24):
                ch = chart_ti(p, i, conv)
                cnt[conv][classify(ch, p)] += 1
                changed[conv] += ch[1:3] != chart(p, i)[1:3]
                res[(conv, p, i)] = ch[1:3]
    print("   charts that differ from the ordinary chart: A {}, B {}"
          .format(changed["A"], changed["B"]))
    print("\n   class                    ordinary   conv. A   conv. B")
    plain = collections.Counter(category(p, i) for p in range(1, 10)
                                for i in range(24))
    for n in names:
        print("   {:22s} {:10d} {:9d} {:9d}".format(
            n, plain[n], cnt["A"][n], cnt["B"][n]))
    same = sum(1 for p in range(1, 10) for i in range(24)
               if res[("A", p, i)] == res[("B", p, i)])
    print("\n   charts on which A and B agree: {} of 216 ({:.4f})".format(
        same, same / 216))
    print("\nReading: the replacement method changes most charts, and")
    print("the two conventions disagree on half of them. A reading that")
    print("depends on which convention a master follows is a property")
    print("of the convention, which must be stated before any test.")
#    charts that differ from the ordinary chart: A 182, B 182
#
#    class                    ordinary   conv. A   conv. B
#    wang shan wang xiang           48        24        16
#    shang shan xia shui            48         4         2
#    shuang xing hui xiang          60        14        19
#    shuang xing hui zuo            60        14        19
#    other                           0       160       160
#
#    charts on which A and B agree: 108 of 216 (0.5000)
#
# Reading: the replacement method changes most charts, and
# the two conventions disagree on half of them. A reading that
# depends on which convention a master follows is a property
# of the convention, which must be stated before any test.

Each convention changes 182 of the 216 charts. Once a centre number changes, the period star may land at neither the sitting nor the facing, a fifth class, “other”, which has 160 charts under both conventions. The other counts differ: convention A gives 24 prosperous charts and 4 mountain up, water down; convention B gives 16 and 2. The two conventions agree on only 108 charts, exactly half (0.5000).

Hypothesis · not established

Testable consequence. If one replacement convention really corresponds to an observable difference, then in a pre-registered test the outcome difference between classes defined by that convention should be clearly larger than between classes defined by the other. What would show this wrong: if neither convention’s classes relate to outcomes, or the two do not differ, the dispute between conventions has no empirical content.

Summary

Sum to ten, the three combinations and the string of pearls are rare and confined to particular classes. Replacement changes most charts, and the two conventions agree on only half of them: any claim that depends on replacement charts must first state which convention it uses.

Fan, Y. (2026). Xuankong Flying-Star Permutations, Twenty-Four-Mountain Compass Discretization and Craniofacial Ratio Metrology: Lo-Shu Orbit Cycles, Magnetic Declination Flip Rates and Landmark Measurement Error Propagation [玄空飞星置换代数、二十四山罗盘离散化与骨相比例计量] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090215 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).