1 / 63

Chương 3 Tri thức và lập luận

Chương 3 Tri thức và lập luận. Nội dung chính chương 3. Logic – ngôn ngữ của tư duy Logic mệnh đề (cú pháp, ngữ nghĩa, sức mạnh biểu diễn, các thuật toán suy diễn) Prolog (cú pháp, ngữ nghĩa, lập trình prolog, bài tập và thực hành)

Download Presentation

Chương 3 Tri thức và lập luận

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. Chương 3Tri thức và lập luận

  2. Nội dung chính chương 3 • Logic – ngôn ngữ của tư duy • Logic mệnh đề (cú pháp, ngữ nghĩa, sức mạnh biểu diễn, các thuật toán suy diễn) • Prolog (cú pháp, ngữ nghĩa, lập trình prolog, bài tập và thực hành) • Logic cấp một (cú pháp, ngữ nghĩa, sức mạnh biểu diễn, các thuật toán suy diễn) Lecture 1 Lecture 2 Lecture 3,4

  3. Lecture 4Inference in First-Order Logic

  4. Lecture 4: Inference in First-Order Logic - Outline • Proofs (chứng minh) • Unification (hợp nhất) • Generalized modus ponens - GMP(Luật modus ponens tổng quát) • Inference procedures based on GMP (các thủ tục dựa trên luật modus ponens tổng quát) • Forward chaining (suy diễn tiến) • Backward chaining (suy diễn lùi) • Incompleteness of GMP-based inferences (tính không đầy đủ của suy diễn tiến và lùi). • Inference procedures based on Resolution (thủ tục suy diễn hợp giải, thủ tục có tính đầy đủ trong logic cấp một) • Logic programming (lập trình logic) CS 561, Session 16-18

  5. Entailment and proof - Hệ quả logic và chứng minh CS 561, Session 16-18

  6. Remember:propositionallogicNhớ lại:Các định lý trong logicmệnh đề CS 561, Session 16-18

  7. Proofs – chứng minh CS 561, Session 16-18

  8. Proofs – Chứng minh (tiếp) The three new inference rules for FOL (compared to propositional logic) are: • Universal Elimination (UE): for any sentence , variable x and ground term , x  {x/} • Existential Elimination (EE): for any sentence , variable x and constant symbol k not in KB, x  {x/k} • Existential Introduction (EI): for any sentence , variable x not in  and ground term g in ,  x {g/x} CS 561, Session 16-18

  9. Proofs – Chứng minh (tiếp) The three new inference rules for FOL (compared to propositional logic) are: • Universal Elimination (UE): for any sentence , variable x and ground term , x  e.g., from x Likes(x, Candy) and {x/Joe} {x/} we can infer Likes(Joe, Candy) • Existential Elimination (EE): for any sentence , variable x and constant symbol k not in KB, x  e.g., from x Kill(x, Victim) we can infer {x/k} Kill(Murderer, Victim), if Murderer new symbol • Existential Introduction (EI): for any sentence , variable x not in  and ground term g in ,  e.g., from Likes(Joe, Candy) we can infer x {g/x} x Likes(x, Candy) CS 561, Session 16-18

  10. Example Proof CS 561, Session 16-18

  11. Example Proof CS 561, Session 16-18

  12. Example Proof CS 561, Session 16-18

  13. Example Proof CS 561, Session 16-18

  14. Search with primitive example rules CS 561, Session 16-18

  15. Unification – Hợp nhất • Unification is a "pattern matching" procedure that takes two atomic sentences, called literals, as input, and returns "failure" if they do not match and a substitution list, Theta, if they do match. • That is, unify(p,q) = Theta means subst(Theta, p) = subst(Theta, q) for two atomic sentences p and q. • Theta is called the most general unifier (mgu) • All variables in the given two literals are implicitly universally quantified • To make literals match, replace (universally-quantified) variables by terms

  16. Unification – Hợp nhất Goal of unification: finding σ CS 561, Session 16-18

  17. Unification – Hợp nhất CS 561, Session 16-18

  18. Unification Algorithm – Giải thuật hợp nhất procedure unify(p, q, theta) Scan p and q left-to-right and find the first corresponding terms where p and q "disagree" ; where p and q not equal If there is no disagreement, return theta ; success Let r and s be the terms in p and q, respectively, where disagreement first occurs If variable(r) then theta = union(theta, {r/s}) unify(subst(theta, p), subst(theta, q), theta) else if variable(s) then theta = union(theta, {s/r}) unify(subst(theta, p), subst(theta, q), theta) else return "failure" end

  19. Unification… • Examples

  20. VARIABLE term More Unification Examples 1 – unify(P(a,X), P(a,b)) σ = {X/b} 2 – unify(P(a,X), P(Y,b)) σ = {Y/a, X/b} 3 – unify(P(a,X), P(Y,f(a)) σ = {Y/a, X/f(a)} 4 – unify(P(a,X), P(X,b)) σ = failure Note: If P(a,X) and P(X,b) are independent, then we can replace X with Y and get the unification to work. CS 561, Session 16-18

  21. Generalized Modus Ponens (GMP) - Luật Modus Ponens tổng quát CS 561, Session 16-18

  22. Soundness of GMP – Tính đúng đắn của GMP CS 561, Session 16-18

  23. Horn form – Dạng câu Horn • We convert sentences to Horn form as they are entered into the KB • Using Existential Elimination and And Elimination • e.g., x Owns(Nono, x)  Missile(x) becomes Owns(Nono, M) Missile(M) (with M a new symbol that was not already in the KB) CS 561, Session 16-18

  24. Forward chaining procedure – Thủ tục suy diễn tiến CS 561, Session 16-18

  25. Backward chaining procedure – Thủ tục suy diễn lùi CS 561, Session 16-18

  26. An Example (from Konelsky) • Nintendo example. • Nintendo says it is Criminal for a programmer to provide emulators to people. My friends don’t have a Nintendo 64, but they use software that runs N64 games on their PC, which is written by Reality Man, who is a programmer. • Query: Has Reality Man done anything criminal? CS 561, Session 16-18

  27. Forward Chaining Programmer(x)  Emulator(y)  People(z)  Provide(x,z,y) Criminal(x) (1) Use(friends, x)  Runs(x, N64 games)  Provide(Reality Man, friends, x) (2) Software(x)  Runs(x, N64 games)  Emulator(x) (3) Programmer(Reality Man) (4) People(friends) (5) Software(U64) (6) Use(friends, U64) (7) Runs(U64, N64 games) (8) • Premises (6), (7) and (8) satisfy the implications fully. CS 561, Session 16-18

  28. Forward Chaining Programmer(x)  Emulator(y)  People(z)  Provide(x,z,y) Criminal(x) (1) Use(friends, x)  Runs(x, N64 games)  Provide(Reality Man, friends, x) (2) Software(x)  Runs(x, N64 games)  Emulator(x) (3) Programmer(Reality Man) (4) People(friends) (5) Software(U64) (6) Use(friends, U64) (7) Runs(U64, N64 games) (8) • So we can infer the consequents, which are now added to the knowledge base (this is done in two separate steps). CS 561, Session 16-18

  29. Forward Chaining Programmer(x)  Emulator(y)  People(z)  Provide(x,z,y) Criminal(x) (1) Use(friends, x)  Runs(x, N64 games)  Provide(Reality Man, friends, x) (2) Software(x)  Runs(x, N64 games)  Emulator(x) (3) Programmer(Reality Man) (4) People(friends) (5) Software(U64) (6) Use(friends, U64) (7) Runs(U64, N64 games) (8) Provide(Reality Man, friends, U64) (9) Emulator(U64) (10) • Addition of these new facts triggers further forward chaining. CS 561, Session 16-18

  30. Forward Chaining Programmer(x)  Emulator(y)  People(z)  Provide(x,z,y) Criminal(x) (1) Use(friends, x)  Runs(x, N64 games)  Provide(Reality Man, friends, x) (2) Software(x)  Runs(x, N64 games)  Emulator(x) (3) Programmer(Reality Man) (4) People(friends) (5) Software(U64) (6) Use(friends, U64) (7) Runs(U64, N64 games) (8) Provide(Reality Man, friends, U64) (9) Emulator(U64) (10) Criminal(Reality Man) (11) • Which results in the final conclusion: Criminal(Reality Man) CS 561, Session 16-18

  31. Backward Chaining • Question: Has Reality Man done anything criminal? • We will use the same knowledge as in our forward-chaining version of this example: Programmer(x)  Emulator(y)  People(z)  Provide(x,z,y) Criminal(x) Use(friends, x)  Runs(x, N64 games)  Provide(Reality Man, friends, x) Software(x)  Runs(x, N64 games)  Emulator(x) Programmer(Reality Man) People(friends) Software(U64) Use(friends, U64) Runs(U64, N64 games) CS 561, Session 16-18

  32. Backward Chaining • Question: Has Reality Man done anything criminal? Criminal(x) CS 561, Session 16-18

  33. Backward Chaining • Question: Has Reality Man done anything criminal? Yes, {x/Reality Man} Criminal(x) Programmer(x) CS 561, Session 16-18

  34. Backward Chaining • Question: Has Reality Man done anything criminal? Yes, {x/Reality Man}Yes, {z/friends} Criminal(x) Programmer(x) People(Z) CS 561, Session 16-18

  35. Backward Chaining • Question: Has Reality Man done anything criminal? Yes, {x/Reality Man}Yes, {z/friends} Criminal(x) Programmer(x) People(Z) Emulator(y) CS 561, Session 16-18

  36. Backward Chaining • Question: Has Reality Man done anything criminal? Yes, {x/Reality Man}Yes, {z/friends} Yes, {y/U64} Criminal(x) Programmer(x) People(z) Emulator(y) Software(y) CS 561, Session 16-18

  37. Backward Chaining • Question: Has Reality Man done anything criminal? Yes, {x/Reality Man}Yes, {z/friends} Yes, {y/U64} yes, {} Criminal(x) Programmer(x) People(z) Emulator(y) Software(y) Runs(U64, N64 games) CS 561, Session 16-18

  38. Backward Chaining • Question: Has Reality Man done anything criminal? Yes, {x/Reality Man}Yes, {z/friends} Yes, {y/U64} yes, {} Criminal(x) Programmer(x) People(z) Emulator(y) Provide (reality man, U64, friends) Software(y) Runs(U64, N64 games) CS 561, Session 16-18

  39. Backward Chaining • Question: Has Reality Man done anything criminal? Yes, {x/Reality Man}Yes, {z/friends} Yes, {y/U64} yes, {} Criminal(x) Programmer(x) People(z) Emulator(y) Provide (reality man, U64, friends) Software(y) Runs(U64, N64 games) Use(friends, U64) CS 561, Session 16-18

  40. Backward Chaining • Backward Chaining benefits from the fact that it is directed toward proving one statement or answering one question. • In a focused, specific knowledge base, this greatly decreases the amount of superfluous work that needs to be done in searches. • However, in broad knowledge bases with extensive information and numerous implications, many search paths may be irrelevant to the desired conclusion. • Unlike forward chaining, where all possible inferences are made, a strictly backward chaining system makes inferences only when called upon to answer a query. CS 561, Session 16-18

  41. Backward chaining Forward chaining Generalized Modus Ponens Completeness • As explained earlier, Generalized Modus Ponens requires sentences to be in Horn form: • atomic, or • an implication with a conjunction of atomic sentences as the antecedent and an atom as the consequent. • However, some sentences cannot be expressed in Horn form. • e.g.: x  bored_of_this_lecture (x) • E.g.: x P(x) => Q(x) • Cannot be expressed in Horn form due to presence of negation. CS 561, Session 16-18

  42. Completeness • A significant problem since Modus Ponens cannot operate on such a sentence, and thus cannot use it in inference. • Knowledge exists but cannot be used. • Thus inference using Modus Ponens is incomplete. CS 561, Session 16-18

  43. Completeness • However, Kurt Gödel in 1930-31 developed the completeness theorem, which shows that it is possible to find complete inference rules. • The theorem states: • any sentence entailed by a set of sentences can be proven from that set. => Resolution Algorithm which is a complete inference method. CS 561, Session 16-18

  44. Completeness in FOL CS 561, Session 16-18

  45. Resolution Procedure… Thủ tục hợp giải • Proof by contradiction method • Given a consistent set of axioms KB and goal sentence Q, we want to show that KB |= Q. This means that every interpretation I that satisfies KB, satisfies Q. But we know that any interpretation I satisfies either Q or ~Q, but not both. Therefore if in fact KB |= Q, an interpretation that satisfies KB, satisfies Q and does not satisfy ~Q. Hence KB union {~Q} is unsatisfiable, i.e., that it's false under all interpretations. • In other words, (KB |- Q) <=> (KB ^ ~Q |- False) • What's the gain? If KB union ~Q is unsatisfiable, then some finite subset is unsatisfiable • Resolution procedure can be used to establish that a given sentence Q is entailed by KB; however, it cannot, in general, be used to generate all logical consequences of a set sentences. Also, the resolution procedure cannot be used to prove that Q is not entailed by KB.

  46. Resolution inference rule CS 561, Session 16-18

  47. Resolution Algorithm – Giải thuật hợp giải procedure resolution-refutation(KB, Q) ;; KB is a set of consistent, true FOL sentences ;; Q is a goal sentence that we want to derive ;; return success if KB |- Q, and failure otherwise KB = union(KB, ~Q) while false not in KB do pick 2 sentences, S1 and S2, in KB that contain literals that unify (if none, return "failure“) resolvent = resolution-rule(S1, S2) KB = union(KB, resolvent) return "success"

  48. Kinship Example KB: (1) father (art, jon) (2) father (bob, kim) (3) father (X, Y)  parent (X, Y) Goal: parent (art, jon)? CS 561, Session 16-18

  49. Refutation Proof/Graph ¬parent(art,jon) ¬father(X, Y) \/ parent(X, Y) \ / ¬father (art, jon) father (art, jon) \ / [] CS 561, Session 16-18

  50. Problems yet to be addressed – Các vấn đề cần giải quyết khi áp dụng hợp giải. • Resolution rule of inference is only applicable with sentences that are in the form P1 v P2 v ... v Pn, where each Pi is a negated or nonnegated predicate and contains functions, constants, and universally quantified variables, so can we convert every FOL sentence into this form? • Resolution strategy • How to pick which pair of sentences to resolve? • How to pick which pair of literals, one from each sentence, to unify?

More Related