% The meaning of the time predicate is self-evident. As for the disk % predicate, there are k disks 1,2,...,k. Disks 1, 2, 3, 4 denote pegs. % Disks 5, ... are "movable". The larger the number of the disk, % the "smaller" it is. % % The program uses additional predicates: % on(T,N,M), which is true iff at time T, disk M is on disk N % move(t,N), which is true iff at time T, it is disk N that will be % moved % where(T,N), which is true iff at time T, the disk to be moved is moved % on top of the disk N. % goal, which is true iff the goal state is reached at time t % steps(T), which is the number of time steps T, required to reach the goal (provided part of Input data) % Read in data on(0,N1,N) :- on0(N,N1). onG(K,N1,N) :- ongoal(N,N1), steps(K). % Specify valid arrangements of disks % Basic condition. Smaller disks are on larger ones :- time(T), on(T,N1,N), N1>=N. % Specify a valid move (only for T