Solution to assignment 1 is here

CS 331 - Introduction to Artificial Intelligence
Assignment 1
Due Date: whatever
SOLUTIONS ARE GIVEN IN RED
Question 1
Consider the graph (of driving times in Vancouver; not drawn to scale) with arc lengths shown
on the arcs:
DT
10
KT
20
PT
5
SG
10
10
10
5
UBC
10
SL
KD
10
Note that the arc costs are for both directions.
For example the arc _UBC, PG_ has
length 10, and the arc _PG, UBC_has length
10. Suppose the neighbours are given in the
following order:
DT: KT
KT: SG, PG, DT
PG: SL, UBC, KT, SG
SG: KD, PG, KT
UBC: PG, SL
SL: PG, KD, MP, UBC
KD: SG, MP, SL
MP: KD, AP, SL
AP: MP
5
20
MP
10
AP
We want to find a path from UBC to DT. For each of the following search methods specify
whether it
halts for this particular graph. If it does halt, specify which solution path is found first and give
the path
length. If it doesn’t halt, briefly explain why.
(a) Depth-first search.
This doesn’t halt. It gets stuck in the cycle:
PG -> SL -> PG -> SL ...
(b) Depth-first search with loop detection.
It halts and finds the path:
UBC -> PG -> SL -> KD -> SG -> KT -> DT
The path length is 45.
(c) Breadth-first search.
It halts and finds the path:
UBC -> PG -> KT -> DT
The path length is 40.
(d) Lowest-cost-first search.
It halts and finds the path:
UBC -> PG -> SG -> KT -> DT
The path length is 35.
(e) A* search.
A*, as expected, finds the best possible path:
UBC -> PT -> SG -> KT -> DT
The path length is 35.
Question 2
Using the predicates Bx (\x is a barber in Podunk") and Sxy (“x shaves y”), translate the
following argument into a sentence of the predicate calculus.
Any barber in Podunk shaves exactly those individuals who do not shave themselves.
Therefore, there is no barber in Podunk.
 


Solution: x Bx  y Sxy  Syy  xBx
There are other possible solution to this problem as well. If they make sense and are consistent
with the statement given, they will be marked as correct.
Question 3
Describe a search space (and/or a search tree) in which breadth first search performs much
worse than depth first search.
Solution. Make any tree that has more children than levels, like the following:
A
B
I
C
D
E
F
G
H
J
The goal node is I. In the case of Breadth first, the number of nodes traversed are 8 before the
goal is reached, in the case of depth first, the number of nodes traversed is 2.
Question 4:
Using depth first: ABEJFGKCDHI
Using breadth first: ABCDEFGHIJK
Question 5:
There are many possible answers to the questions. I will just outline the general answering
criterion for each of the parts of the question.
States: Just specify any way in which the data can be represented in the computer. There can
be a variety of ways, the most common is the use of arrays. A simple explanation of how the
data would be entered is required.
Operators: A cannibal or missionary can either move to the left or the right of the river. How
this should be represented in a system should qualify as a proper answer to this part. For
example, swapping memory locations in the array could define the movement of either a
missionary or cannibal to either side of the river. It actually depends on how you have specified
the states of the system.
Goal: This depends on the start state. If the cannibals are starting off on the left of the river
then the goal would be to move them both to the other side of the river, and correspondingly
the missionaries would be on the other side of the river. Represent the goal in the proper state
representation as specified in the first part of this question.
Start: The start is specified in the question. The representation of the start state in the system
is the requirement of this part.
Cost function: Depending on the state representation, the procedure with which the cost
function is evaluated may vary. If arrays are being used, then the unit 1 can be used to show
movement of one element to another part of the array.
And yes an admissible heuristic, based on the above state representation can be found.
Question 6
The following solution is expected:
WarringEra ( Sess hom aru )  WarringEra ( Naraku)  WarringEra ( Inuyasha )
Every member of the Warring Era is either a human or demon or both.
xWarringEra ( x)  Human( x)  Demon( x)
No human likes rain and all demons like snow.
x( Human( x)  Likes( x, Rain ))
x( Demon( x)  Likes( x, Snow))
Naraku dislikes whatever Sesshomaru likes and likes whatever Sesshomaru dislikes.
y ( Likes( Naraku, y )  Likes( Sess hom aru , y ))
Sesshomaru likes rain and snow:
Likes( Sess hom aru , rain )  Likes( Sess hom aru , snow))
The next part is programming in PROLOG. There are many possible solutions, and if they are
consistent with the programming language syntax and will output the required results, they will
be marked as correct.
Question 7
False, true, false.
Question 8
a) xStudent( x)  (Takes( x, History )  Takes( x, Bio log y ))
b) xyFail ( x, History )  (( x  y )  Fail ( y, History ))
c)
xyFail ( x, History )  Fail ( x, Bio log y )  (( x  y )  ( Fail ( y, History )  Fail ( y, Bio log y )))
d) I have decided to omit this part as the solution is fairly complex and is beyond the objective
of this course. If someone is correctly solved this problem, one bonus mark will be rewarded.
Question 9
a) x(Pr ogram( x)  HasBug ( x))
x( HasBug ( x)  Work ( x))
Pr ogram( P)
b) From the first two rules we get:
 Pr ogram( x)  Work ( x)
And since P is a program, the first part of this must be false. Therefore the program does not
work, as specified by the second component of this proposition.
Question 10
a) x( Student ( x)  Takes( x, AI )  Likes( s, Games))
b) (x( Student ( x)  Takes( x, AI )  Likes( x, Games))
c) x(Work ( s, Sat )  Party( x, Sat ))  (Works( s, Sat )  Party( s, Sat ))
d) sTakes( s, AI )  Party( s, Sat )
e) I have decided to omit this part as the solution is fairly complex and is beyond the objective
of this course. If someone is correctly solved this problem, one bonus mark will be rewarded.
Question 11
Please wait for the solution of this question. There were some problems with the solution and
it will be revised. I will post the updated solution hopefully by tonight