0% found this document useful (0 votes)
28 views88 pages

AI Module No 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views88 pages

AI Module No 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 88

Module No : 04

Knowledge and Reasoning


• Knowledge and Knowledge representation
• Now that have looked at general problem solving, lets look at
knowledge representation and reasoning which are important
aspects of any artificial intelligence system
• In this section we will become familiar with classical methods of
knowledge representation and reasoning in AI.
• Understanding theoretical or practical aspects of the subject is
called as knowledge
• We can gain knowledge through experience acquired based on the
facts, information etc. about the subject
• After gaining knowledge about some subject we can apply that
knowledge to derive conclusions about various problems related
to that subject based on some reasoning
• Knowledge and Reasoning
• A Knowledge Based Agent
• Knowledge base is a set of representations of facts and
information
• Knowledge level is a base level(initial knowledge) of an agent,
which consists of domain-specific content (information about the
surrounding in which the agent is working)
• Knowledge based agent make use of the existing Knowledge
along with the current input from the environment in order to infer
hidden aspects of the current state
• Agent makes use of TELL and ASK mechanism
• A Knowledge Based Agent
• TELL(K): is a function that adds knowledge ‘K’ to the
knowledge base (what needs to know about surrounding to
perform some action)
• ASK(K): is a function that queries the agent about the truth of ‘K’
(what actions should be carried out to get desired output)
• The WUMPUS World
• WUMPUS is an early computer game also known as “Hunt the Wumpus”
developed by Gregory Yob in 1972 . It was originally written in BASIC
• Let’s understand the meaning of words used in the game
• Wumpus: रहस्यमय राक्षस,अ त क्रूर व्यि त
• Pit: गहरा गढ्ढा
• Breeze: हल्की हवा
• Stench: दुगन्
र्ग ध,गंदगी
• Glitter: चमक
• Let’s understand the game
• WUMPUS world is like a cave which represents number of rooms
• Based on a hide and seek format
• Rooms which are connected by passage way(we will take 4*4 grid to
understand the game)
• WUMPUS is a monster who lives in one of the rooms of the cave
• WUMPUS eats the agent(player) if agent comes in the same room
• Agent starts from any random position in the cave and has to explore the cave
• The WUMPUS World
• Pit: few rooms have bottomless pits; agent and even Wumpus can
fall into pit if they come into that room
• Stench: stench experienced in a room which has Wumpus in its
neighbourhood room
• Breeze: Breeze experienced in a room which has pit in its
neighbourhood room
• Arrow: agent can shoot the arrow in straight line to kill Wumpus
• Gold: one of the rooms glitters and which consists of Gold
• The WUMPUS World
• Actions which can be performed by the agent
• Move: to move in forward direction
• Turn: to turn left/right by 90 degree
• Grab: to pick up gold if it is in the same room as the agent
• Shoot: to shoot the arrow in the straight line
• Goal of the game
• An agent should grab the gold and come back to starting position
• Award/Points(based on the actions performed by an agent)
• 1000 points to come out of the cave with gold
• 1 point is taken away for every action taken
• 10 points are taken away if the arrow is used
• 1000 points are taken away if the agent gets killed
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Player Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World

4
3

2
Player

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World

4
3
Player has arrow and can be shoot once to kill Wumpus

2
Player

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Stench

4
Wumpus Stench

3
Stench

2
Player

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Breeze PIT

4
Breeze PIT Breeze

3
Breeze

2
Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World

4 Even Wumpus can fall into a PIT

2
1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World

4
Gold

2
Player

1
1 2 3 4
By Mr. Sachin Balawant Takmare
• WUMPUS World
• Exploring a WUMPUS World
• The first percept is shown in diagram, from which the agent can
conclude that its neighbouring squares, [1,2] and [2,1], are free of
dangers—they are OK.
• Diagram(a) shows the agent’s state of knowledge at this point.
• Exploring a WUMPUS World
• A cautious agent will move only into a
square that it knows to be OK.
Let us suppose the agent decides to move
forward to [2,1].
• The agent perceives a breeze
(denoted by “B”) in [2,1], so there must be a
pit in a neighbouring square.
• The pit cannot be in [1,1], by the rules of the game, so there must be a
pit in [2,2] or [3,1] or both.
• The notation “P?” in Figure(b) indicates a possible pit in those squares.
• At this point, there is only one known square that is OK and that has not
yet been visited. So the prudent agent will turn around, go back to [1,1],
and then proceed to [1,2].
• Exploring a WUMPUS World
• The agent perceives a stench in [1,2], resulting in
the state of knowledge shown in Figure (c).
• The stench in [1,2] means that there must be a
Wumpus nearby.
• But the Wumpus cannot be in [1,1], by the
rules of the game, and it cannot be in [2,2]
(or the agent would have detected a stench
when it was in [2,1]).
• Therefore, the agent can infer that the
Wumpus is in [1,3].
• The agent has now proved to itself that
there is neither a pit nor a Wumpus in [2,2],
so it is OK to move there.
• Exploring a WUMPUS World
• Here in figure not shown the agent’s state of knowledge at [2,2]; we just
assume that the agent turns and moves to [2,3], giving us Figure (d).
• In [2,3], the agent detects a glitter, so it will grab the gold and then
return home.
Exploring a WUMPUS world
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Player Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Player Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
WUMPUS World
Stench Breeze PIT

4
Wumpus PIT Breeze

3
Stench Breeze

2
Breeze PIT Breeze

1
1 2 3 4
By Mr. Sachin Balawant Takmare
• PEAS description of WUMPUS World
• We can play and feel this game by downloading it from Google
play on android devices
• PEAS description of WUMPUS World
Assume a robotic agent as a player
• Performance measure
• +1000 for grabbing the gold and coming back to the starting position
• -1000 if agent is killed(by falling into pit or eaten by Wumpus)
• - 1 for every move
• - 10 for using the arrow
• Environment
• Empty rooms
• Rooms with Wumpus
• Rooms with Pit
• Room with gold which is glittery
• Rooms with breeze and stench
• Arrow to shoot the Wumpus
• PEAS description of WUMPUS World
• Actuators (Effectors)
• Motor to move forward, Turn left by 900 and Turn right by 900
• Robotic arm to grab the gold
• Mechanism to shoot an arrow
• Sensors
• Camera to get the view
• Odour sensor to smell the stench
• PEAS description of WUMPUS World
• The Wumpus world environment has following characteristics
1. Fully observable
2. Deterministic
3. Episodic
4. Static
5. Discrete
6. Single agent
• Reasoning(Logic)
• Reasoning is associated with thinking, cognition, and intellect.
• The philosophical field of logical studies in which humans reason
formally through arguments
• Reasoning may be subdivided into many forms, we are going to
study only following
✔ Propositional Logic(PL)
✔ First Order Predicate Logic
• Propositional Logic(PL)
• PL is a simple knowledge representation language
• A proposition is the statement of a fact. We usually assign a
symbolic variable (Symbols are denoted by capital letters like A,B,C, etc.)
to represent a proposition, e.g.
• P = It is raining
• Q = I carry an umbrella
• A proposition is a sentence whose truth values may be
determined. So, each proposition has a truth value,(Constants have
truth values i.e. 0 is False and 1 is True) e.g.
• The proposition ‘A rectangle has four sides’ is true
• The proposition ‘The world is a cube’ is false.
• PL is the foundation for higher logics like First Order Logic(FOL)
• Propositional Logic(PL)
• Different propositions may be logically related and we can form
compound statements of propositions using logical connectives.
• Common logical connectives are:
1. ˄ AND (Conjunction)
2. ˅ OR (Disjunction)
3. ¬ NOT (Negation)
4. => If … then (Conditional)
5. <=> If and only if (bi-conditional)
• Propositional Logic(PL)
• Propositional Logic(PL)
• To define logical connectives truth tables are used
• Following Truth Table shows five connectives

A B A˄B A˅B ¬A A=>B A<=>B

T T

T F

F T

F F
• Propositional Logic(PL)
• To define logical connectives truth tables are used
• Following Truth Table shows five connectives

A B A˄B A˅B ¬A A=>B A<=>B

T T T

T F F

F T F

F F F
• Propositional Logic(PL)
• To define logical connectives truth tables are used
• Following Truth Table shows five connectives

A B A˄B A˅B ¬A A=>B A<=>B

T T T T

T F F T

F T F T

F F F F
• Propositional Logic(PL)
• To define logical connectives truth tables are used
• Following Truth Table shows five connectives

A B A˄B A˅B ¬A A=>B A<=>B

T T T T F

T F F T F

F T F T T

F F F F T
• Propositional Logic(PL)
• To define logical connectives truth tables are used
• A=>B equal to ¬A ˅ B

A B A˄B A˅B ¬A A=>B A<=>B

T T T T F T

T F F T F F

F T F T T T

F F F F T T
• Propositional Logic(PL)
• To define logical connectives truth tables are used
• A<=>B equal to (A=>B) ˄ (B=>A)

A B A˄B A˅B ¬A A=>B A<=>B

T T T T F T T

T F F T F F F

F T F T T T F

F F F F T T T
• Propositional Logic(PL)
Conversion of sentences into PL
1. It is hot and sunny
• A: it is hot
• B: it is sunny
✔ A˄B

3. She can have either tea or coffee


• A: She can have tea
• B: she can have coffee
✔ A˅ B
• Propositional Logic(PL)
Conversion of sentences into PL
3. I don’t like Stephen but I like Peter
• A: I like Stephen
• B: I like Peter
✔ ¬A˄B

4. If it is humid then it will rain


• A: it is humid
• B: it will rain
✔ A => B
• Propositional Logic(PL)
Conversion of sentences into PL
5. John is good looking and wealthy but not healthy
• A: John is good looking
• B: John is wealthy
• C: John is healthy
✔ (A ˄ B) ˄ ¬C

6. Ram is the English teacher but not Maths teacher


• A: Ram is a English teacher
• B: Ram is a Maths teacher
✔ A˄¬B
• Propositional Logic(PL)
Conversion of sentences into PL
7. If it is rainy I will stay at home
• A: it is rainy
• B: I will stay at home
• A => B

8. If John brought an i-phone today then he either sold his old mobile
or took a bank loan
• A: John brought i-phone
• B: John sold his old mobile
• C: John took a bank loan
✔ A => (B ˅ C)
• Propositional Logic(PL)
Conversion of sentences into PL
9. If it is hot and humid then it is raining
• A: it is hot
• B: it is humid
• C: it is raining
✔ (A ˄ B) => C

10. Cat chases mice or bird but not at a same time


• A: cat chases mice
• B: cat chases bird
✔ (A ˅ B) ˄ ¬ (A ˄ B)
• Propositional Logic(PL)
Conversion of sentences into PL
11. Dolphin’s neither literate not able to read but they are intelligent
• A: Dolphin’s are literate
• B: Dolphin’s are able to read
• C: Dolphin’s are intelligent
✔ (¬ A ˅ ¬ B) ˄ C
• Propositional Logic(PL)
Conversion from PL to CNF(Conjunctive Normal Form)
• Propositional Logic(PL)
Conversion from PL to CNF(Conjunctive Normal Form)
• Propositional Logic(PL)
Conversion from PL to CNF(Conjunctive Normal Form)

Q2. (A 🡪 B) 🡪 C
Q.3 (A V B) 🡪(C 🡪 D)
Q.4 ¬ ((P V ¬ Q) 🡪 R) 🡪(P ˄ R))
• Propositional Logic(PL)
• Inference in PL:
• If knowledge base is having initial knowledge A=B and B=C
then inference is A=C
• Inference is a new sentence created logically according to
knowledge base
• First Order Logic(FOL)
• FOL is also called as First Order Predicate Logic
• It is much more expressive than PL to represent knowledge
• In FOL we can represent information using relations, variables and
quantifiers
• e.g. 1. “It is Sunday today” can be represented as : today(Sunday)
• e.g. 2. “Gorilla is Black” can be represented as : Gorilla(X)🡪Black(X)
• Rules has two parts predecessor and successor. If the predecessor is
evaluated to true successor will be true
• It uses the implication symbol🡪
• e.g. “if the bag is of Blue colour, I will buy it” will be represented as
• colour(bag, blue)🡪buy(bag)
• First Order Logic(FOL)
• Quantifiers:
• They quantify the number of variables taking part in the relation

• Universal Quantifier(∀):
• Pronounced as “for all” and it is applicable to all the variables in the
predicate
• “ ∀ x A” means A is true for every replacement of x
• 🡪 is the main connective with ∀
• E.g. “Every Gorilla is Black” can be represented by
• ∀ x (Gorilla(x) 🡪 Black(x) )
• E.g. “Everyone in TE Comps is smart” can be represented by
• ∀ x (x, TE Comps 🡪 smart(x) )
• First Order Logic(FOL)
• Existential Quantifier(∃):
• Pronounced as “there exists”
• “∃ x A” means A is true for at least one replacement of x
• ˄ is the main connective with ∃
• E.g. “There is a white Dog” can be represented by
• ∃ x (Dog(x) 🡪 White(x) )
• E.g. “Someone killed the cat and is guilty” can be represented by
• ∃ x Killed(x, Cat) ˄ guilty(x)
❑ Conversion of sentences into FOL
1. “It is Sunday today” can be represented as : today(Sunday)
2. “Gorilla is Black” can be represented as : Gorilla(X)🡪Black(X)
3. “if the bag is of Blue colour, I will buy it” will be represented as
colour(bag, blue)🡪buy(bag)
4. “Every Gorilla is Black” can be represented as
∀ x (Gorilla(x) 🡪 Black(x) )
5. “Everyone in BE Comps is smart” can be represented as
∀ x (x, BE Comps 🡪 smart(x) )
6. “There is a white Dog” can be represented as
∃ x (Dog(x) 🡪 White(x) )
7. “Someone killed the cat and is guilty” can be represented as
∃ x Killed(x, Cat) ˄ guilty(x)
❑ Convert the following sentences into FOL
1. Apple is a fruit
fruit(apple)
2. John is tall
tall(John)
3. Country China is an enemy of India
Enemy(China, India)
4. Anish only likes easy courses
∀ x : Courses(x) ˄ Easy(x) 🡪 Likes(Anish, x)
5. If it is Saturday and warm then Sam is in the Park
day(Saturday) ˄ whether(Warm) 🡪 in_the_park(Sam)
❑ Convert the following sentences into FOL
6. Ravi likes all kind of food
∀x : Food(x) 🡪 Likes(Ravi, x)
7. Ajay eats peanuts and still alive
Eats(Ajay, Peanuts) ˄ Alive(Ajay)
8. Anything anyone eats and not killed is food
∀x ∀y : Eats(x, y) ˄ ¬ Killed(x)
9. Every perfect square is divisible by some prime
∀x ∃y : Square(x) ˄ Divides(Prime, x)
10. All the missiles were sold to PAK by China
∀x Missile(x) ˄ Owns(PAK, x) 🡪 Sell (China, x, PAK)
❑ Convert the following sentences into FOL

11. Bill takes either Image Processing or Soft Computing


Takes (Bill, IP) V Takes (Bill, SC)
12. Some students loves Bill, All students loves Bill
∃x students(x) ˄ Loves(x, Bill)
∀x students(x) 🡪 Loves(x, Bill)
• Convert FOL(First Order Logic) to CNF (Conjunctive Normal Form)
• Steps to convert FOL to CNF:
1. Conversion of sentences into FOL
2. Eliminate implications
3. Standardize variables
4. Move negative inwards
5. Skolemization
6. Drop universal quantifier
• Convert FOL(First Order Logic) to CNF (Conjunctive Normal Form)
1. Eliminate implications:
A→B = ¬ A ∨ B
A ↔ B = (A→B) ∧ (B→A)
= (¬ A ∨ B) ∧ (¬ B ∨ A)
2. Standardize variables:
All people who are graduating are happy. All happy people smile.
Someone is graduating.
∀(X) Smile(X)
∃(X) Graduating(X)
∀(X) Happy(X)
instead of using same variable name use different
∀(X) Smile(X)
∃(Y) Graduating(Y)
∀(Z) Happy(Z)
• Convert FOL(First Order Logic) to CNF (Conjunctive Normal Form)
3. Move negation inwards:

¬ [ ∀(X). P(X) ] = ∃(X) . ¬ P(X)


¬ [∃(X). P(X) ] = ∀(X) . ¬ P(X)
¬ (A ∧ B) = ¬ A ∨ ¬B
¬ (A ∨ B) = ¬ A ∧ ¬B
¬ (¬ A) = A
• Convert FOL(First Order Logic) to CNF (Conjunctive Normal Form)
4. Skolemization:
Replace Existential quantifiers(∃) with Skolem constants
e.g.
Before skolemization
1. someone is smiling ∃(X)Smile(X)
2. someone is graduating ∃(X)Graduating(X)

After skolemization
1. Smile(A)
2. Graduating(B)
• Convert FOL(First Order Logic) to CNF (Conjunctive Normal Form)
5. Drop universal quantifiers:
Replace universal quantifiers(∀) with constants
e.g.
Before dropping universal quantifier
1. All are smiling ∀(X)Smile(X)
2. All are graduating ∀(X)Graduating(X)

After dropping universal quantifier


1. Smile(X)
2. Graduating(Y)
• First Order Logic(FOL)
Q. Consider the following facts about people
1. All people who are graduating are happy
2. All happy people smile
3. Someone is graduating
• Convert to FOL
• Convert FOL to CNF
• Prove that “Is someone smiling?” using resolution
• Draw resolution graph/tree
• Convert FOL(First Order Logic) to CNF (Conjunctive Normal Form)
• Steps to convert FOL to CNF:
1. Conversion of sentences into FOL
2. Eliminate implications
3. Standardize variables
4. Move negative inwards
5. Skolemization
6. Drop universal quantifier
• Convert to FOL
Q. Consider the following facts about people
1. All people who are graduating are happy
2. All happy people smile
3. Someone is graduating
Answers:
A. All people who are graduating are happy
∀ x (Graduating(x) → Happy(x) )
B. All happy people smile
∀ x (Happy (x) → Smile(x) )
C. Someone is graduating
∃ x Graduating(x)
We are going to prove that ‘someone is smiling?’, so will write this in FOL
∃ x Smiling(x)
• Convert to CNF
Step:1 Eliminate implications [use formula A→B = ¬ A ∨ B]
Answers:
A. All people who are graduating are happy
∀ x [Graduating(x) → Happy(x) ]
∀ x [¬ Graduating(x) ∨ Happy(x) ]
B. All happy people smile
∀ x [ Happy (x) → Smile(x) ]
∀ x [¬ Happy (x) ∨ Smile(x) ]
C. Someone is graduating
∃ x Graduating(x)
Someone is smiling ∃ x Smiling(x) … we will consider Someone is not
smiling and prove it is wrong i.e. assume ¬ [∃ x Smiling(x)]
• Convert to CNF
Step:2 Standardized variables (Use different variable name for every
statement)
Answers:
A. All people who are graduating are happy
∀ X [¬ Graduating(X) ∨ Happy(X) ]
B. All happy people smile
∀ Y [¬ Happy (Y) ∨ Smile(Y) ]
C. Someone is graduating
∃ Z [ Graduating(Z) ]
Assume ¬ [ ∃ W Smiling(W) ]
• Convert to CNF
Step:3 Move negation inwards
Answers:
A. All people who are graduating are happy
∀ X [¬ Graduating(X) ∨ Happy(X) ] …remain as it is
B. All happy people smile
∀ Y [¬ Happy (Y) ∨ Smile(Y) ] … remain as it is
C. Someone is graduating
∃ Z [ Graduating(Z) ] … remain as it is

Assume ¬ [ ∃ W Smiling(W) ] .. It will change to ∀ W (¬ Smile(W) )


• Convert to CNF
Step:4 Skolemization (Remove ∃ operator)
Answers:
A. All people who are graduating are happy
∀ X [¬ Graduating(X) ∨ Happy(X) ] …remain as it is
B. All happy people smile
∀ Y [¬ Happy (Y) ∨ Smile(Y) ] … remain as it is
C. Someone is graduating
∃ Z [ Graduating(Z) ] … It will change to Graduating(A)

∀ W (¬ Smile(W) ) ….remain as it is
• Convert to CNF
Step:4 Drop universal quantifier (Remove ∀ operator)
Answers:
A. All people who are graduating are happy
∀ X [¬ Graduating(X) ∨ Happy(X) ] … It will change to
¬ Graduating(X) ∨ Happy(X)……(Fact 1)
B. All happy people smile
∀ Y [¬ Happy (Y) ∨ Smile(Y) ] … It will change to
¬ Happy (Y) ∨ Smile(Y) …… (Fact 2)
C. Someone is graduating
Graduating(A)….. remain as it is….. (Fact 3)

∀ W (¬ Smile(W) ) ….it will change to (¬ Smile(W) …. (Fact 4)


• Resolution Tree
If fact ‘F’ is to be proved then assume ‘¬F’ and start
It contradict all the other rules in knowledge base
The process stops, when it returns ‘NULL’
Prove that “Is someone smiling?” using resolution
So, start with what you want to prove with negative value

¬ Smile(W)

Now search into the list of rules for smile (i.e. Fact 2) and draw it in front
of first box, like

¬ Smile(W) ¬ Happy (Y) ∨ Smile(Y)


• Resolution Tree
Now contradict/compare above two boxes, positive smile and
negative smile get cancelled

¬ Smile(W) ¬ Happy (Y) ∨ Smile(Y)

¬ Happy (W) Y has been replaced by W


• Resolution Tree
Now find/search happy from the list of facts (i.e. fact 1)

¬ Smile(W) ¬ Happy (Y) ∨ Smile(Y)

¬ Happy (W) ¬ Graduating(X) ∨ Happy(X)

Now contradict above two boxes,


positive Happy and negative Happy get
¬ Graduating(W)
cancelled
X has been replaced by W
• Resolution Tree
Now find/search Graduation from the list of facts (i.e. fact 3)

¬ Smile(W) ¬ Happy (Y) ∨ Smile(Y)

¬ Happy (W) ¬ Graduating(X) ∨ Happy(X)

¬ Graduating(W) Graduating(A)
Now contradict above two boxes,
positive Graduation and negative Graduation
get cancelled
NULL
• Final Resolution Tree
Hence “Someone is not smiling” is Wrong, so “Someone is smiling” is Proved

¬ Smile(W) ¬ Happy (Y) ∨ Smile(Y)

¬ Happy (Y) ¬ Graduating(X) ∨ Happy(X)

¬ Graduating(W) Graduating(A)

NULL
• FOL-CNF-Resolution
Exercise:
Q. Consider the following facts
1. Ravi likes all kind of food
2. Apple and Chicken are food
3. Anything anyone eats and is not killed is food
4. Ajay eats peanuts and still alive
5. Rita eats that Ajay eats
• Convert to FOL
• Convert FOL to CNF
• Prove that “Ravi likes Peanuts” using resolution
• Draw resolution Graph/Tree
• FOL-CNF-Resolution
Exercise:
Q. Consider the following facts
1. It is a crime for an America to sell weapons to the enemy nations
2. Country Nono is an enemy of America
3. Nono has some missiles
4. All the missiles were sold to Nono by Colonel
5. Missile is a weapon
6. Colonel is an American
• Convert to FOL
• Convert FOL to CNF
• Prove that “Colonel is a Criminal” using resolution
• Draw resolution Graph/Tree
• Inference in First Order Logic
Inference- (conclusion/decision)
Inference engine:
It is component of the system that applies logical rules to the
knowledge base to deduce new information
There are two modes of inference engine
1. Forward chaining: start with the known facts and asserts new
facts
2. Backward chaining: start with goal and work backward to
determine what facts must be asserted so that the goal can be
achieved
• Inference in First Order Logic
1. Forward chaining:
Conclude from A and A => B to B
It is raining(A); if it is raining the road is wet(A=>B)
Infer: the road is wet(B)
2. Backward chaining
Conclude from B and A => B to A
The road is wet(B); if it is raining the road is wet(A=>B)
Infer: It is raining(A)
• Inference in First Order Logic
Forward chaining
• Let’s look at how a doctor goes about diagnosing a patient.
• He asks the patient for symptoms and then infers diagnosis from
symptoms.
• When based on the available data a decision is taken then the
process is called as the forward chaining
• It works from an initial state and reaches to goal state
• Inference in First Order Logic
• Inference in First Order Logic
Backward chaining
• Backward chaining : start with goal and work backward to
determine what facts must be asserted so that the goal can be
achieved
• Backward chaining is an inference strategy that works backward
from a hypothesis to a proof.
• You begin with a hypothesis about what the situation might be.
Then you prove it using given facts,
• e.g. a doctor may suspect some disease and proceed by inspection
of symptoms.
• In backward chaining terminology, the hypothesis to prove is
called the goal.
• Inference in First Order Logic
• Inference in First Order Logic
Forward vs. backward chaining
• The exploration of knowledge has different mechanisms in
forward and backward chaining.
• Backward chaining is more focused and tries to avoid exploring
unnecessary paths of reasoning. Forward chaining, on the other
hand is like an exhaustive search.

You might also like