关于「定位的代数:关联矩阵、零空间与结账窗口」,《四柱复式守恒代数》给出的定量结论是什么?

结论:程序列出了零空间的一组基,每一行都是一种「余额完全不变的错误」。第一行:T01 少记 45000 分,同时 T02 多记 45000 分。这两笔都是「现金借、预收订金贷」,一笔少一笔多,现金与预收订金两个账户的余额都不变。第二行:T01 与 T09 各多记 20000 分;T01 是收订金,T09 是退订金,同时多记同样的数,现金一进一出抵消,预收订金也一贷一借抵消。后面三行分别是两笔采购之间、两笔运费之间、两笔订金之间的互相挪移。

数据口径:本书用可运行的程序说明,单式流水本身不含任何检验:在一个示意日上漏记一笔 1,500.00 元的尾款,表格依旧自洽,只有拿银行余额来比才出现差额。 书中参数为示意;全部计算由书中程序生成;本书属于非个人化的会计、税务或法律建议。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 01, 02, 09, 20000, 45000

entries 12, accounts 9, touched 8, rank 7
invisible directions (null space)5
each line: fen added to each entry's size, balances unchanged
T01-45000 T02:+45000
T01:+20000 T09:+20000
T03-96300 T10:+96300
T05-3500 T11:+3500
T01-30000 T12:+30000
T01 +1/6 with T02 -2/9 moves accounts: none
查看完整验算程序
# Chapter 3. p31: balances see accounts, not entries: the cycle space.
# Model: the day of p12 as an incidence matrix M (rows = accounts,
# columns = entries, entry = its legs). Closing balances are
# b = opening + M x with x the all-ones vector. A vector of relative
# amount errors e changes every balance by M e, so errors with M e = 0
# are invisible to the trial balance and to every account-level match.
# Rank and a null-space basis are computed with exact fractions
# (Gauss-Jordan). Columns sum to zero, so rank <= touched accounts - 1.
from fractions import Fraction as F

ACCTS = ("CASH", "STOCK", "AR", "DEP", "REV", "COGS", "FX", "SHIP",
         "CAP")
DAY = (
    ("T01", (("CASH", 60000), ("DEP", -60000))),
    ("T02", (("CASH", 45000), ("DEP", -45000))),
    ("T03", (("STOCK", 178560), ("CASH", -178560))),
    ("T04", (("FX", 1240), ("CASH", -1240))),
    ("T05", (("SHIP", 12000), ("CASH", -12000))),
    ("T06", (("DEP", 80000), ("AR", 150000), ("REV", -230000))),
    ("T07", (("COGS", 170000), ("STOCK", -170000))),
    ("T08", (("CASH", 150000), ("AR", -150000))),
    ("T09", (("DEP", 20000), ("CASH", -20000))),
    ("T10", (("STOCK", 96300), ("CASH", -96300))),
    ("T11", (("SHIP", 3500), ("CASH", -3500))),
    ("T12", (("CASH", 30000), ("DEP", -30000))),
)


def matrix():
    m = [[F(0)] * len(DAY) for _ in ACCTS]
    for c, (_, legs) in enumerate(DAY):
        for a, amt in legs:
            m[ACCTS.index(a)][c] = F(amt)
    return m


def rref(m):
    m = [row[:] for row in m]
    pivots, r = [], 0
    for c in range(len(m[0])):
        p = next((i for i in range(r, len(m)) if m[i][c] != 0), None)
        if p is None:
            continue
        m[r], m[p] = m[p], m[r]
        piv = m[r][c]
        m[r] = [x / piv for x in m[r]]
        for i in range(len(m)):
            if i != r and m[i][c] != 0:
                f = m[i][c]
                m[i] = [x - f * y for x, y in zip(m[i], m[r])]
        pivots.append(c)
        r += 1
    return m, pivots


def null_basis(m):
    red, piv = rref(m)
    free = [c for c in range(len(m[0])) if c not in piv]
    basis = []
    for f in free:
        v = [F(0)] * len(m[0])
        v[f] = F(1)
        for r, c in enumerate(piv):
            v[c] = -red[r][f]
        basis.append(v)
    return basis


if __name__ == "__main__":
    m = matrix()
    touched = [a for a, row in zip(ACCTS, m) if any(row)]
    _, piv = rref(m)
    print("entries {}, accounts {}, touched {}, rank {}".format(
        len(DAY), len(ACCTS), len(touched), len(piv)))
    basis = null_basis(m)
    print("invisible directions (null space) = {}".format(len(basis)))
    print("each line: fen added to each entry's size, balances unchanged")
    for v in basis:
        terms = []
        for i, x in enumerate(v):
            if x != 0:
                size = max(a for _, a in DAY[i][1])
                terms.append("{}:{:+d}".format(DAY[i][0], int(x * size)))
        print("  " + "  ".join(terms))
    e = [F(0)] * len(DAY)
    e[0], e[1] = F(1, 6), F(-2, 9)
    shift = [0] * len(ACCTS)
    for r, row in enumerate(m):
        for c in range(len(DAY)):
            shift[r] += row[c] * e[c]
    moved = [a for a, s in zip(ACCTS, shift) if s != 0]
    print("T01 +1/6 with T02 -2/9 moves accounts: {}".format(
        ",".join(moved) if moved else "none"))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《四柱结算与复式记账的守恒代数、代购流水零差错对账不变量母典》第 3 章「定位的代数:关联矩阵、零空间与结账窗口」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-318 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026318,
  author    = {Fan, Yafu},
  title     = {The Conservation Algebra of Four-Pillar Settlement and Double-Entry Bookkeeping: Invariants for Error-Free Reconciliation of Buying-Agent Ledgers},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论