Search mechanisms in prolog, Computer Engineering

Assignment Help:

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.


Related Discussions:- Search mechanisms in prolog

Over fitting considerations, Over fitting Considerations : Hence in le...

Over fitting Considerations : Hence in left unchecked there backpropagation in multi-layer networks can be highly susceptible to overfitting itself to the training examples. B

Design a circuit which computes the square of a number, Design a circuit wh...

Design a circuit which computes the square of a number? This should not make use of any multiplier circuits. This should use Multiplexers and some other logic as: 1^2=0+1=1

Sigmoid units-artificial intelligence, Sigmoid units - Artificial intellige...

Sigmoid units - Artificial intelligence Remember that the function inside units take as input the weighted sum, S, of the values coming from the units associated to it. The fun

Explain about the logical devices, Explain about the Logical Devices ...

Explain about the Logical Devices Locator, to indicate a position and/or orientation Pick, to select a displayed entity To input a single value in the space of re

What is basic working of modem, Q. What is basic working of Modem? A mo...

Q. What is basic working of Modem? A modem (modulator/demodulator) is an electronic device that takes digital data as a serial stream of bits and produces a modulated carrier s

Performance equation of computer system, Performance Equation of computer s...

Performance Equation of computer system: Following equation is frequently used for expressing a computer's performance ability: The CISC approach tries to minimize the

Fundamental types of flash memory, Q. Fundamental types of flash memory? ...

Q. Fundamental types of flash memory? Code Storage Flash which is made by Intel, AMD, Atmel. It stores programming algorithms and it is largely found in cell phones. Data

Computer Graphics, Distinguish between uniform scaling differential scaling...

Distinguish between uniform scaling differential scaling

Flynn’s classification, Flynn's Classification Flynn's classification i...

Flynn's Classification Flynn's classification is based on multiplicity of data streams and instruction streams observed by the CPU during program execution. Let Ds and Is  are

How do you get workflow automation in e-business environment, How do you ge...

How do you get workflow automation into e-business environment? In order to run smoothly, organizations frequently standardize processes across the organization and support use

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