Question

(a) Describe the working principles of Prolog. (b) Explain the principle of separating knowledge and inference...

(a) Describe the working principles of Prolog. (b) Explain the principle of separating knowledge and inference by using Prolog. 2.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a) Describe the working principles of Prolog.

Ans -

Prolog is a logic programming language. It has a very crucial role in artificial intelligence. Unlike many other programming languages, Prolog is intended primarily as a declarative programming language. In prolog, logic is expressed as relations (called as Facts and Rules). Core heart of prolog lies at the logic being applied. Formulation or Computation is carried out by running a query over these relations.

Basic working principals of prolog

1. Resolution

2. Backtracking

3. Generate and Test

4. The Debugger

1.Resolution

Prolog’s execution mechanism is based on resolution, Actual execution strategy is more efficient than this presentation — more like the way conventional languages are implemented

This description leaves off how unification works This is only a rough sketch

The Basic Algorithm

1. Start with a query g 1, g 2, g 3,... and empty stack

2. If the query is empty, terminate succeeding; otherwise, choose the first goal from the query

3. If no program clause matches the chosen goal, then:

4. If the stack is empty, terminate failing; otherwise, pop the query and clause from the stack and return to 3

5. Otherwise: choose the first clause whose head matches the chosen goal; push query and next clause on a stack

6. Replace the first goal with the body of the chosen clause at the front of the query and return to 2

2.Backtracking

Nondeterminism describes a computation that may have more than one result, for example ?- parent(diana, X).

Support for nondeterminism is an important feature of Prolog

Prolog handles nondeterminism by backtracking — undoing all work done since a tentative choice was made so an alternative choice can be tried

Backtracking is performed in steps 3 and 4 when multiple clauses matched a selected goal, and later a goal fails

3.Generate and Test

This example shows that the two calls to member behave very differently: First call member(Z, [a,b]) successively generates elements of the list [a,b] Second call member(Z, [b,c]) tests the solutions generated by the first call This is because when the first call is made, Z is unbound, but when the second call is made, Z is bound

generate and test is a simple but powerful technique for solving compound constraints
The bound/unbound state of the arguments of a predicate invocation is called its mode

4. The Debugger

Understanding choice points and backtracking is essential to understanding Prolog code; debugger is a good way

The Byrd box model can be visualized:

call exit fail redo

Call port initial entry to the goal

Exit port successful completion of the goal

Redo port backtracking into the goal

Fail port final failure of the goal

Debugger turned on by trace, and off with nodebug.

(b) Explain the principle of separating knowledge and inference by using Prolog.

A rule can be viewed as an extension of a fact with added conditions that also have to be satisfied for it to be true. It consists of two parts. The first part is similar to a fact (a predicate with arguments). The second part consists of other clauses (facts or rules which are separated by commas) which must all be true for the rule itself to be true. These two parts are separated by ":-". You may interpret this operator as "if" in English

father(jack, susan).                             /* Fact 1 */
father(jack, ray).                               /* Fact 2 */
father(david, liza).                             /* Fact 3 */
father(david, john).                             /* Fact 4 */
father(john, peter).                             /* Fact 5 */
father(john, mary).                              /* Fact 6 */
mother(karen, susan).                            /* Fact 7 */
mother(karen, ray).                              /* Fact 8 */
mother(amy, liza).                               /* Fact 9 */
mother(amy, john).                               /* Fact 10 */
mother(susan, peter).                            /* Fact 11 */
mother(susan, mary).                             /* Fact 12 */

parent(X, Y) :- father(X, Y). /* Rule 1 */
parent(X, Y) :- mother(X, Y). /* Rule 2 */
grandfather(X, Y) :- father(X, Z), parent(Z, Y). / * Rule 3 */
grandmother(X, Y) :- mother(X, Z), parent(Z, Y). /* Rule 4 */
grandparent(X, Y) :- parent(X, Z), parent(Z, Y). /* Rule 5 */
yeye(X, Y) :- father(X, Z), father(Z, Y). /* Rule 6 */
mama(X, Y) :- mother(X, Z), father(Z, Y). /* Rule 7 */
gunggung(X, Y) :- father(X, Z), mother(Z, Y). /* Rule 8 */
popo(X, Y) :- mother(X, Z), mother(Z, Y). /* Rule 9 */
A program describes the relationships of the members in a family
Add a comment
Know the answer?
Add Answer to:
(a) Describe the working principles of Prolog. (b) Explain the principle of separating knowledge and inference...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT