1 / 63

FOPL

First order predicate logic

jayagupta
Télécharger la présentation

FOPL

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. Introduction to Artificial Intelligence First-order Logic (Logic, Deduction, Knowledge Representation) Bernhard Beckert UNIVERSITÄT KOBLENZ-LANDAU Winter Term 2004/2005 B. Beckert: KI für IM – p.1

  2. Outline Why first-order logic? Syntax and semantics of first-order logic Fun with sentences Wumpus world in first-order logic B. Beckert: KI für IM – p.2

  3. Propositional logic allows partial / disjunctive / negated information (unlike most data structures and databases) Propositional logic is compositional: meaning of B1,1∧P1,2is derived from meaning of B1,1and of P1,2 Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) Propositional logic has very limited expressive power (unlike natural language) Example: Cannot say “pits cause breezes in adjacent squares” except by writing one sentence for each square Pros and Cons of Propositional Logic Propositional logic is declarative: pieces of syntax correspond to facts B. Beckert: KI für IM – p.3

  4. Propositional logic is compositional: meaning of B1,1∧P1,2is derived from meaning of B1,1and of P1,2 Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) Propositional logic has very limited expressive power (unlike natural language) Example: Cannot say “pits cause breezes in adjacent squares” except by writing one sentence for each square Pros and Cons of Propositional Logic Propositional logic is declarative: pieces of syntax correspond to facts Propositional logic allows partial / disjunctive / negated information (unlike most data structures and databases) B. Beckert: KI für IM – p.3

  5. Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) Propositional logic has very limited expressive power (unlike natural language) Example: Cannot say “pits cause breezes in adjacent squares” except by writing one sentence for each square Pros and Cons of Propositional Logic Propositional logic is declarative: pieces of syntax correspond to facts Propositional logic allows partial / disjunctive / negated information (unlike most data structures and databases) Propositional logic is compositional: meaning of B1,1∧P1,2is derived from meaning of B1,1and of P1,2 B. Beckert: KI für IM – p.3

  6. Propositional logic has very limited expressive power (unlike natural language) Example: Cannot say “pits cause breezes in adjacent squares” except by writing one sentence for each square Pros and Cons of Propositional Logic Propositional logic is declarative: pieces of syntax correspond to facts Propositional logic allows partial / disjunctive / negated information (unlike most data structures and databases) Propositional logic is compositional: meaning of B1,1∧P1,2is derived from meaning of B1,1and of P1,2 Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) B. Beckert: KI für IM – p.3

  7. Pros and Cons of Propositional Logic Propositional logic is declarative: pieces of syntax correspond to facts Propositional logic allows partial / disjunctive / negated information (unlike most data structures and databases) Propositional logic is compositional: meaning of B1,1∧P1,2is derived from meaning of B1,1and of P1,2 Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) Propositional logic has very limited expressive power (unlike natural language) Example: Cannot say “pits cause breezes in adjacent squares” except by writing one sentence for each square B. Beckert: KI für IM – p.3

  8. First-order logic Assumes that the world contains Objects people, houses, numbers, theories, Donald Duck, colors, centuries, ... Relations red, round, prime, multistoried, ... brother of, bigger than, part of, has color, occurred after, owns, ... Functions +, middle of, father of, one more than, beginning of, ... First-order Logic Propositional logic Assumes that the world contains facts B. Beckert: KI für IM – p.4

  9. Relations red, round, prime, multistoried, ... brother of, bigger than, part of, has color, occurred after, owns, ... Functions +, middle of, father of, one more than, beginning of, ... First-order Logic Propositional logic Assumes that the world contains facts First-order logic Assumes that the world contains Objects people, houses, numbers, theories, Donald Duck, colors, centuries, ... B. Beckert: KI für IM – p.4

  10. Functions +, middle of, father of, one more than, beginning of, ... First-order Logic Propositional logic Assumes that the world contains facts First-order logic Assumes that the world contains Objects people, houses, numbers, theories, Donald Duck, colors, centuries, ... Relations red, round, prime, multistoried, ... brother of, bigger than, part of, has color, occurred after, owns, ... B. Beckert: KI für IM – p.4

  11. First-order Logic Propositional logic Assumes that the world contains facts First-order logic Assumes that the world contains Objects people, houses, numbers, theories, Donald Duck, colors, centuries, ... Relations red, round, prime, multistoried, ... brother of, bigger than, part of, has color, occurred after, owns, ... Functions +, middle of, father of, one more than, beginning of, ... B. Beckert: KI für IM – p.4

  12. Note The equality predicate is always in the vocabulary It is written in infix notation Syntax of First-order Logic: Basic Elements Symbols KingJohn, 2, Koblenz, C,... Constants Brother, >, =, ... Predicates Sqrt, LeftLegOf, ... Functions x, y, a, b, ... Variables Connectives ∧ ∨ ¬ ⇒ ⇔ Quantifiers ∀ ∃ B. Beckert: KI für IM – p.5

  13. Syntax of First-order Logic: Basic Elements Symbols KingJohn, 2, Koblenz, C,... Constants Brother, >, =, ... Predicates Sqrt, LeftLegOf, ... Functions x, y, a, b, ... Variables Connectives ∧ ∨ ¬ ⇒ ⇔ Quantifiers ∀ ∃ Note The equality predicate is always in the vocabulary It is written in infix notation B. Beckert: KI für IM – p.5

  14. Term function ( term1, ..., termn) or constant or variable Syntax of First-order Logic: Atomic Sentences Atomic sentence predicate ( term1, ..., termn) or term1= term2 B. Beckert: KI für IM – p.6

  15. Syntax of First-order Logic: Atomic Sentences Atomic sentence predicate ( term1, ..., termn) or term1= term2 Term function ( term1, ..., termn) or constant or variable B. Beckert: KI für IM – p.6

  16. Syntax of First-order Logic: Atomic Sentences Example Brother ( KingJohn, RichardTheLionheart ) B. Beckert: KI für IM – p.7

  17. Syntax of First-order Logic: Atomic Sentences Example Brother | {z } predicate ( KingJohn | {z constant , RichardTheLionheart | {z constant ) } } B. Beckert: KI für IM – p.7

  18. Syntax of First-order Logic: Atomic Sentences Example Brother | {z } predicate ( KingJohn | {z constant | {z term , RichardTheLionheart | {z constant | {z term ) } } } } B. Beckert: KI für IM – p.7

  19. Syntax of First-order Logic: Atomic Sentences Example Brother | {z } predicate ( KingJohn | {z constant | {z term , RichardTheLionheart | {z constant | {z term {z atomic sentence ) } } } } | } B. Beckert: KI für IM – p.7

  20. Syntax of First-order Logic: Atomic Sentences Example ( Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn)) ) > B. Beckert: KI für IM – p.8

  21. Syntax of First-order Logic: Atomic Sentences Example ( Length | {z } function (LeftLegOf | {z function (Richard | {z } constant )), Length | {z } function (LeftLegOf | {z function (KingJohn | {z constant )) ) > | {z } predicate } } } B. Beckert: KI für IM – p.8

  22. Syntax of First-order Logic: Atomic Sentences Example ( Length | {z } function | (LeftLegOf | {z function (Richard | {z } constant , Length | {z } function | (LeftLegOf | {z function (KingJohn | {z constant )) )) ) > |{z} predicate } } } {z term } {z term } B. Beckert: KI für IM – p.8

  23. Syntax of First-order Logic: Atomic Sentences Example ( Length | {z } function | (LeftLegOf | {z function (Richard | {z } constant , Length | {z } function | (LeftLegOf | {z function (KingJohn | {z constant )) )) ) > |{z} predicate } } } {z term } {z term } | {z } atomic sentence B. Beckert: KI für IM – p.8

  24. Example Syntax of First-order Logic: Complex Sentences Built from atomic sentences using connectives ¬S S1∧S2 S1∨S2 S1⇒ S2 S1⇔ S2 (as in propositional logic) B. Beckert: KI für IM – p.9

  25. Syntax of First-order Logic: Complex Sentences Built from atomic sentences using connectives ¬S S1∧S2 S1∨S2 S1⇒ S2 S1⇔ S2 (as in propositional logic) Example Sibling( KingJohn,Richard ) Sibling( Richard,KingJohn ) ⇒ B. Beckert: KI für IM – p.9

  26. Syntax of First-order Logic: Complex Sentences Built from atomic sentences using connectives ¬S S1∧S2 S1∨S2 S1⇒ S2 S1⇔ S2 (as in propositional logic) Example Sibling | {z } predicate ( KingJohn | {z term ,Richard | {z } term Sibling | {z } predicate ( Richard | {z } term ,KingJohn | {z term ) ⇒ ) } } B. Beckert: KI für IM – p.9

  27. Syntax of First-order Logic: Complex Sentences Built from atomic sentences using connectives ¬S S1∧S2 S1∨S2 S1⇒ S2 S1⇔ S2 (as in propositional logic) Example Sibling | {z } predicate | ( KingJohn | {z term ,Richard | {z } term Sibling | {z } predicate | ( Richard | {z } term ,KingJohn | {z term ) ⇒ ) } } {z } {z } atomic sentence atomic sentence B. Beckert: KI für IM – p.9

  28. Syntax of First-order Logic: Complex Sentences Built from atomic sentences using connectives ¬S S1∧S2 S1∨S2 S1⇒ S2 S1⇔ S2 (as in propositional logic) Example Sibling | {z } predicate | ( KingJohn | {z term ,Richard | {z } term Sibling | {z } predicate | ( Richard | {z } term ,KingJohn | {z term ) ⇒ ) } } {z } {z } atomic sentence atomic sentence | {z } complex sentence B. Beckert: KI für IM – p.9

  29. Domain A non-empty (finite or infinite) set of arbitrary elements Interpretation Assigns to each – constant symbol: a domain element – predicate symbol: a relation on the domain (of appropriate arity) – function symbol: a function on the domain (of appropriate arity) Semantics in First-order Logic Models of first-order logic Sentences are true or false with respect to models, which consist of – a domain – an interpretation (also called universe) B. Beckert: KI für IM – p.10

  30. Interpretation Assigns to each – constant symbol: a domain element – predicate symbol: a relation on the domain (of appropriate arity) – function symbol: a function on the domain (of appropriate arity) Semantics in First-order Logic Models of first-order logic Sentences are true or false with respect to models, which consist of – a domain – an interpretation (also called universe) Domain A non-empty (finite or infinite) set of arbitrary elements B. Beckert: KI für IM – p.10

  31. Semantics in First-order Logic Models of first-order logic Sentences are true or false with respect to models, which consist of – a domain – an interpretation (also called universe) Domain A non-empty (finite or infinite) set of arbitrary elements Interpretation Assigns to each – constant symbol: a domain element – predicate symbol: a relation on the domain (of appropriate arity) – function symbol: a function on the domain (of appropriate arity) B. Beckert: KI für IM – p.10

  32. The truth value of a complex sentence in a model is computed from the truth-values of its atomic sub-sentences in the same way as in propositional logic Semantics in First-order Logic Definition An atomic sentence predicate ( term1, ..., termn) is true in a certain model (that consists of a domain and an interpretation) iff the domain elements that are the interpretations of term1,...,termn are in the relation that is the interpretation of predicate B. Beckert: KI für IM – p.11

  33. Semantics in First-order Logic Definition An atomic sentence predicate ( term1, ..., termn) is true in a certain model (that consists of a domain and an interpretation) iff the domain elements that are the interpretations of term1,...,termn are in the relation that is the interpretation of predicate The truth value of a complex sentence in a model is computed from the truth-values of its atomic sub-sentences in the same way as in propositional logic B. Beckert: KI für IM – p.11

  34. Models for First-order Logic: Example KingJohn, Richard person, king, crown brother, on_head, left_leg Constants: Predicates: Functions: B. Beckert: KI für IM – p.12

  35. Example “Everyone studying in Koblenz is smart: x (StudiesAt(x,Koblenz) ⇒ Smart(x)) | {z sentence ∀ |{z} variables } Universal Quantification: Syntax Syntax ∀ variables sentence B. Beckert: KI für IM – p.13

  36. Universal Quantification: Syntax Syntax ∀ variables sentence Example “Everyone studying in Koblenz is smart: x (StudiesAt(x,Koblenz) ⇒ Smart(x)) | {z sentence ∀ |{z} variables } B. Beckert: KI für IM – p.13

  37. Intuition ∀xP is roughly equivalent to the conjunction of all instances of P ∀ x StudiesAt(x,Koblenz) ⇒ Smart(x) Example equivalent to: StudiesAt(KingJohn,Koblenz) ⇒ Smart(KingJohn) StudiesAt(Richard,Koblenz) ⇒ Smart(Richard) StudiesAt(Koblenz,Koblenz) ⇒ Smart(Koblenz) ∧ ∧ ∧ ... Universal Quantification: Semantics Semantics ∀xP is true in a model iff for all domain elements d in the model: P is true in the model when x is interpreted by d B. Beckert: KI für IM – p.14

  38. ∀ x StudiesAt(x,Koblenz) ⇒ Smart(x) Example equivalent to: StudiesAt(KingJohn,Koblenz) ⇒ Smart(KingJohn) StudiesAt(Richard,Koblenz) ⇒ Smart(Richard) StudiesAt(Koblenz,Koblenz) ⇒ Smart(Koblenz) ∧ ∧ ∧ ... Universal Quantification: Semantics Semantics ∀xP is true in a model iff for all domain elements d in the model: P is true in the model when x is interpreted by d Intuition ∀xP is roughly equivalent to the conjunction of all instances of P B. Beckert: KI für IM – p.14

  39. Universal Quantification: Semantics Semantics ∀xP is true in a model iff for all domain elements d in the model: P is true in the model when x is interpreted by d Intuition ∀xP is roughly equivalent to the conjunction of all instances of P ∀ x StudiesAt(x,Koblenz) ⇒ Smart(x) Example equivalent to: StudiesAt(KingJohn,Koblenz) ⇒ Smart(KingJohn) StudiesAt(Richard,Koblenz) ⇒ Smart(Richard) StudiesAt(Koblenz,Koblenz) ⇒ Smart(Koblenz) ∧ ∧ ∧ ... B. Beckert: KI für IM – p.14

  40. Example ∀x(StudiesAt(x,Koblenz) ⇒ Smart(x)) Correct: “Everyone who studies at Koblenz is smart” ∀x(StudiesAt(x,Koblenz) ∧ Smart(x)) Wrong: “Everyone studies at Koblenz and is smart”, i.e., “Everyone studies at Koblenz and everyone is smart” A Common Mistake to Avoid Note is the main connective with ∀ ⇒ Common mistake Using ∧ as the main connective with ∀ B. Beckert: KI für IM – p.15

  41. ∀x(StudiesAt(x,Koblenz) ∧ Smart(x)) Wrong: “Everyone studies at Koblenz and is smart”, i.e., “Everyone studies at Koblenz and everyone is smart” A Common Mistake to Avoid Note is the main connective with ∀ ⇒ Common mistake Using ∧ as the main connective with ∀ Example ∀x(StudiesAt(x,Koblenz) ⇒ Smart(x)) Correct: “Everyone who studies at Koblenz is smart” B. Beckert: KI für IM – p.15

  42. A Common Mistake to Avoid Note is the main connective with ∀ ⇒ Common mistake Using ∧ as the main connective with ∀ Example ∀x(StudiesAt(x,Koblenz) ⇒ Smart(x)) Correct: “Everyone who studies at Koblenz is smart” ∀x(StudiesAt(x,Koblenz) ∧ Smart(x)) Wrong: “Everyone studies at Koblenz and is smart”, i.e., “Everyone studies at Koblenz and everyone is smart” B. Beckert: KI für IM – p.15

  43. Example “Someone studying in Landau is smart: x (StudiesAt(x,Landau)∧Smart(x)) | {z sentence ∃ |{z} variables } Existential Quantification: Syntax Syntax ∃ variables sentence B. Beckert: KI für IM – p.16

  44. Existential Quantification: Syntax Syntax ∃ variables sentence Example “Someone studying in Landau is smart: x (StudiesAt(x,Landau)∧Smart(x)) | {z sentence ∃ |{z} variables } B. Beckert: KI für IM – p.16

  45. Intuition ∃xP is roughly equivalent to the disjunction of all instances of P ∃ x StudiesAt(x,Landau)∧Smart(x) Example equivalent to: StudiesAt(KingJohn,Landau)∧Smart(KingJohn) StudiesAt(Richard,Landau)∧Smart(Richard) StudiesAt(Landau,Landau)∧Smart(Landau) ∨ ∨ ∨ ... Existential Quantification: Semantics Semantics ∃xP is true in a model iff there is a domain element d in the model such that: P is true in the model when x is interpreted by d B. Beckert: KI für IM – p.17

  46. ∃ x StudiesAt(x,Landau)∧Smart(x) Example equivalent to: StudiesAt(KingJohn,Landau)∧Smart(KingJohn) StudiesAt(Richard,Landau)∧Smart(Richard) StudiesAt(Landau,Landau)∧Smart(Landau) ∨ ∨ ∨ ... Existential Quantification: Semantics Semantics ∃xP is true in a model iff there is a domain element d in the model such that: P is true in the model when x is interpreted by d Intuition ∃xP is roughly equivalent to the disjunction of all instances of P B. Beckert: KI für IM – p.17

  47. Existential Quantification: Semantics Semantics ∃xP is true in a model iff there is a domain element d in the model such that: P is true in the model when x is interpreted by d Intuition ∃xP is roughly equivalent to the disjunction of all instances of P ∃ x StudiesAt(x,Landau)∧Smart(x) Example equivalent to: StudiesAt(KingJohn,Landau)∧Smart(KingJohn) StudiesAt(Richard,Landau)∧Smart(Richard) StudiesAt(Landau,Landau)∧Smart(Landau) ∨ ∨ ∨ ... B. Beckert: KI für IM – p.17

  48. Example ∃x(StudiesAt(x,Landau) ∧ Smart(x)) Correct: “There is someone who studies at Landau and is smart” ∃x(StudiesAt(x,Landau) ⇒ Smart(x)) Wrong: “There is someone who, if he/she studies at Landau, is smart” This is true if there is anyone not studying at Landau Another Common Mistake to Avoid Note is the main connective with ∃ ∧ Common mistake Using ⇒ as the main connective with ∃ B. Beckert: KI für IM – p.18

  49. ∃x(StudiesAt(x,Landau) ⇒ Smart(x)) Wrong: “There is someone who, if he/she studies at Landau, is smart” This is true if there is anyone not studying at Landau Another Common Mistake to Avoid Note is the main connective with ∃ ∧ Common mistake Using ⇒ as the main connective with ∃ Example ∃x(StudiesAt(x,Landau) ∧ Smart(x)) Correct: “There is someone who studies at Landau and is smart” B. Beckert: KI für IM – p.18

  50. Another Common Mistake to Avoid Note is the main connective with ∃ ∧ Common mistake Using ⇒ as the main connective with ∃ Example ∃x(StudiesAt(x,Landau) ∧ Smart(x)) Correct: “There is someone who studies at Landau and is smart” ∃x(StudiesAt(x,Landau) ⇒ Smart(x)) Wrong: “There is someone who, if he/she studies at Landau, is smart” This is true if there is anyone not studying at Landau B. Beckert: KI für IM – p.18

More Related