John Stannard on the first free ascent of Foops 1967. Published by,5861 Greentree Road,Lebanon OH 45036 U S A. phone 1 513 425 8050,fax 1 513 425 8025,e mail info amzi com. web www amzi com,Book Edition Copyright 1989 by Springer Verlag. On line Edition Copyright 2000 by Amzi inc All Rights Reserved. This document Work is protected by copyright laws and international copyright treaties as well as other intellectual. property laws and treaties You may use and distribute copies of this Work provided each copy of the Work is a true and. complete copy including all copyright and trademark notices and each copy is accompanied by a copy of this notice. You may not distribute copies of this Work for profit either on a standalone basis or included as part of your own. product or work without written permission from Amzi You may not charge any fees for copies of this work including. media or download fees You may not include this Work as part of your own works You may not rename edit or create. any derivative works from this Work Contact Amzi for additional licensing arrangements. Amzi is a registered trademark and Logic Server Active Prolog Tutor Adventure in Prolog and the flying squirrel logo. are trademarks of Amzi inc,Last Updated August 2000. PDF version March 2001 edited designed and compiled by Daniel L Dudley daniel dudley chello no. When I compare the books on expert systems in my library with the production expert systems I know of I note that. there are few good books on building expert systems in Prolog Of course the set of actual production systems is a little. small for a valid statistical sample at least at the time and place of this writing here in Germany and in the first days. of 1989 But there are at least some systems I have seen running in real life commercial and industrial environments. and not only at trade shows, I can observe the most impressive one in my immediate neighborhood It is installed in the Telephone Shop of the. German Federal PTT near the Munich National Theater and helps configure telephone systems and small PBXs for. mostly private customers It has a neat graphical interface and constructs and prices an individual telephone. installation interactively before the very eyes of the customer. The hidden features of the system are even more impressive It is part of an expert system network with a distributed. knowledge base that will grow to about 150 installations in every Telephone Shop throughout Germany Each of them. can be updated individually overnight via Teletex to present special offers or to adapt the selection process to the. hardware supplies currently available at the local warehouses. Another of these industrial systems supervises and controls in soft real time the excavators currently used in Tokyo. for subway construction It was developed on a Unix workstation and downloaded to a single board computer using a. real time operating system The production computer runs exactly the same Prolog implementation that was used for. programming too, And there are two or three other systems that are perhaps not as showy but do useful work for real applications such as. oil drilling in the North Sea or estimating the risks of life insurance for one of the largest insurance companies in the. world What all these systems have in common is their implementation language Prolog and they run on real life. computers like Unix workstations or minis like VAXs Certainly this is one reason for the preference of Prolog in. commercial applications, But there is one other probably even more important advantage Prolog is a programmer s and software engineer s. dream It is compact highly readable and arguably the most structured language of them all Not only has it done. away with virtually all control flow statements but even explicit variable assignment too. These virtues are certainly reason enough to base not only systems but textbooks on this language Dennis Merritt has. done this in an admirable manner He explains the basic principles as well as the specialized knowledge representation. and processing techniques that are indispensable for the implementation of industrial software such as those mentioned. above This is important because the foremost reason for the relative neglect of Prolog in expert system literature is. probably the prejudice that it can be used only for backward chaining rules Nothing is farther from the truth Its. relational data base model and its underlying unification mechanism adapt easily and naturally to virtually any. programming paradigm one cares to use Merritt shows how this works using a copious variety of examples His book. will certainly be of particular value for the professional developer of industrial knowledge based applications as well as. for the student or programmer interested in learning about or building expert systems I am therefore happy to have. served as his editor,Peter H Schnupp,Munich January 1989. Building Expert Systems in Prolog iii,Acknowledgements. A number of people have helped make this book possible They include Dave Litwack and Bill Linn of Cullinet who. provided the opportunity and encouragement to explore these ideas Further thanks goes to Park Gerald and the Boston. Computer Society sounding boards for many of the programs in the book Without the excellent Prolog products from. Cogent now Amzi AAIS Arity and Logic Programming Associates none of the code would have been developed A. special thanks goes to Peter Gable and Paul Weiss of Arity for their early help and Allan Littleford provider of both. Cogent Prolog and feedback on the book Jim Humphreys of Suffolk University gave the most careful reading of the. book and advice based on years of experience As have many other Mac converts I feel compelled to mention my. Macintosh SE Microsoft Word and Cricket Draw for creating an enjoyable environment for writing books And finally. without both the technical and emotional support of Mary Kroening the book would not have been started or finished. Table of Contents,Preface iii,Acknowledgements iv,1 Introduction 1. 1 1 Expert Systems 1,1 2 Expert System Features 3,Goal Driven Reasoning 3. Uncertainty 4,Data Driven Reasoning 4,Data Representation 5. User Interface 6,Explanations 7,1 3 Sample Applications 7. 1 4 Prolog 8,1 5 Assumptions 8,2 Using Prolog s Inference Engine 9. 2 1 The Bird Identification System 9,Rule formats 9. Rules about birds 10,Rules for hierarchical relationships 10. Rules for other relationships 11,2 2 User Interface 13. Attribute Value pairs 13,Asking the user 13,Remembering the answer 14. Multi valued answers 14,Menus for the user 15,Other enhancements 16. 2 3 A Simple Shell 16,Command loop 17,A tool for non programmers 19. 2 4 Summary 19,Exercises 19,3 Backward Chaining with Uncertainty 21. 3 1 Certainty Factors 21,An Example 21,Rule Uncertainty 22. User Uncertainty 22,Combining Certainties 23,Properties of Certainty Factors 23. 3 2 MYCINs Certainty Factors 24,Determining Premise CF 24. Building Expert Systems in Prolog v,Combining Premise CF and Conclusion CF 24. Premise Threshold CF 25,Combining CFs 25,3 3 Rule Format 26. 3 4 The Inference Engine 27,Working Storage 27,Find a Value for an Attribute 27. Attribute Value Already Known 28,Ask User for Attribute Value 28. Deduce Attribute Value from Rules 28,Negation 30,3 5 Making the Shell 30. Starting the Inference 31,3 6 English like Rules 32. Exercises 33,4 Explanation 35,Value of Explanations to the User 35. Value of Explanations to the Developer 35,Types of Explanation 36. 4 1 Explanation in Clam 36,Tracing 38,How Explanations 39. Why Questions 41,4 2 Native Prolog Systems 43,Exercises 46. 5 Forward Chaining 47,5 1 Production Systems 47,5 2 Using Oops 48. 5 3 Implementation 52,5 4 Explanations for Oops 56. 5 5 Enhancements 56,5 6 Rule Selection 57,Generating the conflict set 57. Time stamps 58,5 7 LEX 58,Changes in the Rules 59,Implementing LEX 59. 5 8 MEA 61,Exercises 62,6 Frames 65,6 1 The Code 66. 6 2 Data Structure 66,vi Table of Contents,6 3 The Manipulation Predicates 68. 6 4 Using Frames 74,6 5 Summary 75,Exercises 75,7 Integration 77. 7 1 Foops Frames and Oops 77,Instances 77,Rules for frinsts 79. Adding Prolog to Foops 80,7 2 Room Configuration 81. Furniture frames 82,Frame Demons 83,Initial Data 84. Input Data 85,The Rules 86,Output Data 89,7 3 A Sample Run 90. 7 4 Summary 91,Exercises 91,8 Performance 93,8 1 Backward Chaining Indexes 93. 8 2 Rete Match Algorithm 94,Network Nodes 95,Network Propagation 96. Example of Network Propagation 97,Performance Improvements 99. 8 3 The Rete Graph Data Structures 100,8 4 Propagating Tokens 101. 8 5 The Rule Compiler 103,8 6 Integration with Foops 108. 8 7 Design Tradeoffs 109,Exercises 109,9 User Interface 111. 9 1 Object Oriented Window Interface 111,9 2 Developer s Interface to Windows 111. 9 3 High Level Window Implementation 114,Message Passing 115. Inheritance 115,9 4 Low Level Window Implementation 117. Exercises 120,Building Expert Systems in Prolog vii. 10 Two Hybrids 121,10 1 CVGEN 121,10 2 The Knowledge Base 122. Rule for parameters 122,Rules for derived information 123. Questions for the user 124,Default rules 124,Rules for edits 125. Static information 125,10 3 Inference Engine 126,10 4 Explanations 127. 10 5 Environment 128,10 6 AIJMP 129,10 7 Summary 130. Exercises 130,11 Prototyping 131,11 1 The Problem 131. 11 2 The Sales Advisor Knowledge Base 131,Qualifying 132. Objectives Benefits Features 132,Situation Analysis 133. Competitive Analysis 133,Miscellaneous Advice 134,User Queries 134. 11 3 The Inference Engine 135,11 4 User Interface 136. 11 5 Summary 138,Exercises 138,12 Rubik s Cube 139. 12 1 The Problem 139,12 2 The Cube 140,12 3 Rotation 142. 12 4 High Level Rules 142,12 5 Improving the State 143. 12 6 The Search 144,12 7 More Heuristics 145,12 8 User Interface 145. 12 9 On the Limits of Machines 146,Exercises 146,viii Table of Contents. Appendices Full Source Code 147,A Native 149,Birds Knowledgebase birds nkb 149. Native Shell native pro 153,B Clam 157,Car Knowledgebase car ckb 157. Birds Knowledgebase birds ckb 158,Clam Shell clam pro 163. Build Rules bldrules pro 176,C Oops 179,Room Knowledgebase room okb 179. Animal Knowledgebase animal okb 184,Oops Interpreter oops pro 187. D Foops 193,Room Knowledgebase room fkb 193,Foops foops pro 200. E Rete Foops 211,Room Knowledgebase room rkb 211,Rete Compiler retepred pro 218. Rete Runtime retefoop pro 225,F Windows 239,Windows Demonstration windemo pro 239. Windows windows pro 243,G Rubik 273,Cube Solver rubik pro 273. Cube Display rubdisp pro 286,Cube Entry rubedit pro 289. Move History rubhist pro 291,Moves and Rotations rubmov pro 293. Rubik Help rubhelp pro 296,Rubik Data rubdata pro 297. Building Expert Systems in Prolog ix,1 Introduction. Over the past several years there have been many implementations of expert systems using. various tools and various hardware platforms from powerful LISP machine workstations. to smaller personal computers, The technology has left the confines of the academic world and has spread through many. commercial institutions People wanting to explore the technology and experiment with it. have a bewildering selection of tools from which to choose There continues to be a debate. as to whether or not it is best to write expert systems using a high level shell an AI. language such as LISP or Prolog or a conventional language such as C. This book is designed to teach you how to build expert systems from the inside out It. presents the various features used in expert systems shows how to implement them in. Prolog and how to use them to solve problems, The code presented in this book is a foundation from which many types of expert systems. can be built It can be modified and tuned for particular applications It can be used for. rapid prototyping It can be used as an educational laboratory for experimenting with. expert system concepts,1 1 Expert Systems, Expert systems are computer applications which embody some non algorithmic expertise. for solving certain types of problems For example expert systems are used in diagnostic. applications servicing both people and machinery They also play chess make financial. planning decisions configure computers monitor real time systems underwrite insurance. policies and perform many other services which previously required human expertise. Expert User,expertise User,Knowledge Inference System. Engineer Engine Engineer,encoded Knowledge Working. expertise Base Storage, Figure 1 1 Expert system components and human interfaces. Expert systems have a number of major system components and interface with individuals. in various roles These are illustrated in figure 1 1 The major components are. Building Expert Systems in Prolog 1, Knowledge base a declarative representation of the expertise often in IF THEN. Working storage the data that is specific to a problem being solved. Inference engine the code at the core of the system which derives recommendations. from the knowledge base and problem specific data in working storage. User interface the code that controls the dialog between the user and the system. To understand expert system design it is also necessary to understand the major roles of. individuals who interact with the system These are. Domain expert the individual or individuals who currently are experts solving the. problems the system is intended to solve, Knowledge engineer the individual who encodes the expert s knowledge in a. declarative form that can be used by the expert system. User the individual who will be consulting with the system to get advice that would. have been provided by the domain expert, Many expert systems are built with products called expert system shells The shell is a. piece of software which contains the user interface a format for declarative knowledge in. the knowledge base and an inference engine The knowledge engineer uses the shell to. build a system for a particular problem domain, Expert systems are also built with shells that are custom developed for particular. applications In this case there is another key individual. System engineer the individual who builds the user interface designs the declarative. format of the knowledge base and implements the inference engine. Depending on the size of the project the knowledge engineer and the system engineer. might be the same person For a custom built system the design of the format of the. knowledge base and the coding of the domain knowledge are closely related The format. has a significant effect on the coding of the knowledge. One of the major bottlenecks in building expert systems is the knowledge engineering. process The coding of the expertise into the declarative rule format can be a difficult and. tedious task One major advantage of a customized shell is that the format of the. knowledge base can be designed to facilitate the knowledge engineering process. The objective of this design process is to reduce the semantic gap Semantic gap refers to. the difference between the natural representation of some knowledge and the. programmatic representation of that knowledge For example compare the semantic gap. between a mathematical formula and its representation in both assembler and FORTRAN. FORTRAN code for formulas has a smaller semantic gap and is therefore easier to work. Since the major bottleneck in expert system development is the building of the knowledge. base it stands to reason that the semantic gap between the expert s representation of the. knowledge and the representation in the knowledge base should be minimized With a. customized system the system engineer can implement a knowledge base whose structures. are as close as possible to those used by the domain expert. This book concentrates primarily on the techniques used by the system engineer and. knowledge engineer to design customized systems It explains the various types of. inference engines and knowledge bases that can be designed and how to build and use. 2 Chapter 1 Introduction, them It tells how they can be mixed together for some problems and customized to meet. the needs of a given application,1 2 Expert System Features. There are a number of features which are commonly used in expert systems Some shells. provide most of these features and others just a few Customized shells provide the. features which are best suited for the particular problem The major features covered in. this book are, Goal driven reasoning or backward chaining an inference technique which uses IF. THEN rules to repetitively break a goal into smaller sub goals which are easier to. Coping with uncertainty the ability of the system to reason with rules and data that. are not precisely known, Data driven reasoning or forward chaining an inference technique that uses IF. THEN rules to deduce a problem solution from initial data. Data representation the way in which the problem specific data in the system is. stored and accessed, User interface that portion of the code that creates an easy to use system. Explanations the ability of the system to explain the reasoning process that it used to. reach a recommendation,Goal Driven Reasoning, Goal driven reasoning or backward chaining is an efficient way to solve problems that. can be modelled as structured selection problems That is the aim of the system is to. pick the best choice from many enumerated possibilities For example an identification. problem falls in this category Diagnostic systems also fit this model since the aim of the. system is to pick the correct diagnosis, The knowledge is structured in rules which describe how each of the possibilities might. be selected The rule breaks the problem into sub problems For example the following. top level rules are in a system which identifies birds. family is albatross and,color is white,bird is laysan albatross. family is albatross and,color is dark,bird is black footed albatross. The system would try all of the rules which gave information satisfying the goal of. identifying the bird Each would trigger sub goals In the case of these two rules the sub. goals of determining the family and the color would be pursued The following rule is one. that satisfies the family sub goal,order is tubenose and. size large and,wings long narrow,Building Expert Systems in Prolog 3. family is albatross, The sub goals of determining color size and wings would be satisfied by asking the user. By having the lowest level sub goal satisfied or denied by the user the system effectively. carries on a dialog with the user The user sees the system asking questions and responding. to answers as it attempts to find the rule which correctly identifies the bird. Uncertainty, Often in structured selection problems the final answer is not known with complete. certainty The expert s rules might be vague and the user might be unsure of answers to. questions This can be easily seen in medical diagnostic systems where the expert is not. able to be definite about the relationship between symptoms and diseases In fact the. doctor might offer multiple possible diagnoses, For expert systems to work in the real world they must also be able to deal with. uncertainty One of the simplest schemes is to associate a numeric value with each piece of. information in the system The numeric value represents the certainty with which the. information is known There are numerous ways in which these numbers can be defined. and how they are combined during the inference process. Data Driven Reasoning, For many problems it is not possible to enumerate all of the possible answers beforehand. and have the system select the correct one For example system configuration problems. fall in this category These systems might put components in a computer design circuit. boards or lay out office space Since the inputs vary and can be combined in an almost. infinite number of ways the goal driven approach will not work. The data driven approach or forward chaining uses rules similar to those used for. backward chaining However the inference process is different The system keeps track. of the current state of problem solution and looks for rules which will move that state. closer to a final solution, A system to layout living room furniture would begin with a problem state consisting of a. number of unplaced pieces of furniture Various rules would be responsible for placing the. furniture in the room thus changing the problem state When all of the furniture was. placed the system would be finished and the output would be the final state Here is a rule. from such a system which places the television opposite the couch. unplaced tv and,couch on wall X and,wall Y opposite wall X. place tv on wall Y, This rule would take a problem state with an unplaced television and transform it to a state. that had the television placed on the opposite wall from the couch Since the television is. now placed this rule will not fire again Other rules for other furniture will fire until the. furniture arrangement task is finished, Note that for a data driven system the system must be initially populated with data in. contrast to the goal driven system which gathers data as it needs it Figure 1 2 illustrates. the difference between forward and backward chaining systems for two simplified rules. The forward chaining system starts with the data of a 1 and b 2 and uses the rules to. 4 Chapter 1 Introduction, derive d 4 The backward chaining system starts with the goal of finding a value for d and. uses the two rules to reduce that to the problem of finding values for a and b. Forward Chaining,Data Rules Conclusion,IF a 1 b 2 THEN C 3 IF C 3 THEN d 4 d 4. Backward Chaining,Subgoals Rules Goal,IF a 1 b 2 THEN C 3 IF C 3 THEN d 4 d 4. Figure 1 2 Difference between forward and backward chaining. Data Representation, For all rule based systems the rules refer to data The data representation can be simple or. complex depending on the problem The four levels described in this section are. illustrated in figure 1 3,Attribute Value Pairs,color white. Object Attribute Value Triples,arm chair width 3,straight chair width 2. object width color type,chair 1 3 orange easy,chair 2 2 brown straight. fur default 4,elephant monkey,size tusks type tail size legs. large default 2 constraint curly medium 2,Figure 1 3 Four levels of data representation.
IDE Project Management and Building Guide for MSP430 Reference information, which gives reference information related to the topic area. Read this section for information about certain GUI components. You can easily access this type of information for a certain component in the IDE by pressing F1.
CPE 323: Laboratory Assignment #1 Getting Started with the MSP430 IAR Embedded Workbench by Alex Milenkovich, email@example.com Objectives: This tutorial will help you get started with the MSP30 IAR Embedded Workbench
programming phase, thus still increasing development costs. In the last years there has been an increase in the num-ber of middlewares and frameworks (see further) which try to face the problem of ful llment and optimization of 3D dynamic virtual environments in order to solve the techni-cal requirements of complex videogames. The framework we
kooperatif tipe Snowball Drilling dapat meningkatkan pemahaman konsep proses pembentukan tanah pada pembelajaran IPA siswa kelas V SD Negeri Wonotoro, Sambi, Boyolali tahun ajaran 2012/2013. Kata kunci: Pemahaman konsep, proses pembentukan tanah, Snowball Drilling. Ilmu Pengetahuan Alam (IPA) adalah pengetahuan yang mempelajari alam semesta
Welcome to the GameGuru Loader user guide. GameGuru Loader is an easy way to convert and optimise your GameGuru Level creations into high quality, multi-platform ready, media and code that is compatible with the AppGameKit programming language, allowing for speedy development of immersive 3D environments and games.
The purpose of these game-motivated programming exercises is to weave a social fabric into the programming process. The idea is to emphasize both individual and group performance. Such an idea has recently been the focus in the development of software tools for on-line project management systems at companies such as IBM.
Level 3 Certi? cate in Customer Service Sample Test Paper Improving customer service 13. Making special customer service arrangements, giving offers for repeat business, running a points programme and early noti? cation to customers of special offers are best described as examples of: Sales promotion exercises. Providing information to ...
Level 3 Certificate in Principles of Recruitment Practice or the Level 3 Certificate in Recruitment Practice. Level 3 NVQ Diploma in Recruitment. The apprentice will complete Level 2 English and Maths (if not already achieved). 4. Assessment Gateway For the apprentice to progress to the End Point Assessment (EPA), the