Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROLOG- LOGICAL EXPRESSION FOR ALL OF THEM Suppose we have a database of the reigns of the Sovereign Princes of Wales in the 9th and

PROLOG- LOGICAL EXPRESSION FOR ALL OF THEM

Suppose we have a database of the reigns of the Sovereign Princes of Wales in the 9th and 10th centuries. The predicate reigns is defined such that the goal reigns(X, Y, Z) is true if the prince named X reigned from year Y to year Z. The list of facts in the database looks like this.

reigns(rhodri, 844, 878).

reigns(anaruwd, 878, 916).

reigns(hywel, 916, 956).

reigns(lago-sp-idwal, 956,979).

reigns(hywel-ap-iemf, 979,985).

reigns(cadwallon, 985, 986).

reigns(marcdudd, 986, 999).

Define a rule called is-prince that given a name and a date would search the database and compare the given date against the dates of the reign.

(10)Write a Prolog program that computes the factorial of N. For example,

?- fac(4,X). will give

X = 24

?- fac(5,X). will results in

X = 120

We already have the following relationships defined.

Father (X, Y) /* X is the father of Y */

Mother(X, Y) /* X is the mother of Y */

Male(X) /* X is male */

Female(X) /* X is female */

Parent(X, Y) /* X is a parent of Y */

Diff(X, Y) /* X and Y are different */

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

Students also viewed these Databases questions