You are on page 1of 9

COS351D/203/2007

School of Computing

Techniques of Artificial Intelligence


COS351D

TUTORIAL LETTER 203/2007

Discussion of Assignment 3
COS351D/203/2007

Table of Contents

Outline of syllabus for Chapters 1 to 9.................................................................................... 3

Solution: Assignment 3 ........................................................................................................... 5


COS351D/203/2007

Outline of syllabus for Chapters 1 to 9, 18, 20

Chapter 1
Read as background.

Chapter 2
Familiarise yourself with the concepts and terminology.

Chapter 3
Study everything. You have to understand all the algorithms and be able to apply them to a given
problem statement. You do not need to memorise any pseudo-code.

Chapter 4
Study everything except the following sections, which you can omit entirely:
- Memory-bounded heuristic search, pp. 101 – 104.
- 4.4 Local Search in Continuous Spaces, pp. 119 – 129.
You have to understand all the algorithms and be able to apply them to a given problem statement.
You do not need to memorise any pseudo-code.

Chapter 5
Study everything except the following section, which you can omit entirely:
- 5.4 The Structure of Problems, pp. 151 – 155.
You have to understand all the algorithms and be able to apply them to a given problem statement.
You do not need to memorise any pseudo-code.

Chapter 6
Study sections 6.1, 6.2 and 6.3. You have to understand the minimax and alpha-beta algorithms, and
be able to apply them to a given problem statement.
Read sections 6.4, 6.5, 6.6, 6.7 and 6.8. You have to understand the concepts covered in these
sections, but you do not need to be familiar with any particular game such as backgammon, chess or
any card game.

Chapter 7
Study everything except the following section, which you can omit entirely:
- 7.7 Agents based on propositional logic, pp. 225 – 232.
Many of the concepts introduced in this chapter should already be familiar to you from COS261.
However, there are some important algorithms in this chapter that you will probably not be familiar
with. In particular, you have to understand and be able to apply forward and backward chaining,
resolution, and the DPLL and WALKSAT algorithms.

Chapter 8
Most of the concepts introduced in this chapter should also already be familiar to you. Read the
chapter to refresh your memory. Make sure that you can translate English language sentences and
paragraphs into first-order logic.

Chapter 9
You have to be able to convert an English language paragraph into first-order logic, convert this into
conjunctive normal form, and use resolution to show that a given conclusion follows from the
premises. In order to apply the resolution algorithm, you will need to understand the unification of
terms. You can omit the following sections:
- 9.3 Forward chaining, pp. 280 – 287;
- 9.4 Backward chaining, pp. 287 – 295.
You can also omit everything from p. 300 Completeness of resolution to the end of the chapter.

Chapter 18
Understand the forms of learning and the concepts of inductive learning. You have to be able to
construct a decision tree and reason with the contents thereof. The theory of decision trees is also
important. You can omit the following sections:
- 18.4 Ensemble Learning, pp. 664 – 668;

3
COS351D/203/2007

- 18.5 Why Learning Works, pp. 668 – 673.

Chapter 20
Sections 20.1 to 20.4 serve as background to much of the rest of the chapter. Read and understand
the concepts as far as it pertains to sections 20.5 onwards. Section 20.5 forms the core of the work
that you need to understand fully. You will have to be able to construct a simple neural network and
train it using a given training set. You have to understand the limitations of the various models of
neural networks. You can omit the following sections:
- 20.6 Kernel machines, pp. 749 – 752;
- 20.7 Case Study, pp. 752 – 754.

4
COS351D/203/2007

Solution: Assignment 3

Answer 1

Exercise 5.2 on page 158.

There are 18 solutions for colouring Australia with 3 colours. Start with SA, which can have any of
three colours. The moving clockwise, WA can have either of the remaining two colours. Thereafter,
everything else on the mainland is strictly determined. That makes a total of 3x2 = 6 possibilities for
the mainland, and all 3 possible colours for Tasmania. Thus a total of 3x2x3 = 18.

Answer 2

Exercise 5.4 on page 158.

a) This problem is similar to the 8-queens problem in that one could start with an empty puzzle
(no words filled in), and end with a puzzle in which all the boxes are filled with letters such
that consecutive strings make up words. An incremental formulation such as the one
described on page 66 would therefore be suitable. Depth-first search is a simple search
choice, where each successor fills in one of the words from a dictionary. It is better to go one
word at a time to minimize the number of steps. The states are any arrangement in which 0 or
more words are filled in on the puzzle. In the initial state there are no words filled in. The
successor function fills in any additional word which is not in conflict with words already filled
in. A goal is any state in which all words are filled in. This formulation is as a general search
problem, but it is in fact already also a formulation as a CSP – it is essentially the same as the
second CSP formulation we give below.

b) To formulate a problem as a CSP, you need to decide what the variables are, what the
domain of each variable is (i.e. what are the legal values that can be assigned to variables),
and what the constraints between variables are (i.e. what relationships should hold between
variables).

You could have a variable for each box in the puzzle, where the value of each variable is a
letter, and the constraints are the vertical or horizontal row of letters must make a valid word.
This approach is feasible with a most-constraining heuristic.

Alternatively, we could have each string of consecutive vertical and horizontal boxes as a
single variable. The domain of each variable is words of the right length from a dictionary. The
constraint would say that intersecting strings must have the same letter at their intersection.

Solving the latter formulation requires fewer steps and fewer constraints, but will have a larger
domain (assuming a good size dictionary) than the first formulation. Either is feasible.

Answer 3

4-queens problem.

One possible solution is to represent each of the four columns as a variable, with the position of the
queen in that column represented by the row in which she is found.

Variables: X1, X 2 , X 3 , X 4
Domain(s): Each variable has domain {1, 2, 3, 4}.
Constraints: X1 ≠ X 2 , X1 ≠ X 3 , X1 ≠ X 4 , X 2 ≠ X 3 , X 2 ≠ X 4 , X 3 ≠ X 4

5
COS351D/203/2007

X1 +1 ≠ X 2 , X1 −1 ≠ X 2
X1 + 2 ≠ X 3 , X1 − 2 ≠ X 3
X1 + 3 ≠ X 4 , X1 − 3 ≠ X 4
X 2 +1 ≠ X 3 , X 2 −1 ≠ X 3
X2 + 2 ≠ X4, X2 − 2 ≠ X4
X 3 +1 ≠ X 4 , X 3 −1 ≠ X 4

A more compact constraint would be to use a 4-arity constraint Alldifferent ( X 1 , X 2 , X 3 , X 4 ), which


means that none of the four variables of this function may have the same value.

Answer 4

Exercise 6.3 on page 190.

a) The game tree for the four-square game in Exercise 6.3. Terminal states are in boxes, loop
states are in double-boxes. Each state is annotated with its minimax value in a circle.
+1 (1,4)

+1 (2,4)

+1 (2,3)

+1 (4,3) (1,3) -1

-1 (1,2) (1,4) ?

-1 (3,2)

-1 (3,1) (3,4) ?

(2,4) ?

b) The “?” values are handled by assuming that an agent with a choice between winning the
game and entering a “?” state will always choose the win. That is min(-1, ?) is -1 and
max(+1,?) is +1. If all successors are “?”, the backed-up value is set to “?”.

c) Standard minimax will fail on this game tree, since it is depth-first and would go into an infinite
loop. It can be fixed by comparing the current state against the stack; and if the state is
repeated, then return a “?” value. Propagation of “?” is handled as in (b) above. Although it
will work on this tree it will not always work because it is not clear how to compare “?” with a
drawn position, nor is it clear how to compare wins of different degrees, as in Backgammon.
Finally, in games with chance nodes, it is unclear how to compute the average of a number
and “?”. Note that it is not correct to treat repeated states automatically as drawn positions. In
this example, both (1,4) and (2,4) repeat in the tree but are both won positions.

6
COS351D/203/2007

Answer 5

Exercise 6.12 on page 192.

a) The following modification to the MAX-VALUE part of the minimax algorithm will allow the
winner of a MAX move to play again (WINNER(s) and WINNER(trick) are equivalent):

function MAX-VALUE(state) returns a utility value


if TERMINAL-TEST(state) then return UTILITY(state)
v ← −∞
for a, s in SUCCESSORS(state) do
if WINNER(s) = Max
then v ← MAX( v ,MAX-VALUE(s))
else v ← MAX( v ,MIN-VALUE(s))
return v

A similar modification to MIN-VALUE needs to be done to allow the winner of the MIN move to
play again. Therefore, the successors of MIN or MAX nodes can be a mixture of MIN and MAX
nodes.

b) Part of the game tree for the game shown on page 179. Note specifically the positions of MIN
and MAX nodes.

7
COS351D/203/2007

MAX MIN
S = Spades S
H 6
2
4
H = Hearts D 6
C 9,8 10,5
D = Diamonds
C = Clubs
MAX MIN MAX MIN MAX MIN
S 2 S 2 S 2
H 4 H 6 4 H 6 4
D 6 D D 6
C 9,8 10,5 C 9,8 10,5 C 9 10,5

MAX MIN
S 2
H
D 6
C 9,8 10,5

MAX MIN MAX MIN


S 2 S 2
H H
D D 6
C 9,8 10,5 C 9 10,5

0 0

MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN
S S 2 S 2 S 2 S 2
H H H H H
D D D D 6 D 6
C 9,8 10,5 C 9,8 10 C 9,8 5 C 9 10 C 9 5

+2 0 +4 +2 0

MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN
S S 2 S 2 S 2 S 2 S S 2
H H H H H H H
D D D D D 6 D 6 D 6
C 9 10,5 C 9 10 C 9 5 C 9 10 C 10 C 9 5 C 9

+2 0 +4 +2 0 0 +2

MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN
S S S 2 S 2 S S 2 S 2 S S S 2
H H H H H H H H H H
D D D D D D D 6 D D 6 D 6
C 9 5 C 9 10 C 9 C 9 C 9 10 C 9 C C 9 5 C 5 C

+2 +2 0 +4 +2 +4 0 0 -2 +2

MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN MAX MIN
S S S S 2 S S 2 S S S S 2
H H H H H H H H H H
D D D D D D D 6 D D 6 D
C 9 C 10 C 9 C C 10 C C C 9 C C

+2 +2 0 +4 +2 +4 0 0 -2 +2

+2 +2 0 +4 +2 +4 0 0 -2 +2

Answer 6

Exercise 7.8 on page 237.

a) Valid.
b) Satisfiable.
c) Satisfiable.
d) Valid.
e) Valid.
f) Valid.
g) Valid.
h) Satisfiable.

Many people are fooled by (e) and (g) because they think of implication as being causation, or
something similar. In (e) they feel it is the combination of Smoke and Heat that leads to Fire, and thus
that there is no reason why one or the other alone should lead to fire. Similarly, in (g), they feel that
there is not necessarily a causal relationship between Big and Dumb, so the sentence should be
falsifiable, but not valid. However, this reasoning is incorrect, because implication is not causation.
Implication is just a kind of disjunction (in the sense that P ⇒ Q is the same as ¬P ∨ Q ). So
Big ∨ Dumb ∨ ( Big ⇒ Dumb)
is equivalent to

8
COS351D/203/2007

Big ∨ Dumb ∨ ¬Big ∨ Dumb) ,


which is equivalent to
Big ∨ ¬Big ∨ Dumb ,
which is true whether Big is true or false, and is therefore valid.

Answer 7

Exercise 7.9 on page 238.

From the first two statements, we see that if the unicorn is mythical, then it is immortal; otherwise it is
mortal and a mammal. So it must either be immortal or a mammal, and thus horned. That means it is
also magical. However, we can’t deduce anything about whether it is mythical.

We rewrite the paragraph as follows in the language of propositional logic:

mythical ⇒ immortal
¬ mythical ⇒ (mortal ∧ mammal)
(¬ mortal ∨ mammal) ⇒ horned
horned ⇒ magical

You can now use any of a number of proof systems to formalise the argument given above. For
example, try proving that that the unicorn is horned by resolution refutation. Or show that you cannot
prove that the unicorn is mythical, using resolution with forward chaining.

You might also like