What does Four Pillars and Double Entry conclude, in numbers, about “The Detection Matrix of Nine Error Types: What the Trial Balance Catches and What It Lets Through”?

Answer: The column headed cases gives the number of forms each type can take on this day. Each of the twelve entries can be left out once, duplicated once or reversed once. Misposting moves each leg of each entry to each account not already in that entry, giving 172 forms; compensating errors take one leg from each of two different entries, add ten yuan to one and subtract ten from the other, giving 286 forms. Altogether there are 581 forms.

Scope of the numbers: With runnable programs this book shows that a single-entry list contains no test of itself: on an illustrative day, leave out a balance payment of 1,500.00 yuan and the spreadsheet stays perfectly consistent; a gap appears only against the bank balance. Parameters are illustrative; all calculations are generated by the book's programs; the book is general analysis, not individualised accounting, tax or legal advice.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 172, 286, 581

typecasesFPTBDELOC
omit entry120.8330.0001.0001.000
duplicate120.8330.0001.0001.000
wrong acct1720.4360.0000.9480.948
reversal120.8330.0001.0001.000
x10 both120.8330.0001.0001.000
compensate2860.4900.0000.7800.780
omit leg250.4001.0001.0000.880
slip leg250.4001.0001.0000.880
same side250.4001.0001.0000.880
all5810.4910.1290.8760.861
Show the full program
# Chapter 2. p21: the detection matrix of nine error types, enumerated.
# Model: the illustrative day of p12. Every error of each type is
# generated exhaustively on that day and the damaged books are run
# through four schemes (FP four pillars on counted cash, TB trial
# balance, DE trial balance plus outside evidence for CASH, STOCK, AR,
# DEP and SHIP; the single-entry list never fires and is not shown).
# LOC = share of cases in which DE names at least one wrong account.
# Error types follow the textbook list of errors a trial balance does
# not reveal, plus the one-sided slips it does reveal. Exact integers.
from itertools import combinations

ACCTS = ("CASH", "STOCK", "AR", "DEP", "REV", "COGS", "FX", "SHIP",
         "CAP")
EXT = ("CASH", "STOCK", "AR", "DEP", "SHIP")
OPEN = {"CASH": 1500000, "STOCK": 420000, "AR": 0, "DEP": -380000,
        "REV": 0, "COGS": 0, "FX": 0, "SHIP": 0, "CAP": -1540000}
DAY = (
    (("CASH", 60000), ("DEP", -60000)),
    (("CASH", 45000), ("DEP", -45000)),
    (("STOCK", 178560), ("CASH", -178560)),
    (("FX", 1240), ("CASH", -1240)),
    (("SHIP", 12000), ("CASH", -12000)),
    (("DEP", 80000), ("AR", 150000), ("REV", -230000)),
    (("COGS", 170000), ("STOCK", -170000)),
    (("CASH", 150000), ("AR", -150000)),
    (("DEP", 20000), ("CASH", -20000)),
    (("STOCK", 96300), ("CASH", -96300)),
    (("SHIP", 3500), ("CASH", -3500)),
    (("CASH", 30000), ("DEP", -30000)),
)


def post(entries):
    bal = dict(OPEN)
    for legs in entries:
        for acct, amt in legs:
            bal[acct] += amt
    return bal


def swap_digits(n):
    s = str(abs(n))
    for i in range(len(s) - 1):
        if s[i] != s[i + 1]:
            t = s[:i] + s[i + 1] + s[i] + s[i + 2:]
            return int(t) if n > 0 else -int(t)
    return n


def legs_of():
    return [(i, j) for i, legs in enumerate(DAY) for j in range(len(legs))]


def edit(i, legs):
    return DAY[:i] + (tuple(legs),) + DAY[i + 1:]


def cases():
    out = {}
    out["omit entry"] = [DAY[:i] + DAY[i + 1:] for i in range(len(DAY))]
    out["duplicate"] = [DAY[:i + 1] + DAY[i:] for i in range(len(DAY))]
    out["reversal"] = [edit(i, [(a, -m) for a, m in DAY[i]])
                       for i in range(len(DAY))]
    out["x10 both"] = [edit(i, [(a, 10 * m) for a, m in DAY[i]])
                       for i in range(len(DAY))]
    om, sl, ss, wr = [], [], [], []
    for i, j in legs_of():
        legs = list(DAY[i])
        a, m = legs[j]
        om.append(edit(i, legs[:j] + legs[j + 1:]))
        sl.append(edit(i, legs[:j] + [(a, swap_digits(m))] + legs[j + 1:]))
        ss.append(edit(i, legs[:j] + [(a, -m)] + legs[j + 1:]))
        for b in ACCTS:
            if b not in [x for x, _ in legs]:
                wr.append(edit(i, legs[:j] + [(b, m)] + legs[j + 1:]))
    out["wrong acct"] = wr
    out["omit leg"] = om
    out["slip leg"] = sl
    out["same side"] = ss
    comp = []
    for (i, j), (k, l) in combinations(legs_of(), 2):
        if i == k:
            continue
        d = list(DAY)
        a, m = d[i][j]
        d[i] = d[i][:j] + ((a, m + 1000),) + d[i][j + 1:]
        b, n = d[k][l]
        d[k] = d[k][:l] + ((b, n - 1000),) + d[k][l + 1:]
        comp.append(tuple(d))
    out["compensate"] = comp
    return out


def rate(k, n):
    return "{:.3f}".format(k / n)


if __name__ == "__main__":
    truth = post(DAY)
    order = ("omit entry", "duplicate", "wrong acct", "reversal",
             "x10 both", "compensate", "omit leg", "slip leg",
             "same side")
    allc = cases()
    print("type         cases     FP     TB     DE    LOC")
    tot = [0, 0, 0, 0, 0]
    for name in order:
        fp = tb = de = loc = 0
        for entries in allc[name]:
            book = post(entries)
            s = 0
            for a in ACCTS:
                s += book[a]
            flagged = [a for a in EXT if book[a] != truth[a]]
            fp += book["CASH"] != truth["CASH"]
            tb += s != 0
            de += (s != 0) or bool(flagged)
            loc += bool(flagged)
        n = len(allc[name])
        for idx, v in enumerate((n, fp, tb, de, loc)):
            tot[idx] += v
        print("{:11s} {:6d} {:>6s} {:>6s} {:>6s} {:>6s}".format(
            name, n, rate(fp, n), rate(tb, n), rate(de, n), rate(loc, n)))
    n = tot[0]
    print("{:11s} {:6d} {:>6s} {:>6s} {:>6s} {:>6s}".format(
        "all", n, rate(tot[1], n), rate(tot[2], n), rate(tot[3], n),
        rate(tot[4], n)))

Single source and citation

Fan, Y. (2026). The Conservation Algebra of Four-Pillar Settlement and Double-Entry Bookkeeping: Invariants for Error-Free Reconciliation of Buying-Agent Ledgers (Version 1.0.0), Chapter 2: The Detection Matrix of Nine Error Types: What the Trial Balance Catches and What It Lets Through. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 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}
}

Other chapter answers in this book