Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

COS351-D/102/2004

COS351-D

ARTIFICIAL INTELLIGENCE TECHNIQUES

TUTORIAL LETTER 102

Examination tutorial letter

DEPARTMENT OF THEORETICAL COMPUTING


SCHOOL OF COMPUTING
2

Dear student,

This letter contains information regarding the examination paper, and a few guidelines on how to study
for the examination.

You have to prepare the whole syllabus as set out in the study guide (tutorial letter 501). The
examination paper consists of practical and theoretical questions. There are no programming questions
and no multiple choice questions.

You will be expected to know the definitions in the prescribed book, but you don't have to know them
verbatim: you should be able to recognise a term used in a question in order to answer that question
appropriately, or you may be asked to explain what a term means (in your own words).

You have to know the algorithms that are included in the syllabus. For example, we may give you a
problem and ask you to solve it using the A* algorithm. In such a question, we do not require you to
write down the algorithm, but rather to show all the stages during the execution of the algorithm. For
example, you may be asked to produce a search tree, or give the order in which nodes are visited (see
Question 4 below).

Review the assignment problems, our solutions and the study guide. You can expect a number of
questions in the examination that are similar to some of the assignment questions. We include an
example of a typical exam paper, in both English and Afrikaans. We do not include a memorandum,
nor will we provide one. However, we will gladly help you with specific problems you may have with
any question you have attempted.

Finally, a few remarks on writing the paper:

• Read the questions carefully. You will lose marks if you do not follow the instructions.
• Mark your answer clearly with the relevant question number. You may answer the questions in
any order.
• You can make rough notes anywhere but cross them out before you hand in your answer book,
so that it is clear what should be marked.
• Write legibly - we cannot give marks if we cannot decipher your handwriting.

Good luck with your preparations for the examination!

Prof. K Britz (429-6494)


Ms. C de Ridder (429-6777)
3 COS351-D/102

Example Examation Paper

Question 1 [20]

The Boolean function x1 + x2 . x3 in three variables is linearly separable, which means that it can be
implemented by a threshold logic unit.

a) What does the statement given above mean in terms of the space of input vectors of the TLU?(2)

b) Give the desired output for each of the following input vectors to a TLU implementing the
Boolean function given above.

<0, 1, 0>
<1, 0, 0>
<0, 0, 1>
<1, 1, 1> (2)

c) The weight change rule for the fixed increment error correction procedure is given by:

Wi+1 = Wi + c(di - fi) Xi.

Define all the variables used in this rule. (3)

d) Train a TLU to implement the given Boolean function, using the fixed increment error
correction procedure, and the training set given in (b) in the given order. Repeat until the TLU
is trained for the given training set. Use augmented weight and input vectors, a zero threshold, a
constant learning rate of 1, and set the initial weights to 0. (10)

e) Draw a picture of the TLU (not the input vector space!), showing the final weights and
threshold value. (3)

Question 2 [8]

Design a production system to control the security area of a bank, through which clients enter and leave
the bank. The security area consists of a cubicle with two doors, one on each side. Door A leads to the
bank, and door B to the outside. Each door has a call button on each side. To enter the bank, a client
presses the button on the outside of door B. When the door opens, the person can enter the security
area, and door B closes again. The client can then press the button to open door A. When door A opens,
the client can enter the bank, and the door closes behind him. More than one person may be in the
security area at the same time, but both doors may not be open at the same time.

The security system can sense which buttons have been pressed, and whether either door A or door B is
open. It is able to perform the following actions: Open either door A or door B; close either door A or
door B, and wait ∆ seconds - a fixed time sufficient for a client to enter or exit through an open door.

Your production system should give preference to clients inside the security area. Secondary to this
criterion, it should give preference to clients who want to leave the bank above those who want to enter
the bank.
4

Question 3 [10]

Consider the following variation of the missionaries and cannibals problem. Three friends, Tom, Dick
and Harry, want to cross a river. The only boat available can carry at most two passengers. The
problem is that Tom and Dick are not on friendly terms and can never be left alone in each other's
company. You have to find a way in which all three can safely cross the river.

a) Describe a suitable state representation and draw the entire state description graph. (You only
have to include the legal states.) (8)

b) Indicate the order in which the nodes will be visited during a breadth-first search. (2)

Question 4 [12]

In the Two Francs and Pounds puzzle there is a box with five cells. A cell may either be
empty, or it may be occupied by one coin. In the start state, the two leftmost cells are each occupied by
a one Franc coin (F), the two rightmost cells are each occupied by a one Pound coin (P) and the middle
cell is empty:

F F P P

We are required to interchange the locations of the Franc and Pound coins to reach the goal state:

P P F F

As a move in the puzzle, a Franc coin can either [1] hop to the right over one other coin into an empty
cell, or [2] slide to the right into an adjacent empty cell, and a Pound coin can either [3] slide to the left
into an adjacent empty cell or [4] hop to the left over one other coin into an empty cell. The cell from
which a coin slid or hopped becomes the new empty cell.

Let’s look at an example of a move. If we perform move [1] from state

F P F P

we end up with the state

P F F P

Consider the partial search graph (We only show the legal states):
5 COS351-D/102

a) Let ¡(n) be the number of coins not in their desired positions in the state represented by node n.
For example, in the initial state above, all four coins are not in their desired positions, and thus
¡(n)=4 for that node. Let g(n) be the depth of node n.

Perform the first number of steps of an A* search to find a solution path from the start state to a
goal state. Stop when a node with a depth of 4 has been selected for expansion. Do not add any
nodes to the given graph.

You have to indicate the order in which the nodes are expanded, showing the OPEN queue after
each step, as well as the g, ¡ and f^ values of every expanded node. Use the node numbers
provided in the picture. (8)

b) When is a heuristic function admissable? Why do we usually require an admissible heuristic for
an A* search? (4)
6

Question 5 [12]

Consider the game tree below. The numbers in parentheses at the leaf (tip) nodes are the static scores.
The first player wants to maximise his score.

Use the alpha-beta procedure to determine which move the first player should choose. Assume that
nodes are examined in left-to-right order. You have to show the order in which nodes are examined, the
backed-up values of nodes, and also which nodes need not be examined. Also indicate whether each
cut is an alpha cut or a beta cut.

Question 6 [8]

a) Prove by resolution refutation that r is a logical consequence of the set {¬q w r, ¬p wq, p}. Use
the set of support strategy. (5)

b) What does it mean to say a resolution strategy is refutation complete? Is the set of support
strategy refutation complete? (3)

Question 7 [12]

a) State the propositional satisfiability (PSAT) problem. (2)

b) In the Four-Queens Problem we try to place four queens on a 4x4 chess board so that none can
capture the other. That is, only one queen can be on any row, column, or diagonal of the board.
We say that a queen has been placed safely if she cannot be captured by any other queen
already placed. The start state is an empty 4x4 chess board, and the goal state is a 4x4 chess
board containing four queens that are all legally placed. Let qij represent the square in row i,
column j of the board. Let qij = true if there is a queen on square (i,j), else qij = false. Give a
propositional statement which states: "If a queen is placed in row 1, column 1, then she is safe". (4)

c) Outline how your answer to (b) can be used to obtain a statement which indicates whether all
7 COS351-D/102

four placed queens are safe. You do not have to write out your answer fully. (3)

d) Explain why PSAT can be viewed as a constraint satisfaction problem. (3)

Question 8 [5]

Convert the following predicate sentence to clause form:

(œx) P(x) e (›x) ((œz) Q(x,z) w (œz) R(x,y,z)).

Question 9 [13]

a) Write the following statements as predicate calculus sentences:

0 is even.
If x is even, then the successor of x is odd.
If x is odd, then the successor of x is even.

Use a unary function symbol succ(x) for the successor of x. (4)

b) Convert your answer to (a) above to a Prolog program. (3)

c) Show how a Prolog interpreter will prove that succ(succ(x)) is even. (3)

d) Discuss the search strategy Prolog uses to prove a goal clause. (3)
8

Voorbeeld Eksamenvraestel

Vraag 1 [20]

Die Boole funksie x1 + x2 . x3 in drie veranderlikes is lineêr skeibaar, wat beteken dat dit deur 'n logika-
drumpeleenheid (LDE) geïmplementeer kan word.

a) Wat beteken bostaande stelling in terme van die ruimte van toevoervektore van die LDE? (2)

b) Gee die gewensde afvoer vir elk van die volgende toevoervektore tot 'n LDE wat die bostaande
Bool funksie implementeer.

<0, 1, 0>
<1, 0, 0>
<0, 0, 1>
<1, 1, 1> (2)

c) Die gewigsveranderingsreël vir die vaste-inkrement foutregstellingsprosedure word gegee deur:

Wi+1 = Wi + c(di - fi) Xi.

Definieer al die veranderlikes wat in hierdie reël gebruik word. (3)

d) Lei 'n LDE op om die gegewe Bool funksie te implementeer. Gebruik die vaste-inkrement
foutregstellingsprosedure en die opleidingstel in (b), in die gegewe volgorde. Herhaal totdat die
LDE opgelei is vir die gegewe opleidingstel. Gebruik aangevulde gewigs- en toevoervektore, 'n
nul drumpelwaarde, 'n konstante leertempo van 1, en stel die aanvangsgewigte na 0. (10)

e) Teken 'n prentjie van die LDE (nie die toevoer-vektorruimte nie!). Wys die finale gewigte en
drumpelwaarde. (3)

Vraag 2 [8]

Ontwerp 'n produksiestelsel om die sekuriteitsarea van 'n bank, waardeur kliënte die bank binnekom en
verlaat, te beheer. Die sekuriteitsarea bestaan uit 'n hokkie met twee deure, een aan elke kant. Deur A
lei na die bank en deur B na buite. Elke deur het 'n roepknoppie aan elke kant. Om die bank binne te
gaan, druk die kliënt die knoppie aan die buitekant van deur B. Wanneer die deur oopgaan, kan die
persoon die sekuriteitsarea binnetree, en deur B maak weer toe. Die kliënt kan dan die knoppie druk
om deur A oop te maak. Wanneer deur A oopgaan, kan die kliënt die bank binnegaan, en die deur gaan
agter hom toe. Meer as een persoon mag terselfdertyd in die sekuriteitsarea wees, maar beide deure
mag nie terselfdertyd oop wees nie.

Die sekuriteitstelsel kan bepaal watter roepknoppies gedruk is, en of deur A of deur B oop is. Dit kan
die volgende aksies uitvoer: Maak deur A of deur B oop; maak deur A of deur B toe; en wag ∆
sekondes - 'n vaste tyd wat lank genoeg is vir 'n kliënt om deur 'n oop deur in te kom of uit te gaan.

Die produksiestelsel moet voorrang aan kliënte binne die sekuriteitsarea gee. Ondergeskik hieraan,
moet dit voorrang gee aan kliënte wat die bank wil verlaat bo diegene wat die bank wil binnegaan.
9 COS351-D/102

Vraag 3 [10]

Beskou die volgende variasie van die sendelinge-en-kannibale probleem. Drie vriende, Tom, Dick en
Harry, wil 'n rivier oorsteek. Die enigste beskikbare boot kan hoogstens twee pasassiers dra. Die
probleem is dat Tom en Dick nie op vriendskaplike terme is nie en nooit alleen in mekaar se geselskap
gelaat kan word nie. U moet 'n manier vind vir al drie om die rivier veilig oor te steek.

a) Beskryf 'n geskikte toestandsvoorstelling en teken die hele toestandsvoorstellingsgrafiek. (Sluit


slegs die wettige toestande in.) (8)

b) Dui die volgorde waarin die nodusse besoek sal word tydens 'n breedte-eerste soektog, aan. (2)

Vraag 4 [12]

In die Twee Franke en Ponde probleem is daar 'n doos met vyf selle. 'n Sel kan leeg wees, of daar kan
'n munt in wees. In die begintoestand, is daar 'n Frank munt (F) in die linkerkantste twee selle, 'n Pond
munt (P) in die regterkantste twee selle, en die middelste sel is leeg :

F F P P

Ons moet die posisies van die Frank en Pond munte omruil om die doeltoestand te bereik:

P P F F

Die volgende skuiwe word toegelaat: 'n Frank munt kan òf [1] na regs spring oor 'n ander munt tot in 'n
leë sel, òf [2] na regs gly tot in 'n aanliggende leë sel, en 'n Pond munt kan òf [3] na links gly tot in 'n
aanliggende leë sel òf [4] na links spring oor 'n ander munt tot in 'n leë sel. Die sel van waar 'n munt
gegly of gespring het, word die nuwe leë sel.

Kom ons kyk na 'n voorbeeld van 'n skuif. As ons skuif [1] uitvoer vanuit toestand:

F P F P

eindig ons in die toestand:

P F F P

Beskou die gedeeltelike soekgrafiek (ons wys slegs die wettige toestande):
10

a) Laat ¡(n) die aantal munte wees wat nie in hul gewensde posisies is in die toestand wat deur
nodus n voorgestel word nie. In die begintoestand hierbo, is geeneen van die vier munte
byvoorbeeld in hul gewensde posisies nie, dus ¡(n)=4 vir hierdie nodus. Laat g(n) die diepte
van nodus n wees.

Doen die eerste aantal stappe van 'n A* soektog om 'n oplossingspad vanaf die beginnodus tot
by 'n doelnodus te vind. Stop wanneer 'n nodus op diepte 4 gekies is vir uitbreiding. Moenie
enige nodusse by die gegewe grafiek voeg nie.

Toon die volgorde waarin nodusse uitgebrei word, aan. Gee ook die OOP tou na elke stap,
sowel as die g, ¡ en f^ waardes van elke uitgebreide nodus. Gebruik die nodusnommers wat in
die soekboom hierbo gegee word. (8)

b) Wanneer is 'n heuristieke funksie toelaatbaar? Waarom word 'n toelaatbare heuristiek
gewoonlik vir 'n A* soektog vereis? (4)
11 COS351-D/102

Vraag 5 [12]

Beskou die spelboom hieronder. Die nommers tussen hakies by die eindnodusse is die statiese tellings.
Die eerste speler wil sy telling maksimeer.

Gebruik die alpha-beta prosedure om vas te stel watter skuif die eerste speler moet kies. Aanvaar dat
nodusse van links na regs ondersoek word. Wys die volgorde waarin nodusse ondersoek word, die
teruggeskryfde waardes van nodusse, asook watter nodusse nie ondersoek hoef te word nie. Wys ook of
elke snit 'n alpha-snit of 'n beta-snit is.

Vraag 6 [8]

a) Bewys deur resolusie refutasie dat r 'n logiese gevolg is van die versameling {¬q w r, ¬p wq, p}.
Gebruik die ondersteuningsversameling strategie. (5)

b) Wat beteken dit om te sê 'n resolusie strategie is refutasie-volledig? Is die


ondersteuningsversameling strategie refutasie-volledig? (3)

Vraag 7 [12]

a) Stel die proposisionele bevredigbaarheidsprobleem (PSAT). (2)

b) Die doel van die Vier-Koninginne Probleem is om vier koninginne op 'n 4x4 skaakbord te plaas
sodat nie een 'n ander kan vang nie. Daar mag dus slegs een koningin in enige ry, kolom of
diagonaal van die bord wees. Ons sê dat 'n koningin veilig geplaas is as sy nie deur enige ander
koningin wat alreeds geplaas is, gevang kan word nie. Die begintoestand is 'n leë 4x4
skaakbord, en die doeltoestand is 'n 4x4 skaakbord wat vier koninginne bevat wat almal veilig
geplaas is. Laat qij die vierkant in ry i, kolom j van die bord aandui. Laat qij = waar wees as daar
'n koningin op vierkant (i,j) is, anders is qij = vals. Gee 'n proposisionele stelling wat stel dat:
"Indien 'n koningin in ry 1, kolom 1 geplaas is, dan is sy veilig". (4)
12

c) Skets hoe u antwoord op (b) gebruik kan word om 'n stelling te verkry wat aandui of al vier die
koninginne wat geplaas is, veilig is. U hoef nie die antwoord volledig uit te skryf nie. (3)

d) Verduidelik waarom PSAT as 'n beperkingsbevredigingsprobleem beskou kan word. (3)

Vraag 8 [5]

Skakel die volgende predikaatsin om na klousule vorm:

(œx) P(x) e (›x) ((œz) Q(x,z) w (œz) R(x,y,z)).

Vraag 9 [13]

a) Skryf die volgende stellings as sinne in predikaatkalkulus:

0 is ewe.
As x ewe is, dan is die opvolger van x onewe.
As x onewe is, dan is die opvolger van x ewe.

Gebruik 'n unêre funksiesimbool succ(x) vir die opvolger van x. (4)

b) Skakel u antwoord op (a) hierbo om na 'n Prolog-program. (3)

c) Wys hoe 'n Prolog-interpreteerder sal bewys dat succ(succ(x)) ewe is. (3)

d) Bespreek die soekstrategie wat Prolog gebruik om 'n doelklousule te bewys. (3)

You might also like