Given a database1 describing what activities entities take part in with facts of the form:
took_part(N, A)
: N
took part in activity A
day(A,Day)
: Activity A
was on Day
Where Day
is one of monday
, tuesday
, wednesday
, thursday
, friday
, saturday
or sunday
. An activity occurs on exactly one day.
Below is an excerpt of the database:
took_part(fenchurch, dining_at_the_end_of_the_universe).
took_part(slartibartfast, the_42_club).
took_part(zaphod_beeblebrox, painting_the_hart_of_gold).
took_part(marvin, dining_at_the_end_of_the_universe).
took_part(trillian, the_42_club).
took_part(tricha_mc_millen, painting_the_hart_of_gold).
took_part(arthur_dent, dining_at_the_end_of_the_universe).
day(dining_at_the_end_of_the_universe ,monday).
day(the_42_club ,monday).
day(painting_the_hart_of_gold ,monday).
We are now curious to find out which entities could have met and which could not. Write the following predicates to find out:
have_met(X,Y)
: X
and Y
were at the same event on the sane day (you do not meet yourselves).dif_place(X,Y,Day)
: X
and Y
were on a different event on Day
.did_not_meet(X,Y)
: X
and Y
did not meet this week.to test your predicates you can use this database2. Tip: type LifeTheUniverseAndEverything.
ENTER in SWI Prolog.