Final 往年卷|G 搜索、逻辑、概率
往年期末卷 G 搜索、逻辑、概率:F25、F24、Y24 原题按专题整理,逐题折叠推算答案、英文答法与回查页码。非官方。
手机上宽表格可左右滑动;自测答案默认收起,点击题目下方按钮查看。
使用边界:期末复习,非官方材料。考试安排按课程公告整理,正式要求以讲师通知和课堂公告为准。本页按往年期末卷的题目整理,题面按题库里的转述和解答重写、措辞可能与原卷不同,往年卷没有官方答案,解答均为推算答案;往年卷只说明以前怎么出题,不代表今年的题目和分值。
复习资料:考试安排与范围地图 · 专家系统与推荐系统 · Agent 与生成式 AI
先做题再看解析:G 往年卷:搜索、逻辑、概率 · H 往年卷:CNN 与神经网络 · I 往年卷:延伸与简答 · J 判断 1–25 · K 判断 26–50 · L 选择题 · M 问答:搜索、逻辑、概率 · N 问答:回归、聚类、神经网络 · O 问答:CNN、RNN 与拓展 · P 期中后新内容
怎么做:先只看题面,用英文作答,写出公式和每一步,再展开核对;解析里的数值照底稿,页码为 PDF 页序。
卷号代号:F25、F24 为 FAN 出卷,Y24 为 YONG 出卷。原卷的图在这里改写成文字或表格,题面为整理后的转述。
G 搜索、逻辑、概率
G1 · Search algorithms on a weighted graph (F25 Q1, 15 marks)
The graph is undirected with edge costs S–A = 2, S–B = 3, S–D = 5, A–C = 4, B–D = 4, C–D = 1, C–G = 2, D–G = 5. The start is S and the goal is G. Heuristic values: h(A) = 2, h(B) = 5, h(C) = 2, h(D) = 1, h(G) = 0. Ties are broken alphabetically, and each state is expanded at most once.
For DFS, BFS, greedy best-first search and A*, give the expansion order (including the final removal of G), the path found and its cost.
G1 · 查看答案与解析
答案(推算答案):
| 算法 | 展开顺序(含最后取出的 G) | 路径与代价 |
|---|---|---|
| DFS(递归、当前分支优先、已访问去重) | S, A, C, D, B, G | S→A→C→D→G,2+4+1+5=12 |
| BFS(生成时记 parent) | S, A, B, D, C, G | S→D→G,5+5=10 |
| Greedy(按 h) | S, D, G | S→D→G,10 |
| A*(按 g+h,遇到更小的 g 就更新) | S, A, D, B, C, G | S→A→C→G,2+4+2=8 |
A* 的过程:
- 展开 S 后 Open 里有 A(g=2, f=4)、B(g=3, f=8)、D(g=5, f=6)。
- 展开 A 得 C(g=6, f=8)。
- 展开 D:经 D 到 C 的 g 也是 6,相等,保留原 parent A;生成 G(g=10, f=10)。
- B 和 C 的 f 都是 8,字母序先 B。
- 展开 C 时 G 的 g 降到 8、f=8,最后取出 G。
如果 g 相等时也允许改 parent,会得到同样代价 8 的 S→D→C→G。
English: DFS (recursive, visited states skipped) expands S, A, C, D, B, G and returns S→A→C→D→G with cost 12. BFS expands S, A, B, D, C, G and returns S→D→G with cost 10. Greedy best-first search expands S, D, G and returns S→D→G with cost 10. A* expands S, A, D, B, C, G and returns S→A→C→G with cost 8. BFS ignores edge costs, so it finds the path with the fewest edges rather than the cheapest path.
易错点:DFS 有两种实现。原题只说「每个节点展开一次」,没说已经在 Open 里的节点要不要移位或改 parent。上表按递归式写;如果采用「已在 Open 里就不再入栈」,顺序和路径都会变。考试题面给了 Open 规则就照题面做,答卷上写一句采用了哪种约定。BFS 找到代价 10 的路而不是 8,这不矛盾。
回查:L02、T02(BFS 与 DFS);L02 p.52–67(Greedy 与 A*);T03 p.31–34(同一状态出现更便宜路径)。
G2 · Translating sentences into propositional logic (F24 Q2, 9 marks)
Let A = Tom goes to the zoo, B = Jason goes to the zoo, C = Eric goes to the zoo, D = Michael goes to the zoo. Translate sentences (a)–(g) into propositional logic.
底稿只收录了七句的译式,没有收录英文原句。做法:先背下面的翻译口诀,再展开对照七个译式,练习把每个译式读回英文。
G2 · 查看答案与解析
答案(推算答案):
| 小题 | 译式 |
|---|---|
| a | D → (B ∧ C) |
| b | C → (¬A ∧ ¬B) |
| c | D ↔ (C ∧ ¬A) |
| d | D → (¬C → A) |
| e | (¬D → C) ∧ (D → ¬B) |
| f | A → ((¬B ∧ ¬C) → D) |
| g | [(A ∧ B ∧ C) ↔ ¬D] ∧ [(¬A ∧ ¬B) → (D → C)] |
翻译口诀:P only if Q 写成 P → Q;provided that 引出的是前提;「X 是 Y 的必要条件」箭头从 Y 指向 X;but 就是 AND。
English: “P only if Q” is written P → Q. A clause introduced by “provided that” is the premise. “X is a necessary condition for Y” is written Y → X. “But” is translated as AND.
易错点:only if 和 if 的箭头方向相反;必要条件写在箭头右边。
回查:L03b。
G3 · Simplifying a formula (F24 Q3, 6 marks)
Simplify (¬p → q) → (q → ¬r) as far as possible, and check the result with a truth table.
G3 · 查看答案与解析
答案(推算答案):
(¬p → q) → (q → ¬r) ≡ ¬(p ∨ q) ∨ (¬q ∨ ¬r) ≡ (¬p ∧ ¬q) ∨ ¬q ∨ ¬r ≡ ¬q ∨ ¬r
最后一步是吸收律。真值表 8 行逐行核对过。
English: Rewriting each implication as a disjunction gives ¬(p ∨ q) ∨ (¬q ∨ ¬r). De Morgan’s law gives (¬p ∧ ¬q) ∨ ¬q ∨ ¬r, and absorption reduces this to ¬q ∨ ¬r. All eight truth-table rows agree.
易错点:¬p → q 化成 p ∨ q,外层再取否定才是 ¬(p ∨ q);最后一步要写出吸收律的名字。
回查:L03b p.36–38、T05。
G4 · Validity and resolution (F25 Q2, 15 marks)
Let L = (α → γ) ∨ (β → γ) and R = (α ∧ β) → γ. Decide whether L → R is valid, satisfiable or unsatisfiable, and prove the answer by resolution.
G4 · 查看答案与解析
答案(推算答案):
- L = (α → γ) ∨ (β → γ) = ¬α ∨ ¬β ∨ γ;R = (α ∧ β) → γ = ¬α ∨ ¬β ∨ γ。两边是同一个式子。
- L 和 R 只在 α, β, γ = T, T, F 那一行为假,其余七行为真,所以 L → R 八行全真,是 valid,自然也 satisfiable。
- 归结证明:否定主式得 L ∧ ¬R,化成子句 ¬α ∨ ¬β ∨ γ、α、β、¬γ。
- 先和 α 消得 ¬β ∨ γ,再和 β 消得 γ,再和 ¬γ 得空子句 □。
- 原式的否定不可满足,所以原式 valid。
English: Both L and R are equivalent to ¬α ∨ ¬β ∨ γ, and both are false only when α, β, γ = T, T, F. Hence L → R is true in all eight rows: it is valid, and therefore also satisfiable. Resolution: the negation L ∧ ¬R gives the clauses ¬α ∨ ¬β ∨ γ, α, β and ¬γ. Resolving with α gives ¬β ∨ γ, with β gives γ, and with ¬γ gives the empty clause. The negation is unsatisfiable, so the formula is valid.
易错点:归结证 valid 要先否定整个主式;否定 L → R 得 L ∧ ¬R,不是 ¬L ∧ R。
回查:L03b p.17(valid 与 satisfiable);L03b p.35–43(归结)。
G5 · Resolution proof (Y24 Q32)
Let t = John has a trip, m = he climbs a mountain, b = he goes to the beach, g = he has a girlfriend. The knowledge base is: t → (m ∨ b), ¬g → ¬b, m → g, ¬g. Prove by resolution that John does not have a trip.
G5 · 查看答案与解析
答案(推算答案):
- 子句:① ¬t ∨ m ∨ b,② g ∨ ¬b,③ ¬m ∨ g,④ ¬g。
- 要证 ¬t,加入它的否定 ⑤ t。
- ③④ 得 ¬m;②④ 得 ¬b。
- ① 与 ¬m、¬b 得 ¬t,再与 ⑤ 得 □。
English: Clauses: (1) ¬t ∨ m ∨ b, (2) g ∨ ¬b, (3) ¬m ∨ g, (4) ¬g. Add the negated goal (5) t. Resolving (3) and (4) gives ¬m; resolving (2) and (4) gives ¬b. Resolving (1) with ¬m and ¬b gives ¬t, which resolves with (5) to the empty clause. Therefore John does not have a trip.
易错点:加入的是要证结论的否定(t),不是结论本身。
回查:L03b p.35–43。
G6 · Total probability (F25 Q3, 10 marks)
Three brands D, G and M have market shares P(D) = .5, P(G) = .3 and P(M) = .2. Their reliability rates are 98%, 97% and 93%. Find the probability that a randomly chosen product malfunctions.
G6 · 查看答案与解析
答案(推算答案):
- 可靠率先换成故障率:.02、.03、.07。
- 全概率公式:P(故障) = .5×.02 + .3×.03 + .2×.07 = .033,即 3.3%。
English: By the law of total probability, weight each brand’s malfunction probability by its market share and sum the contributions: .5×.02 + .3×.03 + .2×.07 = .033, i.e. 3.3%.
易错点:题目给的是可靠率,要先换成故障率;不能把三个可靠率直接平均。
回查:L03a p.15–17。
G7 · Bayesian network (Y24 Q31)
The network is M → B and M → S ← E. P(M) = .1, P(E) = .4; P(B∣M) = .7, P(B∣¬M) = .3; P(S∣E,M) = .9, P(S∣E,¬M) = .3, P(S∣¬E,M) = .1, P(S∣¬E,¬M) = .2.
(a) Compute P(S,E,M,B) and P(¬S,E,M,B). (b) Compute P(B). (c) Compute P(M∣B). (d) Compute P(M∣S,B,E).
G7 · 查看答案与解析
答案(推算答案):
| 问 | 代入 | 结果 |
|---|---|---|
| a. P(S,E,M,B) | .9×.4×.1×.7 | .0252 |
| a. P(¬S,E,M,B) | .1×.4×.1×.7 | .0028 |
| b. P(B) | .7×.1 + .3×.9(E、S 不用算) | .34 |
| c. P(M∣B) | .7×.1 / .34 | 7/34 ≈ .205882 |
| d. P(M∣S,B,E) | (.9×.7×.1) / [(.9×.7×.1) + (.3×.3×.9)],公共因子 P(E) 约掉 | .4375 |
拿步骤分的写法:先写出要算的是 P(原因∣观察),列分子,分母把所有原因加总。
English: (a) The joint probability factorises along the network: P(S,E,M,B) = P(S∣E,M)P(E)P(M)P(B∣M) = .0252, and P(¬S,E,M,B) = .0028. (b) P(B) = P(B∣M)P(M) + P(B∣¬M)P(¬M) = .34; E and S are not needed. (c) By Bayes’ rule, P(M∣B) = .7×.1/.34 = 7/34 ≈ .205882. (d) P(M∣S,B,E) = (.9×.7×.1)/[(.9×.7×.1) + (.3×.3×.9)] = .4375, where the common factor P(E) cancels.
易错点:(b) 只需对 M 求和,E 和 S 与 B 无关;(d) 的分母要把 M 和 ¬M 两种情况都加上。
回查:L03a p.21–27、T04;同类题回查 A1 Q4、T04 三类基础题、L03a 的检测例。
个人整理的学习笔记,不是官方材料;数字与结论以课件和讲师为准。