1% Computational Intelligence: a logical approach. Example 2.28.
    2% CILOG Code. Copyright 1998, Poole, Mackworth, Goebel and OUP.
    3
    4% am(H,M) where H is an integer in [1,12] and M is integer in range [0,59]
    5% denotes the function H:M am.
    6% For example am(5,33) denotes 5:33am. am(12,30) denotes half-past midnight.
    7% am(11,59) denotes the time one minute before noon.
    8
    9% pm(H,M) denotes the time H:M after noon.
   10
   11% Note that midnight is am(12,00) and noon is pm(12,00).
   12
   13% before(T1,T2) is true if time T1 is before time T2 in the same day.
   14before(am(H1,M1),pm(H2,M2)).
   15before(am(12,M1),am(H2,M2)) <-
   16   H2<12.
   17before(am(H1,M1),am(H2,M2)) <-
   18   H1<H2 &
   19   H2<12.
   20before(am(H,M1),am(H,M2)) <-
   21   M1<M2.
   22before(pm(12,M1),pm(H2,M2)) <-
   23   H2<12.
   24before(pm(H1,M1),pm(H2,M2)) <-
   25   H1<H2 &
   26   H2<12.
   27before(pm(H,M1),pm(H,M2)) <-
   28   M1<M2.
   29
   30% EXAMPLE QUERIES
   31% ask before(am(10,15),pm(3,22)).
   32% ask before(am(10,15),am(3,22)).
   33% ask before(am(10,15),am(10,22)).
   34% ask before(am(10,15),am(11,02)).