🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4262

Re: What does/should your Prolog make of this ?

#4262
From: Richard O'keefe
Date: Wed, 07 Mar 1990 23:33
76 lines
3600 bytes
In article <1990Mar7.104021.28421@sics.se>, alf@sics.se (Thomas Sj|land) writes:
> Another issue that has come up and which could interest this group 
> relates to  bagof(setof)-semantics : 

> What should be the behaviour of the following queries
> (in the program 'p(X)') ?

I don't understand what "in the program 'p(X)'" means.

> ?- freeze(X,write(foo)), bagof(_,(X=1 ; X=2),L).

Ignoring the freeze, the call to bagof/3 would create a list L=[U,U] in
some versions of Prolog, L=[U,V] in others.  When the elements of the
result are not ground, setof/3 and bagof/3 have no non-operational meaning.
In NU Prolog version 1.4, the result is

    2?- prog(L).
    foofoofooL = [_CYIXR] ;
    fooL = [_CYIXU] ;
    fail.

which seems reasonable to me.

> ?- Y=1,
>    bagof((X,Y),p(X),L).

This should be the same as bagof((X,1), p(X), L), and should presumably
act just as it does in non-coroutining Prologs.

> ?- bagof((X,Y),p(X),L), 
>    Y=1.

I repeat that setof/3 and bagof/3 have no non-operational meaning
when the elements of the result would not be ground.  It seems to
me entirely reasonable for a coroutining implementation of these
predicates to compute the set
    V' = {variables in the Template} \ {variables in the Generator}
and do something like

	setof(T, G, L) => setof(T, (G, await_all_ground(V')), L)
	bagof(T, G, L) => bagof(T, (G, await_all_ground(V')), L)

the wait has to be inside the generator in case the generator
binds some constrained variables and the awakened constraints bind
some of the variables in V'.

> Is there a need for more versions of findall/bagof/setof?

Yes.  NU Prolog has some of them.  For reasons entirely unrelated to
coroutining, there are still other versions that would be useful.

> PS.	
> Ought we not to think about bigger character sets for Prolog 
> including Europe and Japan and also FULL (complete, :-)) English 
> in the syntax ?

The document PS/6 was written in mid-1984 and explicitly recommends
that Prolog should accept Kanji, each glpyh being represented by a
single integer code.  Xerox Quintus Prolog does this.  I believe
that the approach taken by Xerox Quintus Prolog is the right one.
Quintus Prolog handles the full 8859/1 character set, and if Debray
didn't make too many changes to the tokeniser I gave him, so does
SB Prolog.

It is quite straightforward to define Prolog token-level syntax in
terms of sets of characters, leaving character set size and coding
implementation defined.  The main difficulty (which my current
specification _just_ manages to cope with) is that some character
sets include several replicates of the same characters (for example
IBM's DBCS apparently includes two copies of each non-control EBCDIC
character) and one might want all the replicates of the digits to
function equivalently, without confusing them elsewhere.  (Xerox
are right: subscript/superscript/width and so on are part of the
"looks" of an INSTANCE of a character and should not be part of
the code of the IDENTITY of the character.  Alas, IBM (RT AIX) and
others don't agree.
Technical Details
Message-ID: <2962@goanna.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!uokmax!munnari.oz.au!goanna!ok
References: <1990Mar1.210219.5687@Neon.Stanford.EDU> <1557@maestro.htsa.aha.nl> <1990Mar7.104021.28421@sics.se>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!uokmax!munnari.oz.au!goanna!ok
From: ok@goanna.oz.au (Richard O'keefe)
Newsgroups: comp.lang.prolog
Subject: Re: What does/should your Prolog make of this ?
Message-ID: <2962@goanna.oz.au>
Date: 7 Mar 90 23:33:59 GMT
References: <1990Mar1.210219.5687@Neon.Stanford.EDU> <1557@maestro.htsa.aha.nl> <1990Mar7.104021.28421@sics.se>
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 76