Class 13
Class 13
Class 13
Lecture 13
First-order logic
Milos Hauskrecht
milos@cs.pitt.edu
5329 Sennott Square
Administration announcements
Midterm:
• Thursday, October 25, 2012
• In-class
• Closed book
1
First-order logic (FOL)
• More expressive than propositional logic
• Main additions:
– Represents explicitly objects, their properties, relations and
lets us make statements about them;
– Introduces variables that refer to arbitrary objects of certain
type that can be substituted by a specific object
– Introduces quantifiers allowing us to make statements for
groups objects without the need to represent each of them
separately
Logic
Logic is defined by:
• A set of sentences
– A sentence is constructed from a set of primitives according
to syntax rules.
• A set of interpretations
– An interpretation gives a semantic to primitives. It associates
primitives with objects, values in the real world.
• The valuation (meaning) function V
– Assigns a truth value to a given sentence under some
interpretation
V : sentence interpretation {True , False }
2
First-order logic: Syntax
Terms in FOL:
• Constant symbols: represent specific objects
– E.g. John, France, car89
• Variables: represent objects of a certain type (type = domain of
discourse)
– E.g. x,y,z
• Functions applied to one or more terms
– E.g. father-of (John)
father-of(father-of(John))
– t1 = t2 equivalence of terms
Example:
John = father-of(Peter)
3
First order logic: Syntax
Sentences in FOL:
• Complex sentences:
• Assume , are sentences in FOL. Then:
– ( ) ( ) ( ) ( )
and
– x y
are sentences
Symbols ,
- stand for the existential and the universal quantifier
Semantics: Interpretation
An interpretation I is defined by a mapping constants, predicates
and function to the domain of discourse D or relations on D
• domain of discourse: a set of objects in the world we represent
and refer to;
An interpretation I maps:
• Constant symbols to objects in D
I(John) =
• Predicate symbols to relations, properties on D
I(brother) = ; ; ….
I(father-of) = ; ; ….
CS 1571 Intro to AI M. Hauskrecht
4
Semantics of sentences
Meaning (evaluation) function:
V : sentence interpretation {True , False }
A predicate predicate(term-1, term-2, term-3, term-n) is true for
the interpretation I , iff the objects referred to by term-1, term-
2, term-3, term-n are in the relation referred to by predicate
I(John) = I(Paul) =
I(brother) = ; ; ….
Semantics of sentences
• Equality V(term-1= term-2, I) = True
Iff I(term-1) =I(term-2)
• Boolean expressions: standard
• Quantifications
V( x , I) = True substitution of x with d
5
Sentences with quantifiers
• Universal quantification
6
Sentences with quantifiers
• Universal quantification
7
Sentences with quantifiers
• Universal quantification
8
Sentences with quantifiers
• Universal quantification
9
Sentences with quantifiers
• Existential quantification
10
Sentences with quantifiers
• Existential quantification
11
Translation with quantifiers
• Assume two predicates S(x) and P(x)
Nested quantifiers
• More than one quantifier may be necessary to capture the
meaning of a statement in the predicate logic.
Example:
• There is a person who loves everybody.
• Translation:
– Assume:
• Variables x and y denote people
• A predicate L(x,y) denotes: “x loves y”
• Then we can write in the predicate logic:
?
12
Nested quantifiers
• More than one quantifier may be necessary to capture the
meaning of a statement in the predicate logic.
Example:
• There is a person who loves everybody.
• Translation:
– Assume:
• Variables x and y denote people
• A predicate L(x,y) denotes: “x loves y”
• Then we can write in the predicate logic:
x y L(x,y)
Translation exercise
Suppose:
– Variables x,y denote people
– L(x,y) denotes “x loves y”.
Translate:
• Everybody loves Raymond. ?
13
Translation exercise
Suppose:
– Variables x,y denote people
– L(x,y) denotes “x loves y”.
Translate:
• Everybody loves Raymond. x L(x,Raymond)
• Everybody loves somebody. ?
Translation exercise
Suppose:
– Variables x,y denote people
– L(x,y) denotes “x loves y”.
Translate:
• Everybody loves Raymond. x L(x,Raymond)
• Everybody loves somebody. xy L(x,y)
• There is somebody whom everybody loves. ?
14
Translation exercise
Suppose:
– Variables x,y denote people
– L(x,y) denotes “x loves y”.
Translate:
• Everybody loves Raymond. x L(x,Raymond)
• Everybody loves somebody. xy L(x,y)
• There is somebody whom everybody loves. yx L(x,y)
• There is somebody who Raymond doesn't love. ?
Translation exercise
Suppose:
– Variables x,y denote people
– L(x,y) denotes “x loves y”.
Translate:
• Everybody loves Raymond. x L(x,Raymond)
• Everybody loves somebody. xy L(x,y)
• There is somebody whom everybody loves. yx L(x,y)
• There is somebody who Raymond doesn't love.
y¬L(Raymond,y)
• There is somebody whom no one loves. ?
15
Translation exercise
Suppose:
– Variables x,y denote people
– L(x,y) denotes “x loves y”.
Translate:
• Everybody loves Raymond. x L(x,Raymond)
• Everybody loves somebody. xy L(x,y)
• There is somebody whom everybody loves. yx L(x,y)
• There is somebody who Raymond doesn't love.
y¬L(Raymond,y)
• There is somebody whom no one loves.
y x ¬L(x,y)
Order of quantifiers
• Order of quantifiers of the same type does not matter
For all x and y, if x is a parent of y then y is a child of x
x , y parent ( x , y ) child ( y , x )
y , x parent ( x , y ) child ( y , x )
16
Order of quantifiers
• Order of quantifiers of the same type does not matter
For all x and y, if x is a parent of y then y is a child of x
x , y parent ( x , y ) child ( y , x )
y , x parent ( x , y ) child ( y , x )
Order of quantifiers
• Order of quantifiers of the same type does not matter
For all x and y, if x is a parent of y then y is a child of x
x , y parent ( x , y ) child ( y , x )
y , x parent ( x , y ) child ( y , x )
17
Connections between quantifiers
Everyone likes ice cream
?
x likes ( x , IceCream )
18
Connections between quantifiers
Everyone likes ice cream
x likes ( x , IceCream )
x likes ( x , IceCream )
19
Connections between quantifiers
20
Connections between quantifiers
• Objects: people
John , Mary , Jane ,
• Properties: gender
Male ( x ), Female ( x )
• Relations: parenthood, brotherhood, marriage
Parent ( x , y ), Brother ( x , y ), Spouse ( x , y )
• Functions: mother-of (one for each person x)
MotherOf ( x )
21
Kinship domain in FOL
Relations between predicates and functions: write down what
we know about them; how relate to each other.
• Male and female are disjoint categories
x Male ( x ) Female ( x )
• Parent and child relations are inverse
x , y Parent ( x , y ) Child ( y , x )
• A grandparent is a parent of parent
g , c Grandparen t ( g , c ) p Parent ( g , p ) Parent ( p, c )
• And so on ….
CS 1571 Intro to AI M. Hauskrecht
22