Pl&fopl 1
Pl&fopl 1
First-Order Logic
Propositional Logic
• PL : Weak knowledge representation
language
• Can not express complex AI problems
– Hard to identify if the used entity is
“individual” eg. Vishnu, Mumbai, 2021 etc
– Can not directly represent properties of
individual entities or relationships between
the individual entities eg. Vishnu is tall
– Can not express specialization,
generalization or patterns eg. All
rectangles have 4 sides
First Order Logic (FOL)
• More expressive than PL
• Represents information using variables,
relations and quantifiers
• Vishnu is Tall:
Vishnu(x)-> Tall(x)
• It is Sunday today
today(Sunday)
First Order Logic (FOL)
• FOL symbols: Constant, Variable, Function
• Assuming ‘x’ is a domain of values,
– Constant Term: A term with fixed value which
belongs to the domain
– Variable Term: A term which can be assigned
values in the domain
– Function: Say ‘f’ is a function of ‘n’ arguments. If
we assume that t1,t2,t3,…,tn are terms then
f (t1,t2,t3,…,tn) is also called as term.
• FOL: uses Propositional Logic as a base, so
connectives are same
First Order Logic (FOL)
• FOL Rules:
– Predicate Logic has two parts
a)Predecessor b) Successor
• If predecessor is evaluated to TRUE,
successor will be TRUE
– Implication → symbol
• Eg. If the bag is of blue color, I will buy it.
– Color(bag, blue) → buy(bag)
First Order Logic (FOL)
• Universal Quantifier ‘∀’:
• It specifies that the statement within its range is true
for everything of every instance of particular thing
• “for all x” "for each x" "for every x"
– ∀xA: A is True for every replacement of x
– "All man drink coffee" : ∀x(man(x) --> drink(x, coffee))
– “Every Gorilla is Black” : ∀x(Gorilla(x) → Black(x))
– “Everyone at DJ is smart” : ∀x At (x, DJ) → smart(x)
– "All birds fly" : ∀x(bird(x) --> fly(x))
– "Every man respects his parent" :
∀xman(x) --> respects(x, parent)
First Order Logic (FOL)
• Existential Quantifier ‘∃’: “there exists x” "for
some x" "for atleast one x"
• Which express that the statement within its scope is
true for at least one instance of something
– ∃xA: A is True for at least one replacement of x
– “There is a white dog” : ∃ x(Dog(x) ^ White(x))
– "Some girls are intelligent" : ∃ x(girls(x) ^ Intelligent(x))
– “Someone killed the cat and is guilty” :
∃ killed (x, cat ) ^ guilty (x)
Sentences
• A predicate is a sentence
• If sen, sen’ are sentences & x a
variable, then
(sen), sen, x sen, x sen,
sen sen’, sen sen’, sen sen’
are sentences
• Nothing else is a sentence
Examples of Sentences
Birthday( x, y) – x celebrates birthday on
date y
y x Birthday (x, y) –
For all dates, there exists a person who
celebrates his/her Birthday on that date.
That is – “everyday someone celebrates
his/her Birthday”
Examples (contd.)
Brother( x, y) – x is y’s brother
Loves (x, y) – x loves y
x y Brother (x, y) Loves (x, y)
Everyone loves (all of) his/her brothers.
•
Reasoning in FOL
• Eg.
• Using Predicate logic find the course of
Anish's liking for the following,
I. Anish only likes easy course
II. Computer courses are hard
III. All electronic courses are easy
IV. DSP is an electronics course
Reasoning in FOL
• Using Predicate logic find the course of
Anish's liking for the following,
Solution: Converting given facts into FOL
I. ∀x : course(x)^easy(x) -> likes(Anish,x)
II. ∀x : course(x)^computer(x) -> hard(x)
III. ∀x : course(x)^electronics(x) -> easy(x)
IV.Eletronics(DSP)
V. Curse(DSP)
Reasoning in FOL
• Consider the following problem:
If a perfect square is divisible by a prime p,
then it is also divisible by square of p.
Every perfect square is divisible by some
prime.
36 is a perfect square.
3. perfect_sq (36)
Inferencing
• From 2 and Universal Elimination
(4) y perfect_sq (36) prime (y)
divides (36, y)
• From 4 and Existential Elimination
(5) perfect_sq (36) prime (P)
divides (36, P)
• From (1) and (5)
(6) divides (36, square(P))
Inferencing (contd.)
• From (5) and (6)
(7) prime (P) divides (36, square(P))
• No Existential Quantifier
Conversion to Horn Sentences
• Existential Quantifiers can be removed using
Existential Elimination (Skolemization)
– If the existential quantifier is outside any
universal quantifier, a Skolem constant is
introduced. E.g. y prime (y) prime(P), where P
is a Skolem constant
Principle:
Suppose x is a literal and S1 and S2 are two
sets of propositional sentences represented n
clausal form
4. Equilateral (ABC)
Proof by refutation
• To prove
Angle B is equal to Angle C
Equal (B,C)
Let us disprove
Not equal (B,C)
Equal (B,C)
Let us try to disprove this
Equilateral (ABC) V
Equal
Equal (B,C) Isosceles (ABC)
(AB,AC) V
Equal (B,C) Isosceles (ABC) V
Equal (AB,AC)
Isosceles
(ABC) V
Equal Equal (AB,AC) V Equal
(AB,AC) (B,C)
Equal
(AB,AC)
Equilateral (ABC)
Isosceles (ABC)
Isosceles (ABC)
Equilateral Equilateral (ABC)
V Isosceles (ABC)
(ABC) V
Isosceles
(ABC) Isosceles (ABC)
V Equal (AB,AC)
Equilateral (ABC)
Equal (AB,AC) V
Equal (B,C)
Equilateral (ABC)
Equilateral (ABC)
Null
clause
Procedure for Resolution
• Convert given propositions into clausal
form
• Convert the negation of the sentence to be
proved into clausal form
• Combine the clauses into a set
• Iteratively apply resolution to the set and
add the resolvent to the set
• Continue until no further resolvents can
be obtained or a null clause is obtained
What is it for Predicate Logic
A Few Statements
• All people who are graduating are
happy.
• Someone is graduating.
• Is someone smiling?
(Conclusion)
Solving the problem
• We intend to code the problem in
predicate calculus.
• Someone is graduating
– (x) graduating (x)
• Is someone smiling
– (x) smiling (x)
Predicates
1. (x) graduating (x) → happy (x)
{name1/w}
7. Null clause
Quiz
Solve the problem with resolution
If a perfect square is divisible by a prime p,
then it is also divisible by square of p.
Every perfect square is divisible by some
prime.
36 is a perfect square.
X = peter
Y = jim ? ;
no
| ?- grandparent(X,Y).