interm	-  using PTN to translate a program written using "interms" into
------		Prolog

Files in this directory:

interm.nl     - code to translate a ".int" file into a ".nl" file
interm_gr.gr  - the grammar rules
test.int      - a sample program for testing also contains demo/0


To Run
------

% ../../ptn				% load ptn

NU-Prolog 1.6.4
1?- gr2nl(interm_gr).			% translate grammar rules
true.					% create ".nl" file - once only

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

3?- consult(interm).			% consult interm translator
Consulting interm.nl.
true.

4?- interm(test).			% perform translation on file test.int
true.					% new file test.nl created

5?- consult(test).			% consult the newly created file
Consulting test.nl
true.

6?- demo.				% run the demo
 This demonstrates the use of interming

1: Accessing fact1{three:3, two:2, one:1}. with arguments
   out of order
   Call is to fact1{ one:X, two:Y, three:Z}.

  X = 1  Y = 2  Z = 3

2: Some backtracking 
   The call is to:
                car{ model:A, rego:B}
                write( A), write(B),
                nl, fail.

corolla  abc_123
thousand  xyz_789
fail.
7?-

			% Inspect the file test.nl 
Some Explanation
----------------

Interming is taken from a paper: 
"Interming: Unifying Keyword and Positional Notations"
Susan Hirsh, et al.  Xerox Parc  Feb 1987

The idea is to represent terms whose arguments are specified by their
position in the term with a different structure where the
order and arity is not required.

Keyword terms are terms in which a value can be specified by pairing 
it with an attribute name

an example might be:

car{ rego:abc_123, make:toyota, model:corolla, colour:white, owner:john}.

and when accessing the car fact, the order of the terms isn't important:

find_owner( Rego, Owner) :-
	car{ rego:Rego, owner:Owner}.



An interm is either a fact (as above) in which case it is translated into
a similarly named fact/1, whose sole argument is a list of terms representing
the Name:Value pairs of the interm.
The above car interm is translated into:

car( [rego(abc_123), make(toyota), model(corolla), colour(white), owner(john)]).

If an interm is used as part of a query (and only allowed in the body
of a clause), it will be translated into a lookup/2 goal.

for example:

find_owner( Rego, Owner) :-
	car{ rego:Rego, owner:Owner}.

will translate into:

find_owner( Rego, Owner) :-
	lookup( car, [rego(Rego), owner(Owner)]).

lookup/2 is defined in the interm.nl file

{Liz Haywood May 1994}

