2. • In propositional logic, we can only represent
the facts, which are either true or false.
• PL is not sufficient to represent the complex
sentences or natural language statements.
• The propositional logic has very limited
expressive power. Ex:
1. "Some humans are intelligent"
2. "Sachin likes cricket”
3. First-Order logic
• First-order logic is another way of knowledge
representation in artificial intelligence. It is an
extension to propositional logic.
• FOL is sufficiently expressive to represent the
natural language statements in a concise way.
• First-order logic is also known as Predicate logic
or First-order predicate logic.
• It is a powerful language that develops
information about the objects in a easy way and
express the relationship between those objects.
4. • First-order logic does not only assume that the
world contains facts like propositional logic
but also assumes the following things in the
world:
– Objects, which are things with individual identities
– Properties of objects that distinguish them from
other objects
– Relations that hold among sets of objects
– Functions, which are a subset of relations where
there is only one “value” for any given “input”
5. • Examples:
– Objects: Students, lectures, companies, cars ...
– Relations: Brother-of, bigger-than, outside, part-of,
has-color, occurs-after, owns, visits, precedes, ...
– Properties: blue, oval, even, large, ...
– Functions: father-of, best-friend, second-half, one-
more-than ...
• As a natural language, first-order logic also has
two main parts:
• Syntax
• Semantics
6. User provides
• Constant symbols, which represent individuals in the
world
– Mary
– 3
– Green
• Function symbols, which map individuals to individuals
– father-of(Mary) = John
– color-of(Sky) = Blue
• Predicate symbols, which map individuals to truth values
– greater(5,3)
– green(Grass)
– color(Grass, Green)
– Valmiki wrote Ramayan [wrote(Valmiki, Ramayan)]
7. FOL Provides
• Variable symbols
– E.g., x, y, foo
• Connectives
– Same as in PL: not (), and (), or (), implies (), if
and only if (biconditional )
• Quantifiers
– Universal x or (Ax)
– Existential x or (Ex)
8. Atomic sentences:
• Atomic sentences are the most basic
sentences of first-order logic.
• We can represent atomic sentences
as Predicate (term1, term2, ......, term n).
Example:
Ravi and Ajay are brothers: => Brothers(Ravi, Ajay)
Chinky is a cat: => cat (Chinky).
9. Complex Sentences:
• Complex sentences are made by combining
atomic sentences using connectives.
• First-order logic statements can be divided into
two parts:
• Subject: Subject is the main part of the
statement.
• Predicate: A predicate can be defined as a
relation, which binds two atoms together in a
statement.
10. • Consider the statement: "x is an integer.", it
consists of two parts, the first part x is the
subject of the statement and second part "is
an integer," is known as a predicate.
11. Universal Quantifier ( ):
• Universal quantifier, which specifies that the
statement within its range is true for everything
or every instance of a particular thing.
• If x is a variable, then ∀x is read as:
• For all x
• For each x
• For every x.
12. Example
• All man drink coffee.
• Let a variable x which refers to a cat so all x can be
represented in UOD as below:
• ∀x man(x) → drink (x, coffee).
13. Existential Quantifier:
• Existential quantifiers, which express that the
statement within its scope is true for at least one
instance of something.
• If x is a variable, then existential quantifier will be
∃x or ∃(x). And it will be read as:
• There exists a 'x.'
• For some 'x.'
• For at least one 'x.'
15. Properties of Quantifiers
• The main connective for universal quantifier ∀ is
implication →.
• The main connective for existential quantifier ∃ is
and ∧.
• In universal quantifier, ∀x∀y is similar to ∀y∀x.
Ex: (x)(y)P(x,y) ↔ (y)(x) P(x,y)
• In Existential quantifier, ∃x∃y is similar to ∃y∃x.
Ex: (x)(y)P(x,y) ↔ (y)(x) P(x,y)
• ∃x∀y is not similar to ∀y∃x.
16. Sentences are built from terms and atoms
• A term (denoting a real-world individual) is a constant symbol, a
variable symbol, or an n-place function of n terms.
x and f(x1, ..., xn) are terms, where each xi is a term.
A term with no variables is a ground term
• An atomic sentence (which has value true or false) is an n-place
predicate of n terms
• A complex sentence is formed from atomic sentences connected by
the logical connectives:
P, PQ, PQ, PQ, PQ where P and Q are sentences
• A quantified sentence adds quantifiers and
• A well-formed formula (wff) is a sentence containing no “free”
variables. That is, all variables are “bound” by universal or existential
quantifiers.
(x)P(x,y) has x bound as a universally quantified variable, but y is
free.
17. Quantifiers
• Universal quantification
– (x)P(x) means that P holds for all values of x in the
domain associated with that variable
– E.g., (x) dolphin(x) mammal(x)
• Existential quantification
– ( x)P(x) means that P holds for some value of x in the
domain associated with that variable
– E.g., ( x) mammal(x) lays-eggs(x)
– Permits one to make a statement about some object
without naming it
18. Quantifiers
• Universal quantifiers are often used with
“implies” to form “rules”:
(x) student(x) smart(x) means “All students are
smart”
• Universal quantification is rarely used to make
blanket statements about every individual in the
world:
(x)student(x)smart(x) means “Everyone in the world
is a student and is smart”
19. • Existential quantifiers are usually used with “and”
to specify a list of properties about an individual:
(x) student(x) smart(x) means “There is a student
who is smart”
• A common mistake is to represent this English
sentence as the FOL sentence:
(x) student(x) smart(x)
– But what happens when there is a person who is not a
student?
20. Quantifier Scope
• Switching the order of universal quantifiers does
not change the meaning:
– (x)(y)P(x,y) ↔ (y)(x) P(x,y)
• Similarly, you can switch the order of existential
quantifiers:
– (x)(y)P(x,y) ↔ (y)(x) P(x,y)
• Switching the order of universals and existentials
does change meaning:
– Everyone likes someone: (x)(y) likes(x,y)
– Someone is liked by everyone: (y)(x) likes(x,y)
21. Connections between All and Exists
We can relate sentences involving and
using De Morgan’s laws:
(x) P(x) ↔ (x) P(x)
(x) P ↔ (x) P(x)
(x) P(x) ↔ (x) P(x)
(x) P(x) ↔ (x) P(x)
23. Universal instantiation
(a.k.a. universal elimination)
• If (x) P(x) is true, then P(C) is true, where C is
any constant in the domain of x
• Example:
(x) eats(Ziggy, x) eats(Ziggy, IceCream)
• The variable symbol can be replaced by any
ground term, i.e., any constant symbol or
function symbol applied to ground terms only
24. Existential instantiation
(a.k.a. existential elimination)
• From (x) P(x) infer P(c)
• Example:
– (x) eats(Ziggy, x) eats(Ziggy, Stuff)
• Note that the variable is replaced by a brand-new
constant not occurring in this or any other sentence in
the KB
• Also known as skolemization; constant is a skolem
constant
• In other words, we don’t want to accidentally draw
other inferences about it by introducing the constant
• Convenient to use this to reason about the unknown
object, rather than constantly manipulating the
existential quantifier
25. Existential generalization
(a.k.a. existential introduction)
• If P(c) is true, then (x) P(x) is inferred.
• Example
eats(Ziggy, IceCream) (x) eats(Ziggy, x)
• All instances of the given constant symbol are
replaced by the new variable symbol
• Note that the variable symbol cannot already
exist anywhere in the expression
26. Translating English to FOL
Every gardener likes the sun.
x gardener(x) likes(x,Sun)
You can fool some of the people all of the time.
x t person(x) time(t) can-fool(x,t)
You can fool all of the people some of the time.
x t (person(x) time(t) can-fool(x,t))
x (person(x) t (time(t) can-fool(x,t)))
All purple mushrooms are poisonous.
x (mushroom(x) purple(x)) poisonous(x)
No purple mushroom is poisonous.
x purple(x) mushroom(x) poisonous(x)
x (mushroom(x) purple(x)) poisonous(x)
There are exactly two purple mushrooms.
x y mushroom(x) purple(x) mushroom(y) purple(y) ^ (x=y) z
(mushroom(z) purple(z)) ((x=z) (y=z))
Clinton is not tall.
tall(Clinton)
X is above Y iff X is on directly on top of Y or there is a pile of one or more other
objects directly on top of one another starting with X and ending with Y.
x y above(x,y) ↔ (on(x,y) z (on(x,z) above(z,y)))
Equivalent
Equivalent
27. Practice
1. All birds fly.
2. Every man respects his parent.
3. Some boys play cricket.
4. Not all students like both Mathematics and
Science.
5. Only one student failed in Mathematics.
29. Free and Bound Variables
• The quantifiers interact with variables which appear in a suitable
way. There are two types of variables in First-order logic which
are given below:
• Free Variable: A variable is said to be a free variable in a formula
if it occurs outside the scope of the quantifier.
Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.
• Bound Variable: A variable is said to be a bound variable in a
formula if it occurs within the scope of the quantifier.
Example: ∀x [A (x) B( y)], here x and y are the bound variables.
•
30. Predicate Symbol:
Valmiki wrote Ramayan
wrote(valmiki,ramayan)
Constant Symbol: Represent the objects.
Ex; Rama,sita,car,elephant etc.,
Variable symbol: These symbols are permitted
to have indefinite values about the entity
31. Ex: x likes y
likes(x,y)
Function symbol: These symbols are used to
represent special type of relationship or
mapping.
John’s father is married to John’s mother.
Married(father(john),mother(john))
32. Exercise
1. John likes Cricket OR football
2. John lives in a house and the color of the house is
green.
3. If car belongs to john then it is green.
4. John did not write Ramayana.
5. All elephants are gray.
6. Some courses in CSE are easy
33. • Likes(John, Cricket) V likes(John, football)
• Lives(john, house) Ʌ colour (house, green)
• Belongs(car, john) → colour (car, green)
• ¬Write(john, ramayana)
• All elephants are gray
X:elephant(x) →colour(x, gray)
• Some courses in CSE are easy
ƎX: Course(x) Ʌ easy(x, CSE)
34. • Venkatesh only likes easy courses.
• Science courses are not easy.
• All the courses in the arts department are
easy.
• B.Sc is a science course
35. • Venkatesh only likes easy courses
X:easycourse(x) →likes(venkatesh,X)
• Science courses are not easy
x:science_course(x) →¬easy_course(x)
• All the courses in the arts department are
easy
x:course(x)Ʌarts(x) → easy(x)
36. • B.Sc is a science course
science_course(B.Sc)
37. • Mani only likes easy games.
• Boxing is hard.
• All the indoor games are easy.
• Table Tennis is an indoor game.
• Q: Is mani likes table tennis.
38. • Mani only likes easy games
X:easy_games(x) → likes(mani,game(x))
• Boxing is hard
Hard(boxing)
• All the indoor games are easy.
x: indoorgame(x) → easygames(x)
• Table Tennis is an indoor game.
Indoorgame(Table Tennis)
39. • Karate fighters are very strong.
• Mani is a karate fighter.
• Mani broke some body-part of every other
karate fighter.
• Mani broke the leg of the karate fighter who
broke the jaw of raja.
• Raja is a boxer
• Boxers are not as strong as karate fighters.
40. • Karate fighters are very strong
X:very_strong(karate_fighter(x))
• Mani is a karate fighter
Karate_fighter(mani)
• Mani broke some body-part of every other
karate fighter
Ǝx: y:Body_part(x)
Ʌkarate_fighter(y)Ʌbroke(mani,y(x))
41. • Mani broke the leg of the karate fighter who
broke the jaw of raja.
broke(mani,karate_fighter(leg))Ʌbroke(karate
_fighter, (jaw(Raja))
• Raja is a boxer
boxer(raja)
• Boxers are not as strong as karate fighters
x: y:¬strong_as(boxer(x),karate_fighter(y))
42. • Vishnu likes all kinds of fruits
• Mani is a good student
• All good students have high grades
• All students with high grades are bright
• Narayanan likes seeing English movies.
43. 1.Marcus was a man.
Man(marcus)
2. Marcus was a Pompeian.
Pompeian(marcus)
3. All Pompeians were Romans.
X: pompeian(x) →roman(x)
4. Caesar was a ruler.
ruler(caesar)
5. All Romans were either loyal to Caesar or hated
him.
44. X:roman(x) →loyalto(x,caesar)Vhate(x,caesar)
6. Everyone is loyal to someone.
X:ƎY:loyalto(x,y)
7. People only try to assassinate rulers they are not loyal
to.
x: y: person(x) Ʌruler(y) Ʌtryassassinate(x,y)
→¬loyalto(x,y)
8. Marcus tried to assassinate Caesar.
tryassassinate(marcus,caesar)
9. All men are people.
X:man(x) → person(x)
45. Q: Was Marcus loyal to Caesar?
A: loyalto(Marcus,Caesar)
46. • Marcus was a man.
Man(marcus)
• Marcus was a Pompeian.
pompeian(marcus)
• Marcus was bourn in 40 A.D.
born(marcus,40)
• All men are moral.
x: man(x) → mortal(x)
• All Pompeians died when the volcano erupted in
79 A.D
47. [ X:pompeian(x) → died(x,79)]
Ʌerupted(volcano,79)
• No mortal lives longer than 150 years
X: t1: t2:mortal(x)Ʌborn(x,t1) Ʌgt(t2-t1,150)
→Dead(x,t2)
• Now=1991
• Alive means not died.
48. X: t:[alive(x,t) → ¬dead(x,t)] Ʌ[¬ dead(x,t) →
alive(x,t)]
• If someone dies, then he is dead at all later
times.
X: t1 : t2:died(x,t1) Ʌgt(t2,t1) → dead(x,t2)