Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!uxc.cso.uiuc.edu!clio!wengert From: wengert@clio.las.uiuc.edu Newsgroups: comp.lang.prolog Subject: Re: existential quantification in bagof Message-ID: <16400007@clio> Date: 16 Feb 89 18:55:00 GMT References: <1584@kulcs.kulcs.uucp> Lines: 44 Nf-ID: #R:kulcs.kulcs.uucp:1584:clio:16400007:000:1477 Nf-From: clio.las.uiuc.edu!wengert Feb 16 12:55:00 1989 Arity Prolog, given the call findall(X,member(X,[Y,Z]),S). responds X = _0034 Y = _0048 Z = _005C S = [_00FC,00EC] This is the same result you find surprising on the TI. What you seem to be surprised by is the different variables in the list formed in S. Arity says, "The findall predicate is similar to bagof, except that any free variable is assumed to be existentially quantified." Given that, the above response strikes me as perfectly logical. Think of what the query is. It asks: What would I find if I looked for anything that was a member of a list which contained something followed by something? The answer: You would get something and something. The fact that these are different variables in the answer points out the fact that bound variables in a different scope are not to be identified even if they are typographically the same. In logic classes it is important to explain that (Ex)policeman(x) and (Ex)murderer(x) does not given the conclusion that some policeman is a murderer. It is safer, therefore, to write (Ex)policeman(x) and (Ey)murderer(y). If, therefore, you had a list containing some policeman followed by some policeman (Ex)policeman(x),(Ey)policeman(y), and then you asked what you would find in that list, the answer: (Ev)policeman(v), (Ew)policeman(w) would be correct. Since Prolog does not include the quantifiers indicating scope, the use of divergent variables is almost required. bob wengert wengert@clio.las.uiuc.edu