procedure trynextmove (xyiintegervar donebooleanthe function-procedure canbedone expresses the predicate tour can be completed from this move and is used within trynextmove in the linear search over possible move destinations determined according to the jump pattern of knights introduce two local variables and to stand for the coordinates of the move destinations examined by the linear search loop the function canbedone must know uv it is also efficient to pass to canbedone the number of this new movewhich is known to be + then the signature of canbedone can be chosen as followsprocedure canbedone (uvi integer)boolean certainly board not full in trynextmove can be expressed as also introduce logical variable eos to signal the condition no more candidates then the algorithm is refined as followsprocedure trynextmove (xyiintegervar doneboolean)var eosbooleanuvintegerbegin if then initialize selection of candidates for the next move and select first one uvwhile ~eos ~canbedone(uvi+ do select next candidate uv enddone :~eos else done :true end end trynextmoveprocedure canbedone (uvi integer)booleanvar donebooleanbegin record movetrynextmove(uvi done)if ~done then erase move endreturn done end canbedone an obvious next step is to represent the board by matrixsay let us also introduce type to denote index valuesvar harray nn of integer the decision to represent each field of the board by an integer instead of boolean value denoting occupation allows to record the history of successive board occupations in the simplest fashion the following convention is an obvious choiceh[xy [xyifield xy has not been visited field xy has been visited in the -th move ( < which statements can now be refined on the basis of these decisionswe can actually complete the refinement of the function-procedure canbedonethe operation of recording the legal move is expressed by the assignment hxy :iand the cancellation of this recording as hxy : alsowe can now express the enumeration of the allowed moves uv from the position xy in the