Hello,

On Thu, Aug 26, 2010 at 08:38, Pedro Fialho <[email protected]> wrote:
> Thank you for your answer,
>
> Indeed it now returns a valid result, though not the correct one.
> Namely it returns:
>
>  ...,rel(de,A,B),rel(para,A,C)...
>
> which breaks the constraint that implies the 3rd argument
> of one rel/3 to be the 2nd argument of the other rel/3.

Well, I was merely showing you why the list changes. The list in your
example does not fulfill this constraint either before unification:

memberchk(
               rel(_215226,_215227,_215228),
               ['conclusao'(_198617),'diagnostico'(_198661),
                paciente(_198705),nome(_198705,'Rita Ambrosio'),
                rel(de,_198617,_198661),rel(para,_198617,_198705)    %
This is rel(de, A, B), rel(para, A, C)
               ])

But, after unification, it does:

  memberchk(
               rel(de,_198617,_198617),
               ['conclusao'(_198617),'diagnostico'(_198617),
                paciente(_198705),nome(_198705,'Rita Ambrosio'),
                rel(de,_198617,_198617),rel(para,_198617,_198705)
               ])

And you said:

> Notice the rel(de,_198617,_198661) predicate is changed to 
> rel(de,_198617,_198617) although member/2 is not stated as a
> destructive process.

So now it seems to me the input list to pred1/2 is broken. It should
contain rel(para,_198661,_198705) instead of
rel(para,_198617,_198705), and this is really the source of your
troubles... or did I just get confused?

One more thing: comparing variable instances is done with the
structural equality operator ==/2. It might not be what you really
want, though, because:

| ?- X == X.

yes
| ?- X == Y.

no

Regards,

-- 
Nicolas

_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog

Reply via email to