lecture7 ch7.1,9 except9.7

Artificial Intelligence: A Modern Approach

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture 7: First-order logic ICS 171, Summer 2000 AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 1 Outline Syntax and semantics of FOL Fun with sentences Comparison with propositional logic AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 2 Syntax of FOL: Basic elements Constants Predicates Functions Variables Connectives Equality Quanti ers John; 2; UCI; : : : Brother; ; : : : Sqrt; LeftLegOf; : : : x; y; a; b; : : : ^_: , = 89 AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 3 Syntax: Atomic sentences Atomic sentence = predicateterm1 ; : : : ; termn or term1 = term2 Term = functionterm1; : : : ; termn or constant or variable E.g., BrotherBill; Mary LengthLeftLegOf Richard; LengthLeftLegOf John BrotherOf Bill = Bob AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 4 Syntax: Complex sentences Complex sentences are made from atomic sentences using connectives :S; S1 ^ S2; S1 _ S2; S1 S2; S1 , S2 E.g. SiblingTom; Bill SiblingBill; Tom 1; 2 _ 1; 2 1; 2 ^ : 1; 2 Note: Much more expressive power in comparison with propositional logic AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 5 Truth in rst-order logic Sentences are true with respect to a model and an interpretation Model contains objects and relations among them Interpretation speci es referents for constant symbols ! objects predicate symbols ! relations function symbols ! functional relations An atomic sentence predicateterm1 ; : : : ; termn is true i the objects referred to by term1; : : : ; termn are in the relation referred to by predicate AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 6 Semantics: Examples 1. Constant symbols: An interpretation must specify which object in the world is referred to by each constant symbol. 2. Predicate symbols: An interpretation speci es that a predicate refers to a particular relation in the model, e.g. brotherhood predicate Brotherx; y is a binary predicate symbol. 3. Function symbols: Some of the relations between objects are functional; that is, a given object is related to another object by the relation, e.g. function BrotherOf x refers to such objects who are in the relation of bortherhood to x AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 7 Semantics: Universal quanti cation 8hvariablesi hsentencei 8 x P x Every ICS student needs a course in AI: 8 x Studentx; ICS Needsx; AI is equivalent to the conjunction of instantiations of P and is interpreted as P x is true for any possible x from the universe. E.g. 8 x Studentx; ICS Smartx is equivalent to claiming that StudentJohn; ICS SmartJohn ^ StudentRichard; ICS SmartRichard ^ StudentDebbie; ICS SmartDebbie ^ : : : Typically, is the main connective with 8. Common mistake: using ^ as the main connective with 8: 8 x Studentx; ICS ^ Smartx means Everyone is at ICS and everyone is smart" AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 8 Semantics: Existential quanti cation 9 hvariablesi hsentencei Someone at UCI is smart: 9 x Atx; UCI ^ Smartx 9 x P is equivalent to the disjunction of instantiations of P preted as P x is true for some object x in the universe. and is inter- E.g. 9 x Atx; UCI ^ Smartx is equivalent to claiming that Typically, ^ is the main connective with 9. Common mistake: using as the main connective with 9: AtJohn; UCI ^ SmartJohn _ AtRichard; UCI ^ SmartRichard _ AtDebbie; UCI ^ SmartDebbie _ : : : 9 x Atx; UCI Smartx is true if there is anyone who is not at UCI! AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 9 Properties of quanti ers 8x 9x 9x 9x 8 y is the same as 8 y 8 x why?? 9 y is the same as 9 y 9 x why?? 8 y is not the same as 8 y 9 x 8 y Lovesx; y There is a person who loves everyone in the world" Everyone in the world is loved by at least one person" 8 y 9 x Lovesx; y Quanti er duality: each can be expressed using the other 8 x Likesx; IceCream :9 x :Likesx; IceCream 9 x Likesx; Broccoli :8 x :Likesx; Broccoli AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 10 Fun with sentences Everybody loves Jerry . Everybody loves somebody . There is somebody whom everybody loves . Nobody loves everybody . AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 11 Fun with sentences There is somebody whom Lydia doesn't love . There is somebody whom nobody loves . Everyone loves himself or herself . AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 12 Fun with sentences Brothers are siblings . Sibling" is re exive . One's mother is one's female parent . A rst cousin is a child of a parent's sibling . AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 13 Summary First-order logic: - is a general purpose representation language based on the assumption of the existance of objects and relations in the world - has an increased expressive power compare to propositional logic There exists a complete inference procedure for FOL. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 14 Inference in first-order logic AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 15 Outline Proofs Uni cation Generalized Modus Ponens Forward and backward chaining Completeness Resolution AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 16 Proofs Sound inference: nd such that KB j= . Proof process is a search, operators are inference rules. E.g., Modus Ponens MP ; AtJoe; UCB AtJoe; UCB OK Joe OK Joe E.g., And-Introduction AI ^ 8x fx= g OK Joe CSMajorJoe OK Joe ^ CSMajorJoe E.g., Universal Elimination UE 8 x Atx; UCB OK x AtPat; UCB OK Pat 17 must be a ground term i.e., no variables AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. Example proof Bob is a bu alo Pat is a pig Bu aloes outrun pigs Bob outruns Pat 1. BuffaloBob 2. PigPat 3. 8 x; y Buffalox ^ Pigy Fasterx; y AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 18 Example proof Bob is a bu alo Pat is a pig Bu aloes outrun pigs Bob outruns Pat AI 1 & 2 UE 3, fx=Bob; y=Patg MP 4 & 5 1. BuffaloBob 2. PigPat 3. 8 x; y Buffalox ^ Pigy 4. BuffaloBob ^ PigPat 5. BuffaloBob ^ PigPat 6. FasterBob; Pat Fasterx; y FasterBob; Pat AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 19 Search with primitive inference rules Operators are inference rules States are sets of sentences Goal test checks state to see if it contains query sentence 1 2 3 AI 1 & 2 AI, UE, MP is a common inference pattern Problem: branching factor huge, esp. for UE Idea: nd a substitution that makes the rule premise match some known facts a single, more powerful inference rule 1 2 3 4 UE 3 {x/Bob, y/Pat} 1 2 3 4 5 MP 5 & 6 1 2 3 4 5 6 AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 20 Uni cation A substitution uni es atomic sentences p and q if p = q p KnowsJohn; x KnowsJohn; x KnowsJohn; x q KnowsJohn; Jane Knowsy; OJ Knowsy; Mothery AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 21 Uni cation A substitution uni es atomic sentences p and q if p = q p KnowsJohn; x KnowsJohn; x KnowsJohn; x q KnowsJohn; Jane fx=Janeg Knowsy; OJ fx=John; y=OJ g Knowsy; Mothery fy=John; x=MotherJohng LikesJohn; OJ LikesJohn; MotherJohn Idea: Unify rule premises with known facts, apply uni er to conclusion E.g., if we know q and KnowsJohn; x LikesJohn; x then we conclude LikesJohn; Jane AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 22 Generalized Modus Ponens GMP p10; p20; : : : ; pn0; p1 ^ p2 ^ : : : ^ pn q where p 0 = p for all i i i q E.g. p10 = FasterBob,Pat p20 = FasterPat,Steve p1 ^ p2 q = Fasterx; y ^ Fastery; z Fasterx; z = fx=Bob; y=Pat; z=Steveg q = FasterBob; Steve GMP used with KB of de nite clauses exactly one positive literal: either a single atomic sentence or conjunction of atomic sentences atomic sentence All variables assumed universally quanti ed AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 23 Forward chaining When a new fact p is added to the KB for each rule such that p uni es with a premise if the other premises are known then add the conclusion to the KB and continue chaining Forward chaining is data-driven e.g., inferring properties and categories from percepts AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 24 Forward chaining example Add facts 1, 2, 3, 4, 5, 7 in turn. Number in = uni cation literal; p indicates rule ring 1. Buffalox ^ Pigy Fasterx; y 2. Pigy ^ Slugz Fastery; z 3. Fasterx; y ^ Fastery; z Fasterx; z 4. BuffaloBob 1a, 5. PigPat 1b,p ! 6. FasterBob; Pat 3a, , 3b, 2a, 7. SlugSteve 2b,p !8. FasterPat; Steve 3a, , 3b,p !9. FasterBob; Steve 3a, , 3b, AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 25 Backward chaining When a query q is asked if a matching fact q0 is known, return the uni er for each rule whose consequent q0 matches q attempt to prove each premise of the rule by backward chaining Some added complications in keeping track of the uni ers More complications help to avoid in nite loops Two versions: nd any solution, nd all solutions Backward chaining is the basis for logic programming, e.g., Prolog AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 26 Backward chaining example 1. Pigy ^ Slugz Fastery; z 2. Slimyz ^ Creepsz Slugz 3. PigPat 4. SlimySteve 5. CreepsSteve Faster(Pat,Steve) 1 Pig(Pat) 3 {} {y/Pat, z/Steve} Slug(Steve) 2 {z/Steve} Creeps(Steve) 5 {} Slimy(Steve) 4 {} AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 27 Completeness in FOL Procedure i is complete if and only if KB `i whenever KB j= Forward and backward chaining are complete for Horn KBs but incomplete for general propositional and rst-order logic E.g., from PhDx HighlyQualifiedx :PhDx EarlyEarningsx HighlyQualifiedx Richx EarlyEarningsx Richx should be able to infer RichMe, but FC BC won't do it Does a complete algorithm exist? AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 28 Resolution Entailment in rst-order logic is only semidecidable: can nd a proof of if KB j= cannot always prove that KB 6j= Cf. Halting Problem: proof procedure may be about to terminate with success or failure, or may go on for ever Resolution is a refutation procedure: to prove KB j= , show that KB ^ : is unsatis able Resolution uses KB , : in CNF conjunction of clauses Resolution inference rule combines two clauses to make a new one: C2 C1 C Inference continues until an empty clause is derived contradiction AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 29 Resolution inference rule Basic propositional version: p1 _ : : : p j : : : _ p m ; q1 _ : : : qk : : : _ qn p1 _ : : : pj ,1 _ pj +1 : : : pm _ q1 : : : qk ,1 _ qk +1 : : : _ qn where pj = :qk For example, Full rst-order version: _ ; : _ _ or equivalently : ; : RichMe UnhappyMe with = fx=Meg :Richx _ Unhappyx AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 30 Conjunctive Normal Form Literal = possibly negated atomic sentence, e.g., :RichMe The KB is a conjunction of clauses Any FOL KB can be converted to CNF as follows: 1. Replace P Q by :P _Q 2. Move : inwards, e.g., :8x P becomes 9x :P 3. Standardize variables apart, e.g., 8x P _ 9x Q becomes 8x P _ 9y Q 4. Move quanti ers left in order, e.g., 8x P _ 9x Q becomes 8x9y P _ Q 5. Eliminate 9 by Skolemization next slide 6. Drop universal quanti ers 7. Distribute ^ over _, e.g., P ^ Q _ R becomes P _ Q ^ P _ R Clause = disjunction of literals, e.g., :RichMe _ UnhappyMe AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 31 Skolemization 9x Richx becomes RichG1 where G1 is a new d d 9 k dy ky = ky becomes dy ey = ey More tricky when 9 is inside 8 E.g., Everyone has a heart" Incorrect: Correct: Skolem constant" 8 x Personx 9 y Hearty ^ Hasx; y 8 x Personx HeartH 1 ^ Hasx; H 1 where H is a new symbol Skolem function" 8 x Personx HeartH x ^ Hasx; H x Skolem function arguments: all enclosing universally quanti ed variables AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 32 Resolution proof To prove : negate it convert to CNF add to CNF KB infer contradiction E.g., to prove Richme, add :Richme to the CNF KB :PhDx _ HighlyQualifiedx PhDx _ EarlyEarningsx :HighlyQualifiedx _ Richx :EarlyEarningsx _ Richx AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 33 Resolution proof PhD(x) HQ(x) {} PhD(x) Rich(x) {} Rich(x) ES(x) {} Rich(x) {x/Me} Rich(Me) ES(x) Rich(x) > > PhD(x) ES(x) > > HQ(x) Rich(x) > > AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 34 Resolution in practice Resolution is complete and usually necessary for mathematics Automated theorem provers are starting to be useful to mathematicians and have proved several new theorems Another detailed example of resolution can be found on pages 282-283. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 35 What you need to know syntax and semantics of propositional and FOL including but not limited to the semantics of the logical connectives and quanti cation be able to translate English sentences to logics de nitions of entailment, completeness, soundness, validity and so on uni cation be able to apply inference rules to derive new rules be able to use resolution proof by refutation AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. 36 ...
View Full Document

Ask a homework question - tutors are online