[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gprolog member/2 error ?!

From: Pedro Fialho
Subject: Re: Gprolog member/2 error ?!
Date: Thu, 26 Aug 2010 14:23:19 +0000 (UTC)
User-agent: Loom/3.14 (

> 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:

['conclusao'(E),'diagnostico'(F),paciente(G),nome(G,'Rita Ambrosio'),

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), 
        arg(2, Z, _:X).

I get the result:

nome(C,'Rita Ambrosio'),rel(de,A,B),rel(para,A,C)]-

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 

Best Regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]