Ai Assignment
Ai Assignment
1. Solve the wumpus world problem with the help of predicate logic and rules of inference.
Ans -
● The agent explores a cave consisting of rooms connected by passageways.
● Lurking somewhere in the cave is the Wumpus, a beast that eats any agent that enters
its room.
● Some rooms contain bottomless pits that trap any agent that wanders into the room.
● The Wumpus can fall into a pit too, so avoid them.
● Occasionally, there is a heap of gold in a room.
● The goal is to collect the gold and exit the world without being eaten.
● The agent always starts with [1,1] facing to the right.
● The agent has only one move.
● The agent will perceive the stench if he is in the room adjacent to the Wumpus.
● The agent will perceive a breeze if he is in the room directly adjacent to the Pit.
● The agent will perceive the glitter in the room where the gold is present.
● Initially, the agent is in the first room or on the square [1,1], and we already know that
this room is safe for the agent.
Since the agent is alive and perceives neither a breeze nor a stench at [1,1], it knows that
[1,1] and its neighbours are OK.
In Room [1,1] the agent does not feel any breeze or any Stench which means the adjacent
squares are also OK.
Now agent will either move to [1, 2] or [2,1]. Suppose the agent moves to the room [2, 1], at
this room agent perceives some breeze which means Pit is around this room. The pit can be in
[3, 1] or [2,2] so we will add the symbol ‘P?’ to say that, is this Pit room. Now the agent will
go back to the [1, 1] room.
In-room [2,2], there is no stench and no breezes present so let's suppose the agent decides to
move to [2,3]. In-room [2,3] agent perceives glitter, so it should grab the gold and climb out
of the cave.
>> Apply unit resolution on W11 ⋀ W12 ⋀ W22 ⋀ W13 and ¬W11
⇒ W12 ⋀ W22 ⋀ W13
2. Solve using resolution, Consider the following axioms:All hounds howl at night.
Anyone who has any cats will not have any mice.
Light sleepers do not have anything which howls at night.
John has either a cat or a hound.
(Conclusion) If John is a light sleeper, then John does not have any mice
Ans -
Hound(x): x is a hound.
Howl(x): x howls at night.
Have(x, y): x have y.
LS(x): x is a light sleeper.
Cat(y): y is a cat.
Mouse(z): z is a mouse.
1. ∀x(Hound(x) → Howl(x))
2. ∀x(Have(x, y) ∧ Cat(y) → ¬(Have(x, a) ∧ Mouse(a)))
3. ∀x LS(x) ∧ Have(x, y) → Howl(y)
4. Have(John, y) ∧ (Cat(y) ∨ Hound(y)))
5. LS(John) → ¬ (Have(John, y) ∧ Mouse(y))
1. ¬Hound(x) ∨ Howl(x)
2. ¬(Have(x, y) ∧ Cat(y)) ∨ ¬(Have(x, a) ∧ Mouse(a))
3. ¬( LS(x) ∧ Have(x, y)) ∨ ¬Howl(y)
4. Have(John, y) ∧ (Cat(y) ∨ Hound(y))
5. LS(John) ∨ Have(John, y) ∧ Mouse(y)
3. Unify (if possible) the following pairs of predicates and give the resulting
substitutions. b is a constant.
1. ∀ x (Loves(Mary,x) → Star(x))
2. ∀ x (Student(x) ∧ ¬ Pass(x) → ¬ Play (x))
3. Student (John)
4. ∀ x (Student (x) ∧ ¬ Study (x) → ¬ Pass (x))
5. ∀ x (¬ Play (x) → ¬ Star (x))
6. ¬ Study (John) → ¬ Loves (Mary,John) [Conclusion]
1. ¬ Loves(Mary,x) ∨ Star(x)
2. ¬ (Student(x) ∧ ¬ Pass(x)) ∨ ¬ Play (x)
3. Student (John)
4. ¬ (Student (x) ∧ ¬ Study (x)) ∨ ¬ Pass (x)
5. Play (x) ∨ ¬ Star (x)
6. Study (John) ∨ ¬ Loves (Mary,John) [Conclusion]