Koyal – A Multi-purpose Expert System – MD-CoB-CoA Knowledge Representation Using PROLOG in J2SE Prof.Sreedhar Babu Department of Electrical Engineering Amrita Viswa Vidyapeetham Amritapuri, Kerala [email protected] Archana, Vineeth & Veena Department of Computer Science & Applications Amrita Viswa Vidyapeetham Amritapuri, Kerala [email protected]
com Abstract— Expert systems are AI? s greatest commercial success. It is a research-oriented application area of AI. An expert system uses knowledge specific to a problem domain to provide “expert quality” performance.
Predicate logic is being used for knowledge representation which is further programmed using PROLOG inference engine for deriving intelligent conclusions. The current research paper introduces a rule-based expert system that provides a medical diagnosis for determining the health problems and classification of birds and animals. The user has to have some knowledge about these topics so that he can query the system. Three knowledge bases are provided for each domain. The specialized computer language PROLOG embedded into J2SE is used to develop this system.
Keywords-component: Expert System; Knowledge-base; Medical Diagnosis, Rule-based ES, Knowledge representation PROLOG; J2SE. 1. INTRODUCTION : THE KOYAL EXPERT SYSTEM The current paper of Koyal has mainly two modules: 1. 1. Knowledge Base 1. 2. User Interface 1. 1 Knowledge Base [1 & 2] Mainly, three knowledge bases are required for the system. They are bird? s knowledge base for identifying a bird, animal knowledge base for identifying an animal and a disease knowledge base for medical diagnose. The system uses this knowledge base for finding solutions.
Knowledge is represented in rule-based format. The rule of the system is in the form of: IF first premise and second premise, and ………. THEN conclusion This is semantically same as a Prolog rule: conclusion:first_ premise, second_ premise, ………… Premises are written as attribute-value pair. The attribute is represented as a predicate and the value as the argument to the predicate. Each knowledge base will have to have a high-level goal, which calls the sub goals to be satisfied. When all the premises are satisfied, then the final conclusion is obtained. . 2. User Interface The user interface is the Prolog interpreter? s interface, and the input data is stored directly in the program. It is implemented in Java by loading the prolog inference engine into the java program. The prolog program itself will provide a user interface. The predicate ask and menuask will provide these functions. The ask is responsible is for getting the information from the user and remembering the user? s response. The ask predicate will have to determine from the user whether or not a given attribute-value pair is true.
The ask prompts the user with the requested attribute and value and seeks confirmation or denial of the proposed information. The ask is represented as object-attribute-value triples where the attribute values are tied to various objects in the system. The menuask will further improve the user interface by adding a menu capability which gives the user a list of possible values for an attribute. The main precondition of our Koyal System is that a common user who has no knowledge about the specialized „domain? annot interact with the system and in such a situation the output accuracy will depend on the user inputs. 2. Description of the System Flow The system flow chart represented in the figure 2 displays the flow of the information from one process to another . We can say that it is a detailed representation of the structured chart in the Fig. 2. 1. 2. 1. User The user will enter the text and this text is passed to the inference engine. 2. 2. Inference Engine A rule-based system requires some kind of program to manipulate the rules – for example to decide which ones are ready to fire. (i. . which ones have conditions that match the contents of working memory). The program that does this is called an inference engine, because in many rule-based systems, the task of the system is to infer something from knowledge base. This inference engine will prove or disprove the goal/rules in the knowledge base and used to derive conclusions. e. g. a diagnosis, from the data using the rules. 2. 3. Knowledge base The knowledge base contains rules which describe general knowledge about a particular problem domain. 2. 4. User Interface The User Interface will interact with the user i. e. it will query the user for getting information to satisfy goals inside knowledge base. The predicates ask and menuask works here to gather information from user. 2. 5. Working Memory The working memory of a rule-based system is a store of information used by the system to decide which of the condition-action rules in the knowledge base is able to be fire. It might be used to store intermediate conclusions i. e. the satisfied goals and any other information inferred by the system from the data (using the condition-action rules). Finally the inference engine will infer the working memory more solution. . Knowledge Representation Using PL [4 & 5] Since Predicate Logic is one of the oldest and most important logistical approach for reasoning, primarily developed and used in the area of mathematics by logicians as a means of formal reasoning and now it is vastly being used by the programmers for expert systems for its flexibility of accurate natural language representation, this paper also includes the various methods of knowledge representation supported by Predicate Logic that can be conveniently programmed with the PROLOG programming language.
The major predicates that are being used in the paper include: The following symbols will be used for logical connectives. ~ not or negation & and or conjunction V or or disjunction ? if … then or implication ? If and only if or double implication Valid statements or sentences in PL are determined according to the rules of propositional syntax. For the estimated validity of uncertainties, heuristics based on either fuzzy or neural network or neuro-fuzzy can be implemented.
Let the predicate function B(X) be a bird with a particular name X, then the composite predicate B(X) which needs various functional variables to be satisfied type of family, color, head, voice, flight type, throat, type of food it eats, country, region, tail, size etc.
… Fig. 3. 1 represents the associate network for the classification of birds. For X = albatross, the functional variables are family type, color, size etc. are indicated, i. e. , if N1(F), N3(C) and N9(S) are the predicate functions with variables, family type, color and size of birds etc. , then the w. f. f. (well-formed formulae) can be written as follows, E1: ?
X BIRD(X) E2: B (N1(F) & N2(O) & N4(N) & N5 (L) & N6(Bi) & N9(S) & N10(W) & N3(C) ) E3: B (N1 (albatross) & N2 (tubenose) & N4 (external_tubular) & N5(at_sea) & N6(hooked) & N9(large) & N10(long_narrow) & N3(white) ) E1 > E2 The various predicates for E2 are defined in E3 ? X B(X) > E3 resulting in X = laysan_albatross The various functional predicates of the composite predicate expression E1 specified in E2 as B (N1(F) & N2(O) & N4(N) & N5 (L) & N6(Bi) & N9(S) & N10(W) & N3(C) ) where F indicated family, O indicates order, N indicates nostrils, L indicates live at, Bi indicates bill, S indicates size, W indicates wings, C indicates color . . Working of the System:  • User enters the problem which he wants to know about the particular domain. • The entered query is analyzed and a keyword is extracted depending on the “domains”. • The keyword is passed to the inference engine. • The inference engine will call the high level goal of the knowledge base that starts the program. • ask/2 and menuask/3 predicate will poses questions to the users and get enough information which is used to satisfy the sub-goals. • Known/3 predicate is used to remember the answer entered by the user. The built-in predicate „asserta? stores the satisfied goals dynamically in the working memory. • Another built-in predicate retractall/1 is used to delete clauses dynamically from the prolog internal database during the execution of a goal thus backtracking can be avoided. • Finally the inference engine will retrieve the final goal from the working memory and provide solution to the user problem. Fig 4. 2 describes the various major predicate functions implemented in Koyal J2SE with PROLOG as supportive declarative language. 5. SYSTEM IMPLEMENTATION AND TESTING [3 & 7] 5. Introduction to System Implementation Implementation is the stage of project. When the theoretical design is turned into a working system. At this stage the main work load, the greatest upheaval and the major impact on the existing practices shifts to the user department. Prolog files include knowledge base and user interface. The size of the knowledge depends on the awareness of the creator about the domain. By referring theses knowledge base the system will derive solution for the problems. Knowledge base is one factor which determines the expertness of a system.
It defines a common vocabulary for researchers who need to share information about the domain. It includes machine-interpretable definitions of basic concepts in the domain and relationship among them. 5. 3 TESTING Testing methodologies are adopted in the course of any system development. Any systems performance is based on testing that it follows. Some of the most prominent methods are: • White Box • Black Box 5. 3. 1 White Box Under white box testing the modules were tested individually and all the bugs were eliminated.
This testing method has been of little influence to the whole project since most of the modules have to be integrated for well functioning. 5. 3. 2 Black Box The core testing was undertaken under this testing. Once all the modules were integrated the whole system was tested to ensure that it matches with the specification. 6. THE CONSTRAINTS OF KOYAL EXPERT SYSTEM: 1. The knowledge of the Koyal expert system is domain specific. 2 . Identification of the keyword is critical 3. The user should have some knowledge about the domain otherwise the system will respond with less accuracy.
ACKNOWLEDGMENT We humbly express our gratitude to Sri Mata Amritanandamayi, the Chancellor of Amrita Visva Vidya Peettam and the fellow faculty and student members of computer science for the successful completion in the prototype design and implementation phases. REFERENCES Websites: ? ? ? ? http://en. wikipedia. org/wiki/Expert_system http://www. wtec. org/loyola/kb/c1_s1. htm http://www. aaai. org/aitopics/pmwiki/pmwiki. php/AIT opics/ExpertSystems http://www. paine. org/students/lectures/lect3/node7. ht ml Fig. 5. is the architectural flow diagram of Koyal for the classification of birds, animals and the medical diagnosis. If the implementation stage is not carefully planned and controlled, it can cause chaos. Implementation involves careful planning, investigation of the current system and its constraints on implementation, design of methods to achieve the changeover, training of staff in the changeover procedure and evaluation of changeover methods. This phase of implementation has allowed us to integrate various cutting edge technologies in the project which involves the implementation of Prolog and Java.
Testing phase included white box testing and black box testing thought most of the testing was performed as system testing. 5. 2 IMPLEMENTATION The implementation phase of software development is concerned with the translation of the structural design specification into source code. The primary goal is to write source code and internal documentation. Testing, Debugging and modification are performed in this phase also. The first step in developing an expert system has been the creation of a Prototype model of the actual system on the basis of the reference model available.
In case of an expert system each system? s knowledge is domain specific so every system has its own advantage and disadvantage. We cannot consider the system as expert in every aspect. This will require time and much effort to develop such a spool proof system. After testing the prototype further modification were incorporated in it by including extra features and implementing the knowledge base part of our system. The prototype is then tested. After the user is satisfied with the function of the prototype the actual system is developed.
JPL is a library using the SWI-Prolog foreign interface and the Java jni interface providing a bidirectional interface between Java and Prolog that can be used to embed Prolog in Java as well as for embedding Java in Prolog. In both setups it provides a reentrant bidirectional interface. jpl allows the loading of prolog engine to Java. Thereby we can load the prolog files which contain knowledge regarding the domains. ? Books: http://www. primenet. com/pcai/New_Home_Page/ai_in fo/expert_systems. html A Guide to Expert Systems by Donald A. Waterman Ist Edition, Addison-Wesley Publishing Company.  Russell, S. and P. Norvig, 2002.
Artificial Intelligence: A Modern Approach, Prentice Hall, Second Edition.  Analysis and design of information systems by V. Rajaraman, 5th print, PH  Introduction to Artificial Intelligence and Expert Systems by Dan W. Patternson, PHI Pvt. Limited, Eighth Reprint 2000.  Expert Systems Theoty and Practices by Jean-Louis Ermine, PHp Publications, 2007  Introduction to Expert Systems by Peter Jackson, Addison-Wesley, Pearson Education Asia ltd. , Reprint 2000  Foundation of Artificial Intelligences and Expert Systems” by V S Janakiraman, K Sarukesi, P Gopalakrishnan, Macmillan Series in Computed Science, Reprint 2001.