COMP9414/9814/3411 16s1 First Order Logic 1 COMP3411: Artificial Intelligence 8. First Order Logic Overview First Order Logic Universal and Existential Quantifiers Russell & Norvig, Chapter 8. Fun with Sentences Keeping Track of Change Planning Situation Calculus COMP9414/9814/3411 16s1 First Order Logic 2 Syntax of First Order Logic COMP9414/9814/3411 16s1 First Order Logic 3 Logics in General Objects: people, houses, numbers, theories, colors, football games, wars, centuries... Predicates: red, round, bogus, prime, multistoried,... brother of, bigger than, inside, part of, has color, occurred after, owns, comes between,... Functions: father of, best friend, third inning of, one more than,... Language Ontology Epistemology Propositional logic facts true / false / unknown First-order logic facts, objects, relations true / false / unknown Temporal logic facts, objects, relations, times true / false / unknown Probability theory facts degree of belief Fuzzy logic facts + degree of truth known interval value
COMP9414/9814/3411 16s1 First Order Logic 4 Syntax of First-order logic COMP9414/9814/3411 16s1 First Order Logic 5 Sentences Constants Gold,Wumpus,[1, 2],[3, 1], etc. Predicates Ad jacent(), Smell(), Breeze(), At() Functions Result() Variables x, y, a, t,... Connectives Equality = Quantifiers Atomic sentence = predicate(term 1,...,term n ) or term 1 = term 2 Term = f unction(term 1,...,term n ) or constant or variable e.g. At(Agent,[1,1],S 0 ) Holding(Gold,S 5 ) Complex sentences are made from atomic sentences using connectives S, S 1 S 2, S 1 S 2, S 1 S 2, S 1 S 2 e.g. Pit(x) Ad jacent(x,y) COMP9414/9814/3411 16s1 First Order Logic 6 Universal Quantification COMP9414/9814/3411 16s1 First Order Logic 7 Universal Quantification variables sentence Where there s glitter, there s gold: x Glitter(x) At(Gold, x) x P is equivalent to the conjunction of instantiations of P Glitter([1,1]) At(Gold,[1,1]) Glitter([1,2]) At(Gold,[1,2]) Glitter([1,3]) At(Gold,[1,3])... Typically, is the main connective with Common mistake: using as the main connective with x Glitter(x) At(Gold, x) means There is Glitter everywhere and Gold everywhere.
COMP9414/9814/3411 16s1 First Order Logic 8 Existential Quantification COMP9414/9814/3411 16s1 First Order Logic 9 Existential Quantification variables sentence Some sheep are black x Sheep(x) Black(x) x P is equivalent to the disjunction of instantiations of P Sheep(Dolly) Black(Dolly) Sheep(Lassie) Black(Lassie) Sheep(Skippy) Black(Skippy)... Typically, is the main connective with Common mistake: using as the main connective with x Sheep(x) Black(x) is true if there is anyone who is not at sheep! COMP9414/9814/3411 16s1 First Order Logic 10 Properties of Quantifiers COMP9414/9814/3411 16s1 First Order Logic 11 Fun with Sentences x y is the same as y x (Why?) x y is the same as y x (Why?) x y is not the same as y x x y Loves(x, y) There is a person who loves everyone in the world y x Loves(x, y) Everyone in the world is loved by at least one person Quantifier duality: each can be expressed using the other x Likes(x, IceCream) x Likes(x, Broccoli) x Likes(x, IceCream) x Likes(x, Broccoli) Brothers are siblings Sibling is symmetric One s mother is one s female parent A first cousin is a child of a parent s sibling
COMP9414/9814/3411 16s1 First Order Logic 12 Fun with Sentences COMP9414/9814/3411 16s1 First Order Logic 13 Reactive agent for the Wumpus World Brothers are siblings x,y Brother(x,y) Sibling(x,y) Sibling is symmetric x,y Sibling(x,y) Sibling(y,x) One s mother is one s female parent x,y Mother(x,y) (Female(x) Parent(x,y)) A first cousin is a child of a parent s sibling x, yfirstcousin(x, y) p, ps Parent(p, x) Sibling(ps, p) Parent(ps, y) Reflex action: t AtGold(t) Action(Grab, t) Reflex with internal state: do we have the gold already? t AtGold(t) Holding(Gold, t) Action(Grab, t) Holding(Gold,t) cannot be observed. Therefore, keeping track of change is essential. Also, how do we know if we are on our way in or out of the cave? COMP9414/9814/3411 16s1 First Order Logic 14 Deducing Hidden Properties COMP9414/9814/3411 16s1 First Order Logic 15 Keeping Track of Change Properties of locations: x,t At(Agent,x,t) Smell(t) Smelly(x) x,t At(Agent,x,t) Breeze(t) Breezy(x) Squares are breezy near a pit: Causal rule infer effect from cause x,y Pit(x) Ad jacent(x,y) Breezy(y) Diagnostic rule infer cause from effect y Breezy(y) x Pit(x) Ad jacent(x,y) Facts hold in situations, rather than eternally e.g. Holding(Gold,Now) rather than just Holding(Gold) Situation calculus is one way to represent change: Adds a situation argument to each non-eternal predicate e.g. Now denotes a situation in Holding(Gold,Now) Situations are connected by the Result function Result(a,s) is the situation that results from doing a is s Gold Definition for the Breezy predicate (combines Causal and Diagnostic): y Breezy(y) [ x Pit(x) Ad jacent(x,y)] Gold S 0 S 1 Forward
COMP9414/9814/3411 16s1 First Order Logic 16 Describing actions I COMP9414/9814/3411 16s1 First Order Logic 17 Describing actions II Effect axiom describe changes due to action s AtGold(s) Holding(Gold, Result(Grab, s)) Frame axiom describe non-changes due to action s HaveArrow(s) HaveArrow(Result(Grab, s)) Frame problem: find an elegant way to handle non-change (a) representation avoid frame axioms (b) inference avoid repeated copy-overs to keep track of state Qualification problem: true descriptions of real actions require endless caveats what if gold is slippery or nailed down or... Ramification problem: real actions have many secondary consequences what about the dust on the gold, wear and tear on gloves,... Successor-state axioms solve the representational frame problem. Each axiom is about a predicate (not an action per se): P true afterwards [an action made P true P true already and no action made P false] For holding the gold: a, s Holding(Gold, Result(a, s)) [(a=grab AtGold(s)) (Holding(Gold,s) a Release)] COMP9414/9814/3411 16s1 First Order Logic 18 Making Plans COMP9414/9814/3411 16s1 First Order Logic 19 Making Plans: a Better Way Initial condition in KB (knowledge base): At(Agent,[1,1],S 0 ) At(Gold,[1,2],S 0 ) Query: Ask(KB, s Holding(Gold, s)) i.e., in what situation will I be holding the gold? Answer: s=result(grab,result(forward,s 0 )) i.e., go forward and then grab the gold This assumes that the agent is interested in plans starting at S 0 and that S 0 is the only situation described in the KB. Represent plans as action sequences [a 1,a 2,...,a n ] PlanResult(p,s) is the result of executing p in s Then the query Ask(KB, p Holding(Gold,PlanResult(p,S 0 ))) has the solution p =[Forward, Grab] Definition of PlanResult in terms of Result: s PlanResult([],s)=s a, p, s PlanResult([a p], s) = PlanResult(p, Result(a, s)) Planning systems are special-purpose reasoners designed to do this type of inference more efficiently than a general-purpose reasoner.
COMP9414/9814/3411 16s1 First Order Logic 20 Summary First-order logic: objects and relations are semantic primitives syntax: constants, functions, predicates, equality, quantifiers Increased expressive power: sufficient to define Wumpus World Situation calculus: conventions for describing actions and change can formulate planning as inference on a knowledge base