expert1	- production rule translation prior to compiling

Files in this directory:

rules2nl.ptn   - ptn code to translate if - then rules into Prolog 
rules_gr.gr    - the grammar rules required 
bc.nl          - simple backward chaining interpreter (Bratko)
fc.nl	       - simple forward chaining interpreter  (Bratko)
forward.ptn    - ptn code for forward chaining
rules2nl2.ptn  - also for forward chaining
house.rule     - a test sample of if - then rules     (Bratko)
 
To run
------

% ../../ptn			% load ptn

Nu-Prolog 1.6.4
1?- ptn2nl(rules2nl).		% translate the ptn code into Prolog
true.				% this takes a few seconds
				% required ONCE only
2?- gr2nl(rules_gr).		% translate grammar rules
true.				% required ONCE only

3?- consult(rules_gr).		% consult the grammar rules
Consulting rules_gr.nl
Warning: descendent/2 redefined	% ignore warning
true.

4?- consult(rules2nl).		% consult the rules => Prolog translator 
Consulting rules2nl.nl
true.

5?- rules2nl(house).		% translate the rules in house.rule
true.				% into Prolog clauses and write them to
				% house.nl

6?- consult(house).		% consult the house clauses and facts
Consulting house.nl
true.

7?- leak_in_kitchen.		% query the "rules" directly - no
true.				% interpreter required.


		%Inspect the files house.rule and house.nl

Forward chaining example 	% assuming the above has been run
------------------------

% ../../ptn			% load ptn
Nu-Prolog 1.6.4
1?- ptn2nl(forward).            % translate the ptn code into Prolog
true.                           % this takes a few seconds
                                % required ONCE only

3?- consult(rules_gr).          % consult the grammar rules
Consulting rules_gr.nl
Warning: descendent/2 redefined % ignore warning
true.

4?- consult(house).             % consult the house clauses and facts
Consulting house.nl
true.

5?- consult(forward).           % consult the rules => Prolog translator
Consulting rules2nl.nl		% for forward chaining
true.

6?- forward(house).	        % create list of rules for forward chaining
Undefined predicate: kitchen_dry/0 	% ignore.....
Derived: leak_in_kitchen	% and fire rules in list
Derived: no_water_from_outside	% asserting new facts
Derived: problem_in_kitchen


Some Explanation
----------------

This is an example of translating a SIMPLE set of production rules 
into their equivalent Prolog clauses.

Work is still in progress on a much bigger and more meaningful
example - including frames, and more complex conditions etc.

There is a simple (Bratko Chapter 14) interpreter for backward and
forward chaining. (bc.nl and fc.nl)

Using the "conventional" interpreter
------------------------------------
A backward chaining interpreter is in bc.nl together with a few
simple rules. You will notice that 'if', 'then', 'or', and 'and' have
been renamed 'if1', 'then1' etc. This is because NU-Prolog has these
operators already built-in with different precedences.
Other Prolog's (such as Arity) have an "expert system shell" already
supplied.

To run
------

% np

NU-Prolog 1.6.4
1?- consult(bc).
Consulting bc.nl.
done
true.
2?- is_true(leak_in_kitchen).
true.

similarly for forward chaining, in fc.nl


{Liz Haywood May 1994}
