0
votes

I'm a prolog programming assignment and I not able to represent the following predicate in prolog form.

The Batman who loves to watches soccer and buys ticket from Bill, never plays Hockey or Cricket in his free time.

I'm not able to write negation part of the predicate in the list format. The list is of the form.

member([batman,soccer,gotham,tikcet,bill],Listname)

batman - name of the batman soccer - what the person likes to do gotham - City of origin tikcet - buys something to do what he likes bill - preson selling ticket

Appreciate any help.

Thanks!

1

1 Answers

0
votes

I don't see the connection between the problem and your list.

The Batman who loves to watch soccer and buys tickets from Bill, never plays Hockey or Cricket in his free time.

The first part looks to me like this:

loves(batman, watching(soccer)).
buys(batman, tickets, bill).

The last part looks to me like this:

:- dynamic plays/2.

This just tells Prolog that plays/2 is a kind of fact and that these facts will be forthcoming.

Then you could write the query like so:

?- loves(Batman, watching(soccer)), 
   buys(Batman, tickets, bill), 
   \+ plays(Batman, hockey),
   \+ plays(Batman, cricket).

This looks like it reflects the question to me, and it gives the expected response:

Batman = batman.