关于「编译:把规则句变成谓词、决策表与决策树」,《专著蒸馏与技能包工程》给出的定量结论是什么?
结论:编译把抽取单变成三种可运行的形式:原子谓词、决策表、决策树。比较词决定开闭,三位写手对同一条定金规则的三种写法,在 8000 元这一个点上分别是完备、冲突与缺口;本书只接受左闭右开的切法,并为每个阈值配三个边界样本。单位与浮点要先钉死:0.3 读成 30,加急费就从 2040 元变成 204000 元;底线 0.2 的毛利率判断,用错一种写法就会误拒,而底线 0.35 恰好看不出来。手册五条规则展开到 32 格上,有 12 格冲突、1 格缺口,首条命中的优先次序加一个拒绝分支把它们全部收住,同时报告每条规则被遮蔽了多少格。信息增益会被标识类字段骗到满分,增益比也拦不住,只能在建树之前按模式排除;决策树能从案例里复现规则,却会把一条规则复制到多个分支,所以书里写明的规则一律编译成决策表。编译报告与边界黄金样本交给第四章,变成发布前的校验门槛。
数据口径:书中样本全部虚构,定价与成交规则只写一般框架,不是法律或合规意见。 全书按证据分级标注每一条说法,以《荀子·劝学》考辨工具与积累,所有计算由书中程序生成,作者的判断一律写进假说框并写明什么结果会推翻它。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.2, 0.3, 0.35, 2040, 204000, 30
| price 2000 cost 1300 floor 0.35: exact margin 7/20, below floor False | |
| (p - c) / p | 0.35 below floor False |
| 1 - c / p | 0.35 below floor False |
| price 1000 cost 800 floor 0.2: exact margin 1/5, below floor False | |
| (p - c) / p | 0.2 below floor False |
| 1 - c / p | 0.19999999999999996 below floor True |
| grid: price 1000..20000 step 100, cost step 50; pairs where 1 - c/p flips the floor test | |
| floor 0.1 | 39 flips, first (1000, 900) |
| floor 0.2 | 39 flips, first (1000, 800) |
| floor 0.35 | 0 flips |
| floor 0.45 | 20 flips, first (1000, 550) |
| rush fee on 6800 yuan, rate 0.3 as fraction | 2040 yuan |
| rush fee on 6800 yuan, rate 30% as percent | 2040 yuan |
| rush fee on 6800 yuan, rate 30 bare number | 204000 yuan |
| round(0.125, 2) | 0.12 decimal half-up = 0.13 |
| round(0.375, 2) | 0.38 decimal half-up = 0.38 |
| round(2.675, 2) | 2.67 decimal half-up = 2.68 |
| round(1.005, 2) | 1.0 decimal half-up = 1.01 |
| ten payments of 0.1 yuan: running total 0.9999999999999999, fsum 1.0, integer fen 100 | |
| 0.1 + 0.2 = | 0.3: False; Fraction: True |
查看完整验算程序
# Chapter 3. p33: Units, binary floats and rounding at a compiled threshold.
# The fictional handbook says "decline any order whose gross margin is below 0.35". Two algebraically
# equal margin formulas can give different floats; exact Fractions never do, and whether the float
# version misfires depends on the floor itself, so one passing threshold proves nothing. Then: the same
# rush fee read as a fraction, a percent and a bare number; Python's round() (half to even, on the
# binary value) versus decimal ROUND_HALF_UP on the decimal string; and a running float total versus
# fsum and integer fen.
import math
from decimal import Decimal, ROUND_HALF_UP
from fractions import Fraction
if __name__ == "__main__":
for price, cost, floor in ((2000, 1300, "0.35"), (1000, 800, "0.2")):
m1, m2, m3 = (price - cost) / price, 1 - cost / price, 1 - Fraction(cost, price)
print(" price {} cost {} floor {}: exact margin {}, below floor {}".format(
price, cost, floor, m3, m3 < Fraction(floor)))
print(" (p - c) / p = {!r:22s} below floor {}".format(m1, m1 < float(floor)))
print(" 1 - c / p = {!r:22s} below floor {}".format(m2, m2 < float(floor)))
print(" grid: price 1000..20000 step 100, cost step 50; pairs where 1 - c/p flips the floor test")
for floor in ("0.1", "0.2", "0.35", "0.45"):
bad = [(p, c) for p in range(1000, 20001, 100) for c in range(0, p, 50)
if (1 - c / p < float(floor)) != (1 - Fraction(c, p) < Fraction(floor))]
first = ", first {}".format(bad[0]) if bad else ""
print(" floor {:4s}: {:2d} flips{}".format(floor, len(bad), first))
fee = 6800
for label, rate in (("0.3 as fraction", Fraction(3, 10)), ("30% as percent", Fraction(30, 100)),
("30 bare number", Fraction(30))):
print(" rush fee on {} yuan, rate {:15s} -> {} yuan".format(fee, label, fee * rate))
for x in ("0.125", "0.375", "2.675", "1.005"):
print(" round({}, 2) = {} decimal half-up = {}".format(
x, round(float(x), 2), Decimal(x).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)))
tenths, running = [0.1] * 10, 0.0
for t in tenths: # a naive running total, kept only to show the drift
running += t
print(" ten payments of 0.1 yuan: running total {!r}, fsum {!r}, integer fen {}".format(
running, math.fsum(tenths), sum([10] * 10)))
print(" 0.1 + 0.2 == 0.3: {}; Fraction: {}".format(0.1 + 0.2 == 0.3,
Fraction(1, 10) + Fraction(2, 10) == Fraction(3, 10)))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《专著向智能体技能包无损蒸馏、规则可执行化编译与系统自进化工程》第 3 章「编译:把规则句变成谓词、决策表与决策树」(版本 0.1.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-150 · v0.1.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026150,
author = {Fan, Yafu},
title = {Lossless Distillation of Monographs into Agent Skill Packs, Executable Rule Compilation and Self-Evolving Systems},
year = {2026},
publisher = {5D Library},
edition = {0.1.0},
note = {DOI pending}
}