常识推理:事实、默认与未知
Common-sense reasoning
检查小型物理模型,把蕴含的答案与可撤回假设分开。
common-sense-reasoning要解决的问题
杯子在托盘上,托盘移动了,杯子也会移动吗?有用的答案依赖句子可能没说出的知识:杯子是否被固定在原处、移动是否平稳,以及是否有别的动作独立移动杯子。
常识推理把不完整描述与关于物体、动作、时间和日常情境的背景知识连接起来。系统需要区分:什么由已知事实推出,什么只在某个假设下成立,什么仍然未知。Davis与Marcus的2015年综述,用日常推理解释了问题为什么横跨语言、感知和机器人;其中评价属于有日期的分析,不是对今天所有模型的测量。Commonsense Reasoning and Commonsense Knowledge in Artificial Intelligence
定义与保证
使用一个刻意受限的模型,包含四个布尔变量:杯子在托盘上、托盘移动、杯子相对房间被固定,以及杯子相对房间移动。规定此处只考虑托盘携带这一种移动机制,不建模滑动、倾洒或独立移动。
分别表示杯子移动、承托、托盘移动与被固定。与证据相容的世界为:
如果所有相容世界对查询一致,这个值由模型与证据蕴含;如果世界之间不一致,答案未知。如果没有相容世界,程序报告输入与模型不一致,而不是利用经典逻辑中的爆炸原理回答所有查询。
已知、但未知时,有两个相容世界。时杯子移动,时杯子不动。“杯子没有被固定”的默认值选择了前一种世界,但这个选择是假设,不是新观察到的事实。默认推理允许在信息变化时撤回部分结论,Reiter对此问题给出了形式处理。这里的单默认过滤器小得多,不计算任意默认逻辑扩展。A Logic for Default Reasoning
最小实现
程序枚举全部16种布尔赋值,保留满足规定规律与显式证据的世界,并记录答案是否依赖默认值。未知证据应省略,不应编码为假。硬事实先于任何默认值被检查。
from itertools import product
VARIABLES = ("on_tray", "tray_moves", "held_fixed", "cup_moves")
def worlds(evidence):
if not isinstance(evidence, dict) or any(k not in VARIABLES for k in evidence):
raise ValueError("evidence must map known variable names to booleans")
if any(type(value) is not bool for value in evidence.values()):
raise ValueError("use true/false facts; omit unknown values")
result = []
for values in product((False, True), repeat=len(VARIABLES)):
world = dict(zip(VARIABLES, values))
carried = world["on_tray"] and world["tray_moves"] and not world["held_fixed"]
if world["cup_moves"] != carried:
continue
if all(world[key] == value for key, value in evidence.items()):
result.append(world)
return result
def infer(evidence, use_default=False, query="cup_moves"):
if query not in VARIABLES:
raise ValueError("unknown query")
if type(use_default) is not bool:
raise ValueError("use_default must be boolean")
compatible = worlds(evidence)
if not compatible:
raise ValueError("facts contradict the declared toy model")
values = {world[query] for world in compatible}
if len(values) == 1:
return {"status":"entailed", "value":next(iter(values)), "assumptions":{}}
if use_default and "held_fixed" not in evidence:
assumed = {"held_fixed":False}
selected = worlds({**evidence, **assumed})
selected_values = {world[query] for world in selected}
if selected and len(selected_values) == 1:
return {"status":"default", "value":next(iter(selected_values)), "assumptions":assumed}
return {"status":"unknown", "value":None, "assumptions":{}}
if __name__ == "__main__":
observed = {"on_tray":True, "tray_moves":True}
print("facts only:", infer(observed))
print("with default:", infer(observed, True))
print("new evidence:", infer({**observed, "held_fixed":True}, True))
print("explicitly free:", infer({**observed, "held_fixed":False}))
facts only: {'status': 'unknown', 'value': None, 'assumptions': {}}
with default: {'status': 'default', 'value': True, 'assumptions': {'held_fixed': False}}
new evidence: {'status': 'entailed', 'value': False, 'assumptions': {}}
explicitly free: {'status': 'entailed', 'value': True, 'assumptions': {}}
初始事实无法确定答案。默认值提供暂定的“移动”,并明确记录held_fixed=False。新增观察held_fixed=True后,得到被蕴含的“不移动”。没有丢失经典逻辑后果:较早的肯定答案被标为默认,而不是蕴含。
程序也可以通过query查询其他变量。例如,根据此玩具规律,杯子移动的证据会迫使其他条件成立。这是选定等价关系的后果,不是关于所有杯子移动的普遍物理规律。
若有个布尔变量,显式世界枚举需要考察种赋值,检查与存储一般都具有指数规模。这里仅有四个变量,所以每个答案都能检查。较大知识系统使用更丰富的表示与推理方法,但仍需要揭示答案背后的假设。
局限与替代
困难往往在于选择模型并获取可靠证据。如果有人独立推动杯子,规定的等价关系可能不足;此时矛盾可以提示修改模型,而不应该成为丢弃正确观察的理由。代码本身不会发现缺失的物理机制。
语言与社会情境知识还带来其他歧义:描述可能省略参照系、时间或例外。解释流畅,不证明这些缺口已经被正确解决。应测试哪些变化应该改变结论,哪些变化不应该。
本例只有一个明确选定的默认值,不涉及默认值之间的竞争。多个默认值可能交互,产生不同扩展或优先级。完整问题还包含不确定性、感知与知识获取。小模型教授证据边界,不是通用常识基准,也不测量是否具有类人理解。
练习与答案
1. 杯子在移动托盘上,但held_fixed未知时,能推出什么?
既不蕴含移动,也不蕴含不移动;模型中两者都可能。
2. 默认答案必须附带什么?
held_fixed=False这一假设,以及与蕴含相区别的标记。
3. 为什么新的held_fixed=True证据可以反转答案?
先前答案依赖可撤回假设,新事实排除了该假设。
4. 玩具规律与可靠观察冲突时,应检查什么?
除了证据,也应检查规律遗漏的机制与假设,可能是模型失效。
研究与下一步
用常识综述理解所需知识的广度,用Reiter论文理解形式默认推理。应把明确规定的玩具规律,与判断哪些背景知识适用这一更难的任务进行比较。
先判断,再看解释
初始证据本身确立了杯子移动的什么结论?
学习目标
- 区分蕴含答案、默认值与未知信息。
- 检验新证据改变的是假设,还是暴露模型局限。
先修与延伸
查看知识关联图 →参考文献
- Commonsense Reasoning and Commonsense Knowledge in Artificial Intelligence
Ernest Davis; Gary Marcus · 2015 - A Logic for Default Reasoning
Raymond Reiter · 1980
版本1 · 编写状态: 已完成记录中的技术复核
查看技术检查记录(AI)
Codex · 2026-09-07 · Codex single-AI-author technical check: bounded primary-source passages, explicit finite models, executed programs, independent mathematical/exhaustive references, input boundaries and bilingual alignment. Not independent human or second-agent review; no full-system research reproduction claimed.
- 单个AI作者进行技术检查:可运行示例、精确或字面参照、明确假设及对应的双语公式与习题。实际执行和渲染结果另行记录。
- 8项测试:两个相容世界、未知与假、显式假设、默认撤回、玩具证据不一致、反向查询,以及81种部分证据赋值在相容完整世界扩展下保留蕴含。
- 逐项对照双语论点、定义、假设、公式、代码、结果及四组练习。均为原创有限教学程序,不声称复现已发表系统或研究基准。冻结前修正目录ID。
- 完整双语正文与对应习题迁入,正式文章状态及SHA绑定。算法篇测试读取正式MDX;历史篇不虚列可执行程序或计算测试。
- 出版导航将已发表主题指向完整文章并移除对应待写措辞,未发表目标保留目录入口;原理、公式、程序与习题未改,重新绑定最终正文SHA。
核对的来源位置:
- Commonsense Reasoning and Commonsense Knowledge in Artificial Intelligence · Author survey physical1–2 introduction and bounded problem framing;2015 publication confirmed by DOI metadata, not a2026 model evaluation.
- A Logic for Default Reasoning · Reuse original default-logic definitions and distinction between missing knowledge and explicit negation; one-filter toy does not implement general extensions.
相关主题