home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / ai.prl / mike1.exe / BROWSE.PL next >
Encoding:
Text File  |  1990-09-07  |  3.7 KB  |  92 lines

  1. /* file: BROWSE.PL {hierarchical frame browsing utility} */
  2. /*                          *************
  3.                                M I K E
  4.                             *************
  5.                Micro Interpreter for Knowledge Engineering
  6.                   {written in Edinburgh-syntax Prolog}
  7.  
  8. MIKE: Copyright (c) 1989, 1990 The Open University (U.K.)
  9.  
  10. MIKE is intended for educational purposes, and may not
  11. be sold as or incorporated in a commercial product without
  12. written permission from: The Copyrights Officer, Open University,
  13. Milton Keynes MK7 6AA, U.K.
  14.  
  15. The Open University accepts no responsibility for any legal or other
  16. consequences which may arise directly or indirectly as a result of the
  17. use of all or parts of the contents of this program.
  18.  
  19. This software accompanies Open University Study Pack PD624, 'KNOWLEDGE
  20. ENGINEERING'.  Complete sets of study pack materials may be obtained from:
  21.  
  22.                       Learning Materials Sales Office
  23.                       The Open University
  24.                       P.O. Box 188
  25.                       Milton Keynes MK7 6DH, U.K.
  26.  
  27.                       Tel: [+44] (908) 653338
  28.                       Fax: [+44] (908) 653744
  29. */
  30. /*
  31. A hierarchical frame browsing utility, that shows graphically your frame
  32. hierarchy.  It is more fully documented in the accompanying READ.ME file */
  33.  
  34. browse :-   /* PATCH 19 JAN: Z^ & Z1^ critical (_ nogood in some Prologs) */
  35.  'pd624 setof1'(X, Y^Z^(Y subclass_of X, not(X subclass_of Z)), RootNodes1),
  36.  'pd624 setof1'(X1, Y1^Z1^(Y1 instance_of X1,         /* PATCH 16 JAN '90 */
  37.                         not(X1 subclass_of Z1),
  38.                         not('pd624 member'(X1,RootNodes1))
  39.                        ),
  40.                RootNodes2),
  41. /*  findall(Obj, Obj instance_of 'Newly Created Object', Loners), */
  42.   append(RootNodes1,RootNodes2,RootNodes),
  43. /*  append(Loners, RootNodes, AllRootNodes), */
  44.   treewrite(RootNodes, 0).    /* PATCH 20 JAN '90: 2nd setof finds NCO */
  45.  
  46. browse(N) :-
  47.   treewrite([N], 0).
  48.  
  49. treewrite([], _).
  50. treewrite([X|Xs], Indentation) :-
  51.    nl, tab(Indentation), write(X),
  52.    get_children(X, Kids),
  53.    NewIndent is Indentation + 2,
  54.    treewrite(Kids, NewIndent),
  55.    treewrite(Xs, Indentation).
  56.  
  57. get_children(Node, Kids) :-
  58.         findall(X, X subclass_of Node, Group1),
  59.         findall(Y, Y instance_of Node, Group2),
  60.         append(Group1, Group2, Kids).
  61.  
  62. 'pd624 setof1'(Var, Goals, Ans) :-  /* PATCH 16 JAN 90 */
  63.          setof(Var, Goals, Ans),
  64.          !.
  65. 'pd624 setof1'(_,_,[]).
  66.  
  67. /* KB LOADING UTILITY */
  68. /* New with version 1.3 */
  69.  
  70. 'banner line' :-
  71.   nl,
  72.   write('------------------------------------------------------------------'),
  73.   nl.
  74.  
  75. kb X :-  /* load new knowledge base and print out summary information */
  76.     initialise,       /* clear up working memory and various flags */
  77.     fc_reset_history, /* clear up forward-chaining history storage */
  78.     abolish(rule,1),  /* get rid of any current rules */
  79.     abolish(with, 2), /* get rid of any current frames */
  80.     reconsult(X),     /* if file/pathname is wrong, reconsult complains */
  81.     /* the above line overwrites old frames and rules, but the preceding
  82.        calls of 'abolish' are necessary in case the new file happens
  83.        not to have one or the other (i.e. frames or rules) within it */
  84.     write('New knowledge base loaded.'),'banner line',
  85.     write('Currently loaded frames (?- describe <frame>. for details):'),
  86.     nl,browse,'banner line',
  87.     show(rules),'banner line',
  88.     current_conflict_resolution_strategy(Strategy),
  89.     write('The current conflict resolution priority list (in order) is:'),nl,
  90.     write('     '), write(Strategy), 'banner line',
  91.     show(wm), 'banner line'.
  92.