% Towers of Hanoi

% This version treats disks like blocks in
% the block world

% There are three pegs, and n disks
% which are stacked onto the pegs

% The disks are all of different sizes
% A disk may only have smaller disks on top
% of it

include "../library-ontology"
include "../library"

sorts
  Disk;

inclusions
  Disk << Thing;

module TOWERS_OF_HANOI;

  % This module captures info about moving the disks
  % onto pegs
  import MOUNT;

  objects
    Peg(1..3):  Supporter;
    D(1..3) : Disk;

  variables
     d1, d2   : Disk;
     s        : Supporter;
     i,j      : 1..3;

  import TIME;

  axioms
    % Two disks cannot be directly on top of the same supporter
    constraint Support(d1)=Support(d2) -> d1=d2;

    % We can only move disks which are clear (not under others)
    nonexecutable Mount(d1,s) if Support(d2)=d1;

    % A disk cannot be moved onto a disk being moved also
    nonexecutable Mount(d1,d2) & Mount(d2,s);

    % A disk can only have a smaller disk on top of it
    constraint Support(D(i))=D(j) -> i < j;
