Search mechanisms in prolog, Computer Engineering

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.

Posted Date: 1/10/2013 5:56:32 AM | Location : United States







Related Discussions:- Search mechanisms in prolog, Assignment Help, Ask Question on Search mechanisms in prolog, Get Answer, Expert's Help, Search mechanisms in prolog Discussions

Write discussion on Search mechanisms in prolog
Your posts are moderated
Related Questions
For the sake of trying to make intelligent behavior though really all that's being done is work with artificial neural networks where every cell is a very easy processor and the go

Write a short note on pointer operators in c Pointers (that is, pointer values) are generated with the ''address-of'' operator &, which we can also think of as the ''pointer-to

1. Figure 1 below shows the truth table for five different functions. Each truth table shows the inputs x1, x2 and the desired output d. (a) Write down which of these functions

What is PBO and PAI events? PBO- Process before Output-It verifies the flow logic before displaying the screen. PAI- Process after Input-It verifies the flowlogic after

Discuss about OS as system software? OS is a large program or actually a collection of routines that is used to control the sharing of and interaction between various computer

What is SEGMENT - Assembler directives SEGMENT:  This directive defines to assembler the start of a segment with name segment-name.  Segment name must be unique and follows the

Find the minimum SOP and POS expression for the following functions using Karnaugh Map and realize the expression using appropriate gates. Also realize SOP form using NAND-to-NAND

'On many systems, you can describe a function matherr which will be known as when there are certain floating-point errors, like errors in the math routines in .

According to the report, network 1 and network 2 are not able to reach network 3. As shown on OTBNetwork Topology above, OTB Inc. has 2 routing protocols running due transition iss

Explain the Architectural description languages Architectural description languages (ACLs) have been developed for the architectural description in analysis and design process