home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / pdprolog / provit.pro < prev    next >
Text File  |  1986-05-05  |  2KB  |  46 lines

  1. /* A ProLog program to handle syllogisms of the type
  2.                        All X are Y
  3.                        Z is X
  4.           Therefore -  Z is Y
  5.  
  6.    Tom Sullivan - 5415 Grand Ave. Western Springs, IL 60558
  7.                      November, 1985
  8.    Type go.<CR> to run the program.  Enjoy.
  9. */
  10.  
  11. go :- nl,nl,nl,nl,nl,nl,nl,nl,nl,
  12.       nl,nl,nl,nl,nl,nl,nl,nl,nl,
  13.       print ('                     <<<<<   Theorem Prover   >>>>>'),
  14.       nl,nl,
  15.       print ('         Enter the name of a Greek,animal,plant,fish,insect,or bird.'),
  16.       go1.
  17.  
  18. go1 :- nl,nl,nl,nl,nl,print ('Name  >> '),
  19.        read (N),
  20.        onlist (N),!.  /* see Clocksin & Mellish pp. 88-90  for use of cut */
  21.  
  22. listof (men,    ([socrates,plato,aristotle,homer])).
  23. listof (animals,([dog,cat,horse,cow,pig,bear,lion])).
  24. listof (plants, ([rose,petunia,daisy,oak,elm,corn])).
  25. listof (fish,   ([waleye,pike,muski,bass,trout])).
  26. listof (insects,([ant,beetle,spider,fly,mantis])).
  27. listof (birds,  ([wren,robin,heron,eagle,hawk,crow])).
  28.  
  29. mortals ([men,animals,plants,fish,insects,birds]).
  30.  
  31. member (X,[X|_]).
  32. member (X,[_|Y]) :- member (X,Y).      /* see C&M p.53  */
  33.  
  34. onlist (N) :- listof (Y,(Z)), member (N,Z),
  35.               nl,nl,print ('Searching ... ',Y),
  36.               nl,nl,print ('        1. ',N,' is in ',Y,'  ... and '),
  37.               mortal (Y,N);stop.
  38.  
  39. mortal (Y,N) :- mortals (Z), member (Y,Z),
  40.                 nl,nl,print ('Searching .... mortals'),
  41.                 nl,nl,print ('        2. ',Y,' are mortal.'),
  42.                 nl,nl,print ('        Therefore ',N,' is mortal.'), go1.
  43.  
  44. stop :- nl,print ('   That\'s not in the data!'),
  45.         nl,nl,print ('                           Type <go.> for more.').
  46.