Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Included are the facts and rules made for part 1 and 2: node(a),node(b),node(c),node(d),node(e),node(f) ,node(g),node (h) edge(a, b), edge(b, c), v, edge(c, a), edge(c, d), edge(c,

image text in transcribed

Included are the facts and rules made for part 1 and 2:

node(a),node(b),node(c),node(d),node(e),node(f) ,node(g),node (h)

edge(a, b), edge(b, c), v, edge(c, a), edge(c, d), edge(c, e), edge(d, e), edge(d, h), edge(e, f), edge(e, g), edge(f, g), edge(g, e)

parent(X,Y):- edge(X,Y).

ancestor(X,Y):- parent(X,Y) ancestor(X,Y):- parent(X,Z), ancestor(Z,Y).

child(X,Y):-edge(Y,X).

path(X, X, _, [X]). path(X, Y, Visited, [X | Path]) :- edge(X, Z), not(member(Z, Visited)), path(Z, Y, [Z | Y], Path).

length_of_path([_], 0). % path of length 0 has distance 0 length_of_path([X, Y], L) :- edge(X,Z), length_of_path([Z,Y],L2), L is 1+L2. % There is a direct edge from X to Z % Z and Y are connected by a path of length L2

connected(X,Y):-path(X,Y,_,P1); path(X,Y,_,P2).

undirected_edge(X,Y) :- edge(X,Y) ; edge(Y,X).

undirected_path(X,Y,P) :- path(X,Y,_,P1), P is P1; path(X,Y,_,P2), P is P2.

Create a knowledge base (KB) composed of all the facts and rules that you have written in parts (1), and (2), and save it in a prolog program file called "my_grapghG.pl", and show a print of your program here. Run this Prolog program, and write 4 queries about each of those rules that you have created in part (2) in order to test those rules, and show your queries and their results, and test the correctness of your results. (Note: you should write and test two ground quires (one with positive and one with negative answer) and two non-ground quires for each of the rules that you have created in Part B.) Add the following rule to your program, and test it and describe its function. tpath(Node1,Node2):-edge(Nodel, SomeNode), edge(SomeNode,Node2)

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

manageremployee relationship deteriorating over time;

Answered: 1 week ago