Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Prolog only (syntax and semantics.} (Use siwpl-SWI-Prolog) We can represent a hierarchical multiple inheritance structure as a collection of objects in Prolog, connected with

Use Prolog only (syntax and semantics.} (Use siwpl-SWI-Prolog)

We can represent a hierarchical multiple inheritance structure as a collection of objects in Prolog, connected with "isa" relations. Given such a Prolog representation of a structure, we would like to determine all the objects from which a given object can inherit properties. For the purposes of this question, we assume that this inheritance relationship is reflexive --- ie, an object can inherit properties from itself.

We assume that the inheritance structure is a directed acyclic graph (DAG). While it will not have cycles, there may still be multiple paths connecting a pair of nodes. Write a relation inherits-from(X,Y) that holds when

Y is an ancestor of X in the isa-based inheritance structure. If Y is not instantiated, then successive values for Y should be produced. You should produce each ancestor exactly once; no duplicates.

Example: If we have the following knowledge base: object(a). object(b). object(c). object(d). object(e). object(f). isa(a,b). isa(a,c). isa(b,e). isa(c,d). isa(d,b). isa(d,f). Then we should get the following results: ?-inherits-from(a,e). true ?-inherits-from(b,f). false. ?-inherits-from(a,X). X=a; X=b; X=c; X=e; X=d; X=f; false

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

Determine the appropriate tax filing status.

Answered: 1 week ago

Question

Do you think physicians should have unions? Why or why not?

Answered: 1 week ago