Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Riddle: Best Kept Secrets in Prolog Nr. 7

25 views
Skip to first unread message

burs...@gmail.com

unread,
Sep 13, 2017, 6:40:08 AM9/13/17
to
Q: Can a Prolog system work, where unification happens only in the head?

A: Yes, although (=)/2 is usually a built-in, it can be defined as a fact:

X = X.

a fact is a degenerated head of a clause head :- true.

burs...@gmail.com

unread,
Sep 13, 2017, 6:40:40 AM9/13/17
to
Further many built-ins, except for meta built-ins such
as var/1 can be viewed as facts, possibly an infinite
set of such facts. For example

functor/3 can be viewed as facts:

functor(f(_,_,_), f, 3).
etc..

But not all built-ins then generate all infinite solutions.
Although SWI-Prolog does stuff that for example
GNU-Prolog cannot do. See here:

GNU-Prolog:

GNU Prolog 1.4.4 (64 bits)
Compiled Apr 23 2013, 16:05:07 with cl

?- arg(I, f(a,b,c), A).
uncaught exception: error(instantiation_error,arg/3)

SWI-Prolog:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.5.13)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- arg(I, f(a,b,c), A).
I = 1,
A = a ;
I = 2,
A = b ;
I = 3,
A = c.

A nice little extension, if I am not totally wrong, not found in
the ISO core standard.
0 new messages