Download presentation

Presentation is loading. Please wait.

Published byMercy Neal Modified over 2 years ago

1
First-Order Logic ECE457 Applied Artificial Intelligence Spring 2007 Lecture #7

2
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 2 Outline First-order logic (FOL) Sentences Russell & Norvig, chapter 8 Inference Russell & Norvig, chapter 9

3
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 3 First-Order Logic Propositional logic is limited Cannot represent information concisely We want something more expressive First-order logic Allows the representation of objects, functions on objects and relations between objects Allows us to represent almost any English sentence

4
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 4 New Symbols in FOL Constant symbol An individual object in the world Bob, James, Hat Predicate symbol A relation between two objects that can be true or false Brother(Bob, James), OnHead(Hat, Bob) Function symbol Special type of relation that maps one object to another Head(Bob) All symbols begin with uppercase letters

5
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 5 New Variables in FOL Begin with lowercase letters Stand-in for any symbol Brother(x,y) x is the brother of y

6
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 6 New Quantifiers in FOL Universal quantifier x means “For all x…” Always true Usually used with x means “Not all x…” Existential quantifier x means “There exists an x…” True for at least one interpretation Usually used with x means “There exists no x…”

7
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 7 Properties of New Quantifiers Nesting x y P(x,y) same as y x P(x,y) x y P(x,y) same as y x P(x,y) x y P(x,y) not same as y x P(x,y) Duality x P(x) same as x P(x) x P(x) same as x P(x)

8
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 8 Sentences in FOL Term Constant symbol, function symbol, or variable Atom (atomic sentence) Predicate symbol with value true or false Represents a relation between terms Sentence (complex sentence) Atom(s) joined together using logical connectives and/or quantifiers

9
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 9 Example Sentences Purple mushrooms are poisonous Purple(x) Mushroom(x) Poisonous(x) Some purple mushrooms are poisonous x Purple(x) Mushroom(x) Poisonous(x) (bad!) x Purple(x) Mushroom(x) Poisonous(x) No purple mushrooms are poisonous x Purple(x) Mushroom(x) Poisonous(x) x Purple(x) Mushroom(x) Poisonous(x) There are exactly two purple mushrooms x y z Purple(x) Mushroom(x) Purple(y) Mushroom(y) (x=y) Purple(z) Mushroom(z) (x=z) (y=z)

10
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 10 Example Sentences You can fool some people all the time x y Person(x) Time(y) CanBeFooled(x,y) Everyone who loves all animals is loved by someone x y Animal(y) Love(x,y) z Love(z,x) No living man can kill the Witch-King x Living(x) Man(x) CanKill(x, Witch-King)

11
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 11 Wumpus World in FOL Predicate to represent adjacent rooms x,y,a,b Adjacent([x,y],[a,b]) [a,b] {[x+1,y], [x-1,y], [x,y+1], [x,y-1]} Sentences to represent the relationship between breezy rooms and pits r Breeze(r) s Adjacent(r,s) Pit(s) s Pit(s) ( r Adjacent(r,s) Breeze(r)) And so on…

12
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 12 Inference in FOL We know how to do inference in propositional logic Can we reduce FOL to propositional logic and infer from there? Propositionalization Eliminate universal quantifiers Eliminate existential quantifiers

13
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 13 Universal Instantiation A universal variable x in a true sentence P(x) can be substituted by any (and all) ground terms g without variables in the domain of x, and P(g) will be true SUBST({x/g},P(x)) = P(g) Example x {Bob, James, Tom} x Strong(x) Fast(x) Athlete(x) Strong(Bob) Fast(Bob) Athlete(Bob) Strong(James) Fast(James) Athlete(James) Strong(Tom) Fast(Tom) Athlete(Tom)

14
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 14 Existential Instantiation Any existential variable x in a true sentence P(x) can be replaced by a constant symbol not already in the KB Skolem constant Example x Purple(x) Mushroom(x) Poisonous(x) Purple(C) Mushroom(C) Poisonous(C)

15
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 15 Inference Example We know the following All of Bob’s dogs are brown. Fido is a dog. Bob owns Fido. Can we infer that Fido is brown? Translate into FOL KB x Dog(x) Own(Bob,x) Brown(x) Dog(Fido) Own(Bob,Fido) Apply inference rules Universal Instantiation with {x/Fido}: Dog(Fido) Own(Bob,Fido) Brown(Fido) And-Introduction: Dog(Fido) Own(Bob,Fido) Modus Ponens: Brown(Fido)

16
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 16 Problem with Propositionalization The set of ground substitution can be infinite Function symbols can be nested infinitely Example: Father(Bob), Father(Father(Bob)), Father(Father(Father(Bob))), … Algorithms can prove sentence is entailed Search every depth successively until sentence is found Algorithms cannot prove sentence is not entailed Will search deeper and deeper, forever Entailment in FOL is semidecidable

17
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 17 Problem with Propositionalization Modify the previous example x Dog(x) Own(Bob,x) Brown(x) Dog(Fido) Own(Bob,Fido) Dog(Barky) Brown(Fido) is obvious to us Universal Instantiation also expands Dog(Barky) Own(Bob,Barky) Brown(Barky) which is obviously unnecessary (to us) Recall Modus Ponens: (α β), α β

18
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 18 Generalized Modus Ponens Combine And-Introduction, Universal Elimination, and Modus Ponens p 1 ’, p 2 ’,…, p n ’, (p 1 p 2 … p n q) SUBST( , q) p 1 = Dog(x) p 2 = Own(Bob,x) q = Brown(x) p 1 ’ = Dog(Fido) p 2 ’ = Own(Bob,Fido) = {x/Fido} SUBST( , q) = Brown(Fido) Requires some form of pattern matching

19
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 19 Unification Unification algorithm takes two sentences p and q Returns the substitutions to make both sentences match, or failure if none is possible UNIFY(p,q) = , where is the list of substitutions in p and q Find the matching that places the least restrictions on the variables Most general unifier (MGU)

20
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 20 Unification Given sentences p and q, is empty Scan p and q left to right If they disagree on terms r and s If r is a variable If s is a complex term and r occurs in s Fail Else Add r/s to Else if s is a variable (but r is a complex term) If s occurs in r Fail Else Add s/r to Else (both r and s are complex term) Apply unification to r and s

21
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 21 Unification Rules Function symbols and predicate symbols unify with function symbols and predicate symbols that have identical names and number of arguments Constant symbols can only unify with identical constant symbols Variables can unify with other variables, constant symbols, or function symbols Variables cannot unify with a term in which that variable occurs. x cannot unify with P(x), as that leads to P(P(P(P(…P(x)…)))) That is an occur check error

22
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 22 Forward / Backward Chaining Recall from Propositional Logic Inference using Modus Ponens Either forward chaining or backward chaining We have Generalized Modus Ponens for FOL Inference is possible! Forward chaining or backward chaining

23
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 23 Forward / Backward Chaining Forward chaining Data-driven reasoning Start with known symbols Infer new symbols and add to KB Use new symbols to infer more new symbols Repeat until query proven or no new symbols can be inferred Backward chaining Goal-driven reasoning Start with query, try to infer it If there are unknown symbols in the premise of the query, infer them first If there are unknown symbols in the premise of these symbols, infer those first Repeat until query proven or its premise cannot be inferred

24
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 24 Resolution Recall from Propositional Logic ) (α β), (¬β γ) (α γ) Resolution rule is both sound and complete Proof by contradiction Convert KB to conjunctive normal form (CNF) Add negation of query Then perform inference until we reach a contradiction resulting from the negated query Reaching contradiction means query is true

25
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 25 Resolution Steps 1. Convert problem into FOL KB 2. Convert FOL statements in KB to CNF 3. Add negation of query (in CNF) in KB 4. Use resolution to infer new clauses from KB 5. Produce a contradiction that proves our query

26
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 26 Conversion to CNF Three new steps (4, 5, 6) 1. Eliminate biconditionals: (α β) ((α β) (β α)) 2. Eliminate implications: (α β) (¬α β) 3. Move/Eliminate negations: ¬(¬α) α, ¬(α β) (¬α ¬β), ¬(α β) (¬α ¬β) 4. Standardize variables: x P(x) x Q(x) x P(x) y Q(y) 5. Skolemize: x P(x) P(C) 6. Drop universal quantifiers: x P(x) P(x) 7. Distribute over : (α (β γ)) ((α β) (α γ))

27
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 27 Example of Resolution Consider the story Anyone passing their 457 exam and winning the lottery is happy. Anyone who studies or is lucky can pass all their exams. Bob did not study but is lucky. Anyone who’s lucky can win the lottery. Is Bob happy?

28
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 28 Example of Resolution Convert to FOL Anyone passing their exams and winning the lottery is happy. x Pass(x, 457) Win(x,Lottery) Happy(x) Anyone who studies or is lucky can pass all their exams. x y Study(x) Lucky(x) Pass(x,y) Bob did not study but is lucky. ¬Study(Bob) Lucky(Bob) Anyone who’s lucky can win the lottery. x Lucky(x) Win(x,Lottery) Is Bob happy? Happy(Bob)

29
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 29 Example of Resolution Convert to CNF x Pass(x, 457) Win(x,Lottery) Happy(x) x ¬(Pass(x, 457) Win(x,Lottery)) Happy(x) x ¬Pass(x, 457) ¬Win(x,Lottery) Happy(x) ¬Pass(x, 457) ¬Win(x,Lottery) Happy(x) x y Study(x) Lucky(x) Pass(x,y) x y ¬(Study(x) Lucky(x)) Pass(x,y) x y (¬Study(x) ¬Lucky(x)) Pass(x,y) (¬Study(x) ¬Lucky(x)) Pass(x,y) (¬Study(x) Pass(x,y)) (¬Lucky(x) Pass(x,y))

30
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 30 Example of Resolution Convert to CNF ¬Study(Bob) Lucky(Bob) x Lucky(x) Win(x,Lottery) x ¬Lucky(x) Win(x,Lottery) ¬Lucky(x) Win(x,Lottery) Negation of query for resolution ¬Happy(Bob)

31
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 31 Example of Resolution Content of KB ¬Pass(x 1, 457) ¬Win(x 1,Lottery) Happy(x 1 ) ¬Study(x 2 ) Pass(x 2,y 1 ) ¬Lucky(x 3 ) Pass(x 3,y 2 ) ¬Study(Bob) Lucky(Bob) ¬Lucky(x 4 ) Win(x 4,Lottery) ¬Happy(Bob)

32
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 32 Example of Resolution Resolution {x 1 /Bob} (¬Pass(x 1, 457) ¬Win(x 1,Lottery) Happy(x 1 )) ¬Happy(Bob) ¬Pass(Bob, 457) ¬Win(Bob,Lottery) {x 4 /Bob} (¬Pass(Bob, 457) ¬Win(Bob,Lottery)) (¬Lucky(x 4 ) Win(x 4,Lottery)) ¬Pass(Bob, 457) ¬Lucky(Bob)

33
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 33 Example of Resolution Resolution No substitution needed (¬Pass(Bob, 457) ¬Lucky(Bob)) Lucky(Bob) ¬Pass(Bob, 457) {x 3 /Bob, y 2 /457} ¬Pass(Bob, 457) (¬Lucky(Bob) Pass(Bob,457)) ¬Lucky(Bob) No substitution needed ¬Lucky(Bob) Lucky(Bob) Empty clause: FALSE

Similar presentations

Presentation is loading. Please wait....

OK

Inference and Resolution for Problem Solving

Inference and Resolution for Problem Solving

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on minimum wages act in tamil Ppt on eye os od Ppt on ms dos commands Ppt on leaders of the revolt of 1857 Ppt on network security basics Ppt on ramayana in sanskrit One act play ppt on ipad Ppt on wireless sensor network security model using zero knowledge protocol Ppt on polynomials and coordinate geometry calculator Ppt on reverse brain drain