Search mechanisms in prolog - artificial intelligence, Computer Engineering

Assignment Help:

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

first_name(tony,tonyblair).

first_name(georgedubya,georgebush).

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.


Related Discussions:- Search mechanisms in prolog - artificial intelligence

What is check box, A dialog box, generally square, that records an on or of...

A dialog box, generally square, that records an on or off value.

Unlike ipv4 & ipv6 which field in base header not include, Unlike Ipv4, Ipv...

Unlike Ipv4, Ipv6 does not include which field in the base header? Unlike Ipv4, Ipv6 does not contain the Field for Fragmentation information into the base header.

What is meant by branch instruction, What is meant by branch instruction? ...

What is meant by branch instruction? A branch instruction is an instruction which changes the contents of the PC with the branch target address. This address is usually get by

Write 8086 initialisation routine required to program 8255, Write 8086 init...

Write 8086 initialisation routine required to program 8255 for mode 1 with Port A and Port B as output Ports and Port C as an input port. Indicate all the relevant signals.

Can you explain about internet protocol, Q. Can you explain about Internet ...

Q. Can you explain about Internet Protocol? Internet protocol specifies the rules which define the details of how computers communicate. It specifies exactly how a packet shoul

Illustrate the accumulator architecture, Accumulator Architecture: An accu...

Accumulator Architecture: An accumulator is anespecially designated register which supplies one instruction operand and receives result. Instructions in such machines are usually

Balanced trees and their operations, what is ment by avl tree n insertion n...

what is ment by avl tree n insertion n deletion ,2-3 tress insertion n deletion

Illustrate character coded data, Q. Illustrate Character Coded Data? Th...

Q. Illustrate Character Coded Data? The input output happens in the form of ASCII data. These ASCII characters are entered as a string of data. For illustration to get two numb

What are the input for uml development, What are the Input for UML developm...

What are the Input for UML development UML is an attempt to standardize artefacts of analysis and design consisting of semantic models, diagrams and syntactic notations. The fi

What will be the result of adding hexadecimal A6 to 3A, The result of addin...

The result of adding hexadecimal number A6 to 3A is ? Ans. The result will be E0.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd