
Logic Programming and Artificial Intelligence
27 January 2010
Solutions to LPA Problem Sheet 1
1. (a) The following procedure takes two parameters: G, the graph to be coloured and
K, the number of colours. It tries to colour the graph using as colours the integers
1..K.
Procedure COLOUR(G,K)
if all nodes of G are coloured then return TRUE
let V be any uncoloured vertex of G
for C := 1 to K do
if no neighbor of V is coloured with C
then begin
colour V with C
if COLOUR(G,K) then return TRUE
end
return FALSE
(b) O(kn), where nis the number of edges in the graph
(c) The graph-colouring problem is one of the best-known NP-complete problems; see,
for example, the algorithms book by Cormen, Leiserson and Rivest. Therefore, no
polynomial-time algorithm is known. One exists if and only if P=NP.
2. Consider the following truth table:
row l e n u l āe n āu(lāe)ā§
(nāu)
lāu n āe(lāu)āØ
(nāe)
entire
sentence
1 F F F F T T T T T T T
2 F F F T T T T T T T T
3 F F T F T F F T F T T
4 F F T T T T T T F T T
5 F T F F T T T T T T T
6 F T F T T T T T F T T
7 F T T F T F F T T T T
8 F T T T T T T T T T T
9 T F F F F T F F T T T
10 T F F T F T F T T T T
11 T F T F F F F F F F T
12 T F T T F T F T F T T
13 T T F F T T T F T T T
14 T T F T T T T T T T T
15 T T T F T F F F T T T
16 T T T T T T T T T T T
The formula is true in every assignment, so it is a tautology.
3. (a) Performance measure: number of successful tackles, number of goals scored,
number of successful passes, -(number of cards), etc.
Environment: football pitch, football players, referee, ball
Actuators: body. Depending on robot design this may be legs or wheels, arms,
head, motors, etc.
Sensors: camera(s), touch sensor.
(b) The environment is
ā¢partially observable (you can only see one part of the pitch at a time)
ā¢stochastic (other players and the ball move around)
ā¢episodic from game to game (unless you are playing in a tournament or league),
and sequential within a game
1