Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel-eecis!news.mathworks.com!enews.sgi.com!lll-winken.llnl.gov!uwm.edu!math.ohio-state.edu!jussieu.fr!lcr.thomson-csf.fr!news.thomson-lcr.fr!georget
From: georget@thomson-lcr.fr (Yan Georget)
Subject: Re: The Kalotan puzzle
X-Nntp-Posting-Host: morphee.thomson-lcr.fr
Message-ID: <DvvDDH.BHs@news.thomson-lcr.fr>
Sender: news@news.thomson-lcr.fr
Organization: Thomson-CSF, Laboratoire Central de Recherches, Orsay, France
References:  <4udu92$auh@listserv.rice.edu>
Date: Fri, 9 Aug 1996 12:00:53 GMT
Lines: 32


It's easy with the boolean constraint solver of sicstus :

1 : male
0 : female

A : sex of the person who gaves the first answer
B : sex of the person who gaves the second answer
K : sex of the child
R : answer of the child

sex(A,B,K) :-
	check(A,B,K,_).
check(A,B,R,K) :-
	bool:sat(A # B),
	bool:sat(K =< R),
	bool:sat(A =< (R * (~K # (K # R)))),
	bool:sat(B =< (~K * (K # R))).

| ?- sex(A,B,K).

A = 0,
B = 1,
K = 1 ? 

yes

-- 
Yan Georget               Thomson-CSF/Laboratoire Central de Recherche
                          Domaine de Corbeville, 91404 ORSAY CEDEX
tel +33 1 69 33 92 98     FRANCE

