From HiLog to Prolog

Before we briefly explain the encoding of HiLog terms, let us note that the HiLog syntax is a simple (but notationally very convenient) encoding for Prolog terms, of some special form. In the same way that in Prolog:

The encoding of HiLog terms is performed based upon the existing declarations
of * hilog symbols*. These declarations (see section 3.8.4),
determine whether an atom that appears in a functor position of an external
representation of a HiLog term, denotes a functor or the first argument of a
set of special functors ` apply`. The actual encoding is as follows:

- The encoding of any variable or parameter symbol (atom or number) that does not appear in a functor position is the variable or the symbol itself.
- The encoding of any compound term
`t`where the functor*f*is an atom that is not one of the hilog symbols (as a result of a previous`hilog`declaration), is the compound term that has*f*as functor and has as arguments the encoding of the arguments of term*t*. Note that the arity of the compound term that results from the encoding of*t*is the same as that of*t*. - The encoding of any compound term
`t`where the functor*f*is either not an atom, or is an atom that is a hilog symbol, is a compound term that has`apply`as functor, has first argument the encoding of*f*and the rest of its arguments are obtained by encoding of the arguments of term*t*. Note that in this case the arity of the compound term that results from the encoding of*t*is one more than the arity of*t*.

Note that the encoding of HiLog terms described above, implies that even though the HiLog terms:

p(a, b) h(a, b) |

p(a, b) apply(h, a, b) |

We end this short discussion on the encoding of HiLog terms with a small example that illustrates the way the encoding described above is being done. Assuming that the following declarations of parameter symbols have taken place,

:- hilog h. :- hilog (hilog). |

foo(bar) prolog(a,X) apply(hilog,X) apply(123,john,500) apply(X,kostis,sofia) apply(X,Y,Z,apply(Y,W)) f(a,apply(b(c),d)) apply(map(double),[],[]) apply(apply(h,apply(map(P),A,B)),C) |