Re: redundancy



On Oct 22, 5:14 am, omargamil <nicromoni...@xxxxxxxxxxx> wrote:
hey guys..im new to prolog..im using visual prolog 5.2..
so i have this problem...there's a group of kids..and only kids with
same age are supposed to play together..
so this is what i wrote..

predicates
nondeterm age(symbol,integer)
nondeterm play(symbol,symbol).

clauses
age(peter,9).
age(paul,10).
age(chris,9).
age(susan,9).
age(mike,10).

play(X,Y):-
age(X,Z),age(Y,Z),X<>Y.

goal
play(X,Y).

the problem is this will show 8 solutions while they are actually
3..how to avoid this??
thanks in advance.

Unless there are additional constraints, eight solutions
is correct. One redundancy you might want to eliminate
is reporting both play(X,Y) and play(Y,X) as distinct
solutions. That would bring down the count to 4, rather
than 8, e.g. by replacing X<>Y with X < Y.

--c

.



Relevant Pages

  • redundancy
    ... so i have this problem...there's a group of kids..and only kids with ... same age are supposed to play together.. ... nondeterm play. ...
    (comp.lang.prolog)
  • Re: TESS for Turbo Prolog
    ... % The Utility predicates module. ... nondeterm erase. ... nondeterm my_consult. ... % upper horizontal line with corners ...
    (comp.lang.prolog)
  • Re: TESS for Turbo Prolog
    ... % Input and Output utility predicates module. ... nondeterm getEDITfile. ... removewindow. ... write("your % Knowledge base has been saved", ...
    (comp.lang.prolog)
  • Re: TESS for Turbo Prolog
    ... include "menu.pro" % This file comes with your Turbo Prolog system. ... nondeterm consult_window. ... % Colors are red on black with brown frame ...
    (comp.lang.prolog)
  • =?utf-8?B?UmU6IOeUqFRQMjAsIFZQNTHnlJ/oirEsIOS4gOWIh+WHuuaWvOWFreWQiOW9qemWi+Wniw==?=
    ... nondeterm mn. ... fail. ...
    (comp.lang.prolog)