1 / 45

First-Order Logic Prof. Dr. Widodo Budiharto 2018

Course : Artificial Intelligence. First-Order Logic Prof. Dr. Widodo Budiharto 2018. Outline. First-Order Logic Quantifiers Inference using First-order Logic Exercise. introduction. Introduction to First-Order Logic.

charlenej
Télécharger la présentation

First-Order Logic Prof. Dr. Widodo Budiharto 2018

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. Course : Artificial Intelligence First-Order LogicProf. Dr. Widodo Budiharto 2018

  2. Outline First-Order Logic Quantifiers Inference using First-order Logic Exercise

  3. introduction

  4. Introduction to First-Order Logic • Whereas propositional logic assumes the world contains facts, first-order logic (like natural language) assumes the world contains: • Objects: people, houses, numbers, colors, baseball games, wars, … • Relations: red, round, prime, brother of, bigger than, part of, comes between, … • Functions: father of, best friend, one more than, plus, …

  5. Introduction to First-Order Logic • English • Squares adjacent to pits are breezy • Propositional Logic • B1,1 (P1,2 P2,1), B2,1  (P1,1  P2,2 P3,1 ), etc • We should define all possible facts that satisfy the “English” • First-Order Logic •  s Breezy(s)  r Adjacent(r,s)  Pit(r) • We can satisfy the “English” with only a sentence

  6. Introduction to First-Order Logic Standard Logic Symbols  = For all ; [e.g : every one, every body, any time, etc]  = There exists ; [e.g : some one, some time, etc]  = Implication ; [ if … then ….]  = Equivalent ; biconditional [if … and … only … if …]  = Not ; negation  = OR ; disjunction  = AND ; conjunction

  7. Introduction to First-Order Logic Some kind of logic Epistemological commitment: the truth of what can be said about a sentence

  8. Syntax and Semantic of First-Order Logic What are the objects? Relations? Functions?

  9. Syntax and Semantic of First-Order Logic • Basic elements • Constants : KingJohn, 2, Binus, … (Objects) • Predicates : Brother, >, loves, … (Relations) • Functions : Sqrt, LeftLegOf, … (Functions) • Variables : x, y, a, b,... • Connectives : , , , ,  • Equality : = • Quantifiers : , 

  10. Syntax and Semantic of First-Order Logic • Term = function(term1,...,termn) or constant or variable • A logical expression that refers to an object • “Richard the Lionheart is the brother of King John”. • e.g., Brother(Richard, John)  A term • “King John’s left leg” • e.g., LeftLeg(John)  A term

  11. Syntax and Semantic of First-Order Logic • Atomic sentence • formed from a predicate symbol optionally followed by parenthesized list of terms • Brother(Richard, John) • Complex terms as arguments in atomic sentences is : • married (Father(Richard), Mother(John)) • An atomic sentence is true in a given model if • The relationreferred to by the predicate symbol holds among the objects referred to by the arguments.

  12. Syntax and Semantic of First-Order Logic • Complex sentence • Are made from atomic sentences using connectives • Examples: • Brother(LeftLeg(Richard), John) • Brother(Richard, John)  Brother(John, Richard) • King(Richard) King(John) • King(Richard) King(John)

  13. Universal quantifiers • Sentence: All Kings are persons • Variable x = {Richard, King John, the crown} • FOL: x King(x)  Person(x) • Richard is a King  Richard is a person • King John is a King  King John is a person • The crown is a King  the crown is a person

  14. Universal quantifiers • Sentence: All Kings are persons • Variable x = {Richard, King John, the crown} • Attention! Don’t use  for  • FOL: x King(x)  Person(x) • Richard is a King  Richard is a person • King John is a King King John is a person • The crown is a King the crown is a person

  15. Universal quantifiers

  16. Existential quantifiers • Sentence: The King John has a crown on his head • Variable x = {Richard, King John, the crown} • FOL: x Crown(x)  OnHead(x, John) • x is pronounced “There exists an x such that …” or “For some x …” • x P says that P is true in at least one extended interpretation that assigns x to a domain element

  17. Existential quantifiers • Sentence: The King John has a crown on his head • Variable x = {Richard, King John, the crown} • FOL: x Crown(x)  OnHead(x, John) • Richard is a Crown  Richard is on John’s head • King John is a Crown King John is on John’s head • The crown is a Crown the crown is on John’s head • (True) then the sentence is true, at least one

  18. Existential quantifiers

  19. Nested quantifiers • Sentence: Brothers are siblings • x y Brother(x, y)  Sibling(x, y) • Consecutive quantifiers of the same type can be written as one quantifier with several variables • To say that siblinghood is a symmetric relationship: • x,y Sibling(x,y)  Sibling(y,x)

  20. Nested quantifiers • A mixture: • “Everybody loves somebody”: • x y Loves(x, y) • “There is someone who is loved by everyone” : • y x Loves(x, y)

  21. Nested quantifiers

  22. Using First-Order Logic Assertions and queries in first-order logic • Sentences are added to a knowledge base using TELL, exactly as in propositional logic (Assertion) • We can assert that John is a king, Richard is a person, and all kings are persons: • TELL(KB, King(John)) . • TELL(KB, Person(Richard)) . • TELL(KB, ∀ x King(x) ⇒ Person(x)) .

  23. Using First-Order Logic Assertions and queries in first-order logic • We can ask questions of the knowledge base using ASK. • ASK(KB, King(John)) • Answer: True • We can ask what value of x makes the sentence true, using ASKVARS • ASKVARS(KB, Person(x)) • Answer: {x/John} and {x/Richard}

  24. Inference in First-Order Logic We begin with some simple inference rules (Instantiation) that can be applied to sentences with quantifiers to obtain sentences without quantifiers These rules lead naturally to the idea that first-order inference can be done by converting the knowledge base to propositional logic and using propositional inference

  25. Universal Instantiation • Universal Instantiation (UI) • for any variable v and ground term g, • Axiom that all greedy king are evil : • e.g., x King(x) Greedy(x)  Evil(x) yields: • King(John) Greedy(John) Evil(John) • King(Richard) Greedy(Richard) Evil(Richard) • King(Father(John)) Greedy(Father(John))  Evil(Father(John))

  26. Existential Instantiation • Existential Instantiation (EI) • For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base: • e.g., x:Crown (x) OnHead (x, John) yields: • Crown (C1) OnHead (C1, John) • provided C1 is a new constant symbol, called a Skolem constant

  27. Unification

  28. Unification

  29. Unification

  30. Unification

  31. Unification

  32. Unification • To unify Knows (John, x) and Knows (y, z), could return: • θ = {y/John, x/z} or θ = {y/John, x/John, z/John} • The first unifier is more general than the second. • There is a single most general unifier (MGU) that is unique up to renaming of variables. • MGU = { y/John, x/z }

  33. Generalized Modus Ponens (GMP)

  34. Example: Knowledge Base The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American. Prove that Colonel West is a criminal

  35. Example: Knowledge Base • ... it is a crime for an American to sell weapons to hostile nations: • American(x)  Weapon(y)  Sells(x, y, z)  Hostile(z)  Criminal(x) • Nono … has some missiles, i.e., x Owns(Nono, x)  Missile(x): • Owns(Nono,M1) • Missile(M1) • … all of its missiles were sold to it by Colonel West • Missile(x)  Owns(Nono, x)  Sells(West,x,Nono)

  36. Example: Knowledge Base • Missiles are weapons: • Missile(x)  Weapon(x) • An enemy of America counts as "hostile“: • Enemy(x, America)  Hostile(x) • West, who is American … • American(West) • The country Nono, an enemy of America … • Enemy(Nono, America)

  37. Resolution

  38. Conversion to CNF Sentence : “Everyone who loves all animals is loved by someone”: x [y Animal(y)  Loves(x, y)]  [y Loves(y, x)] • Eliminate implications • x [y Animal(y)  Loves(x, y)]  [y Loves(y, x)] • Move  inwards: • x p ≡ x p,  x p ≡ x p • x [y (Animal(y)  Loves(x, y))]  [y Loves(y, x)] • x [y Animal(y) Loves(x, y)]  [y Loves(y, x)] • x [y Animal(y) Loves(x, y)]  [y Loves(y, x)]

  39. Conversion to CNF • Standardize variables: each quantifier should use a different one • x [y Animal(y) Loves(x, y)]  [z Loves(z, x)] • Skolemize: a more general form of existential instantiation. Each existential variable is replaced by a Skolem function of the enclosing universally quantified variables: • x [Animal(F(x)) Loves(x, F(x))]  Loves(G(x),x) • Drop universal quantifiers: • [Animal(F(x)) Loves(x,F(x))]  Loves(G(x),x) • Distribute  over  : • [Animal(F(x))  Loves(G(x),x)]  [Loves(x, F(x))  Loves(G(x), x)]

  40. Conversion to CNF • American(x)  Weapon(y)  Sells(x, y, z)  Hostile(z)  Criminal(x) • American(x)  Weapon(y)  Sells(x, y, z)  Hostile(z)  Criminal(x) • Owns(Nono,M1) and Missile(M1) • Owns (Nono, M1) • Missile(M1) • Missile(x)  Owns(Nono, x)  Sells(West, x, Nono) • Missile(x)  Owns(Nono, x)  Sells(West, x, Nono)

  41. Conversion to CNF • Missile(x)  Weapon(x) • Missile(x)  Weapons(x) • Enemy(x, America)  Hostile(x) • Enemy(x, America)  Hostile(x) • American(West) • American(West) • Enemy(Nono, America) • Enemy(Nono, America)

  42. Resolution • Knowledge Base in CNF • American(x)  Weapon(y)  Sells(x, y, z)  Hostile(z)  Criminal(x) • Missile(x)  Owns(Nono, x)  Sells(West, x, Nono) • Enemy(x, America)  Hostile(x) • Missile(x)  Weapons(x) • Owns (Nono, M1) • Missile(M1) • American(West) • Enemy(Nono, America)

  43. Resolution

  44. References Widodo Budiharto and Derwin Suhartono. (2014). Artificial Intelligence, Andi Offset Publisher Stuart Russell, Peter Norvig. 2010. Artificial Intelligence : A Modern Approach. Pearson Education. New Jersey. ISBN:9780132071482

  45. Given sentences as premise: • John is a student • John is in the Informatics department • Each Informatics’ student must be an engineering student • Mathematic is a difficult lesson • Each engineering student would definitely like Mathematic or hate it • Each student would definitely like a lesson • Students who have never attended difficult lesson certainly do not like the lesson • Peter has never attended the Mathematic lesson Based on given premises above, please create: • FOL • Convert FOL in part a) to CNF • Proof by Resolution, that Peter hate Mathematic. Exercise

More Related