Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Search mechanisms in Prolog:

Here we can needs this simple Prolog program to describe how Prolog searches as:president(X) :- first_name(X, georgedubya), second_name(X, bush).

prime_minister(X) :- first_name(X, maggie), second_name(X, thatcher).

prime_minister(X) :- first_name(X, tony), second_name(X, blair).

first_name(tonyblair, tony).
first_name(georgebush, georgedubya).

second_name(tonyblair, blair).
second_name(georgebush, bush).

If there we loaded this in a Prolog implementation into as Sicstus, or queried the database as:

?- prime_minister(P).

In fact then Sicstus would search in the following manner as: it would run through it is database when pending for it came across a Horn clause or fact for that the head was prime_minister and the arity of the predicate was 1. Than there It would first look at the president clause, so after that reject this to see the name of the head doesn't match with the head in the query. moreover, next it would find the clause as:

prime_minister(X) :- first_name(X, maggie), second_name(X, thatcher).

There fits the bill. After than it would look at the predicates in the body of the clause or see if it could satisfy them. In fact in this case, we see that it would try to find a match for first_name(X, maggie). But, it would fail, it means that there no such information can be found in the database. Because it means that the entire clause fails Sicstus would backtrack, thai is., so it would go back just to looking for a clause with the same head as the query. But it would next find this clause such as:

prime_minister(X) :- first_name(X, tony), second_name(X, blair).

So there then it would look at the body again, than try to find a match for first_name(X, tony). According to that it would look through the datatabase and find X=tonyblair a good assignment hence it means the fact first_name(tonyblair, tony) is found towards the end of the database. as well having assigned X=tonyblair, so it would then look for a match to: second_name(tonyblair, blair), and would succeed. Likewise, the answer tonyblair would make the query succeed, for this would be reported back to us.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9517307

Have any Question?


Related Questions in Computer Engineering

Two people agree to meet at a coffee shop they each

Two people agree to meet at a coffee shop. They each independently pick a random moment in time between 8 a.m. and 9 a.m. and show up exactly at their selected time. But they are very impatient, and only stay for 10 minu ...

Mccann co has identified an investment project with the

McCann Co. has identified an investment project with the following cash flows. Year Cash Flow  1   $800  2    1,090 3    1,350 4    1,475 a. If the discount rate is 7 percent, what is the present value of these cash flow ...

Is there any difference in terms of the information that

Is there any difference in terms of the information that could be provided to the decision maker by an IS that was created using HSM and an IS that was created using SSM?

Draw supply and demand curve to illustrate the following

Draw supply and demand curve to illustrate the following sequences of events. Show changes in one graph. Assume upward sloping for supply curves and downward sloping for demand curves 1. In year 1, the rental apartment m ...

Question suppose you transferred three packets each

Question : Suppose you transferred three packets each containing 1000 bytes of data from one system to another. The entire process took 1 minute and 20 seconds. What is the data rate (bits/sec) of this transmission? Can ...

Please explain which formula i should use to complete the

Please explain which formula I should use to complete the following probability question: The probability that a family will buy a vacation home in Miami, malibu, or newport is 0.25, 0.10 and 0.35. What is the probabilit ...

Question 52 consider the following objects and their

Question 5.2: Consider the following objects and their properties: Car: fuel capacity, serial number, passenger capacity, net weight, license plate Boat: fuel capacity, serial number, passenger capacity, net weight, draf ...

Question whats the roles of user roles and why are they

Question : What's the roles of user roles and why are they necessary for Linux? How are these roles and permission similar and different from other types of users and other operating systems?

What is the broadcast domain and ports for hubs and

What is the Broadcast Domain and Ports for hubs and bridges?

About signed integer representation twos complement

About Signed Integer Representation. Two's Complement Overflow Explain how to perform the signed decimal to Hexadecimal conversion and vice versa. Show it with two examples for each.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As