Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago