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

Chapter 1. The Lo Shu, the Flight Path and the Dihedral Group

The Lo Shu and the flight path

The Lo Shu places 1 to 9 in nine palaces: south 9, north 1, east 3, west 7, south-east 4, south-west 2, north-east 8, north-west 6, centre 5, so that every row, column and diagonal sums to 15. Xuankong flying-star charts move numbers along a fixed path: centre, north-west, west, north-east, south, north, south-west, east, south-east. Read in Lo Shu numbers, this path is exactly 5, 6, 7, 8, 9, 1, 2, 3, 4.

A flying-star chart is fixed by its centre number cc and its direction. Flown forward, the kk-th palace along the path holds c+kc + k; flown backward, c−kc – k; both taken mod 9 and written 1 to 9. Since the kk-th palace has Lo Shu number 5+k5 + k, a chart maps each Lo Shu number xx to c+(x−5)c + (x – 5) or c−(x−5)c – (x – 5). In other words, all flying-star charts are the eighteen maps x↦x+tx \mapsto x + t and x↦−x+tx \mapsto -x + t on the cyclic group ℤ9\mathbb{Z}_9, which form the dihedral group of order 18 (Dummit and Foote 2004).

Calculation

# Chapter 1. p01: The Lo Shu, the flight path and the group D9.
# The Lo Shu places 1 to 9 in the nine palaces (north at the bottom):
#     SE 4   S 9   SW 2
#     E  3   C 5   W  7
#     NE 8   N 1   NW 6
# Flying stars move along the fixed path C, NW, W, NE, S, N, SW, E, SE,
# which visits the palaces in Lo Shu order 5, 6, 7, 8, 9, 1, 2, 3, 4.
# A chart with centre star c, flown forward, puts c + k at the k-th
# palace of the path; flown backward, c - k (numbers taken mod 9 and
# written 1 to 9). Since the k-th palace has Lo Shu number 5 + k, a
# chart is the map x -> c + (x - 5) or x -> c - (x - 5) applied to the
# Lo Shu: the 18 maps x -> +x + t and x -> -x + t on Z9, which form
# the dihedral group of order 18. The program checks this, finds the
# order of each kind of map, counts which charts are magic squares,
# and lists the period charts of the 180-year cycle of nine periods.
LOSHU = {"SE": 4, "S": 9, "SW": 2, "E": 3, "C": 5, "W": 7,
         "NE": 8, "N": 1, "NW": 6}
PATH = ["C", "NW", "W", "NE", "S", "N", "SW", "E", "SE"]
GRID = [["SE", "S", "SW"], ["E", "C", "W"], ["NE", "N", "NW"]]

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

def fly(c, forward=True):
    return {p: norm(c + k if forward else c - k)
            for k, p in enumerate(PATH)}

def is_magic(ch):
    rows = [[ch[p] for p in r] for r in GRID]
    sums = [sum(r) for r in rows] + [sum(c) for c in zip(*rows)]
    sums += [rows[0][0] + rows[1][1] + rows[2][2],
             rows[0][2] + rows[1][1] + rows[2][0]]
    return len(set(sums)) == 1

def order(f):
    x = list(range(1, 10))
    y, n = [f(v) for v in x], 1
    while y != x:
        y, n = [f(v) for v in y], n + 1
    return n

if __name__ == "__main__":
    print("   path visits Lo Shu numbers:", [LOSHU[p] for p in PATH])
    ok = all(fly(c, fw)[p] == norm(c + s * (LOSHU[p] - 5))
             for c in range(1, 10) for fw, s in ((True, 1), (False, -1))
             for p in PATH)
    print("   every chart equals x -> c +/- (x - 5) on the Lo Shu:", ok)
    charts = {tuple(sorted(fly(c, fw).items()))
              for c in range(1, 10) for fw in (True, False)}
    print("   distinct charts: {}".format(len(charts)))
    print("   order of x -> x + 1: {}; of x -> -x + t: {}".format(
        order(lambda v: norm(v + 1)), order(lambda v: norm(-v + 3))))
    magic = [(c, fw) for c in range(1, 10) for fw in (True, False)
             if is_magic(fly(c, fw))]
    print("   magic squares among the 18:", magic)
    print("\n   period  years          chart (SE S SW / E C W / NE N NW)")
    for p in range(1, 10):
        ch = fly(p)
        y0 = 1864 + 20 * (p - 1)
        txt = " / ".join(" ".join(str(ch[q]) for q in r) for r in GRID)
        print("   {:6d}  {} to {}   {}".format(p, y0, y0 + 19, txt))
    print("   nine periods of 20 years: {} years".format(9 * 20))
#    path visits Lo Shu numbers: [5, 6, 7, 8, 9, 1, 2, 3, 4]
#    every chart equals x -> c +/- (x - 5) on the Lo Shu: True
#    distinct charts: 18
#    order of x -> x + 1: 9; of x -> -x + t: 2
#    magic squares among the 18: [(5, True), (5, False)]
#
#    period  years          chart (SE S SW / E C W / NE N NW)
#         1  1864 to 1883   9 5 7 / 8 1 3 / 4 6 2
#         2  1884 to 1903   1 6 8 / 9 2 4 / 5 7 3
#         3  1904 to 1923   2 7 9 / 1 3 5 / 6 8 4
#         4  1924 to 1943   3 8 1 / 2 4 6 / 7 9 5
#         5  1944 to 1963   4 9 2 / 3 5 7 / 8 1 6
#         6  1964 to 1983   5 1 3 / 4 6 8 / 9 2 7
#         7  1984 to 2003   6 2 4 / 5 7 9 / 1 3 8
#         8  2004 to 2023   7 3 5 / 6 8 1 / 2 4 9
#         9  2024 to 2043   8 4 6 / 7 9 2 / 3 5 1
#    nine periods of 20 years: 180 years

The program checks this identity and confirms exactly 18 distinct charts; the translation x↦x+1x \mapsto x + 1 has order 9 and each reflection x↦−x+tx \mapsto -x + t order 2. Of the 18 charts only the two with 5 at the centre, the Lo Shu itself flown forward and its backward twin, are magic squares; the others lose the “fifteen every way” property through the wrap-around. In the cycle of three eras and nine periods each period lasts 20 years, 180 years in all; period 9 runs from 2024 to 2043, and its period chart has 9 at the centre.

The 216 ordinary charts and four classes

A house chart has three layers: the period chart (the period number at the centre, flown forward); the mountain-star chart, whose centre is the period-chart number in the sitting palace; and the facing-star chart, whose centre is the number in the facing palace. Each side chart flies forward or backward according to the polarity of the mountain in the same position (earth, heaven or man) within the palace whose Lo Shu number is that centre number; when it is 5, the Lo Shu number of the palace where the 5 stands is used instead. This book’s polarity convention: in the cardinal palaces (1, 3, 7, 9) the earth, heaven and man mountains are yang, yin, yin; in the corner palaces (2, 4, 6, 8), yin, yang, yang.

Charts fall into four classes by where the period star lands: prosperous mountain, prosperous facing (the mountain-star period star at the sitting, the facing-star one at the facing); mountain up, water down (the reverse); double stars at the facing (both at the facing); double stars at the sitting (both at the sitting).

Calculation

# Chapter 1. p02: All 216 charts and their four classes.
# A house chart for period P and sitting mountain m has three layers:
# the period chart (P in the centre, flown forward); the mountain-star
# chart, whose centre is the period-chart number n found in the
# sitting palace; and the facing-star chart, whose centre is the
# number found in the facing palace. Each side chart flies forward or
# backward by the polarity of the mountain in the same position
# (earth, heaven or man) within the palace whose Lo Shu number is n;
# when n = 5, the palace where the 5 stands is used instead. The
# twenty-four mountains are listed from ren clockwise in pinyin; the
# facing mountain is the one opposite, in the same position.
# Classes, by where the period star P falls in the two side charts:
#   wang shan wang xiang: mountain star P sits, facing star P faces;
#   shang shan xia shui: the reverse of that;
#   shuang xing hui xiang / hui zuo: both P at the facing / sitting.
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"

if __name__ == "__main__":
    base, m, f, sit, face = chart(8, 1)
    print("   check, period 8, zi sitting: mountain star {} and facing star"
          .format(m["S"]))
    print("   {} at the facing palace S -> {}".format(
        f["S"], category(8, 1)))
    names = ["wang shan wang xiang", "shang shan xia shui",
             "shuang xing hui xiang", "shuang xing hui zuo"]
    print("\n   period   wang-wang   shang-xia   hui xiang   hui zuo")
    tot = collections.Counter()
    for p in range(1, 10):
        c = collections.Counter(category(p, i) for i in range(24))
        tot.update(c)
        print("   {:6d} {:11d} {:11d} {:11d} {:9d}".format(
            p, *[c[n] for n in names]))
    print("   {:>6s} {:11d} {:11d} {:11d} {:9d}".format(
        "all", *[tot[n] for n in names]))
    print("\n   shares of 216: " + ", ".join(
        "{:.4f}".format(tot[n] / 216) for n in names))
    for p in (8, 9):
        ws = [MOUNTAINS[i] for i in range(24) if category(p, i) == names[0]]
        print("   period {}, wang shan wang xiang sitting mountains:"
              .format(p))
        print("     " + (" ".join(ws) if ws else "none"))
    print("\nReading: the four classes exhaust all 216 charts, because")
    print("a side chart flown forward always carries P to the palace")
    print("opposite its start, and flown backward keeps it there. The")
    print("class of a chart is fixed by two polarities and nothing else.")
#    check, period 8, zi sitting: mountain star 8 and facing star
#    8 at the facing palace S -> shuang xing hui xiang
#
#    period   wang-wang   shang-xia   hui xiang   hui zuo
#         1           0           0          12        12
#         2           6           6           6         6
#         3           6           6           6         6
#         4           6           6           6         6
#         5          12          12           0         0
#         6           6           6           6         6
#         7           6           6           6         6
#         8           6           6           6         6
#         9           0           0          12        12
#       all          48          48          60        60
#
#    shares of 216: 0.2222, 0.2222, 0.2778, 0.2778
#    period 8, wang shan wang xiang sitting mountains:
#      chou xun si wei qian hai
#    period 9, wang shan wang xiang sitting mountains:
#      none
#
# Reading: the four classes exhaust all 216 charts, because
# a side chart flown forward always carries P to the palace
# opposite its start, and flown backward keeps it there. The
# class of a chart is fixed by two polarities and nothing else.

The program first checks a familiar example: for period 8 sitting at zi and facing wu, both stars in the facing palace Li are 8, double stars at the facing. Of the 216 ordinary charts, prosperous mountain, prosperous facing and mountain up, water down have 48 each (0.2222 each), double stars at the facing and at the sitting 60 each (0.2778 each). In period 8 the prosperous charts sit at chou, xun, si, wei, qian and hai; periods 1 and 9 have no ordinary chart of either of the first two classes, while period 5 has only those two.

The four classes exhaust all charts because of one simple algebraic fact: a side chart flown forward always carries the period star to the palace opposite its starting palace, and flown backward leaves it there. The mountain-star chart starts from the period-chart number in the sitting palace, so whether its period star is “at the sitting or at the facing” depends only on the direction it flies; likewise for the facing stars. The class of every chart is therefore fixed by two polarities and by nothing else.

The flying-star chart for period 9, sitting zi and facing wu. Large numbers: period chart; top left: mountain stars; top right: facing stars; sitting and facing palaces shaded.
Charts of each class in the nine periods (24 per period).

Note

What this is, and what it is not. These counts are properties of a permutation table and say nothing about the fortune of a house. They show that once the path, the polarities and the centring rules are fixed, the configuration is a determined arithmetic result; other conventions give other tables.

Summary

Flying-star charts are affine permutations on the cyclic group of order nine, and the eighteen charts form a dihedral group. The 216 ordinary charts split into four classes by where the period star lands, with shares and per-period distributions that can be computed exactly; the class depends only on the directions of the mountain-star and facing-star charts.

References

Dummit, David S., and Richard M. Foote. 2004. Abstract Algebra. 3rd ed. John Wiley; Sons.

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