Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a prolog program with following facts and rules to create database and answer queries mentioned at the end of this document. Your program
Write a prolog program with following facts and rules to create database and answer queries mentioned at the end of this document. Your program will have following 7 facts: 1. course(X) is a single argument predicate, where X can take the names of the course as elements. 2. department(X) is a single argument predicate, where X can take the names of the department as elements. 3. professor(X) is a single argument predicate, where X can take the names of the professor as elements. 4. student(X) is a single argument predicate, where X can take the names of the student as elements. 5. course in department(C, D) is a two argument predicate, where C represent a course in department D. 6. course-professor (C, P) is a two argument predicate, where C represent a course taught by professor P. 7. student enrolled_in.course(S, C) is a two argument predicate, where S represent a student enrolled for course C. Your program will have rules in prolog format for the following 1. predicate student in.department(X,Y) says X is a student in department Y if X is a student and Y is a department and X is enrolled for any courses in department Y. 2. predicate professor of_student(X, Y) says X is a professor of student Y if Y is a student and X is professor and Y is enrolled for any course taught by X. 3. predicate professor.in_same department(X,Y) says X and Y are professor in the same department if X teaches a course C1 and Y teaches a course C2 and both C1 and C2 are course in the same department. Evaluate the following queries in Prolog compiler: 1. ?- student in_department(X,Y). Whether person X is a student in department Y. 2. ?- student.in.department(X, -). Person X is a student in which department. 3. ?- professor of student(X,Y). Whether Person X is a professor of a person Y. 4. ?- professor _in_same_department(X, Y) Whether person X and Y are in the same department. 5. ?- professor in_same_department(X,-) Who all are in the same department with person X.
Step by Step Solution
★★★★★
3.47 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
The seven facts are courseX departmentX professorX studentX c...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