考点分布

before2026

  1. Event Calculus (8 times)
  2. Prolog vanilla meta interpreter and variations (6 times)
  3. OWA and CWA in Prolog and Description Logic (4 times)
  4. Rule-based Forward Reasoning and RETE (3 times)
  5. LPAD Distribution Semantics (3 times)
  6. Knowledge Graphs Paradigms vs Semantic Web (2 times)
  7. ALC description logic (2 times)
  8. Rule-based FR vs BR (2)
  9. 3 approaches of Reasoning over time (2)
  10. Cut Operator (twice, but unlikely in recent exams)
  11. Bagof, setof and findall (twice, as Cut Operator)
  12. Negation in Prolog (once)
  13. Disjointness, Exhaustive Decomposition and Partition (once in a recent exam)
  14. Event Calculus modelling exercise (once in a recent exam)
  15. Semantic Networks (once)
  16. LPAD short exercise (once in a very old exam)

题型解答

Event Calculus

1. 核心概念总结 (What is Event Calculus?)

Event Calculus (EC) 是由 Kowalski 和 Sergot (1986) 提出的一种基于逻辑的形式化方法,用于表示和推理随时间变化的事件及其结果。

它的核心思想是:世界的状态(Fluents)由事件(Events)的发生而改变,并且在没有反向事件发生之前,状态保持不变(惯性定律)。

你需要掌握以下两组核心术语:

A. 核心谓词 (The Ontology)

这是考试要求“解释术语”时的必答内容:

  1. HoldsAt(F, T):表示流(Fluent,即随时间变化的状态)F 在时刻 T 是成立(True)的。
  2. Happens(E, T):表示事件 E 在时刻 T 发生了。
  3. Initiates(E, F, T):表示事件 E 的发生,导致了流 F 在时刻 T 开始成立(启动)。
  4. Terminates(E, F, T):表示事件 E 的发生,导致了流 F 在时刻 T 停止成立(终止)。
  5. Clipped(T1, F, T2):表示流 F 在时间段 (T1,T2) 之间被某个事件“截断”了(即变成了 False)。
  6. Initially(F):表示流 F 在初始时刻(Time 0)就是成立的。
B. 核心公理 (The Axioms)

这是 EC 推理的逻辑基础(即“状态何时为真”的规则):


2. 考试题型预测 (Exam Patterns)

根据往年试题(2022年和2023年的多次考试),关于 Event Calculus 的题目非常固定,几乎是送分题。

高频真题 (出现于):

"The candidate is invited to describe the predicates/terminology used in the definition of the Event Calculus Framework." (请考生描述事件演算框架定义中使用的谓词/术语。)

变体 (出现于):

"...having care, in particular, of indicating the framework axioms." (...请特别注意指出框架的公理。)

甚至不需要写代码:虽然课程中有用 Prolog 实现 EC 的练习,但在笔试中,题目通常只要求文字描述(English text description)和逻辑公式,而不是写可运行的 Prolog 代码。


3. 答题思路与模板 (Answering Strategy)

如果考试遇到这道题,建议按以下结构作答(直接背诵):

Step 1: 定义基本概念 首先一句话介绍 EC:“Event Calculus is a logic framework based on points of time, used to reason about events and their effects on the state of the world (fluents).”

Step 2: 列出并解释 5 个核心谓词 (必分点) 这是得分的关键,建议使用列表形式:

Step 3: 描述“惯性”公理 (Frame Axioms) 简要说明系统如何判定一个状态在当前是 True 的(即解决了 Frame Problem):

"A fluent holds at a time T if it was initiated by an event at time T1 (where T1 < T), and it has not been clipped (terminated) between T1 and T."

Step 4 (加分项): 区分 Axioms 如果题目问得深一点,可以补充:

例题

The candidate is invited to model the following situation using the Event Calculus approach. "A company produces a headlight for alpinists. There is only one button. Initially the headlight is off; when the button is pressed a first time, the light turns steady on; a further pressure of the button with the light steady on makes the light blinking; a further pression of the button switches the light off."

  1. 定义术语 (Ontology)

首先,明确列出系统中的流(Fluents)和事件(Events)。

  1. 定义初始状态 (Initial State)

题目指出 "Initially the headlight is off"(初始时头灯是关的)。

  1. 定义状态转换公理 (Domain Dependent Axioms)

使用 Initiates(启动状态)和 Terminates(终止状态)谓词。逻辑是:“如果当前处于状态 A,发生了事件 E,则启动状态 B,并终止状态 A”

处理三个转换环节:

A. 从关 (Off) 到 常亮 (Steady On)

"when the button is pressed a first time, the light turns steady on"

B. 从常亮 (Steady On) 到 闪烁 (Blinking)

"a further pressure of the button with the light steady on makes the light blinking"

C. 从闪烁 (Blinking) 到 关 (Off)

"a further pression of the button switches the light off"

可以写上试卷的答案

Fluents: light_offsteady_onblinking Events: push_button

1. Initial State:

Initially(light_off).

2. Domain Dependent Axioms:

% Transition: Off -> Steady On

Initiates(push_button, steady_on, T) :- HoldsAt(light_off, T).
Terminates(push_button, light_off, T) :- HoldsAt(light_off, T).

% Transition: Steady On -> Blinking

Initiates(push_button, blinking, T) :- HoldsAt(steady_on, T).
Terminates(push_button, steady_on, T) :- HoldsAt(steady_on, T).

% Transition: Blinking -> Off

Initiates(push_button, light_off, T) :- HoldsAt(blinking, T).
Terminates(push_button, blinking, T) :- HoldsAt(blinking, T).

关键点提示 (对应评分标准)

  1. 成对出现: 记住 Event Calculus 遵循惯性定律 (Inertia)。状态一旦启动就会一直保持,直到被显式终止。因此,每次状态切换时,必须写 Initiates 新状态,同时 Terminates 旧状态。
  2. Preconditions: 必须在规则体(Body)中检查当前状态(HoldsAt(..., T))。因为同一个按钮在不同状态下有不同的功能(上下文敏感),如果不检查当前状态,按下按钮会导致所有状态同时启动。

Vanilla Meta-Interpreter

1. 标准答案模板 (可以直接背诵)

如果题目要求 "explain the meta-interpreter vanilla and the meaning of each clause",你应该写出以下代码和解释:

Prolog Code:

solve(true) :- !.
solve((A,B)) :- !, solve(A), solve(B).
solve(A) :- clause(A,B), solve(B).

Explanation of each clause:

  1. solve(true) :- !.
    • Base case (基准情况): accurately defines that the goal true is always true. The cut ! is used for efficiency to stop backtracking (since true cannot be solved in any other way).
  2. solve((A,B)) :- !, solve(A), solve(B).
    • Conjunction (合取处理): Handles complex goals connected by logical AND. To solve A and B, the interpreter must first solve A and then solve B. This mimics the standard left-to-right selection rule.
  3. solve(A) :- clause(A,B), solve(B).
    • Rule application (规则应用/归结): To solve an atomic goal A, the interpreter looks for a rule in the knowledge base where the head matches A (using the built-in predicate clause(Head, Body)). Then, it recursively tries to solve the Body (B) of that rule.

2. 考试解题思路与变体应对

在考试中,这道题通常有两种考法:

  1. 死记硬背型:直接让你写出 Vanilla 并解释(如上所述)。
  2. 修改扩展型:让你修改 Vanilla 来实现特定功能。

针对修改扩展型题目,你的解题思路应该是:“只修改负责相关逻辑的那一行”。

以下是三种最常考的变体及应对策略:

变体 A:改变求解顺序 (Right-to-Left Selection Rule)
变体 B:处理系统谓词 (System Predicates)
变体 C:增加计数或追踪功能 (Counting/Tracing)

总结

对于这道题,先背熟那 3 行标准代码

CWA and OWA

题目通常是:"The candidate is invited to introduce the notions of close world assumption and open world assumption, and to briefly discuss how Prolog and Description Logics deal with these aspects."

以下是基于课程讲义(特别是 02-Prolog.pdf 和 07-IntroDL.pdf)的知识点总结和标准答题思路。


1. 核心概念定义

在回答时,首先要给这两个概念下定义:


2. Prolog 与 Description Logics (DL) 的对比

这是题目要求的核心部分,你需要对比这两种技术如何处理上述假设。

A. Prolog (采用 CWA / Negation as Failure)
B. Description Logics / Semantic Web (采用 OWA)

3. 考试中的“杀手锏”例子:Only Male Children

为了拿高分,强烈建议在试卷上使用课件中**"Only Male Children"**的例子来对比两者。

对比回答:

  1. Prolog (CWA):
    • Prolog 会尝试寻找 Federico 的女儿。
    • 因为它找不到任何关于女儿的记录(Failure),它就断定“没有女儿”。
    • 结论Yes,Federico 只有男孩。
  2. Description Logics (OWA):
    • DL 看到 Federico 有一个儿子。
    • 但是,DL 不能排除 Federico 在 KB 之外还有其他女儿的可能性(因为缺失的信息 = 未知,而不是不存在)。
    • 结论Unknown(除非我们在 KB 中显式添加一个“封闭公理”,比如“Federico 只有这一个孩子”)。

4. 考试答题模板

  1. Define CWA: Under CWA, if a fact is not known to be true, it is assumed to be false. This implies that the knowledge base is complete.
  2. Define OWA: Under OWA, if a fact is not known, its truth value is considered unknown. Absence of evidence is not evidence of absence. This assumes the knowledge base might be incomplete.
  3. Prolog's Approach: Prolog adopts a variation of CWA called Negation as Failure. If the proof for a goal P fails, Prolog infers \+ P (not P) is true. This leads to non-monotonic reasoning.
  4. DL's Approach: Description Logics (used in Semantic Web) adopt OWA. Failing to prove a relationship does not imply it doesn't exist. This is necessary for the distributed nature of the Web.
  5. Example: In the "HasOnlyMaleChildren" case:
    • If we only know hasChild(john, tom) and male(tom)Prolog concludes John has only male children (because it finds no daughters).
    • DL does not conclude this, because John might have a daughter not listed in the current ontology. To conclude it in DL, we would need to explicitly state that Tom is the only child (closure axiom).

RETE

A. 为什么要用 RETE?

在一个产生式系统中,如果每一次循环都遍历所有的规则和所有的事实来重新检查匹配,效率极低(复杂度为 O(Rules×FactsPatterns))。 RETE 算法(由 Charles Forgy 提出)是一种高效的模式匹配算法,它通过以空间换时间来加速匹配过程。

B. RETE 的核心思想

  1. 避免重复计算:大部分事实在两个时间步之间是不会变的。RETE 记住了上一次的匹配结果(Partial Matches),只计算变化的部分(增量更新)。
  2. 网络结构 (Network Compilation):它把所有规则的 LHS 编译成一个由节点组成的网络(Discrimination Network)。

C. 网络结构详解 (考试必写点)

RETE 网络主要包含两部分:

考试答题思路与模板

如果考试题目是:"The candidate is invited to briefly introduce the RETE algorithm." (如 2025年7月考题),请按以下结构作答:

"The RETE algorithm is an efficient pattern matching algorithm for rule-based systems (production rule systems). It is designed to optimize the 'Match' phase of the execution cycle."

"Naive matching requires iterating over all facts and rules at every cycle, which is computationally expensive. RETE avoids this by exploiting the fact that the working memory changes slowly (temporal redundancy). It trades memory for speed."

"It compiles the Left Hand Side (LHS) of the rules into a discrimination network consisting of two parts:

  1. Alpha Network: Checks intra-element constraints (e.g., age > 18) and stores partial matches in Alpha Memories.
  2. Beta Network: Performs joins between different patterns (inter-element constraints) and stores combined matches in Beta Memories. When a fact is added or removed, the change propagates through the network, updating only the affected memories."

"The final output of the network is the Conflict Set, which contains all the rule instances ready to be fired."

题目示例The candidate is invited to shortly describe the RETE algorithm. (2022-06-13 考题)。 答题思路: 按以下逻辑组织语言:

  1. Goal: An efficient pattern matching algorithm for production rule systems (Forward Reasoning).
  2. Problem: Naive matching is slow because iterating over all facts and rules at every cycle is computationally expensive.
  3. Solution: RETE compiles the rules' LHS into a discrimination network:
        ◦ Alpha Network: Checks intra-element constraints (e.g., age > 18).
        ◦ Beta Network: Checks inter-element constraints (joins between patterns).
  4. Optimization: It exploits temporal redundancy: since the working memory changes slowly, RETE remembers previous partial matches and only processes the changes (deltas) to the facts.

Rule-based Forward Reasoning

(基于规则的正向推理)

A. 与 Prolog (Backward) 的区别

Prolog (Backward Chaining): 目标驱动(Goal-driven)。你给出一个 Query(目标),系统去寻找支持该目标的规则。
Forward Reasoning (Data-driven): 数据驱动。系统有一个Working Memory (WM) 存放当前所有的事实(Facts)。当新的事实进入 WM 时,如果满足了某些规则的条件,这些规则就会被触发(Triggered)

B. Production Rules (产生式规则)

规则的形式通常是 IF Conditions THEN Actions(在 Drools 中写为 when... then...)。

LHS (Left Hand Side): 规则的条件部分(Premises/Antecedents)。用于匹配 WM 中的事实。
RHS (Right Hand Side): 规则的动作部分(Consequences)。通常会对 WM 进行修改(insert, retract, modify 事实)或执行外部操作(如打印日志)。

C. 执行循环 (The Execution Cycle)

这是一个不断循环的过程,直到没有规则可以运行:

  1. Match (匹配): 找出所有 LHS 满足当前 WM 事实的规则。这些规则实例的集合被称为 Conflict Set (冲突集)
  2. Conflict Resolution (冲突解决): 如果有多条规则同时满足条件,系统根据策略(如优先度 salience、FIFO 等)选择一条规则来执行。
  3. Act/Fire (执行): 执行被选中规则的 RHS。这可能会改变 WM 中的事实。
  4. Loop: 事实变了,回到第 1 步重新匹配。

题型

题目示例Explain the difference between Backward and Forward Reasoning. 答题思路: 使用“方向”、“触发点”和“状态变化”三个维度进行对比。

  1. Direction: BR is goal-driven (starts from query, looks for supporting rules), while FR is data-driven (starts from available facts, triggers rules that match).
  2. Trigger: BR is triggered by a user query. FR is triggered by the arrival/modification of data in the Working Memory.
  3. State: BR typically assumes a static Knowledge Base during the proof. FR explicitly manages a dynamic Working Memory where rules execute side effects (insert/retract facts).

LPAD

Distribution Semantics (分布语义) 是 LPAD(Logic Programs with Annotated Disjunctions)的核心理论基础。

LPAD 的核心思想是将逻辑规则与概率结合,通过分布语义来解释不确定性。

A. LPAD 的语法 (Syntax)

LPAD 扩展了 Prolog 的规则头(Head)。一个规则的头部是一个带注解的析取(Annotated Disjunction)

B. 分布语义的定义 (Semantics)

这是考试的理论核心。分布语义定义了一个**逻辑程序实例(Instances)可能世界(Possible Worlds)**上的概率分布,。

  1. 原子选择 (Atomic Choice): 对于程序中每一个接地(Ground)的规则,我们需要从头部选择一个原子。
  2. 选择 (Selection / Total Composite Choice): 对程序中所有接地规则都进行了一次原子选择后的集合 σ
  3. 世界 (World): 一个具体的“选择” σ 确定了一个普通的逻辑程序 wσ(即一个不含概率的普通 Prolog 程序)。
  4. 世界的概率 P(w): 由构成该世界的每一个独立选择的概率相乘得到。 $$ P(w) = \prod_{(Clause, i) \in \sigma} P(Clause, i) $$
  5. 查询的概率 P(Q): 一个查询 Q 为真的概率,等于所有使 Q 为真的世界 w 的概率之和。 $$ P(Q) = \sum_{w \models Q} P(w) $$

考试答题思路 (Exam Strategy)

在 2025年2月 和 2025年6月 的考试中,均出现了原题:

"The candidate is invited to introduce the distribution semantics adopted in the LPAD, illustrating it with the use of a very simple example.",

遇到这类题目,建议按以下三步走:

Step 1: 定义分布语义 (Define the Semantics)

首先用简洁的语言描述定义。

"Distribution Semantics defines a probability distribution over a set of normal logic programs, called possible worlds (or instances). A probabilistic logic program is not a single program, but a generator of many possible deterministic programs.",

Step 2: 解释“世界”是如何生成的 (Explain "Worlds")

解释如何通过选择头部原子来生成世界。

"For each ground rule in the LPAD, exactly one atom from the disjunctive head is selected according to its annotated probability.

Step 3: 举一个简单的例子 (Provide a Simple Example)

这是拿分的关键。使用课件中经典的“打喷嚏 (Sneezing)”例子最稳妥,。

Write the LPAD code:

% Rule: People with flu sneeze with 0.7 probability
sneezing(X):0.7 ; null:0.3 :- flu(X).

% Fact
flu(bob).

Explain the Worlds: Explain that for the individual bob, there are two possible worlds generated by the rule:

Conclusion:

"The probability of the query ?- sneezing(bob) is the sum of probabilities of worlds where it is true. Here, only w1 makes it true, so P(sneezing(bob))=0.7."

总结

考试时不需要写复杂的数学公式,但必须展示出你理解:LPAD 本质上是定义了多个平行的“可能世界”,查询的概率就是把所有“成功世界”的概率加起来。

Knowledge Graphs Paradigms vs Semantic Web

真题 (2022-07-18 Exam):

"The candidate is invited to briefly introduce the Knowledge Graph paradigms, and which are the main differences w.r.t. the Semantic Web proposal." (请简要介绍知识图谱范式,并说明其与语义网提议的主要区别。)

答题思路模板 (Step-by-Step):

Step 1: 定义 Knowledge Graph (KG) 首先给出一个定义。引用 Fensel 的定义最为稳妥:

"Knowledge Graphs are very large semantic nets that integrate heterogeneous information sources to represent knowledge about certain domains." They focus on storing massive amounts of factual information (billions of triples).

Step 2: 解释为什么会出现 KG (The "Why") 描述 Google 在 2012 年遇到的瓶颈:

"The Semantic Web stack (based on OWL/Description Logics) was considered too complex and computationally expensive for web-scale efficiency. Reasoning on the T-Box (terminological logic) could be slow or non-terminating."

Step 3: 列举主要区别 (The Differences - 核心得分点) 建议使用对比的方式(Bullet points):

Reasoning vs. Traversal: Semantic Web relies on logical inference (reasoners). Knowledge Graphs rely on graph algorithms (fast traversal) and machine learning (Graph Embeddings) to find answers.

Schema Complexity: Semantic Web separates T-Box (Ontology) and A-Box (Facts) strictly. Knowledge Graphs tend to flatten this structure, mixing schema and data, or using very simple vocabularies (like schema.org) to avoid the "knowledge acquisition bottleneck".

Goal: Semantic Web aimed for interoperability and formal correctness. Knowledge Graphs aim for speed, scale, and supporting query answering (e.g., Google's info-box).

Step 4 (加分项): 提及 Graph Embeddings 如果想拿高分,可以补充一句:

"Modern KGs exploit Graph Embedding techniques (like TransE) to map entities and relations into vector spaces, allowing neural networks to predict missing links instead of deducing them logically."

ALC

根据课件《07-IntroDL.pdf》和往年试题(特别是 2023年2月9日 和 2023年6月12日 的考题),ALC (Attributive Language with Complements) 是 Description Logic (描述逻辑) 部分最核心的考点。

题目通常会问:"Briefly introduce the ALC Description Logics, mentioning the operators that are supported... and their meaning."

你需要记住 ALC 是 AL (Attributive Language) 的扩展,增加了任意概念的补集 (Complements)

答题必写要素 (Standard Answer Key):

  1. 基本定义: ALC 是一种具有重要理论意义的描述逻辑片段,它在表达能力和计算复杂性之间取得了良好的平衡。
  2. 核心算子 (Operators/Constructors):
    • Atomic Concepts (原子概念): A (e.g., Person).
    • Universal Concept (全集): (Thing).
    • Bottom Concept (空集): (Nothing).
    • Intersection (交集/AND): CD. 表示同时属于概念 C 和 D 的个体 (e.g., Student  Worker).
    • Negation/Complement (否定/NOT): ¬C. 表示不属于概念 C 的个体。这是 ALC 的特征 (e.g., ¬ Male = Female).
    • Value Restriction (值限制/ALL): R.C. 表示一个个体,其所有关系 R 的对象都属于概念 C (e.g.,  hasChild.Male = Parents with only male children).
    • Existential Quantification (存在量化/EXISTS): R.C. 表示一个个体,至少存在一个关系 R 的对象属于概念 C (e.g.,  hasChild.Doctor = Parent of at least one doctor).

虽然不一定单独考,但在解释 DL 时常作为背景知识提及:

如果考题是 "Introduce ALC and its operators",请按此思路作答:

"ALC (Attributive Language with Complements) is a fundamental Description Logic. It extends the basic 'AL' logic by allowing the negation (complement) of arbitrary concepts, not just atomic ones.

The principal operators supported by ALC are:

  1. Conjunction (AND, ): Intersection of concepts. E.g., StudentWorker.
  2. Negation (NOT, ¬): Complement of a concept. E.g., ¬Male.
  3. Universal Restriction (ALL, ): R.C describes individuals whose relationships R all point to instances of C.
  4. Existential Restriction (EXISTS, ): R.C describes individuals that have _at least one_relationship R pointing to an instance of C."

Disjointness **Exhaustive Decomposition Partition

根据提供的资料,Disjointness (不相交性)Exhaustive Decomposition (穷尽分解) 和 Partition (划分) 是属于 "Upper Ontologies" (顶层本体) 和 "Categories" (类别) 章节的理论考点。

这一考点在 2022年12月21日 的考试中作为第 3 题(开放式问答题)原题出现过。

以下是关于该考点的详细出题形式及标准作答思路:

1. 考试真题形式

根据往年试题,题目通常会这样问:

"Within the terminological approach towards the representation of concepts/categories and individuals/instances, the candidate is invited to illustrate the notions of:

2. 标准答题思路 (基于课件-)

建议按以下结构分点作答,定义 + 例子 是拿满分的关键。

A. Disjointness (不相交性)
B. Exhaustive Decomposition (穷尽分解)
C. Partition (划分) - 核心得分点

3. 备考总结