Re: redundancy
- From: Chip Eastham <hardmath@xxxxxxxxx>
- Date: Mon, 22 Oct 2007 08:28:30 -0700
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
.
- Follow-Ups:
- Re: redundancy
- From: sbaker8688
- Re: redundancy
- References:
- redundancy
- From: omargamil
- redundancy
- Prev by Date: Re: redundancy
- Next by Date: Re: redundancy
- Previous by thread: Re: redundancy
- Next by thread: Re: redundancy
- Index(es):
Relevant Pages
|
|