第十三篇 Reasoning 推理
第46章 Reasoning
Reasoning(推理)是 ICAI 在已经形成事实、对象、关系、规则、经验和当前状态的基础上,对已知信息进行组合、判断、演算和推导,从而获得新的认知结果的过程。
如果前面的 Cognitive Chain 是:
Information
↓
Perception
↓
Elements
↓
Objects
↓
Relations
↓
Understanding
↓
Memory
那么进入 Reasoning 后:
Memory
↓
Reasoning
↓
Decision
↓
Action
Reasoning 的核心不是产生语言,而是:
从已知认知结构中,通过规则和关系推导出新的结果。
1. Reasoning 定义
Reasoning 可以定义为:
ICAI 根据当前问题和已有的 Facts、Objects、Relations、Rules、Experience 等认知资源,通过确定性的或条件性的逻辑计算获得推理结果的过程。
基本结构:
已知信息
↓
Facts
Objects
Relations
Rules
Experience
↓
Reasoning
↓
新结论
例如:
Fact:
Battery_A.level = 20
Rule:
IF battery.level < 30
THEN battery.state = low
Reasoning:
20 < 30
Result:
Battery_A.state = low
这里并没有产生新的原始信息。
系统只是根据:
事实 + 规则
得出了:
新的结论
因此:
Reasoning
=
Known Information
+
Logic / Rules
+
Calculation
→
New Conclusion
2. 推理输入
Reasoning 并不是凭空进行。
它需要明确的输入。
主要输入包括:
Current Information
Facts
Objects
Relations
Properties
States
Rules
Conditions
Experience
Memory
Time
Location
可以形成:
Reasoning Input
│
┌──────────┬───────┼───────┬──────────┐
↓ ↓ ↓ ↓ ↓
Facts Objects Relations Rules Experience
│ │ │ │ │
└──────────┴───────┴───────┴──────────┘
↓
Reasoning
不同任务所需要的输入并不完全相同。
例如判断设备是否需要充电:
Object
+
Battery Property
+
Current State
+
Rule
而判断某服务是否适合当前用户:
Object
+
Properties
+
Relations
+
Conditions
+
Facts
+
Experience
因此 Reasoning Engine 首先需要确定:
当前推理需要哪些认知资源。
3. Facts
Facts 是推理最基础的输入之一。
例如:
Fact 001:
Battery_A.level = 20
Fact 002:
Battery_A.type = rechargeable
Fact 003:
Battery_A.state = active
这些事实组成:
FactSet
{
Battery_A.level = 20,
Battery_A.type = rechargeable,
Battery_A.state = active
}
然后规则:
IF level < 30
THEN state = low_battery
进行计算:
20 < 30
得到:
Battery_A.state = low_battery
所以:
Facts
↓
提供已知条件
↓
Rules
↓
推导新事实
需要注意:
推理结果不应该直接被当成原始 Fact。
可以区分:
Observed Fact
和:
Derived Fact
例如:
Observed:
Battery_A.level = 20
而:
Derived:
Battery_A.state = low_battery
后者是推理得到的结果。
4. Objects
Object 是 Reasoning 中的基本认知对象。
例如:
Object:
Battery_A
它具有:
Properties
Relations
States
History
例如:
Battery_A
├── level = 20
├── type = rechargeable
├── state = active
└── device = Device_A
推理可以围绕对象进行:
Object
↓
Property
↓
Condition
↓
Rule
↓
Result
例如:
Object:
Battery_A
Property:
level = 20
Rule:
level < 30
得到:
Battery_A
state = low_battery
对象推理还可以涉及多个对象:
Customer_A
↓
uses
↓
Service_A
如果:
Rule:
IF Customer uses Service
THEN Customer has_service_history
那么:
Customer_A
has_service_history
Service_A
就可以成为新的推理结果。
因此 Object 是推理的载体。
5. Relations
Relations 描述对象之间的连接。
基本结构:
Object_A
↓
Relation
↓
Object_B
例如:
Company_A
↓
provides
↓
Service_A
推理可以通过关系进行传播。
例如已知:
Company_A
provides
Service_A
又知道:
Service_A
supports
FurnitureDelivery
规则:
IF
A provides B
AND
B supports C
THEN
A provides_service_for C
因此:
Company_A
provides
Service_A
Service_A
supports
FurnitureDelivery
可以推导:
Company_A
supports
FurnitureDelivery
这就是关系推理。
基本形式:
A → R1 → B
B → R2 → C
↓
Rule
↓
A → R3 → C
因此 Relation 是 ICAI 建立多对象推理链的重要结构。
6. Rules
Rules 是 Reasoning 的核心控制结构。
规则规定:
在什么条件下,可以得到什么结论。
最基本的规则:
IF Condition
THEN Conclusion
例如:
IF battery.level < 30
THEN battery.state = low
多个条件:
IF
battery.level < 30
AND
device.state = active
THEN
device.state = needs_charge
多个对象:
IF
Customer_A uses Service_A
AND
Service_A supports FurnitureDelivery
THEN
Customer_A can_use FurnitureDelivery
Rule 的结构
可以定义:
Rule
{
id
conditions
operator
conclusion
priority
state
}
例如:
{
"id": 1001,
"conditions": [
{
"object": "Battery_A",
"property": "level",
"operator": "<",
"value": 30
}
],
"operator": "AND",
"conclusion": {
"object": "Battery_A",
"property": "state",
"value": "low"
},
"priority": 10,
"state": "active"
}
推理过程:
Facts
↓
Rule Conditions
↓
Condition Matching
↓
Condition Satisfied
↓
Rule Activated
↓
Conclusion
如果条件不满足:
Condition
↓
FALSE
↓
Rule 不产生结论
如果信息不足:
Condition
↓
UNKNOWN
↓
等待更多信息
如果条件冲突:
Condition
↓
CONFLICT
↓
进入冲突处理
因此 Reasoning 不应该强行得到结论。
它必须允许:
TRUE
FALSE
UNKNOWN
CONFLICT
等结果。
7. Experience
Experience 为 Reasoning 提供历史行为依据。
Fact 告诉系统:
过去是什么。
Experience 可以告诉系统:
过去这样处理的结果是什么。
例如:
Current Condition:
Furniture
Shenzhen → HongKong
FactMemory:
Service_A supports FurnitureDelivery
ExperienceMemory:
过去选择 Service_A
→ 成功
因此 Reasoning 可以形成:
Fact
+
Current Condition
+
Historical Experience
+
Rule
↓
Reasoning
↓
Candidate Result
经验不能直接替代事实和规则。
例如:
过去 10 次成功
只能说明:
Historical Experience = favorable
不能直接推出:
这次一定成功
因此:
Experience
=
历史依据
Rule
=
逻辑依据
Fact
=
已知事实
Current Condition
=
当前依据
四者可以共同参与推理。
8. 推理过程
Reasoning 的完整过程可以划分为几个步骤。
第一步:确定推理目标
例如:
目标:
判断 Service_A 是否适合当前任务
第二步:获取推理输入
读取:
Facts
Objects
Relations
Rules
Experience
Current State
形成:
ReasoningContext
第三步:建立条件
例如:
object = Furniture
origin = Shenzhen
destination = HongKong
service = Service_A
第四步:匹配条件
通过前面的 Matching:
Object Matching
Property Matching
Relation Matching
State Matching
Time Matching
Location Matching
Condition Matching
得到:
Condition Result
第五步:执行规则
例如:
Rule_001:
IF
Service_A supports Furniture
AND
Service_A supports HongKong
THEN
Service_A is_candidate
第六步:读取经验
查询:
ExperienceMemory
得到:
过去使用 Service_A
→ 成功
第七步:形成结论
综合:
Facts
+
Relations
+
Rules
+
Experience
+
Current Conditions
得到:
Service_A
candidate = true
第八步:记录推理链
例如:
Fact_001
↓
Fact_002
↓
Rule_001
↓
Condition_001
↓
Conclusion_001
最终得到:
ReasoningResult
9. 推理结果
推理结果是 Reasoning 对输入进行逻辑处理后产生的新认知结论。
基本结构:
ReasoningResult
{
goal
conditions
matched_facts
matched_objects
matched_relations
applied_rules
used_experiences
conclusion
state
}
例如:
{
"goal": "service_match",
"matched_facts": [
"Service_A supports Furniture"
],
"matched_relations": [
"Service_A supports HongKong"
],
"applied_rules": [
"Rule_001"
],
"used_experiences": [
"Experience_001"
],
"conclusion": {
"service": "Service_A",
"candidate": true
},
"state": "confirmed"
}
推理结果可以有不同状态:
CONFIRMED
SUPPORTED
POSSIBLE
UNKNOWN
CONFLICT
REJECTED
例如:
条件全部满足
→ CONFIRMED
部分条件满足
→ POSSIBLE
缺少必要信息
→ UNKNOWN
存在相互冲突的规则或事实
→ CONFLICT
因此:
Reasoning 不一定产生肯定答案。
“未知”和“冲突”本身也是有效的推理结果。
10. 推理链
推理链(Reasoning Chain)记录:
结论是如何从已有事实一步一步得到的。
例如:
Fact_001:
Battery_A.level = 20
Rule_001:
IF level < 30
THEN state = low_battery
Condition_001:
20 < 30
Conclusion_001:
Battery_A.state = low_battery
形成:
Fact_001
↓
Condition_001
↓
Rule_001
↓
Conclusion_001
多步骤推理链
例如:
Fact_001:
Company_A provides Service_A
Fact_002:
Service_A supports FurnitureDelivery
Rule_001:
IF A provides B
AND B supports C
THEN A supports C
第一步:
Company_A
↓
provides
↓
Service_A
第二步:
Service_A
↓
supports
↓
FurnitureDelivery
第三步:
Rule_001
最终:
Company_A
↓
supports
↓
FurnitureDelivery
形成:
Fact_001
+
Fact_002
↓
Rule_001
↓
DerivedFact_001
推理链的数据结构
可以定义:
ReasoningChain
{
id,
goal,
steps,
conclusion,
state
}
其中:
steps
[
Fact
Condition
Rule
IntermediateResult
Rule
Conclusion
]
例如:
ReasoningChain
{
"id": "RC001",
"goal": "service_match",
"steps": [
"Fact_001",
"Fact_002",
"Rule_001",
"Condition_001",
"Conclusion_001"
],
"conclusion": "Service_A is suitable",
"state": "confirmed"
}
这样 ICAI 后续不仅知道:
结论是什么
还能够知道:
为什么得到这个结论
这对于:
验证
诊断
冲突处理
错误修复
经验形成
学习
都非常重要。
Reasoning核心模型
第46章可以将 Reasoning 总结为:
Reasoning
│
┌───────────────┼───────────────┐
↓ ↓ ↓
Facts Objects Relations
│ │ │
└───────────────┼───────────────┘
↓
Rules
+
Conditions
+
Experience
↓
Reasoning
↓
┌─────────┴─────────┐
↓ ↓
Conclusion Reasoning Chain
↓ ↓
New Cognition Traceable
更完整的 ICAI 链路:
Information
↓
Perception
↓
Elements
↓
Objects
↓
Relations
↓
Understanding
↓
Memory
│
├── FactMemory
├── LongMemory
└── ExperienceMemory
↓
Reasoning
↓
Decision
↓
Action
↓
Result
↓
Experience
↓
Learning
↓
Memory Update
本章核心定义
Reasoning 是 ICAI 利用 Facts、Objects、Relations、Rules、Conditions、Experience 和 Memory 等已有认知资源,通过匹配、逻辑判断、条件计算和规则推导,形成新结论并记录推理过程的认知机制。
最核心的计算关系:
Known Facts
+
Objects
+
Relations
+
Rules
+
Experience
+
Current Conditions
↓
Reasoning
↓
New Conclusion
↓
Reasoning Chain
因此,Reasoning 在 ICAI 中承担的是:
从“已经知道什么”,推导“根据这些已知条件,现在能够得出什么”。
而下一层 Decision 则进一步解决:
“根据推理结果,现在应该选择什么。”