Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Logic Programming 4. Logic Programming [Total: 25 marks] In this question, we consider the Prolog program below. The rules (shown in bold type) are incomplete

Logic Programming

image text in transcribed

4. Logic Programming [Total: 25 marks] In this question, we consider the Prolog program below. The rules (shown in bold type) are incomplete link (mary,peter). link (john, peter). link (mary, amy) link (john, david) link (amy, bob). friend (x.Y) :- . . list friends (X,L) :- . 4(a) [5 marks] The fact link (john,peter) means that john and peter are friends We want to make each link bidirectional, e.g., peter and john are friends However, we do not want to add additional facts like link (peter, john) in the above program Write the rule(s) for friend (X, Y) in order to solve this problem. [10 marks] 4(b) Write the rule(s) for list_friends (X,L) such that L represents the list of all friends of X. Consider the following queries. Guess the result of each query in a Prolog interpreter list friends (john, L) list friends (amy, L) Result 4(c) [10 marks] We recommend X and Y to be friends if they are not friends but they have at least one common friend Write the rule(s) for recommend (X, Y) Consider the following queries. Guess the result of each query in a Prolog interpreter recommend (john, amy) recommend (david, john) ue Result END OF THE PAPERnn 4. Logic Programming [Total: 25 marks] In this question, we consider the Prolog program below. The rules (shown in bold type) are incomplete link (mary,peter). link (john, peter). link (mary, amy) link (john, david) link (amy, bob). friend (x.Y) :- . . list friends (X,L) :- . 4(a) [5 marks] The fact link (john,peter) means that john and peter are friends We want to make each link bidirectional, e.g., peter and john are friends However, we do not want to add additional facts like link (peter, john) in the above program Write the rule(s) for friend (X, Y) in order to solve this problem. [10 marks] 4(b) Write the rule(s) for list_friends (X,L) such that L represents the list of all friends of X. Consider the following queries. Guess the result of each query in a Prolog interpreter list friends (john, L) list friends (amy, L) Result 4(c) [10 marks] We recommend X and Y to be friends if they are not friends but they have at least one common friend Write the rule(s) for recommend (X, Y) Consider the following queries. Guess the result of each query in a Prolog interpreter recommend (john, amy) recommend (david, john) ue Result END OF THE PAPERnn

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

=+ What would it look like? Who should deliver it?

Answered: 1 week ago