Question
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
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