Enrico Pontelli wrote:
> Well, but the fact that standard Prolog's unification does not terminate
> always depends only from the fact that it relaxes the occur check.
> Furthermore I am not so convinced that Prolog's unification is more
> efficient than a properly implemented Martelli-Montanari (which, again is
> a quasi-linear algorithm) or Paterson-Wegman algorithm.
(I am certain that you are aware of this, but for the rest of the world...)
Note that occur check is not necessary for termination, if the domain
is rational trees rather than terms. For example, in Huet's algorithm,
the occur check is a separate final step, which can be omitted.
Prolog's unification does not do occur check, nor does it keep track of
equivalences the way Huet's algorithm does.
It would be very hard to beat Prolog's unification procedure for actual
Prolog unifications. However, Huet's algorithm should at least be able to
get within a factor of two, although with a slight increase in space
requirement. I seriously doubt that Paterson-Wegman's algorithm could
come anyway near that in a serious logic programming system where several
unifications follow each other and where there is backtracking.
Note 1: There was a nice comparison of linear unification algorithms
(such as Paterson-Wegman and the hard-to-get Martelli & Montanari
algorithm [not the TOPLAS one]) and almost-linear algorithms
(such as Huet's and a slightly modified Martelli & Montanari
algorithm [the TOPLAS version]) from both theoretical and
practical points of view by N. V. Murray in his Ph.D. thesis (1979).
Note 2: What I call Huet's algorithm was also invented independently by
J. A. Robinson and (almost) by L. D. Baxter (all in 1976).
--
Jonas Barklund, Ph.D., lecturer, Uppsala University, Computing Science Dept.
Email jonas@csd.uu.se, phone +46-18-181050, fax +46-18-521270
|