Question: Logic programming Consider the following Prolog database about musicians. plays(alicia, piano) plays (bjork, flute). plays (bjork, piano). plays (imi, guitar). plays (miles, trumpet) plays (norah,

Logic programming Consider the following Prolog database about musicians. plays(alicia, piano) plays (bjork, flute). plays (bjork, piano). plays (imi, guitar). plays (miles, trumpet) plays (norah, guitar). plays (norah, piano). plays (yoyo, cello). In the text box below, do each of the following. You should change the style to "Preformatted" so that your solution is easier to grade. 1. Define a new predicate instrument/1 that includes all of the instruments known about in the database. For example, the query instrument(cello) should return true while instrument(accordian) should return false. Your predicate should be defined in terms of the plays/2 predicate. When enumerating all solutions to a query like instrument(What), it is fine if the same instrument is returned multiple times. (1pt) 2. Define a new predicate strings/1 that includes all musicians who play either guitar or cello. For example, the queries strings yoyo) and strings(jimi) should both return true, but strings(alicia) should return false. (1pt) 3. Define a new predicate multi/1 that includes all musicians who play multiple instruments. For example, the queries multi(bjork) and multi(norah) should both return true, but multi(miles) should return false. (2pts) 4. Define a new predicate duet/2 that relates two different people who can play a duet together. Two people can play a duet together if the first one plays the piano and the second one plays any other instrument besides the piano. Here are some example queries using this predicate. (2pts) ? - duet(norah, Who). who = bjork ; Who - jimi ; Who = miles; Who = yoyo. ?- duet (Who, norah). Who = alicia ; Who = bjork. Logic programming Consider the following Prolog database about musicians. plays(alicia, piano) plays (bjork, flute). plays (bjork, piano). plays (imi, guitar). plays (miles, trumpet) plays (norah, guitar). plays (norah, piano). plays (yoyo, cello). In the text box below, do each of the following. You should change the style to "Preformatted" so that your solution is easier to grade. 1. Define a new predicate instrument/1 that includes all of the instruments known about in the database. For example, the query instrument(cello) should return true while instrument(accordian) should return false. Your predicate should be defined in terms of the plays/2 predicate. When enumerating all solutions to a query like instrument(What), it is fine if the same instrument is returned multiple times. (1pt) 2. Define a new predicate strings/1 that includes all musicians who play either guitar or cello. For example, the queries strings yoyo) and strings(jimi) should both return true, but strings(alicia) should return false. (1pt) 3. Define a new predicate multi/1 that includes all musicians who play multiple instruments. For example, the queries multi(bjork) and multi(norah) should both return true, but multi(miles) should return false. (2pts) 4. Define a new predicate duet/2 that relates two different people who can play a duet together. Two people can play a duet together if the first one plays the piano and the second one plays any other instrument besides the piano. Here are some example queries using this predicate. (2pts) ? - duet(norah, Who). who = bjork ; Who - jimi ; Who = miles; Who = yoyo. ?- duet (Who, norah). Who = alicia ; Who = bjork
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
