home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / EXAMPLES.ARC / CH05EX05.PRO < prev    next >
Encoding:
Prolog Source  |  1988-06-21  |  644 b   |  35 lines

  1. /*
  2.    Turbo Prolog 2.0 Chapter 5, Example Program 5
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. predicates
  9.    type(symbol, symbol)
  10.    is_a(symbol, symbol)
  11.    lives(symbol, symbol)
  12.    can_swim(symbol)
  13.  
  14. goal
  15.    can_swim(What) ,
  16.    write("A ", What, " can swim.").
  17.  
  18. clauses
  19.    type(ungulate, animal).
  20.    type(fish, animal).
  21.  
  22.    is_a(zebra, ungulate).
  23.    is_a(herring, fish).
  24.    is_a(shark, fish).
  25.  
  26.    lives(zebra, on_land).
  27.    lives(frog, on_land).
  28.    lives(frog, in_water).
  29.    lives(shark, in_water).
  30.  
  31.    can_swim(Y) :- 
  32.     type(X, animal) ,
  33.     is_a(Y, X) ,
  34.     lives(Y, in_water). 
  35.