Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following prolog facts: takes(tom, ct331). takes(mary, ct331). takes(joe, ct331). takes(tom, ct345). takes(mary, ct345). instructs(bob, ct331). instructs(ann, ct345). 1. Write a prolog rule called

Consider the following prolog facts:

takes(tom, ct331).

takes(mary, ct331).

takes(joe, ct331).

takes(tom, ct345).

takes(mary, ct345).

instructs(bob, ct331).

instructs(ann, ct345).

1. Write a prolog rule called teaches that returns true if a given instructor teaches a given student.

2. Write a prolog query that uses the teaches rule to show all students instructed by bob.

3. Write a prolog query that uses the teaches rule to show all instructors that instruct mary.

4. What is the result of the query: teaches(ann, joe). Why is this the case?

5. Write a prolog rule called classmates that returns true if two students take the same course. Demonstrate with suitable queries that this rule works as described.

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago