Question
THIS IS A PROLOG QUESTION ! PLEASE ANSWER IT WITH PROLOG . For the purposes of the examples in this question, assume that the following
THIS IS A PROLOG QUESTION ! PLEASE ANSWER IT WITH PROLOG .
For the purposes of the examples in this question, assume that the following facts have been loaded into Prolog:
likes(mary, apple). likes(mary, pear). likes(mary, grapes). likes(tim, mango). likes(tim, apple). likes(jane, apple). likes(jane, mango).
Write a predicate all_like_all(Who_List, What_List) that takes a list of people Who_List and a list of items What_List and succeeds if every person in Who_List likes every item in What_List, according to the predicate likes(Who, What). Your predicate should also succeed if eitherWho_List or What_List is empty. Examples:
?- all_like_all([jane,tim],[apple,mango]). true ?- all_like_all([mary,tim],[apple,grapes]). false. ?- all_like_all([],[bananas]). true
Note that your all_like_all predicate will be tested with different likes(Who, What) facts to those in the examples.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started