Declarative languages questions and answers
Questions
Q1. What are the characteristics of a declarative language?
Q2. Define a ‘fifth generation language’.
Q3. What is an ‘expert system’?
Q4. What are the four components of an expert system?
Q5. Describe how a mechanic would use a car diagnostic expert system to find an engine fault.
Q6. Why should expert systems be regularly updated?
Q7. What is a ‘predicate’?
Q8. Describe with an example what instantiation means.
Q9. Describe what is meant by backtracking.
Q10. Draw a proof tree to demonstrate your understanding of backtracking.
Answers
Q1. With declarative languages, you state a list of facts and a list of rules that tell the computer how the facts are related. When you want to run a program, you simply state a goal, what you want to find out. The program then starts at the beginning and searches through its facts using the rules in the program. It will follow a route through the facts until it finds the answer to the query. As the program threads through the facts in the program, however, it may come to a dead-end. If this happens, the program simply backtracks and tries to find another route that will lead to the answer. It doesn’t actually matter in what order the facts in the program are stated or indeed the rules.
Q2. A fifth generation language is one which has a knowledge base made up of facts and the rules that relate those facts. The knowledge base can then be queried. The user would state goals and input data, and the facts in the knowledge base are then searched using the relationships defined by the rules. The facts are gradually ‘filtered’ until just a few facts remain. These can then be displayed to the user.
Q3. An expert system is a computer application which employs artificial intelligence techniques to mimic a specific area of human expertise and knowledge.
Q4. The four components of an expert system are the knowledge base, the rule base, the inference engine and the user interface.
Q5. Mechanics use expert systems to diagnose engine faults in modern cars. They can connect the engine’s computer into an expert system, which then runs a series of tests. The expert system’s knowledge base is searched by applying a set of rules. It then displays or prints out a number of options for the cause of a particular problem. It may also display the chance that each potential cause is the main culprit and what actions to take to solve the problem.
Q6. Expert systems can become out-of-date as new knowledge becomes available or new relationships between existing knowledge emerge from experience. It is therefore important that their knowledge and rule bases are kept up-to-date.
Q7. A predicate is the name given to a particular rule in a declarative language.
Q8. Instantiation is when you find a match for a particular rule. If you search for male(A) in a cats program, then the goal for PROLOG is to find all instances of male. PROLOG searches its facts and finds ‘patch’. We say that A is instantiated to patch.
Q9. Backtracking is where a declarative programs returns to search a different set of facts in a different path after it fails to find a match for a rule or part of a rule.
Q10. An example of a backtracking diagram is as follows: