Friday, May 16, 2014

Software Tools

Software tools are a ubiquitous part of modern life especially for a software engineer. As a software engineer one handles multiple compilers, integrated design environments (IDE) or something as mundane as Microsoft Excel or PowerPoint. This semester, I added a couple more tools to my toolkit – Prolog, JFLAP and the Petite Chez Scheme.

SWI – Prolog:


Prolog is a logic based programming language and was initially designed for the purpose supporting of Artificial Intelligence programming. I would particularly recommend Swi- Prolog among the various flavors of Prolog available. It is an open source tool that is used for the Prolog programming language. It was particularly useful for practicing my Prolog programming skills. It has a lot of key libraries, good GUI, IDE environment and really good supporting documentation. This made self-learning a lot easier.

JFLAP:



I am sure for every computer science major student, formal languages and computation is one course that can get really difficult to understand. I felt this was mainly because the course can get very theoretical. But while doing this course, I came across JFLAP that really helped me in my understanding of finite machines taught in the formal languages and computation course.

One can play around with this tool to create different finite machines, check the language it produces etc. This tool can be used to experiment on Non Deterministic and Deterministic machines, Turing machines etc. It can also be used to convert a NFA (Non Deterministic Finite Automata) to DFA (Deterministic Finite Automata). It can also be used to obtain regular expressions from a DFA. I found using this tool a lot of fun and very educational.


Petite Chez Scheme:


This is another tool that I used a lot this semester. This is an interpreter for the scheme programming language. Again, it has extensive libraries and a surprisingly good GUI. Even though scheme is a very old programming language, it provides a very good insight into how programming languages have evolved over the years. I really enjoyed using Scheme and would encourage software engineers to do so.


References


Prolog



If you are looking for a completely different programming experience you must simply try Prolog. Using this language you can simply ask your computer simple questions and it will answer it for you. I did a course this semester in which I came across Prolog programming language for the first time. I was pretty impressed with this language as it was completely different from all the languages that I had seen so far. Prolog unlike traditional programming languages is a logical and declarative language. In fact, it was one of the first programming languages based on logic. It was introduced in 1970 by Robert A. Kowalski at Edinburgh University. This language is used widely for artificial intelligence. 

How Prolog works is that it makes deductions based on facts and rules, both of which are specified by the user. A fact describes the object and its relationship with the object. For example, if we consider Silver is shiny as a fact then it is expressed as shiny(Silver) in Prolog. Here 'Silver' is the object. Another example is likes (Swapna, chocolate). This defines a fact that Swapna likes chocolate.

A rule describes a relation between different facts. For example friends(X,Y) :- likes(X,Y),likes(Y,X). Here ':-' is 'if' in Prolog and ',' means 'and'. So this rule means that X and Y are friends if X likes Y and Y likes X. We need to make sure the rules are valid. Every rule must end with a period. The left hand side of the rule has to be a single literal and cannot be negated. In the above example, if the left hand side is not(friends(X,Y)) then it is not a valid rule.

In Prolog the user creates a database with rules and facts. Having done that, the user can ask questions about the various objects and their relationships. Below is a snippet of how the prolog interface looks like.



Let us consider a database example. For instance we can create a database like this:
likes(alice, diamonds).
likes(alice, john).
likes(john, alice).
buys(john, diamonds) :- likes(john, alice).

After the database is created one can ask questions like this:
?- likes (X, diamonds). Would ask the question who likes diamonds
X = alice;                   The answer displayed would be Alice
?- likes (X, john).     Here the question asked is who likes john
X = alice;                Again, the answer displayed would be Alice

A Prolog program database can be thought of a collection of predicate logic statements. The way evaluation takes place is that once you query, prolog performs substitutions based on the logic statements to find the right answer. The searching algorithms are in built in the Prolog compiler.
This predicative logic lends itself naturally to AI programming and thus makes it a very powerful language to use in the fields of artificial intelligence, weather prediction, defense applications to name a few.

References: