Question
a social network involving people who are connected by a friend relationship, as represented below: as Prolog code on the left, and a graphical representation
a social network involving people who are connected by a friend relationship, as represented below: as Prolog code on the left, and a graphical representation on the right. Note that this friend relationship is symmetric, since, on the left, for each pair X, Y of people, if friend (X, Y), then friend (Y, X), and in the graphical representation on the right, the "edges" do not have direction
a. (10 points). Write the Prolog predicate friendofafriend (X, Y) which is true when X has a friend who is a friend of Y. Note: that this does not preclude X from also being a friend of Y.
b. (5 points). Use this friendofafriend predicate to list all of the people who are a friend of a friend of cory. Some people are listed twice, why is this?
c. (5 points). What problem do we encounter if we try to use the predicates connection or path from the previous homework assignments, and why?
friend(abi,bea).friend(abi,cory).friend(bea,cory).friend(bea,dina).friend(cory,dina).friend(dina,eva).friend(dina,fei).friend(eva,fei).friend(fei,gil).friend(bea,abi).friend(cory,abi).friend(cory,bea).friend(dina,bea).friend(dina,cory)friend(eva,dina).friend(fei,dina).friend(fei,eva).friend(gil,fei)
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