1% Computational Intelligence: a logical approach.
    2% CILOG Code. Figure 2.3 & Example 2.13.
    3% Copyright (c) 1998, Poole, Mackworth, Goebel and Oxford University Press
    4
    5% imm_west(R1,R2) is true if room R1 is immediately west of room R2
    6:- 
    7
    8imm_west(r101,r103).    9imm_west(r103,r105).
   10imm_west(r105,r107).
   11imm_west(r107,r109).
   12imm_west(r109,r111).
   13imm_west(r131,r129).
   14imm_west(r129,r127).
   15imm_west(r127,r125).
   16
   17% imm_east(R1,R2) is true if room R1 is immediately east of room R2
   18
   19imm_east(R1,R2) <- 
   20   imm_west(R2,R1).
   21
   22% next_door(R1,R2) is true if room R1 is next door to room R2
   23
   24next_door(R1,R2) <-
   25   imm_east(R1,R2).
   26next_door(R1,R2) <-
   27   imm_west(R1,R2).
   28
   29% two_doors_east(R1,R2) is true if room R1 is two doors east of room R2
   30
   31two_doors_east(R1,R2) <-
   32   imm_east(R1,R) &
   33   imm_east(R,R2).
   34
   35% west(R1,R2) is true if room R1 is somewhere west of room R2
   36
   37west(R1,R2) <-
   38   imm_west(R1,R2).
   39west(R1,R2) <-
   40   imm_west(R1,R) &
   41   west(R,R2).
   42
   43% POSSIBLE QUERIES
   44% ask next_door(R,r105).
   45% ask west(R,r105).
   46% ask west(r105,R).
   47% ask next_door(X,Y).