Search mechanisms in prolog - artificial intelligence, Computer Engineering

Search mechanisms in Prolog

We can utilize this simple Prolog program to describe how Prolog searches:

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).



second_name(tonyblair, blair).

second_name(georgebush, bush).

If we loaded this into a Prolog implementation likeSicstus, and queried the database:

?- prime_minister(P).

then in the following mannerSicstus would search: it would run through it's database until it came across a Horn clause (or fact) for which the head was prime_minister and the arity of the predicate was 1. It would first search at the president clause and reject this because the name of the head does not match with the head in the query. Next it would find that the clause, through:

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

fits the bill. It would then lookin the body of the clause at the predicates and see if it could satisfy them. In this instance, it would try to find a match for first_nameX, maggie). However, it would fail, because no this type of information may be found in the database. That means that the total clause fails, and Sicstus would backtrack, for example, it would go back to looking for a clause with the same head as the query. Of course, it would next find this clause:

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

Then it would look at the body again, and try to discover a match for first_name(X, tony). It would look through the database and   discover   X=tonyblaira  good  assignment,   because  the   factfirst_name(tonyblair, tony) is got towards the end of the database. Similarly, having assigned X=tonyblair, then it would search for a match to: second_name(tonyblair, blair), and would succeed. So, the answer tonyblair would make the query succeed, and this would be reported back to us.

The essential thing to remember is that Prolog implementations search from the top to the bottom of the database, and in the body try each term of a clause in the order in which they appear. We say that Sicstus  has  verified  the  query  prime_minister(P) by  finding  something  which  satisfied  the declaration of what a prime minister is: Tony Blair. It is also good to remembering that Sicstus assumes negation as failure. This means that if it cannot verify a predicate, then the predicate is false. So the query is:

?- \+ president(tonyblair).

Returns an answer of 'true', because Sicstus cannot prove that Tony Blair is a president.

Posted Date: 10/2/2012 7:19:04 AM | Location : United States

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

Write discussion on Search mechanisms in prolog - artificial intelligence
Your posts are moderated
Related Questions
E-commerce is one of the most significant aspects of the internet. Having emerged recently and growing at a steady state, it becomes essential to look at the advantages and disadva

Concept of Multithreading: These troubles increase in the design of large-scale multiprocessors such as MPP as discussed above. Thus, a solution for optimizing this latency should

The number and nature of registers is a major factor which distinguishes among computers. For illustration, Intel Pentium has about 32 registers. A number of these registers are sp

Q. How can we design Radio Button? Radio buttons are used when only one out of group of options is to be chosen. In the illustration code we have put a line break after every b

System Analysis & Design 1. Describe attributes, properties, and characteristics of system. 2. What do you mean by Organizational Aspects of System Life Cycles? Explain.

Summary of Tasks Task Summary attempts to show amount of duration every task has spent starting from beginning of task until its completion on any processor as displayed in Fi

Q. Explain about Hexadecimal Numbers system? Hexadecimal system has 16 digits that are represented as 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. A number (F2) H is equivalent to

Like ULINE the statement VLINE is used to insert vertical lines. No , Vline is not used to insert vertical lines.

State in brief about the proxy server A proxy server also helps a lot since it hides the real IP addresses of users requesting resources outside the firewall. Finally, the

Multiple Instruction and Multiple Data stream (MIMD) In this association, multiple control units and multiple processing elements are prepared as in MISD. But the discrepancy i