Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Given the facts about Bible family relationship: Write the output for the following queries (if there are more than one output, write all of

1. Given the facts about Bible family relationship: Write the output for the following queries (if there are more than one output, write all of them):

a) ?- parent(abraham,X).
b) ?- parent(abraham,_). 
c) ?- parent(Father,esau).
d) ?- parent(F,S).
e) ?- parent(abraham,X),parent(X,Grandson).

2. Write a Prolog rule, brother, which determines if two persons in the Bible family are brothers. For example, after your rule is created, you will have the following output:

?- brother(esau,iacob).
yes

3. Write a Prolog rule that find the last element of a list.

Example: ?- my_last(X,[a,b,c,d]). X = d

4. Write a Prolog rule that duplicate the elements of a list.

Example:

?- dupli([a,b,c,c,d],X).

X = [a,a,b,b,c,c,c,c,d,d]

5. The following is an example code that finds the area and perimeter of a rectangle:

area:- write('Length '),read(L),

area:- write(Width '),read(W),

write('Area is '),A is L*W,write(A),nl,

write('Perimeter is '),P is 2*3.14*R,write(P),nl.

?- area.

Length |: 3.

Width |: 4

Area is 12

Perimeter is 14

Write similar code to find the area and circumference of a circle.

6. Write Prolog rules that verifies if 3 numbers can be the edges of a triangle. Note, in a triangle, the sum of any two edges must be grater than the third edge.

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions