Question: Logic Programming Assignment In this assignment, you are asked to write simple logic programs. 2. A library has a searchable database of books. Each book

Logic Programming Assignment

In this assignment, you are asked to write simple logic programs.

2. A library has a searchable database of books. Each book has a unique classification code. For instance, the book with classification code QA76.642.C39 is entitled Parallel Algorithms; it is published by the CRC Press in 2008 and authored by Henri Casanova, Arnaud Legrand and Yves Robert. Assume that the database contains the following relations each of which is represented as a collection of facts

. ? title(Classifier, Title) says that the title of the book with classification code Classifier is Title;

? publishedBy(Classifier,Publisher) says that the book with classification code Classifier is published by Publisher;

? author(Person, Classifier) says that Person is an author of the book with classification code Classifier;

? publishedIn(Classifier,Year) says that the book with classification code Classifier is published in year Year.

For instance, the above mentioned book is represented as the following facts where a person is represented by a term of the form person(Firstname,Lastname). title("QA76.642.C39", "Parallel Algorithms"). publishedBy("QA76.642.C39","CRC press"). author(person(henri,casanova),"QA76.642.C39"). author(person(arnaud,legrand),"QA76.642.C39"). author(person(yves,robert),"QA76.642.C39"). publishedIn("QA76.642.C39",2008). Build a database containing at least 5 books and write and test the following predicates:

a) Write a predicate multi_authored(Title) that is true if and only if a book named Title has multiple authors;

b) Write a predicate author_title(Person, Title) that is true if and only if Person is an author of a book named Title;

c) Write a predicate author_year(Person, Year) that is true if and only if Person published books in year Year;

d) Write a predicate new_book(Title) that is true if and only if there is a book named Title that is published in 2017 or later.

e) Write a predicate coauthor(Person1, Person2) that is true if and only if Person1 and Person2 co-authored a book.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!