1% CILog code for the electrical environment.
    2% This is the code discussed in Section 3.2 of Computational Intelligence.
    3% Copyright (c) Poole, Mackworth and Goebel and Oxford University Press, 1998
    4
    5% lit(L) is true if light L is lit.
    6lit(L) <-
    7   light(L) &
    8   ok(L) &
    9   live(L).
   10
   11% live(W) is true if W is live (i.e., current will flow through it if grounded)
   12live(W) <-
   13   connected_to(W,W1) &
   14   live(W1).
   15
   16live(outside).
   17
   18% connected_to(W0,W1) is true if W0 is connnected to W1 such that current will
   19% flow from W1 to W0.
   20
   21connected_to(l1,w0).
   22connected_to(w0,w1) <- up(s2).
   23connected_to(w0,w2) <- down(s2).
   24connected_to(w1,w3) <- up(s1).
   25connected_to(w2,w3) <- down(s1).
   26connected_to(l2,w4).
   27connected_to(w4,w3) <- up(s3).
   28connected_to(p1,w3).
   29connected_to(w3,w5) <- ok(cb1).
   30connected_to(p2,w6).
   31connected_to(w6,w5) <- ok(cb2).
   32connected_to(w5,outside).
   33
   34% light(L) is true if L is a light
   35light(l1).
   36light(l2).
   37
   38% up(S) is true if switch S is up
   39% down(S) is true if switch S is down
   40
   41up(s2).
   42down(s1).
   43up(s3).
   44
   45% ok(X) is true if circuit breaker or light X is working (not blown)
   46ok(l1).
   47ok(l2).
   48ok(cb1).
   49ok(cb2).
   50
   51% EXAMPLE QUERIES
   52% ask up(X).
   53% ask connected_to(w0,W).
   54% ask connected_to(w1,W).
   55% ask connected_to(Y,w3).
   56% ask lit(L).
   57% ask live(L).