Question
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,
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
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