Monday, July 24, 2006

Recursion and Memory Management

Today's morning lecture was about Recursion. Recursion bascially means repetition of certain task. In other programing languages it is knows as Loop, but in prolog it is known as Recursion. Recursion is carried out until the answer is met. It does not have huge code, just a single line but it will keep on repeating itself till the answer is found. Recursion can help in saving time because you do not need to type in full code, just type a recuriosn rule and that's it.

Lab lecture was related to memory management in prolog. Recursion as it involves rules calling themselves, uses the stack heavily in this way, and it is possible in large programs for it to become overloaded, causing a program to crash or stop the computer. That's why memory management becomes an imporatnt issue in prolog. In Prolog there is a built in predicate called CUT. Since Prolog is sequentional, means it searches records in the database sequentially, thus causing loads of memory to be used if the program is huge. So it is very important for the programmer to use CUT predicate inorder to make efficient use of memory. CUT is a mechanism to enable the programmer to control the execution of programs. In prolog CUT is represented by an exclamation mark (!).

Backtracking

In today's lecture we studied about backtracking. Backtracking is a methodical way of trying out various sequences of decisions, until you find that works. Backtracking is basically searching in the databse, when prolog carries out search to do any any particular task, it basically is doing backtracking. Each and every condition of code is checked until the right one is found out. Backtracking gave us an idea that how prolog carries out the search inside the database...the good thing about backtracking in prolog is that it is buil into prolog, as a user you do not need to write down the code inorder to carry out your search.

Fail predicate is used in prolog inorder to force backtracking. The fail predicate forces prolog to carry our search even if the answer of query is found in the database.

Thursday, July 13, 2006

TMES

Toy medical expert system is build to diagnose three different diseases: Cold, Flu and Brain Tumour. There are three differnet versions of the expert systm. Each of them has its advantage and disadvantages.

Version-1
In Version-1 rules have been defined and user has been allowed to enter any symptom. The major disadvantage with this version is; if any symptom entered by the user and that is found in more than one disease, then this version will list down the names of all those diseases. For example, if we type in headache, it will list down cold and brain tumour.
Another drawback of this version is, if user enters diagnose(X). and press enter it shows only two diseases Cold and Brain_tumour.

Version-2
Version-2 successfully handles three different queries very well and list down them propery, by propely I mean it does not have the disadvantage which version-1 has. Vesion-2 asks user to type in the symptom name, then it searches the syptom along with the disease name and at the end shows the name of the disease. A small disadvantage with this version is, if user enters any sypmtom which is not found in the databse, it will not come up with any result becasue it hasnt found anything similiar in the database.

Version-3
Like Version-2 Version-3 handles all the queries very well, the disadvantages of version-2 have been overcome in this version of TMES>. Slight modification has been made in this version, when it will comeup with any disease name, it will also show the rule number which was used and if user enters any symptom which is not found against any disease, itw ill simply reply "Not Known" because it does not find the symptom in the databse.

Thursday, July 06, 2006

Fifth Week

Today we didnt have any lecture but today's class was quite a learning phase for students, In today's class, we did Lab-2 and marked Lab-1. The main aim of Lab-2 was to make student familiar with putting differnt records into prolog database and making use of different queries in prolog.
We did two important tasks from Lab-2; Planet database and Animal database. The queries involved in these two databases were about listing records from database using combination of different attributes.

Overall this lecture was quite helpful.