Re: Gprolog member/2 error ?!

Pedro Fialho <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
> 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?
> 

Indeed, the exemplified input list doesn't contain a valid structure for the 
defined constraint. Not sure if I stated this, but the input list to my pred/1
(the [R-C-P|Ls1] in the source code) contains an element which fulfills the 
constraint (found by manual observation), namely:

...,
[[]-sing-[]-E-[],def-sing-[]-F-[],def-sing-[]-G-[],qual-sing-[]-H-[]]-
['conclusao'(E),'diagnostico'(F),paciente(G),nome(G,'Rita Ambrosio'),
rel(de,E,F),rel(para,F,G)]-
[ser(H,a:E)]
,...

I've rewritten my code in a OO way (for clarity) and I still get only
the first element of my input list as result. Namely, for the source:

filterDRS([], []).
filterDRS([R-C-P|Ls], [R1-C1-P1|Ls1]):-
        (aux1(C,P) -> (C=C1, R=R1, P=P1) ; filterDRS(Ls, Ls1) ).

aux1(C, P):-
        memberchk(rel(_,X,Y), C),
        \+ \+ memberchk(rel(_,Y,_), C), 
        nth(1,P,Z),
        arg(2, Z, _:X).

I get the result:

[[[]-sing-[]-A-[],def-sing-[]-B-[],def-sing-[]-C-[],qual-sing-[]-D-[]]-
['conclusao'(A),'diagnostico'(B),paciente(C),
nome(C,'Rita Ambrosio'),rel(de,A,B),rel(para,A,C)]-
[ser(D,a:A)]|_]

Which clearly doesn't fulfill the aux1/2 constraint, although the [R-C-P|Ls]
contains the correct result (above stated).

Thank you very much for your help on this issue. I'm still confused in why 
the list changed...With your hint I got it done/unchanged but my 
understanding of unification still tells me the source should be alright 
(logically/mathematically speaking, the double negation shouldn't make 
difference).

Best Regards,
Peter
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.