Possible bug within GNU Prolog ?

"Ahmed S. Darwish" <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <20070504225412.GA4197@Ahmed>
Hi all,

While Doing a Prolog college assignment, I faced the following strange problem:

occured_once(X, List) is true iff X occured once in List:


occured_once(X, [X]).
occured_once(H, [H | T]) :-
	\+ member(H, T).

occured_once(X, [H | T]) :-
	\+ X = H,
	occured_once(X, T).


Compiling and executing above snipped, here's some queries:

| ?- occured_once(1, [1, 2, X]).

no
| ?- occured_once(1, [1, 2, 3]).

true ? 

yes


So How come first test says that no X satisfy the first query, while it says
that the second query is true (same query substiuting X with 3) ?.

$ gprolog --version
Prolog top-Level (GNU Prolog) 1.2.18

Thanks,

-- 
Ahmed S. Darwish
http://darwish.07.googlepages.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.