Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Prolog) Question 3 (20 pts) Queries in Prolog Assume we have the following knowledge base in a Prolog program: building(engineering, ev). building business, mb). building(library,

(Prolog)

image text in transcribed

image text in transcribed

Question 3 (20 pts) Queries in Prolog 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). facultyjones, 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 (groundon-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). Question 3 (20 pts) Queries in Prolog 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). facultyjones, 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 (groundon-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

Step: 3

blur-text-image

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

Strong analytical, communication, and problem-solving skills

Answered: 1 week ago