Knowledge and reasoning
แนะนำใหม่
6:33
ปัญญาประดิษฐ์และเรียนรู้ของเครื่อง
This course covers the classical core of artificial intelligence, honestly measured. The first three units are the spine: search, logical reasoning and…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| Inference/ˈɪnfərəns/ | deriving new facts from known facts and rules |
| knowledge base/ˈnɒlɪdʒ beɪs/ | a store of facts and rules that a program can reason with |
| Propositional logic/ˌprɒpəˈzɪʃənl ˈlɒdʒɪk/ | logic with true-or-false statements joined by and, or, not and if-then |
| modus ponens/ˈməʊdəs ˈpəʊnənz/ | the rule: from P and "if P then Q", conclude Q |
| Forward chaining/ˈfɔːwəd ˈtʃeɪnɪŋ/ | reasoning from the known facts, applying rules until nothing new can be derived |
| backward chaining/ˈbækwəd ˈtʃeɪnɪŋ/ | reasoning back from a goal to the facts that would prove it |
| sound/saʊnd/ | (of an inference method) never derives a false conclusion from true facts |
| complete/kəmˈpliːt/ | (of an inference method) can derive every conclusion that really follows |
| resolution/ˌrezəˈluːʃn/ | an inference step that combines two clauses containing a literal and its negation |
| clauses/ˈklɔːzɪz/ | disjunctions of literals, such as not-Storm or Delayed, the form resolution works on |
| refutation/rɪfjuːˈteɪʃn/ | proving a statement by showing that its negation leads to a contradiction |
| First-order logic/fɜːst ˈɔːdə ˈlɒdʒɪk/ | logic with variables and quantifiers such as "for all x" |
| unification/ˌjuːnɪfɪˈkeɪʃn/ | finding values for variables that make two logical expressions identical |
| Horn clauses/hɔːn ˈklɔːzɪz/ | rules of the form "these facts together imply one fact" |
Facts, rules and one inference step
- A knowledge base 知识库 stores facts ("it is the weekend") and rules ("if there is a storm, the flight is delayed"). In propositional logic 命题逻辑 a rule is written $P \to Q$: if $P$ is true, then $Q$ is true.
- The basic step of inference 推理 is modus ponens 肯定前件: from $P$ and $P \to Q$, conclude $Q$. Our course knowledge base: facts F1 Storm, F2 Weekend; rules R1 Storm → Delayed, R2 Weekend → HeavyTraffic, R3 HeavyTraffic → Delayed, R4 Delayed → RefundRisk.

Forward chaining starts from —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Forward chaining starts from what is known; backward chaining starts from the goal.
Forward chaining: from the facts outwards
- Forward chaining 前向链接 applies every rule whose condition is already known, adds the new facts, and repeats until nothing new appears.
- On the course knowledge base, each wave fires every rule whose condition is now known:
| Wave | Fires | New facts |
|---|---|---|
| 1 | R1, R2 | Delayed, HeavyTraffic |
| 2 | R3, R4 | RefundRisk (R3's Delayed is already known) |
| 3 | — | none, so stop |
- Forward chaining finds every consequence, useful when you want them all, wasteful when you have one question.
The course KB derives RefundRisk in — waves
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Wave one: Delayed, HeavyTraffic; wave two: RefundRisk.
Backward chaining: from the question back
- Backward chaining 后向链接 starts from the goal. To prove RefundRisk, find a rule that concludes it (R4), so prove Delayed. A rule that concludes Delayed is R1, so prove Storm. Storm is a fact: done in three steps. R2 and R3 are never used, because the search follows the goal.
- A rule only works forwards. From R1 and the fact Delayed you may not conclude Storm: the flight could be delayed by traffic. Reading $P \to Q$ as $Q \to P$ is the classic logic error.
From the rule Storm → Delayed and the fact Delayed, we may conclude Storm.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
That is the converse error. Delayed also follows from HeavyTraffic, so Delayed does not prove Storm; modus ponens runs only from $P$ ไป $Q$.
From Storm → Delayed and Delayed, Storm follows.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
That is affirming the consequent; the delay may have another cause.
Sound and complete
- A method is sound 可靠的 if it never derives something false from true facts. Modus ponens is sound: each step follows directly from a rule.
- A method is complete 完备性 if it can derive every true consequence. Modus ponens alone is not complete for all logic (it cannot handle "A or B" facts, for example); resolution, next, is the standard complete method for proving that a set of clauses is contradictory.
Modus ponens makes inference —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Each step is a valid implication on assumed rules - no falsehood invented.
Rules as clauses, and resolution
- Resolution 归结 works on clauses 子句: lists of literals joined by OR. Rewrite each rule using $P \to Q \equiv \neg P \lor Q$. So R1 becomes the clause $\{\neg\text{Storm}, \text{Delayed}\}$ ("not Storm, or Delayed").
- One resolution step takes two clauses that contain a literal and its negation, and joins the rest: $\{\neg\text{Storm}, \text{Delayed}\}$ and $\{\text{Storm}\}$ give $\{\text{Delayed}\}$. This is modus ponens written as clauses.
$P \to Q$ is equivalent to:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
It is false only when $P$ is true and $Q$ false.
Worked example: proof by refutation
- To prove Delayed, assume the opposite and show it leads to a contradiction (refutation 反驳). Add $\{\neg\text{Delayed}\}$ to the clauses $\{\text{Storm}\}$ and $\{\neg\text{Storm}, \text{Delayed}\}$.
- Step 1: $\{\neg\text{Storm}, \text{Delayed}\}$ with $\{\neg\text{Delayed}\}$ gives $\{\neg\text{Storm}\}$.
- Step 2: $\{\neg\text{Storm}\}$ with $\{\text{Storm}\}$ gives the empty clause: a contradiction. So "not Delayed" is impossible, and Delayed follows. SAT solvers are built on this idea.
Clauses {Storm}, {¬Storm, Delayed}, {¬Delayed}: resolution steps to reach the empty clause?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Cancel Delayed, then Storm.
First-order logic: rules with variables
- Propositional rules need one copy for every flight. First-order logic 一阶逻辑 adds variables: $\forall x\; \text{Storm}(x) \to \text{Delayed}(x)$, "for every leg $x$, a storm on $x$ delays $x$".
- To use the rule on the fact $\text{Storm}(\text{Leg7})$, unification 合一 finds the substitution that makes them match, $x = \text{Leg7}$. Modus ponens then gives $\text{Delayed}(\text{Leg7})$. One rule now covers every leg.
Unify $\text{Delayed}(x)$ with $\text{Delayed}(\text{Leg7})$. The substitution is —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Replacing x by Leg7 makes the two terms identical.
What reasoning costs
- Checking a conclusion with a truth table lists every combination of true and false: $2^n$ rows for $n$ symbols. 20 symbols already need about a million rows, 30 over a billion.
- Propositional rules of the form "these facts imply one fact" can be written as Horn clauses 霍恩子句. Propositional Horn-clause entailment can be decided in time linear in the size of the knowledge base with a suitable chaining algorithm.
How many rows does a truth table over 6 propositional symbols have?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Each symbol doubles the rows: 2^6 = 64.
Marks that slip away
- Reading $P \to Q$ backwards. Delayed does not prove Storm.
- Forward chaining for one question. It derives everything; backward chaining 后向链接 follows only the goal.
- Sound as complete. Never deriving something false is not the same as deriving everything true.
Recap
- Modus ponens: from $P$ and $P \to Q$, conclude $Q$. Forward chaining starts from facts, backward chaining 后向链接 from the goal.
- Clauses use $P \to Q \equiv \neg P \lor Q$; refutation adds the negated goal and resolves to the empty clause.
- Truth tables cost $2^n$ rows; propositional Horn-clause entailment can be decided in linear time.
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้