Up
Go up to 2 Adding to the Electrical Domain

Solution to Overhead Projector Problem.

This code is available as ohp.pl.
% heating(K) is true if kettle K is heating
heating(K) <-
   plugged_into(K,P) &
   live(P) &
   turned_on(K) &
   filled_with_water(K).

% kettle(K) is true if K is a kettle
kettle(k1).
kettle(k2).
kettle(k3).

% plugged_into(K,P) is true if K is plugged into power outlet P
plugged_into(k1,p1).
plugged_into(k2,p2).

% turned_on(K) is true if K is turned on
turned_on(k1).
turned_on(k3).

% filled_with_water(K) is true if K is filled with water
filled_with_water(k1).
filled_with_water(k2).
filled_with_water(k2).
Here is a trace of this program:
     CILOG Version 0.12. Copyright 1998, David Poole.
     CILOG comes with absolutely no warranty.
     All inputs end with a period. Type "help." for help.
     cilog: load 'elect.pl'.
     CILOG theory elect.pl loaded.
     cilog: load 'ohp.pl'.
     CILOG theory ohp.pl loaded.
     cilog: ask ohp_lit(OHP).
     Answer: ohp_lit(ohp1).
       [ok,more,how,help]: more.
     Answer: ohp_lit(ohp2).
       [ok,more,how,help]: more.
     No more answers.
     cilog: ask could_see_transparency(OHP).
     Answer: could_see_transparency(ohp1).
       [ok,more,how,help]: more.
     No more answers.
     cilog: ask can_see(Tran).
     Answer: can_see(lect2_3).
       [ok,more,how,help]: more.
     No more answers.
     cilog: 

Computational Intelligence online material, ©David Poole, Alan Mackworth and Randy Goebel, 1999

Up