users-prolog
[Top][All Lists]
Advanced

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

## Re: help

 From: Edmund GRIMLEY EVANS Subject: Re: help Date: Wed, 20 Dec 2000 14:25:05 +0000 User-agent: Mutt/1.3.12i

```bla blame <address@hidden>:

> Hi,
>
> I'm new to prolog and was just wondering how this
> murder case could be solved in prolog.
>
> Can you implement it?

You could do it like this:

object(pistol). object(umbrella). object(cigarette). object(diary).
object(letter).
action(argued). action(left). action(rang). action(walked). action(murdered).
person(ablaze). person(burner). person(curious). person(dulles).
person(evilson).
motive(harassment). motive(abandonment). motive(sacked). motive(promotion).
motive(hate).

people([]).
people([_-X|L]) :- person(X), people(L).

solution(Murdered) :-
findall(X-_,object(X),Objects),
people(Objects),
\+ ( member(A-X,Objects), member(B-X,Objects), A \= B ),
member(cigarette-burner,Objects),
\+ member(letter-curious,Objects),
\+ member(pistol-curious,Objects),
\+ member(letter-ablaze,Objects),
findall(X-_,motive(X),Motives),
people(Motives),
\+ ( member(A-X,Motives), member(B-X,Motives), A \= B ),
\+ member(sacked-curious,Motives),
\+ member(hate-curious,Motives),
member(hate-Hate,Motives), member(diary-Hate,Objects),
member(sacked-Sacked,Motives), member(letter-Sacked,Objects),
member(harassment-ablaze,Motives),
findall(X-_,action(X),Actions),
people(Actions),
\+ ( member(A-X,Actions), member(B-X,Actions), A \= B ),
member(umbrella-Umbrella,Objects), member(left-Umbrella,Actions),
member(walked-dulles,Actions),
member(argued-Argued,Actions), member(promotion-Argued,Motives),
\+ member(murdered-ablaze,Actions),
member(murdered-Murdered,Actions).

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]
• help, bla blame, 2000/12/09
• Re: help, Edmund GRIMLEY EVANS <=