关于「反例先行:性质测试、收缩与最小矛盾子集」,《愿望形式化编译》给出的定量结论是什么?
结论:第五章的性质测试在第 4 个随机用例找到折扣规则的反例,增量调试用 33 次判定把十二条约束的矛盾缩到 3 条。
数据口径:书中金额为无币种示意单位,参数为示意,全部计算由书中程序生成;本书是非个人化经营建议,不作个人财务或投资建议,心理学文献只写关联与适用条件,区间下界不是任何收入承诺。 书中以标注框区分已发表的证据、可运行的 Python 计算(22 段程序)、原典与作者的假说。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 33
grid points: 1,365 clauses: 12 full set unsatisfiable: True 1-minimal core (3 clauses, 33 oracle calls): C03 orders >= 200 C04 no ads: visits <= 80 C05 conv <= 2 drop C03 -> still unsat: False drop C04 -> still unsat: False drop C05 -> still unsat: False
查看完整验算程序
# Chapter 5. p52: delta debugging finds the minimal contradictory clauses
# Twelve clauses of a compiled wish over price p, conversion c (percent)
# and visits v (hundreds a month); orders = v * c. The full set has no
# solution on the grid. ddmin (Zeller and Hildebrandt 2002) shrinks it
# to a 1-minimal subset that is still contradictory. Illustrative data.
import itertools
GRID = list(itertools.product(range(20, 62, 2), range(1, 6),
range(40, 170, 10)))
def net(p, c, v):
return v * c * p * 0.55 - 1200
CLAUSES = {
"C01 price <= 40": lambda p, c, v: p <= 40,
"C02 price >= 30": lambda p, c, v: p >= 30,
"C03 orders >= 200": lambda p, c, v: v * c >= 200,
"C04 no ads: visits <= 80": lambda p, c, v: v <= 80,
"C05 conv <= 2": lambda p, c, v: c <= 2,
"C06 net >= 1500": lambda p, c, v: net(p, c, v) >= 1500,
"C07 price != 34": lambda p, c, v: p != 34,
"C08 visits >= 50": lambda p, c, v: v >= 50,
"C09 conv >= 1": lambda p, c, v: c >= 1,
"C10 orders <= 260": lambda p, c, v: v * c <= 260,
"C11 unit margin >= 18": lambda p, c, v: p * 0.55 >= 18,
"C12 orders >= 120": lambda p, c, v: v * c >= 120,
}
NAMES = sorted(CLAUSES)
calls = [0]
def unsat(names):
calls[0] += 1
fs = [CLAUSES[n] for n in names]
return not any(all(f(*x) for f in fs) for x in GRID)
def ddmin(items):
n = 2
while len(items) >= 2:
size = len(items) // n
parts = [items[i * size:(i + 1) * size] for i in range(n - 1)]
parts.append(items[(n - 1) * size:])
for part in parts:
if unsat(part):
items, n = part, 2
break
else:
for part in parts:
rest = [x for x in items if x not in part]
if unsat(rest):
items, n = rest, max(n - 1, 2)
break
else:
if n >= len(items):
break
n = min(len(items), 2 * n)
return items
print("grid points: {:,} clauses: {}".format(len(GRID), len(NAMES)))
print("full set unsatisfiable: {}".format(unsat(NAMES)))
core = ddmin(NAMES)
print("1-minimal core ({} clauses, {} oracle calls):".format(
len(core), calls[0]))
for c in core:
print(" " + c)
for c in core:
rest = [x for x in core if x != c]
print("drop {} -> still unsat: {}".format(c[:3], unsat(rest)))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《创始人模糊愿望形式化编译、约束反演与可执行商业系统生成母典》第 5 章「反例先行:性质测试、收缩与最小矛盾子集」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-414 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026414,
author = {Fan, Yafu},
title = {Formalising Fuzzy Founder Wishes: Constraint Inversion, Falsifiable Spec Synthesis and Executable Revenue System Compilation},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}