home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TESTS / LF / T3206.LF < prev    next >
Text File  |  1996-06-04  |  879b  |  43 lines

  1. %
  2. %        WILD-LIFE TESTING
  3. %
  4. %        How predicate is input
  5. %
  6. %    mix of assert and retract
  7. %
  8. % def_predicate(X): creates a predicate with no definition; if the predicate
  9. % has already been defined, it doesn't change its definition.
  10. %
  11. def_predicate(X) :-
  12.     Y=root_sort(X),
  13.     asserta(Y), retract(Y), !.
  14. % def_predicate(X) :- asserta(root_sort(X)),retract(root_sort(X)),!.
  15. %
  16. %    Non-monotonic reasonning
  17. %
  18. % If someone has been decorated, then he is a hero. But, if someday he becomes
  19. % a reckless driver, then he may no longer be considered as a hero.
  20. %
  21. % initial database
  22. %
  23. dynamic(decorated)?
  24. dynamic(roadhog)?
  25. decorated(riri).
  26. decorated(fifi).
  27. roadhog(fifi).
  28. roadhog(loulou).
  29. %
  30. % program
  31. %
  32. mod_db(X):-hero1(X),!.
  33. mod_db(X):-assert(hero1(X)).
  34.  
  35. new_db(X):- decorated(X),mod_db(X),fail.
  36. new_db(X):- roadhog(X),retract(hero1(X)).
  37. new_db(X).
  38.  
  39. hero(X):-new_db(X),hero1(X).
  40.  
  41. def_predicate(`hero1)?
  42.  
  43.