Question
Assume we have the following knowledge base in a Prolog program: building(engineering, ev). building(business, mb). building(library, lb). building(classes, h). building(hr, fg). department(electrical, engineering). department(civil, engineering).
Assume we have the following knowledge base in a Prolog program:
building(engineering, ev). building(business, mb). building(library, lb). building(classes, h). building(hr, fg).
department(electrical, engineering). department(civil, engineering). department(finance, business). department(ibm-exams, lb).
status(engineering, accredited).
faculty(smith, electrical). faculty(walsh, electrical). faculty(smith, computer). faculty(jones, civil). faculty(james, civil). faculty(davis, civil).
faculty(X, Y) :- department(Z, Y), faculty(X, Z).
building(X, Y) :- department(X, Z), building(Z, Y).
status(X, Z) :- department(X, Y), status(Y, Z).
faculty(X) :- faculty(X, _).
Determine the type of each of the following queries (ground/non-ground), and explain what will Prolog respond for each of these queries (write all the steps of unifications and resolutions for each query)?
building(library, lb).
status(finance, A).
department(civil, Bussiness).
faculty(X, civil).
faculty(smith, X).
department(X, Y).
faculty(X, civil), department(civil, Y).
faculty(Smith). building(_, X).
status(X, accredited), building(X, Y).
status(_, X), building(X, Y).
faculty(X), faculty(X, Y), department(Y, _).
faculty(X), faculty(X, Y), !, department(Y, Z). % note there is a cut (!) here
faculty(X), !, faculty(X, _). % note there is a cut (!) here
department(X, _), \+ faculty(_, X).
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