Question: You should use SWI Prolog software to write your code. Q 3 ( 2 0 pts ) . Use Prolog to represent a simple directed

You should use SWI Prolog software to write your code.
Q3(20 pts). Use Prolog to represent a simple directed graph. Define edges between nodes in a
graph using edge(a,b) if there is and edge from a to b.
Add the edges of the graph above as the facts. Write a rule to check if there is a path between
two nodes. Write queries to check if there is a path from a to c, from c to a, from d to b, from b
to e, from fto a.
Q4(15 pts). Write a Prolog code to return the length of a list. Run a query to get the length of
1,3,5,7,9,11. Write your query and Prolog answer to your Word document.
Q5(20 pts). Write a Prolog code to check whether given three values satisfy the triangle
inequality or nor. It states that, for any triangle with sides of lengths a,b, and c, the following
inequalities must hold: a+b>c,a+c>b,b+c>a. Run five queries to check whether the
following triplets satisfy triangle inequality or not: ,
4,1.
You should use SWI Prolog software to write your

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!