22.3 Weapon access: Question
Exercise: Weapon access
Someone who had access to the weapon is someone who could either have stolen the penniless Ben's wooden leg or the hammer. In order to have been able to steal the wooden leg, the person must have been in Odensee Thursday or in Copenhagen Wednesday. In order to have been able to steal the hammer, the person must have been in the flat either wednesday or thursday.
Assume that you have a predicate at your disposal whose signature is as follows:
stay(Person, Day, Place)
This predicate says, for every person, where that person was on a given day. We will write this predicate later. For now, let us assume that we have it at our disposal.
For example, if we wanted to know whether a Person X were in the flat on Tuesday, the call would look like this:
stay(X, tuesday, flat)
Or, if we wanted to know whether the person X were in Copenhagen on Friday, the call would look like this:
stay(X, friday, Copenhagen)
Write a Prolog predicate, consisting of four Prolog clauses, which codifies the information about being able to steal either the wooden leg or the hammer. Call this predicate 'weapon_access'. Be sure to give the predicate one argument, namely the person X.
Click to see an answer.
Up: 22 A Murder Mystery
Next: Key access