Outline

• Why FOL? • Syntax and semantics of FOL First‐Order • Using FOL • Wumpus world in FOL Chapter 8 • Knowledge engineering in FOL (not 8.1)

Pros and cons of propositional logic First‐order logic  Propositional logic is declarative • Whereas propositional logic assumes the  Propositional logic allows partial/disjunctive/negated information world contains facts, first‐order logic (like – (unlike most data structures and databases) natural language) assumes the world contains  Propositional logic is compositional – meaning of B1,1  P1,2 is derived from meaning of B1,1 and of P1,2 – Objects: people, houses, numbers, colors, baseball  Meaning in propositional logic is context‐independent – (unlike natural language, where meaning depends on context) games, wars, … –  Propositional logic has very limited expressive power Relations: red, round, prime, brother of, bigger – (unlike natural language) than, part of, comes between, … – E.g., cannot say "pits cause breezes in adjacent squares“ • except by writing one sentence for each square – Functions: father of, best friend, one more than, plus, …

Syntax of FOL: Basic elements Atomic sentences

• Constants KingJohn, 2, Udel,... Atomic sentence = predicate (term1,...,termn)

• Predicates Brother, >,... or term1 = term2 • Functions Sqrt, LeftLegOf,... = constant • Variables x, y, a, b,... or variable • Connectives , , , ,  or function (term1,...,termn)

• Equality = • E.g., Brother(KingJohn,RichardTheLionheart) , • Quantifiers ,  (Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn))) Married(mother(mother(mary)), father(mother(mary))) Representing Some Sentences Complex sentences

• John likes Mary. Complex sentences are made from atomic • Bill hit John. sentences using connectives • Florida is a state. S, S1  S2, S1  S2, S1  S2, S1  S2, • The product of a and b is c. • 2+3=7. E.g. Sibling(KingJohn,Richard)  • Tweety is yellow. Sibling(Richard,KingJohn) >(1,2)  ≤ (1,2) >(1,2)   >(1,2)

Truth in first‐order logic Models for FOL: Example • Sentences are true with respect to a model and an

• Model contains objects (domain elements) and relations among them

• Interpretation specifies referents for constant symbols → objects predicate symbols → relations function symbols → functional relations

• An atomic sentence predicate(term1,...,termn) is true iff the objects referred to by term1,...,termn are in the relation referred to by predicate

Universal quantification A common mistake to avoid

•  Typically,  is the main connective with  Everyone at UDel is smart: x At(x,UDel)  Smart(x) • Common mistake: using  as the main connective • x P is true in a model m iff P is true with x being each with : possible object in the model x At(x,UDel)  Smart(x) • Roughly speaking, equivalent to the conjunction of means “Everyone is at Udel and everyone is smart” instantiations of x

At(KingJohn,UDel)  Smart(KingJohn)  At(Richard,UDel)  Smart(Richard)  At(NUS,UDel)  Smart(NUS)  ... Existential quantification Another common mistake to avoid

•  • Typically,  is the main connective with  Someone at Udel is smart: x At(x,UDel)  Smart(x) • Common mistake: using  as the main connective • xPis true in a model m iff P is true with x being some with : possible objec t in the modldel x At(x,UDel)  Smart(x) • Roughly speaking, equivalent to the disjunction of instantiations of P is true if there is anyone who is not at UDel! At(KingJohn,UDel)  Smart(KingJohn)  At(Richard,UDel)  Smart(Richard)  At(NUS,UDel)  Smart(NUS)  ...

Properties of quantifiers Equality • x yis the same as y x

• x yis the same as y x • term1 = term2 is true under a given interpretation if and only if term and term refer to the same object • x yis not the same as y x 1 2

• x yLoves(x,y) – “There is a person who loves everyone in the world” • E.g., definition of Sibling in terms of Parent: • y x Loves(x,y) – “Everyone in the world is loved by at least one person” x,y Sibling(x,y)  [(x = y) m,f  (m = f)  Parent(m,x) • duality: each can be expressed using the other  Parent(f,x)  Parent(m,y)  Parent(f,y)]

• x Likes(x,IceCream) x Likes(x,IceCream)

• x Likes(x,Broccoli) x Likes(x,Broccoli)

Using FOL Using FOL

The kinship domain: The set domain: • Brothers are siblings • s Set(s)  (s = {} )  (x,s2 Set(s2)  s = {x|s2}) x,y Brother(x,y)  Sibling(x,y) • x,s {x|s} = {} • x,s x  s  s = {x|s} • One's mother is one's female parent • x,s x  s  [ y,s2} (s = {y|s2}  (x = y  x  s2))] m,c Mother(c) = m  (Female(m)  Parent(m,c)) • s1,s2 s1  s2  (x x  s1  x  s2) • s1,s2 (s1 = s2)  (s1  s2  s2  s1) • “Sibling” is symmetric • x,s1,s2 x  (s1  s2)  (x  s1  x  s2) x,y Sibling(x,y)  Sibling(y,x) • x,s1,s2 x  (s1  s2)  (x  s1  x  s2) Knowledge engineering in FOL Summary

1. Identify the task • First‐order logic: 2. Assemble the relevant knowledge – objects and relations are semantic primitives 3. Decide on a vocabulary of predicates, functions, – syntax: constants, functions, predicates, equality, and constants quantifiers 4. Encode general knowledge about the domain 5. Encode a description of the specific problem instance • Increased expressive power: sufficient to 6. Pose queries to the inference procedure and get define wumpus world answers 7. Debug the knowledge base