Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: FOL (Reading R&N: Chapter 8)

Similar presentations


Presentation on theme: "1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: FOL (Reading R&N: Chapter 8)"— Presentation transcript:

1 1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes gomes@cs.cornell.edu Module: FOL (Reading R&N: Chapter 8)

2 2 Pros and cons of propositional logic Propositional logic is declarative its semantics is based on a truth relation between sentences and possible worlds Propositional logic allows partial/disjunctive/negated information –(unlike most data structures and databases) Propositional logic is compositional: –meaning of B 1,1  P 1,2 is derived from meaning of B 1,1 and of P 1,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) –E.g., cannot say "pits cause breezes in adjacent squares“ except by writing one sentence for each square

3 3 Consider a formula to represent the Pigeon Hole principle: (n+1) pigeons in n holes. P ij – pigeon i goes in hole j Pij  {0,1} i= 1, 2, …, n+1; j = 1, 2, …n Each pigeon has to go in a hole: Starting with pigeon 1 P 11  P 12  …  P 1n … P n+1,1  P n+1,2  …  P n+1,n. : Pigeon Hole Principle

4 4 PH And Two pigeons cannot go in the same hole P 11  ~P 21 ; P 11  ~P 31 ; … P 11  ~P n+1,1 ; ~P 11  ~P 21 ; ~P 11  ~P 31 ; … ~P 11  ~P n+1,1 ; …. ~P n+1,n  ~P 2,n ; ~P n+1,n  ~P 3n ; … ~P n+1,n  ~P n,n ; Resolution proofs of PH take exponentially many steps: Resolution proofs of inconsistency of PH require an exponential number of clauses, no matter in what order we resolve the clauses (Armin Haken 85). Related to NP vs. Co-NP questions

5 5 Pigeon Hole: A more concise formulation  x  y (x  Pigeons) (y  Holes) IN(x,y)  x  x’  y ( IN(x,y)  IN(x’,y)  x=x’)  x  y  y’ (IN(x,y)  IN(x,y’)  y=y’) We have first-order logic with some set notation Pigeons = {P1,P2,…, Pn+1)} Holes = {H1,H2, …, Hn}

6 6 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, … For finite domains, essentially equivalent to propositional logic….but more concise. Often pays off to propositionalize …(more later) We’ll see how key properties from PL carry over: sound and complete proof theory; Sound and refutation complete resolution.

7 7 Syntax of FOL: Basic elements ConstantsKingJohn, 2, CornellUniversity,... PredicatesBrother, >,... FunctionsSqrt, LeftLegOf,... Variablesx, y, a, b,... Connectives , , , ,  Equality= Quantifiers , 

8 8 Atomic sentences A term is a logical expression that refers to an object Atomic sentence =predicate (term 1,...,term n ) or term 1 = term 2 Term =function (term 1,...,term n ) or constant or variable Examples of atomic sentences: Brother(KingJohn,RichardTheLionheart) > (Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn))

9 9 Complex sentences 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. Sibling(KingJohn,Richard)  Sibling(Richard,KingJohn) >(1,2)  ≤ (1,2) >(1,2)   >(1,2)

10 10 Syntax of FOL Sentence  AtomicSentence | (Sentence Connective Sentence) | Quantifier Variable, …. Sentence |  Sentence AtomicSentence  Predicate(Term) | Term=Term Term  Function(Term) | Constant | Variable Connective   |  |  |  Quantifiers   |  Constant  A | X1 | John | … Variable  a | x | s | … Predicate  Before | Greater | Raining |… Function  MotherOf | SqrtOf |…

11 11 Truth in first-order logic Sentences are true with respect to a world and an interpretation A world contains objects (domain elements) and relations among them Interpretation associates constant symbols → objects predicate symbols → relations function symbols →functional relations An atomic sentence predicate(term 1,...,term n ) is true iff the objects referred to by term 1,...,term n are in the relation referred to by predicate

12 12 Models for FOL: Example World with five objects: Richard the LionHeart, king of England (1189-1199); Evil King John, Richard’s brother (1199-1215); The left legs of Richard and John A crown Binary relation Unary relations (or properties) functions LeftLeg(Richard)  x King(x)  Greedy(x)  Evil(x) King(John) Brother(Richard,John)

13 13 Semantics: Universal quantification  (  x) P(x) it is true in an interpretation iif P(x) is true for all the values in the domain of x i.e., the universe of discourse Everyone at Cornell is smart:  x At(x,Cornell)  Smart(x) Roughly speaking, equivalent to the conjunction of instantiations of P At(Mary,Cornell)  Smart(Mary)  At(Richard,Cornell)  Smart(Richard)  At(John,Cornell)  Smart(John) ...

14 14 A common mistake to avoid Typically,  is the main connective with  Common mistake: using  as the main connective with  :  x[ At(x,Cornell)  Smart(x)] means “Everyone is at Cornell and everyone is smart”

15 15 Existential quantification  (  x)P(x) it is true in an interpretation m iff there exists an element x in the universe of discourse such that P(x) is true. Someone at Cornell is smart:  x At(x,Cornell)  Smart(x) Roughly speaking, equivalent to the disjunction of instantiations of P At(John,Cornell)  Smart(John)  At(Mary,Cornell)  Smart(Mary)  At(Richard,Cornell)  Smart(Richard) ...

16 16 Another common mistake to avoid Typically,  is the main connective with  Common mistake: using  as the main connective with  :  x At(x,Cornell)  Smart(x) is true if there is anyone who is not at Cornell!

17 17 More on Quantifiers Loves(x,y) - x loves y  x  y is the same as  y  x  x  y is the same as  y  x  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,IceCream)  x Likes(x,Broccoli)  x  Likes(x,Broccoli) (see additional hidden slides for recapitulation of this material)

18 18 Quantified formulas If ω is a wff and x is a variable symbol, then both  (x) ω and  (x) ω are wffs. x is the variable quantified over; ω is said to be within the scope of the quantifier if all the variables in ω are quantified over in ω, we say that we have a closed wff or closed sentence. Example: (  x) [P(x)  R(x)]; (  x)[P(x)  ((  y) [R(x,y)  S(f(x))]]

19 19 Scope of  All variables are bound (  x) (P(x)  Q(x))   x R(x)

20 20 Love Affairs Loves(x,y)  read: x loves y Everybody loves Jerry  x Loves (x, Jerry) Everybody loves somebody  x  y Loves (x, y) There is somebody whom somebody loves  y  x Loves (x, y) Nobody loves everybody   x  y Loves (x, y) =  x  y  Loves (x, y) There is somebody whom Lydia doesn’t love  y  Loves (Lydia, y)

21 21 Love Affairs Loves(x,y) x loves y There is somebody whom no one loves  y  x  Loves (x, y) There is exactly one person whom everybody loves  y(  x Loves(x,y)   z((  w Loves (w,z)  z=y)) There are exactly two people whom Lynn Loves  x  y ((x  y)  Loves(Lynn,x)  Loves(Lynn,y)  z( Loves (Lynn,z)  (z=x  z=y))) Everybody loves himself or herself  x Loves(x,x) There is someone who loves no one besides herself or himself  x  y Loves(x,y)  (x=y) (note biconditional – why?)

22 Using FOL The set domain: Only sets are empty sets or those made by adjoining something to a set  s Set(s)  (s = {} )  (  x,s 2 Set(s 2 )  s = {x|s 2 }) The empty set has no element adjoined to it  x,s {x|s} = {} Adjoining an element already in the set has no effect  x,s x  s  s = {x|s} Only elements have been adjoined to it  x,s x  s  [  y,s 2 (s = {y|s 2 }  (x = y  x  s 2 ))] Subset  s 1,s 2 s 1  s 2  (  x x  s 1  x  s 2 ) Equality of sets  s 1,s 2 (s 1 = s 2 )  (s 1  s 2  s 2  s 1 ) Intersection  x,s 1,s 2 x  (s 1  s 2 )  (x  s 1  x  s 2 ) Uniion  x,s 1,s 2 x  (s 1  s 2 )  (x  s 1  x  s 2 )

23 23 Using FOL The kinship domain: Brothers are siblings  x,y Brother(x,y)  Sibling(x,y) One's mother is one's female parent  m,c Mother(c) = m  (Female(m)  Parent(m,c)) “Sibling” is symmetric  x,y Sibling(x,y)  Sibling(y,x)

24 24 StatementWhen TrueWhen False  x  y P(x,y)  y  x P(x,y) P(x,y) is true for every pair There is a pair for which P(x.y) is false  x  y P(x,y) For every x there is a y for which P(x,y) is true There is an x such that P(x,y) is false for every y.  x  y P(x,y) There is an x such that P(x,y) is true for every y. For every x there is a y for which P(x,y) is false  x  y P(x,y)  y  x P(x,y) There is a pair x, y for which P(x,y) is true P(x,y) is flase fo every pair x,y.

25 25 Negation Equivalent Statement When is the negation True When is False  x P(x)  x  P(x) For every x, P(x) is false There is an x for which P(x) is true.   x P(x)  x  P(x) There is an x for which P(x) is false. For every x, P(x) is true.

26 26 Equality term 1 = term 2 is true under a given interpretation if and only if term 1 and term 2 refer to the same object E.g., definition of Sibling in terms of Parent:  x,y Sibling(x,y)  [  (x = y)   m,f  (m = f)  Parent(m,x)  Parent(f,x)  Parent(m,y)  Parent(f,y)]

27 27 There is an honest politician  x H(x) Where H(x) denotes: x is honest. (universe of discourse consists of all the politicians) Negation  x H(x)  x  H(x) (Every politician is dishonest) All Americans eat cheeseburgers  x C(x) C(x) denotes: x eats cheeseburgers Negation  x C(x)   x  C(x) (Some American does not eat cheeseburgers)

28 28 Knowledge base for the wumpus world Perception –  t,s,b Percept([s,b,Glitter],t)  Glitter(t) Reflex –  t Glitter(t)  BestAction(Grab,t)

29 29 Deducing hidden properties  x,y,a,b Adjacent([x,y],[a,b])  [a,b]  {[x+1,y], [x-1,y],[x,y+1],[x,y-1]} Properties of squares:  s,t At(Agent,s,t)  Breeze(t)  Breezy(s) Squares are breezy near a pit: –Diagnostic rule---infer cause from effect  s Breezy(s)   r Adjacent(r,s)  Pit(r) –Causal rule---infer effect from cause  r Pit(r)  [  s Adjacent(r,s)  Breezy(s)]

30 30 Interacting with FOL KBs Sentences are added to the knowledge base using TELL (as in PL), assertions. For example, we can assert TELL(KB,King(John)). TELL(KB,  x King(x)  Person(x)) We can ask: Ask (KB,  x Person(x)) The answer to a query with existential variables if true returns a substitution or binding list, which is a set of variable term: {x/John}; if there is more than one possible answer, a list of substitutions can be returned.

31 31 Interacting with FOL KBs Given a sentence S and a substitution σ, Sσ denotes the result of plugging σ into S; e.g., S = Smarter(x,y) σ = {x/Hillary,y/Bill} Sσ = Smarter(Hillary,Bill) Suppose a wumpus-world agent is using an FOL KB and perceives a smell and a breeze (but no glitter) at t=5: Tell (KB,Percept([Smell,Breeze,None],5)) Ask (KB,  a BestAction(a,5)) I.e., does the KB entail some best action at t=5? Answer: Yes, {a/Shoot} ← substitution (binding list) Ask (KB,S) returns some/all σ such that KB╞ σ

32 32 Knowledge engineering in FOL 1.Identify the task 2.Assemble the relevant knowledge 3.Decide on a vocabulary of predicates, functions, and constants 4.Encode general knowledge about the domain 5.Encode a description of the specific problem instance 6.Pose queries to the inference procedure and get answers 7.Debug the knowledge base

33 The digital circuit domain One-bit full adder Input bits to be added Carry bit XOR gates AND gatesOR gate Sum Carry bit for next adder

34 34 The electronic circuit domain One-bit full adder 0 1 1 1 0 0 1 1

35 35 The electronic circuit domain 1 - Identify the task –Does the circuit actually add properly? (circuit verification) –Goal: analyze the design to see if it matches specification. 2 - Assemble the relevant knowledge –Talk about circuits, gates, terminals, and signals: e.g., we use constants (X1, X2, etc) for refering the gates; Types of gates (AND, OR, XOR, NOT) –Irrelevant: size, shape, color, cost of gates 3 - Decide on a vocabulary Constant symbols: X1, X2, … –Alternatives: Type(X 1 ) = XOR (note: XOR constant…) Type(X 1, XOR) XOR(X 1 ) Semantics of function already guarantees that gates have only one type

36 36 Gates or circuits can have one or more input terminals and one or more output terminals. E.g. the function In(1,X1) denotes the first input terminal for gate X1. Connectivity between gates can be represented by a predicate: Connected(Out(1,X1),In(1,X2) Signal has to be on or off – Signal(t) this function takes terminal as an argument and returns the signal value for that terminal. Two constants – 1 and 0. Note: We could use a unary predicate On(t); However, this would make it difficult to ask the question – what are the possible values of the signals at the output terminals of circuit C!? See page 263-264 for full description of vocabulary. The electronic circuit domain

37 37 The electronic circuit domain 4- Encode general knowledge of the domain If two terminals are connected they have the same signal –  t 1,t 2 Connected(t 1, t 2 )  Signal(t 1 ) = Signal(t 2 ) Connected is a commutative predicate –  t 1,t 2 Connected(t 1, t 2 )  Connected(t 2, t 1 ) The signal at every terminal is either 1 or 0 –  t Signal(t) = 1  Signal(t) = 0 –1 ≠ 0

38 38 The electronic circuit domain  An OR gate’s output is 1 iif any of its inputs is 1 –  g Type(g) = OR  Signal(Out(1,g)) = 1   n Signal(In(n,g)) = 1  An AND gate’s output is 0 iif any of its inputs is 0 –  g Type(g) = AND  Signal(Out(1,g)) = 0   n Signal(In(n,g)) = 0  An XOR gate’s output is 1 iif its inputs are different –  g Type(g) = XOR  Signal(Out(1,g)) = 1  Signal(In(1,g)) ≠ Signal(In(2,g))  A NOT gate’s output is different from its input –  g Type(g) = NOT  Signal(Out(1,g)) ≠ Signal(In(1,g))

39 39 The electronic circuit domain 5 - Encode the specific problem instance Type(X 1 ) = XOR Type(X 2 ) = XOR Type(A 1 ) = AND Type(A 2 ) = AND Type(O 1 ) = OR Connected(Out(1,X 1 ),In(1,X 2 ))Connected(In(1,C 1 ),In(1,X 1 )) Connected(Out(1,X 1 ),In(2,A 2 ))Connected(In(1,C 1 ),In(1,A 1 )) Connected(Out(1,A 2 ),In(1,O 1 )) Connected(In(2,C 1 ),In(2,X 1 )) Connected(Out(1,A 1 ),In(2,O 1 )) Connected(In(2,C 1 ),In(2,A 1 )) Connected(Out(1,X 2 ),Out(1,C 1 )) Connected(In(3,C 1 ),In(2,X 2 )) Connected(Out(1,O 1 ),Out(2,C 1 )) Connected(In(3,C 1 ),In(1,A 2 ))

40 40 The electronic circuit domain 6 - Pose queries to the inference procedure What are the possible sets of values of the input of the adder circuit that lead to a signal of 0 for the sum output bit and a value of 1 for the carry output terminal?  i 1,i 2,i 3 Signal(In(1,C 1 )) = i 1  Signal(In(2,C 1 )) = i 2  Signal(In(3,C 1 )) = i 3  Signal(Out(1,C 1 )) = 0  Signal(Out(2,C 1 )) = 1 Answer: (i1 = 1; i2 = 1; i3 = 0) or ((i1 = 1; i2 = 0; i3 = 1) or (i1 = 0; i2 = 1; i3 = 0) What are the possible sets of values of all the terminals of the adder circuit?  i 1,i 2,i 3,o 1,o 2 Signal(In(1,C 1 )) = i 1  Signal(In(2,C 1 )) = i 2  Signal(In(3,C 1 )) = i 3  Signal(Out(1,C 1 )) = o 1  Signal(Out(2,C 1 )) = o 2

41 41 The electronic circuit domain 7 - Debug the knowledge base May have omitted assertions like 1 ≠ 0 What is the advantage over simulation? Pentium bug…

42 42 Summary First-order logic: –objects and relations are semantic primitives –syntax: constants, functions, predicates, equality, quantifiers Increased expressive power! But of course at a cost of increased complexity in general


Download ppt "1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: FOL (Reading R&N: Chapter 8)"

Similar presentations


Ads by Google