Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PROLOG- LOGICAL EXPRESSION FOR ALL OF THEM Suppose we have a database of the rei

ID: 3825210 • Letter: P

Question

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 */

Explanation / Answer

Prerequisitus :

Checks : " Posting Date <= Current Date "

Message : " Posting date is future "

this is running successfully for all users.


now I have more then 100 users, I have to limit my users to post the future date in posting date.

for example : User name : prince , this user have rights to post future date also, remaining all users there is no permission for post the future date. for that i need validation program.

I tried this validation in Checks:

((NOT(User Name = 'PRINCE'))-->(Posting Date <= Current Date ))

is it correct or not ? but I can't get result. Please suggest me the exact validation program ASAP.


Prince

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote