You are on page 1of 20

T0264 – Artificial Intelligence

T0264 – ARTIFICIAL INTELLIGENCE


Session 5 & 6
First Order Logic & Inference

Derwin Suhartono

School of Computer Science


Bina Nusantara University

D3690 - Derwin Suhartono 1


First Order Logic & T0264 – Artificial Intelligence

Inference in FOL

1. Syntax and Semantic of First-Order Logic


2. Using First-Order Logic
3. Inference by Using Backward Chaining
4. Inference by Using Resolution
5. Exercise

D3690 - Derwin Suhartono 2


Syntax and Semantic T0264 – Artificial Intelligence

of First-Order Logic

Model of First-Order Logic

D3690 - Derwin Suhartono 3


Syntax and Semantic T0264 – Artificial Intelligence

of First-Order Logic

Atomic Sentence
• Atomic sentence = predicate (term1,...,termn)
Example:
“Richard the Lionheart is the brother of King John”.
 Brother(Richard, John)

• Complex terms as arguments in atomic sentences is


 married (Father(Richard), Mother(John))

D3690 - Derwin Suhartono 4


Syntax and Semantic T0264 – Artificial Intelligence

of First-Order Logic

Complex Sentence
• Complex sentences are made from atomic sentences
using connectives.
Example:
“All king are person” written as:
x : King(x)  Person(x)
“King John has a crown on his head” written as:
y : Crown(y)  OnHead(y, John)

D3690 - Derwin Suhartono 5


Syntax and Semantic T0264 – Artificial Intelligence

of First-Order Logic

Complex Sentence
• More complex sentences using multiple quantifier :
p q : brother (p, q)  sibling(p, q)

• Symmetric relationship:
p q : sibling(p, q)  sibling(q, p)
Sibling(King John, Richard)  Sibling(Richard, King John)

D3690 - Derwin Suhartono 6


Using First-Order T0264 – Artificial Intelligence

Logic
Given the following statements:
1. Chandra is a student
2. Chandra is a student in SoCS
3. Each SoCS student is a member of SoCS
4. Algorithm is difficult
5. Each student in SoCS likes or hates the Algorithm
6. Each student likes one lesson
7. The student who does not come to difficult lesson dislikes the
lesson
8. Chandra does not come to Algorithm

D3690 - Derwin Suhartono 7


Using First-Order T0264 – Artificial Intelligence

Logic

The FOL form of the statements are:


1. student (Chandra)
2. SoCS (Chandra)
3. x : SoCS(x)  student (x, SoCS)
4. difficult (Algorithm)
5. x : student(x, SoCS)  like(x, Algorithm)  hate(x, Algorithm)
6. x : y : like(x, y)
7. x : y : student(x)  difficult(y)  come(x, y)  like(x, y)
8. come(Chandra, Algorithm)

D3690 - Derwin Suhartono 8


Inference by Using T0264 – Artificial Intelligence

Backward Chaining

Does Chandra like Algorithm?


like(Chandra, Algorithm)

(7)

student(Chandra)  difficult(Algorithm)  come (Chandra, algorithm)

(1)

difficult(Algorithm)  come(Chandra, Algorithm)

(4)

come(Chandra, Algorithm)

(8)

null

D3690 - Derwin Suhartono 9


Inference by Using T0264 – Artificial Intelligence

Resolution

• Inference procedure based on resolution work by


using the principle of proof by contradiction.
• How to?
• Convert to CNF (Clause Normal Form)
• Show clauses obtained by resolving pairs in the row

D3690 - Derwin Suhartono 10


Inference by Using T0264 – Artificial Intelligence

Resolution

Given Axiom Clause Form


P P

(P ^ Q)  R P v Q v R

(S v T)  Q S v Q
T v Q
T T

D3690 - Derwin Suhartono 11


Inference by Using T0264 – Artificial Intelligence

Resolution

D3690 - Derwin Suhartono 12


Inference by Using T0264 – Artificial Intelligence

Resolution

Given the same example, the CNF form are:


1. student (Chandra)
2. SoCS (Chandra)
3. SoCS(x1) v student(x1, SoCS)
4. difficult(Algorithm)
5. student(x2, SoCS) v like(x2,Algorithm) v hate(x2,Algorithm)

6. like(x3,f(x3))

7. student(x4) v difficult(y1) v come(x4,y1) v like(x4,y1)


8. come(Chandra, Algorithm)

D3690 - Derwin Suhartono 13


Inference by Using T0264 – Artificial Intelligence

Resolution
hate(Chandra,Algorithm) 5

Chandra/x2
Prove whether
3 student(Chandra, SoCS) v like(Chandra,Algorithm)
Chandra hates
Chandra/x1
algorithm or not?
SoCS(Chandra) v like(Chandra,Algorithm) 2

7 like(Chandra,Algorithm)

Chandra/x4 ; Algoritma/y1

1 student(Chandra) v difficult(Algorithm) v come(Chandra,Algorithm)

difficult(Algorithm) v come(Chandra,Algorithm) 4

come(Chandra, Algorithm) 8 It is proven that Chandra


hates Algorithm
null (contradiction theory)

D3690 - Derwin Suhartono 14


Inference by Using T0264 – Artificial Intelligence

Resolution

D3690 - Derwin Suhartono 15


Inference by T0264 – Artificial Intelligence

Backward Chaining
Given the following statements:
1. Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeian were Romans.
4. Caesar was a ruler.
5. All Romans were either loyal to Caesar or hated him.
6. Everyone is loyal to someone.
7. People only try to assassinate rulers they aren’t loyal to.
8. Marcus tried to assassinate Caesar.
9. All men are people.
Prove by using Backward Chaining that Marcus is not loyal to Caesar

D3690 - Derwin Suhartono 16


Inference by T0264 – Artificial Intelligence

Backward Chaining
First-Order Logic from the statements are:
1. man(Marcus)
2. Pompeian(Marcus)
3. x : Pompeian (x)  Roman(x)
4. ruler(Caesar)
5. x : Roman(x)  loyalto(x,Caesar) 
hate(x,Caesar)
6. x : y : loyalto (x,y)
7. x : y : person(x)  ruler(y) 
tryassassinate(x,y)   loyalto(x,y)
8. tryassassinate (Marcus, Caesar)
9. x : man(x)  person(x)

D3690 - Derwin Suhartono 17


Inference by T0264 – Artificial Intelligence

Backward Chaining

D3690 - Derwin Suhartono 18


T0264 – Artificial Intelligence

Closing

Any Questions?

D3690 - Derwin Suhartono 19


T0264 – Artificial Intelligence

Exercise
From the last period of “Pemilu” in Jakarta, we have some facts. They are given as
follows:
(1) At that time, Foke was the Vice Governor of Jakarta. (2) Then, Foke went
to propose himself to be the Governor candidate. (3) And the Vice Governor
candidate was Priyanto. (4) Someone who was success would be famous. (5)
Every people who was famous and loved would be elected. (6) Because of his
position, Foke was success and he was loved. (7) Adang was the strongest
rival on that “Pemilu”. (8) All people that were elected will be the Governor.
a. Convert all of the statements to First-Order Logic!
b. Convert the FOL to CNF form!
c. Prove that Foke became the Governor using Resolution!

D3690 - Derwin Suhartono 20

You might also like