You are on page 1of 7

Assignment No 1

NOTE: All questions are compulsory. Please return the solved assignments
within a week’s time.

1) Express the following using first order logic


1 All Italians are Romans
2 Everyone is loyal to someone
3 All postgraduates or graduates with experience are selected.
Assumptions
V means For Every
] Means Their Exist

2) Write Program to solve the Traveling Salesman Problem.


A salesman has a list of cities, each of which he must visit exactly once. There are direct
roads between each pair of cities on the list. Find the route the salesman should follow for
the shortest possible round trip that both starts and finishes at any one of the cities.

3) Write Program using Depth First Search to solve the 15-Puzzle Problem.

4) Write Program using Breadth First Search to solve the 15-Puzzle Problem.

5) Write Program for Best-First Search Algorithm.

6) Consider the following simple production rule base:


If A then B
If B then C
If C then D
If D then E
Discuss how a bottom-up reasoning strategy and top-down reasoning strategy would
use trick rule to infer new knowledge.

7) Explain the terms bottom-up and top-down reasoning and explain the differences that
exist between them.

1
8) For the following sentences:

Represent the sentence in First order logic.

a) Kishore ate a warm samosa.


b) Kishore is telling Prasanth the password.
c) Anil informed the police officer of his address.

9) Using MYCIN’s rules for inexact reasoning, compute CF, MB and MD of h1 given
three observations where
CF(h1 , o1) = 0.5
CF(h1 , o2) = 0.3
CF(h1 , o3) = -0.2

10) A farmer has a goat, a wolf and a cabbage on the west side of a river. He wants to get
all of his animals and his cabbage across the river onto the east side. The farmer has a
row boat but he only has enough room for himself and one other thing. The wolf will eat
the goat if they are left together alone. The goat will eat the cabbage if they are left
together alone. How can the farmer get everything on the east side?

a. Formulate this puzzle as search: i.e. give a state space representation, start
state, goal state and operators.
b. Solve this problem-using search (any method of your choice). Draw the
Search tree and show the final solution.

11) Give a suitable goal test, search state representation (all information that is relevant
for choosing the next search step, etc.) the initial state, operators, and path cost
function for the following problem. Note, there are several possible formulations
which may have an impact on search time.

You want to find your way through a maze, which has only one entrance (on the left
side) and a number of exits (all on the right side). See the maze below for an example.

2
12) Given below is a graph representing a map navigation problem.

7
2
S 4
5 4

1 A B 1
2
1
E 4 5
C 3

3 D

0
G

The number on the links shows the path cost: the number in the box shows the
heuristic evaluation. Assume that during search

• S is the start state and G is the Goal state.


• When placing nodes on the queue use alphabetical ordering to break ties.
• Assume that we never generate child nodes that appear as ancestors of the
current node in the search tree.

a) What is the order that breadth first search will expand the notes?

b) What is the order that iterative deepening search will expand the nodes?

a) What is the order that hill climbing search will expand the nodes?

What is the order that A* search will expand the nodes?

3
13) The following table shows the distances between various cities labelled A thru S (the
distances between two given towns are symmetric).

A B C D E F G H I J K L M N O P Q R S
A 45 42 63
B 45 48 67
C 48 32 46
D 32 23 49
E 23 41
F 42 44 41
G 46 30 28
H 49 30 35
I 41 35 117
J 63 44 22 38
K 41 22 26 33
L 67 26 28
M 28 21 35
N 28 21
O 38 33 44 38
P 35 44 23
Q 23 73
R 38 109
S 117 73 109

This table shows the straight line distance, SLD, between city n and city S
City SLD to City SLD to City SLD to
S S S
A 184.39 G 107.70 M 100.00
B 161.25 H 101.98 N 89.44
C 145.60 I 100.00 O 111.80
D 141.42 J 144.22 P 78.10
E 140.00 K 128.06 Q 67.08
F 148.66 L 113.14 R 101.98
S 0.00

Using the A* algorithm find the optimal route between A and S. Present your results in a
table with the following headings (as shown in the lectures).

4
Expansion Node being Expanded Cost so far Cost for this Total Cost - SLD g(n) + SLD Expanded at
No. Expanded Nodes move g(n) Level?

State the optimal route and the length of that route.

14 a) Describe the terms complete and optimal with regards to evaluating search
strategies?

b) Given the following 8-puzzle, define the problem as a search problem in terms of
states, operators, a goal test and a path cost.

5 4 1 2 3
6 1 8 8 4
7 3 2 7 6 5
Initial State Goal State

c) Consider the following problem.

A
1
1 0

5 B 5
S G
1 5
5
C

Show how uniform cost search would find the optimal route from S to G

5
15) The tower of Hanoi
Somewhere near Hanoi there is a monastery whose monks devote their lives to
a very important task. In their courtyard are three tall posts. On these posts is a set of
sixty-four disks, each with a hole in the center and each of a different radius. When the
monastery was established, all of the disks were on one of the posts, each disk resting on
the one just larger than it. The monks’ task is to move all of the disks to one of the other
pegs. Only one disk may be moved at a time, and all the other disks must be on one of the
pegs. In addition, at no time during the process may a disk be placed on top of a smaller
disk. The third peg can, ofcourse, be used as a temporary resting place for the disks. What
is the quickest way for the monks to accomplish their mission?
Even the best solution to this problem will take the monks a very long time.
This is fortunate, since legend has it that the world will end when they have finished.

16) The monkey and banana problems


A hungry monkey finds himself in a room in which a bunch of bananas is
hanging from the ceiling. The monkey, unfortunately, cannot reach the bananas.
However, in the room there are also a chair and a stick. The ceiling is just the right height
so that a monkey standing on a chair could knock the bananas down with a stick. The
monkey knows how to move around, carry other things around, reach for the bananas,
and wave a stick the air. What is the best sequence of actions for the monkey to take to
acquire lunch?

17) Consider an arithmetic problem represented in letters, as shown in the examples in


fig. Assign a decimal digit to each of the letters in such a way that the answer to the
problem is correct. If the same letter occurs more than once, it must be assigned the same
digit each time. No two different letters may be assigned the same digit.

SEND DONALD CROSS


+MORE +GERALD +ROADS
------------ ----------------- --------------
MONEY ROBERT DANGER

Fig.1

18) Nim is fairly simple game. It begins with 23 objects. Each player takes turns
removing 1, 2, or 3 objects. The goal is to force the other player to take the last object.
Assume an evaluation function as follows, where N is the number of objects remaining.

N mod 4 = 0 is a position worth 4 points.


N mod 4 = 0 is a position worth 3 points.
N mod 4 = 0 is a position worth 2 points.
N mod 4 = 0 is a position worth 1 points.
E.g. a position with 20 objects is worth 4 points because 20 mod 4 is 0. so removing 3
objects would be a good first move, under this evaluation function.

6
a) Assume you go first. Draw the search tree for the first 3 moves (2 of yours and 1
of your opponents) of the game. Use the evaluation function and the MinMax
algorithm to fill in the evaluation value of each node in the tree.
b) After you have filled in the evaluation values, circle any branches that would not
need to be evaluated if Alpha-Beta pruning was used.

19) A sliding-tile puzzle consist of three black tiles, three white tiles an and an empty
space, thus:

B1 B2 B3 W1 W2 W3

There are three legal ways of moving a tile, each with an associated cost:
Slide into the adjacent empty location-cost1
Jump over one tile into the empty location-cost1
Jump over one tile into the empty location-cost2
The goal is to have all the white tiles to the left of all the black tiles and to achieve this at
minimum cost. The final position of the empty space is not important.
Represent the problem using production system rules

20) A problem solving search can proceed either forward (from a known start state to a
desired goal state) or backward (from a goal state to a start state). What factors determine
the choice of direction for a particular problem?

21) Program the interpreter for a production system. You will need to build a table that
holds the rules and a matcher that compares the current state to the left sides of the rules.
You will also need to provide an appropriate control strategy to select among competing
rules. Use your interpreter as the basis of a program that solves water jug problem.

You might also like