# Prolog

9. The next two pages describe a Prolog exercise. Complete it, and submit your database to us, following the directions provided.

10. After you have completed the Prolog exercise, answer these two questions.

Don't use plagiarized sources. Get Your Custom Essay on
Prolog
Get a plagiarism free paper Just from \$13/Page

(a) Can your auntOrUncleByBlood(C,O) rule be expressed as a Horn clause? If so, show the resulting Horn clause. If not, explain why not. You can find the definition of a Horn clause on the last page of the Prolog tutorial handout.

(b) Consider this rule: brotherInLawOf(B,P) :- married(B,X), sibling(X,P).

Looking at the data, we know that Mark Phillips and Prince Charles are brothers-in-law, but this rule will not return true if we supply (mark,charles) as input. Why not? (Hint: Try adding this rule to your database and using trace.)

Background: Almost everyone is aware of, if not exactly fond of, the British royal family. For this portion of the homework, you are to represent a branch of the royal family (see the family tree image, on the next page, for the portion of interest) in Prolog and write several rules that ‘reason’ about the family relationships.

Assignment: Create a Prolog database in a file named royals.pl that allows the user to ask query the royal family tree. In particular, here’s what we want your database to include:

• Facts about the royals. You’ll need:

married(W,M) – States the fact that woman W married man M. Repeat as many times as necessary

for all of the married pairs of royals.

childOf2(C,W,M) – States that C is the child of woman W and man M.

For this assignment, we’ll use the facts given in the family tree fragment shown below. Identify the people by their first names. If you find a duplicate, give the younger person’s name a digit suffix. E.g., frank and frank2.

• The following rules that Prolog can use to determine various family relationships. Implement these in terms of each other and the facts above; do not add any additional facts:

equal(X,X). – That’s it, exactly. Type it as you see it. You’ll probably find it useful as part of another rule later on.

childOf1(C,W) – Determines if C is a child of woman W.

childOf1(C,M) – Determines if C is a child of man M.

sibling(X,Y) – For this assignment, siblings are considered to be people who share the same two parents.

auntOrUncleByBlood(C,O) – Your mother’s sister is an example of an aunt by blood. As the name suggests, uncles by blood count here, too.

Important Notes:

We will not accept rules that include predetermined answers. Write the rules so that Prolog has to figure out the answers for you. If you find yourself trying to put constants in your rules instead of variables, you’re not writing the rules correctly.

When defining the childOf1 rules, you’ll get a “warning: singleton variables” message or two. That’s OK; don’t worry about it.

When you separate like–named facts and rules, you can get ‘discontiguous predicate’ warnings. Simple fix: Keep all like–named items together.

To negate a rule in gprolog, use the \+ operator. For example, \+equal(X,Y) would be true if X and Y are not equal.

Order Now And Get A 20% Discount!
Pages (550 words)
Approximate price: -

Advantages of using our writing services

Custom Writing From Scratch

All our custom papers are written by qualified writers according to your instructions, thus evading any case of plagiarism. Our team consists of native writers from the USA, Canada, and the Uk, making it convenient for us to find the best to handle your order.

Unlimited Free Revisions

If you feel your paper didn't meet all your requirements, we won't stop till it's perfect. You're entitled to request a free revision within 7 days after we submit your paper.

Quality Writing In Any Format

If you have issues with citing sources and referencing, you need not worry. Our writers are highly knowledgeable in referencing, including APA/MLA/Havard/Chicago/Turabian and all other formatting styles.

All our custom papers are delivered on time, even the most urgent. If we need more time to perfect your paper, we may contact you via email or phone regarding the deadline extension.

Originality & Security

At Master Homework, your security and privacy is our greatest concern. For this reason, we never share your personal information with third parties. We use several writing tools to ensure your paper is original and free from plagiarism.

Our agents are online 24 hours a day, 7 days a week, and are always ready to serve you. Feel free to contact us through email or talk to our live agents whenever you need assistance with your order.

Try it now!

## Calculate the price of your order

We'll send you the first draft for approval by at
Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

We work nonstop to see the best client experience.

## Flexible Pricing

We offer pocket-friendly prices that coincide with the preferred client's deadline.