(a) Describe the working principles of Prolog. (b) Explain the principle of separating knowledge and inference by using Prolog. 2.
(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 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 |
(a) Describe the working principles of Prolog. (b) Explain the principle of separating knowledge and inference...
Question 2 (a) Explain the Gestalt Principles. (b) Determine any FOUR (4) of the Gestalt Principles and describe on each of these principle with relevant diagrams.
List and describe (briefly) the AICPA 6 Ethical Principles : (25 pts) Principle Description 1- 2- 3- 4- 5- 6-
3. Describe the working principle of DC motor. Draw the figure and explain? Problem-3: Calculate magnetic moment (H) through a square loop of each side 12 cm carrying current 100 A?
Explain in details the principles of a) Working stress theory b) Limit state theory
A- List and describe (briefly) the AICPA 6 Ethical Principles : (25 pts) Principle Description 1- 2- 3- 4- 5- 6-
1. Explain two reasons why it is important to have a working knowledge of DFDs and flowcharting. 2. What does the Sarbanes-Oxley Act require that is relevant to documentation tools? 3. Describe a situation in which data flow should be shown with two data flow lines instead of one. 4. Describe the different levels of DFDs.
4. [201 Use Prolog (e.g., SWI-Prolog) to create a knowledge base for the family tree of Figure 1 and then ask queries about the family tree. Assume the intended interpretation of all predicates of the form p(x.y) is that "x is the p of y" George eMum r-Kydd Elizabeth Philip Margaret Diana-Charles Anne-Mark Andrew Sarah E William Harry Peter Zara Beatrice Eugenie Figure 1. A typical family tree. The symbol-connects spouses and arrows point to children. Enter the information from...
State Archimedes' principle. 2. Explain the working principle of a hydrometer. 3.Why is the apparent loss of weight of the wooden cylinder larger than its weight in air? 4.Draw a neat diagram showing the forces acting on a solid immersed in a fluid
QUESTION 2 a) Define solar thermal energy and explain the working principle of Active water heating system with neat sketch. (5 marks) b) Explain how hot water is produced in Evacuated Tube Collector (5 marks) c) Explain the working principle of Photo Voltaic cells in generating electrical energy. (5 marks) d) To obtain high amount of solar energy from PV panel, what are the key factors to be considered (5 marks)
Slide 8 chapter 01: Accounting in Business Explain generally accepted accounting principles and define and apply several accounting principles Knowledge Check 03 Before we move on, quiz yourself to test your understanding Question 1 of 2 The private-sector organization that is primarily responsible for developing GAAP for use by all U.S. companies is the: O SEC O IASB O FASB O IFRS submit answer& continue Slide 9 chapter 01: Accounting in Business Explain generally accepted accounting principles and define and...