users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gprolog top-level (was re: Questions about Answers)


From: Daniel Diaz
Subject: gprolog top-level (was re: Questions about Answers)
Date: Mon, 22 Oct 2001 11:46:00 +0200

Hi,

let me explain the gprolog top-level features (and the difference with other 
top-levels: SICStus/Yap
and SWI):


1) gprolog tries to detect when no alternative for a query remains and then 
does not propose another
solution.
(see http://gnu-prolog.inria.fr/manual/manual005.html#toc2)

gprolog:
| ?- X=1 ; X=2 ; X=3.

X = 1 ? ;

X = 2 ? ;

X = 3

yes

while with others (SICStus/Yap/SWI):

| ?- X=1 ; X=2 ; X=3.

X = 1 ? ;

X = 2 ? ;

X = 3 ? ;

no

NB: in the Jeff's example, thanks to indexing on the 1st argument gprolog 
detects X=5 is the last
solution for the query adjacent(1,X) while for adjacent(X,1) all clauses have 
to been tried. But the
query adjacent(2,X) behaves like adjacent(X,2) since the fact adjacent(3,2) is 
the last.



2) gprolog tries to display the solution (substitution) in a pretty form 
(avoiding to display
addresses for unbound variables):

gprolog:
| ?- functor(T,f,3).

T = f(_,_,_)

yes


SICStus/Yap:
| ?- functor(T,f,3).

T = f(_A,_B,_C) ? 

yes


SWI:
?- functor(T,f,3).

T = f(_G279, _G280, _G281) ?

Yes



3) as for other systems optimizing the output (e.g. SICStus/Yap) when no 
variable is displayed and
before interacting with the user (displaying a ? and waiting for a command), 
gprolog displays a
'true' to indicate a success):

gprolog
| ?- X=X ; Y=Y.

true ? ;

yes

SICStus/Yap:
| ?- X=X ; Y=Y.

true ? ;

true ? ;

no



4) gprolog interacts with the user for any query until the last solution 
(proof) is found (so 'true'
will be displayed at each intermediate solution found). Most other systems only 
show the first proof
for a query without any variable (and no propose the interaction).


gprolog:

| ?- write(a); write(b).
a

true ? 
b

yes


SICStus/YAP/SWI:
?- write(a) ; write(b).
a
yes


See you

-- 
Daniel Diaz   address@hidden
http://pauillac.inria.fr/~diaz
gprolog --version 2>&1 | sed -n -e 's/By //p'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]