Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago