2
votes

The question is as follows:

Represent the following in Prolog:

1.Butch is a killer.

2 Mia and Marsellus are married.

3 Zed is dead.

4 Marsellus kills everyone who gives Mia a footmassage.

5 Mia loves everyone who is a good dancer.

6 Jules eats anything that is nutritious or tasty.

My answers are like this, please help me to check if i'm correct or wrong.

  1. killer(butch).

2 married(mia,marsellus).

3 dead(zed).

4 kills(marsellus,X):-givesfootmassage(mia,X).

5 loves(mia,X):-gooddancer(X).

6 eats(jules,X):-nutritious(X);tasty(X).

Thanks so much :)

1

1 Answers

2
votes

You have correctly translated the sentences to Prolog.

But your naming convention makes the code very hard to read!

A good Prolog naming convention makes clear what each argument means.

For example, let us take your last clause:

eats(jules, X) :- nutritious(X) ; tasty(X).

From the context, it is clear that the first argument is a person, and the second is a food. A good predicate name makes this explicit.

Contrast this with:

person_eats_food(jules, Food) :- nutritious(Food) ; tasty(Food).

I recommend you go again through each translation, and try to find better names if possible.