Re: yes with disjunction

From: Kish Shen <ks15_at_icparc.ic.ac.uk>
Date: Fri 13 Jun 2003 02:07:51 PM GMT
Message-Id: <E19QpDb-0003RH-00@tempest.icparc.ic.ac.uk>
I guess no body has answered your question yet....

>Can you tell me if the following is a bug or normal ECLiPSe
>behaviour 

Short answer: it is normal ECLiPSe behaviour.

>  [eclipse 2]: male(timmy).
>  More (0.00s cpu) ?           % *** no 'yes' is given ***

I think there is two issues here: 1) the meaning of `More'; 2) Why does
ECLiPSe offer you a choice here.

1. `More' is the equivalent to SICStus giving you a choice after returning
an answer to your query, e.g. (in SICStus):

| ?- male(X).
X = timmy ? ;
X = reg ? ;
no

and in ECLiPSe:
[eclipse 2]: male(X).
X = timmy
More (0.00s cpu) ? ;
X = reg
Yes (0.00s cpu)

`More' means `yes, here is an answer, but there may be more answers'. 

With male(timmy), this is exactly what ECLiPSe is reporting, as the
alternative in the disjunction is not yet explored.

2. ECLiPSe offers you a choice here, while SICStus does not, is because
SICStus (and most other Prolog systems) implicitly performs a cut after
the first answer if the query was ground (it had no variables), and no
further answers are returned. You can see this with SICStus if we modify 
the male/1 predicate by adding a dummy argument:

male(X, dummy) :-  boy( X) ; man( X).
  boy( timmy).
  man( reg).

| ?- male(timmy, Y).
Y = dummy ? ;
no

This cut is only applied at the top-level query, so (in SICStus):

| ?- [user].
% consulting user...
| try(X) :-
     X = timmy,
     male(X).
...
| ?- try(X).
X = timmy ? ;
no

this has always seems strange to me. Also, if your query can have multiple
answers even when ground, this would not be reported by SICStus, e.g.

 a :- write(1).
 a :- write(2).

| ?- a.
1
yes

In ECLiPSe, the same query returns both answers:

[eclipse 2]: a.
1
More (0.00s cpu) ? ;
2
Yes (0.00s cpu)

(aside: older versions ECLiPSe did the same thing as SICStus, but we
changed this as the current behaviour seems more consistent)

Cheers,

Kish
Received on Fri Jun 13 15:11:06 2003

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:24 PM GMT GMT