1 / 91

Lecture 2 Logic and reasoning 第 2 讲 逻辑及其推理

Lecture 2 Logic and reasoning 第 2 讲 逻辑及其推理. 2.1 Propositional Logic 命题逻辑 2.2 Predicate Calculus 谓词逻辑. Acknowledgment. robotics.stanford.edu/~latombe/cs121/2003/home.htm 补充读物: Nils J. Nilsson 著 , 郑扣根 庄越挺译 Artificial Intelligence A New Synthesis 机械工业出版社 2000 ( 中南大学图书馆 TP18 NES).

dora
Télécharger la présentation

Lecture 2 Logic and reasoning 第 2 讲 逻辑及其推理

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 2 Logic and reasoning第2讲 逻辑及其推理 2.1 Propositional Logic 命题逻辑 2.2 Predicate Calculus 谓词逻辑

  2. Acknowledgment • robotics.stanford.edu/~latombe/cs121/2003/home.htm 补充读物:Nils J. Nilsson著, 郑扣根 庄越挺译 Artificial Intelligence A New Synthesis 机械工业出版社 2000 (中南大学图书馆 TP18 NES) • www.cs.umbc.edu/~ypeng/F02671/lecture-notes/Ch06.ppt

  3. sensors environment ? agent actuators Knowledge base Propositional Logic 命题逻辑 Knowledge-Based Agent

  4. Types of Knowledge • Procedural(过程性的), e.g.: functionsSuch knowledge can only be used in one way -- by executing it • Declarative(描述性的,说明性的), e.g.: constraintsIt can be used to perform many different sorts of inferences

  5. Logic Logic is a declarative language to: • Assert sentences representing facts that hold in a world W (these sentences are given the value true) • Deduce the true/false values to sentences representing other aspects of W

  6. 涵蕴 Entail Sentences Sentences ╞ represent represent Conceptualization World W Facts about W Facts about W hold hold Connection World-Representation

  7. 1 Battery-OK  Bulbs-OK  Headlights-Work 2 Battery-OK  Starter-OK Empty-Gas-Tank  Engine-Starts 3 Engine-Starts Flat-Tire  Car-OK 4 Headlights-Work 5 Battery-OK 6 Starter-OK 7 Empty-Gas-Tank 8 Car-OK Conceptualization World W ╞ Flat-Tire 1. 如果电池正常 且车灯正常, 那么车灯亮 2. 如果电池正常,启动器正常且油箱不空,那么引擎可以发动 3. 如果引擎可以发动,且轮胎没有爆胎,那么汽车正常 4. 车灯亮 5. 电池正常 6.启动器正常 7. 油箱不空 8. 汽车不正常 诊断结论: 轮胎爆胎

  8. Propositional logic: Syntax • Propositional logic is the simplest logic – illustrates basic ideas • The proposition symbols P1, P2 etc are sentences • If S is a sentence, S is a sentence (negation) • If S1 and S2 are sentences, S1 S2 is a sentence (conjunction) • If S1 and S2 are sentences, S1 S2 is a sentence (disjunction) • If S1 and S2 are sentences, S1 S2 is a sentence (implication) • If S1 and S2 are sentences, S1 S2 is a sentence (biconditional)

  9. Propositional logic: Semantics Each model specifies true/false for each proposition symbol E.g. P1,2 P2,2 P3,1 false true false With these symbols, 8 possible models, can be enumerated automatically. Rules for evaluating truth with respect to a model m: S is true iff S is false S1 S2 is true iff S1 is true andS2 is true S1 S2 is true iff S1is true or S2 is true S1 S2 is true iff S1 is false orS2 is true i.e., is false iff S1 is true andS2 is false S1 S2 is true iff S1S2 is true andS2S1 is true

  10. Model • Assignment of a truth value – true or false – to every atomic sentence • Examples: • Let A, B, C, and D be the propositional symbols • m = {A=true, B=false, C=false, D=true} is a model • m’ = {A=true, B=false, C=false} is not a model • With n propositional symbols, one can define 2n models

  11. Model of a KB • Let KBbe a set of sentences • A model m is a model of KB iff it is a model of all sentences in KB, that is, all sentences in KB are true in m • Given a vocabulary A, B, C and D, how many models for A^B  C are there? • for A^B  B?

  12. Model of a A^B  C • A^B  C有多少模型 • {A^B  C, A^B}有多少模型

  13. valid sentenceor tautology Satisfiability of a KB (可满足性) A KB is satisfiable iff it admits(接纳) at least one model; otherwise it is unsatisfiable KB1 = {P, QR} is satisfiableKB2 = {PP} is satisfiable KB3 = {P, P} is unsatisfiable

  14. Logical Entailment (逻辑涵蕴) • KB : set of sentences (知识库) • : arbitrary sentence • KB entails– written KB ╞– iff every model of KB is also a model of  • Alternatively, KB ╞ iff • {KB,} is unsatisfiable (不可满足的) • KB   is valid (永真的)

  15. Model of a A^B  C • 令KB= {A^B  C, A^B} •  = C • 有KB ╞

  16. Validity(永真性) and satisfiability(可满足性) A sentence is valid if it is true in all models, e.g., True, A A, A  A, (A  (A  B))  B Validity is connected to inference via the Deduction Theorem: (演绎定理) KB ╞ α if and only if (KB α) is valid A sentence is satisfiable if it is true in some model e.g., A B, C A sentence is unsatisfiable if it is true in no models e.g., AA Satisfiability is connected to inference via the following: KB ╞ α if and only if (KBα) is unsatisfiable

  17. Inference • I: Set of inference rules • KB: Set of sentences • Inferenceis the process of applying successive inference rules from I to KB, each rule adding its conclusion to KB (推理 就是不断将I中的规则应用到KB,并将其结论加入到KB中的过程。)

  18. Inference Problem • Given: • KB: a set of sentence • : a sentence • Answer: • KB  ?

  19. Inference Rule (推理规则) • An inference rule {, } consists of 2 sentence patterns  and  called the conditions and one sentence pattern  called the conclusion • If  and  match two sentences of KB then the corresponding  can be inferred according to the rule 

  20. {  , }   {, }  Example: Modus Ponens (假言推理) Example: Battery-OK  Bulbs-OK  Headlights-Work Battery-OK  Bulbs-OK Headlights-Work

  21. Sound Inference Rules (deductive rules) • Here are some examples of sound rules of inference. • Each can be shown to be sound using a truth table -- a rule is sound if it’s conclusion is true whenever the premise is true. RULEPREMISE CONCLUSION Modus Ponens(肯定前件) A, A => B B Modus Tollens (否定后件)~B, A => B ~A And Introduction A, B A ^ B And Elimination A ^ B A Or Introduction A A v B Double Negation ~~A A Chaining A => B, B => C A => C

  22.  Connective symbol (implication 蕴含)╞ Logical entailment(逻辑涵蕴) Inference(推理) KB ╞ iff KB   is valid 

  23. Soundness (可靠性) • An inference rule is sound if it generates only entailed sentences (如果一个推理规则只推出蕴含的句子,则为可靠的) • All inference rules previously given are sound, e.g.:modus ponens: {   , }  • The following rule:{   , }  is unsound, which does not mean it is useless (溯因推理,abduction)  

  24. Completeness (完备性) • A set of inference rules is complete if every entailed sentences can be obtained by applying some finite succession of these rules (所有的被蕴含的句子都可被推出,则该规则集为完备的) • Modus ponens alone is not complete, e.g.:from A  B and B, we cannot get A

  25. Use inference rules: generate new sentences X from a one or more existing sentences S. S is called the premise and X the conclusion of the rule. • Proof procedure: a set of inference rules and a procedure of how to use these rules • If X can be generated from S by proof procedure i, we say X is derived from S by i, denoted S|iX, or S | X. • Soundness. An inference procedure is sound if every sentence X it produces from a set of sentences S logically follows from S. (No contradiction is created). if S | X then S |= X • Completeness. A inference procedure is complete, if it is able to produce every sentence that logically follows from any give S. if S |= X then S | X

  26. Proof methods • Proof methods divide into (roughly) two kinds: • Application of inference rules • Legitimate (sound) generation of new sentences from old • Proof = a sequence of inference rule applications Can use inference rules as operators in a standard search algorithm • Typically require transformation of sentences into a normal form • Model checking • truth table enumeration (always exponential in n) • improved backtracking, e.g., Davis--Putnam-Logemann-Loveland (DPLL) • heuristic search in model space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms

  27. Proof The proof of a sentence  from a set of sentences KB is the derivation of by applying a series of sound inference rules

  28. Proof The proof of a sentence  from a set of sentences KB is the derivation of by applying a series of sound inference rules Battery-OK  Bulbs-OK  Headlights-Work Battery-OK  Starter-OK Empty-Gas-Tank  Engine-Starts Engine-Starts Flat-Tire  Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK  Starter-OK  (5+6) Battery-OK  Starter-OK Empty-Gas-Tank  (9+7) Engine-Starts  (2+10) Engine-Starts  Flat-Tire  (3+8) Flat-Tire  (11+12)

  29. 一种新的推理规则: Resolution 消解, 归结

  30. Complementary Literals • A literal is a either an atomic sentence or the negated atomic sentence, e.g.: P or P • Two literals are complementary if one is the negation of the other, e.g.: P and P

  31. Normal forms of PL sentences • Disjunctive normal form (DNF) • Any sentence can be written as a disjunction of conjunctions of literals. • Examples: P ^ Q ^ ~R; A^B v C^D v P^Q^R; P • Widely used in logical circuit design (simplification) • Conjunctive normal form (CNF) • Any sentence can be written as a conjunction of disjunctions of literals. • Examples: P v Q v ~R; (A v B) ^ (C v D) ^ (P v Q v R); P • Normal forms can be obtained by applying equivalence laws [(A v B) => (C v D)] => P  ~[~(A v B) v (C v D)] v P // law for implication  [~~(A v B) ^ ~(C v D)] v P // de Morgan’s law  [(A v B)^(~C ^ ~D)] v P // double negation and de Morgan’s law  (A v B v P)^(~C^~D v P) // distribution law (A v B v P)^(~C v P)^(~D v P) // a CNF

  32. Unit Resolution(消解,归结)Rule • Given two sentences:L1… Lp and Mwhere Li,…, Lp and M are all literals, and M and Li are complementary literals • Infer:L1…Li-1Li+1… Lp

  33. Engine-Starts  Car-OK Examples From:Engine-Starts  Car-OK Engine-Starts Infer:Car-OK Modus ponens From:Engine-Starts  Car-OK Car-OK Infer:Engine-Starts Modus tolens

  34. Shortcoming of Unit Resolution From: • Engine-Starts  Flat-Tire Car-OK • Engine-Starts Empty-Gas-Tank we can infer nothing!

  35. Resolution rule Unit Resolution A v B, ~A B Resolution A v B, ~B v C A v C • Operates on two disjunctions of literals • The pair of two opposite literals cancel each other, all other literals from the two disjuncts are combined to form a new disjunct as the inferred sentence • Resolution rule can replace the following inference rules Modus Ponens A, ~A v B B Modus Tollens ~B, ~A v B ~A Chaining ~A v B, ~B v C ~A v C

  36. Full Resolution Rule • Given two sentences:L1… Lp and M1… Mqwhere L1,…, Lp, M1,…, Mq are all literals, and Li and Mj are complementary literals • Infer:L1…Li-1Li+1…LkM1…Mj-1Mj+1…Mkin which only one copy of each literal is retained (factoring)

  37. Example From: Engine-Starts  Flat-Tire Car-OK Engine-Starts Empty-Gas-Tank Infer: Empty-Gas-Tank  Flat-Tire Car-OK

  38. 一种新的推理规则: Resolution 消解, 归结 是可靠的,但不是完备的。 A ╞ A v B (利用消解规则推导不出)

  39. Resolution Refutation : 消解反演, 归结反驳 是可靠的,且是完备的。

  40. Deduction vs. Satisfiability Test KB  iff {KB,} is unsatisfiable • Hence: • Deciding whether a set of sentences entails another sentence, or not • Testing whether a set of sentences is satisfiable, or not • are closely related problems

  41. Sentence  Clause Form Example: (A B)  (C  D) 1. Eliminate (A B)  (C  D)2. Reduce scope of  (A  B)  (C  D)3. Distribute  over (A  (C  D))  (B  (C  D)) (A  C)  (A  D)  (B  C)  (B  D) Set of clauses: {A  C , A  D , B  C , B  D}

  42. Resolution Refutation Algorithm RESOLUTION-REFUTATION(KB,a) clauses set of clauses obtained from KB and a Repeat: new  {} For each C, C’ in clauses dores  RESOLVE(C,C’) If res contains the empty clause then return yes new  new U resIf newclauses then return no clauses  clauses U new

  43. 1 Battery-OK  Bulbs-OK  Headlights-Work 2 Battery-OK  Starter-OK Empty-Gas-Tank  Engine-Starts 3 Engine-Starts Flat-Tire  Car-OK 4 Headlights-Work 5 Battery-OK 6 Starter-OK 7 Empty-Gas-Tank 8 Car-OK

  44. 5 2 6 Starter-OK  Empty-Gas-Tank  Engine-Starts 7 Empty-Gas-Tank  Engine-Starts 3 Engine-Starts 8 Flat-Tire  Car-OK Flat-Tire Flat-Tire NIL (矛盾) 1 Battery-OK Bulbs-OK  Headlights-Work 2 Battery-OK Starter-OK  Empty-Gas-Tank Engine-Starts 3  Engine-Starts  Flat-Tire  Car-OK 4 Headlights-Work 5 Battery-OK 6 Starter-OK 7 Empty-Gas-Tank 8 Car-OK

  45. Summary • 命题逻辑:语法、语义 • 模型,可满足,逻辑涵蕴 • 推理, 可靠性, 完备性 • 归结/消解 • 归结反驳/消解反演 • Next lecture: 谓词逻辑

  46. 语法、语义、语用

  47. PL is Too Weak a Representational Language • Consider the problem of representing the following information: • Every person is mortal. (S1) • Confucius is a person. (S2) • Confucius is mortal. (S3) • S3 is clearly a logical consequence of S1 and S2. But how can these sentences be represented using PL so that we can infer the third sentence from the first two?

  48. Weakness of PL • Hard to identify "individuals." E.g., Mary, 3 • Individuals cannot be PL sentences themselves. • Difficult to directly and clearly talk about properties of individuals or relations between individuals (hard to connect individuals to class properties). • E.g., property of being a human implies property of being mortal • Generalizations, patterns, regularities can't easily be represented. • All members of a class have this property • Some member of a class have this property • A better representation is needed to capture the relationship (and distinction) between objects and classes, including properties belonging to classes and individuals

  49. First-Order Logic (Predicate Calculus abbreviated FOL or FOPC) is expressive enough to concisely represent this kind of situation by separating classes and individuals • Explicit representation of individuals and classes, x, Mary, 3, persons. • Adds relations, variables, and quantifiers, e.g., • “Every person is mortal”Forall X: person(X) => mortal(X) • “There is a white alligator”There exists some X: Alligator(X) ^ white(X)

  50. Predicate Calculus

More Related