home
 
 
AI Languages
 
 


AI programs have often been written in specialized languages designed strictly for AI. The two big AI languages originally were PROLOG and Lisp. Neither language is used that much in industry (they are still used somewhat in academia), but it is helpful to understand both languages a little because most current AI languages were originally based on elements of PROLOG and Lisp.

PROLOG is a logic-based language. That is, PROLOG is presented with a set of facts, rules, and goals, and it attempts to prove that the goals are true by applying the rules to the facts. If it succeeds it proving the goal, it has established the truth of that goal; if it does not, it has established that the goal is false or at least that there is not enough information to determine whether it is true or false. PROLOG proceeds by backward chaining. That is, it starts with the goal and works backward to see what would need to be true in order for the goal to be true. To succeed in proving the goal, PROLOG would need to eventually reduce the goal to simple facts.

So basically the way PROLOG works is that you give it a set of rules which describes your knowledge about an area. Then you give it a set of facts which describe a given situation. Finally, you present it with a goal-- something which you are trying to establish as true or false--and see whether PROLOG can prove it true.

Here's a simple example of how PROLOG might work:

cat(x) :- furry(x), meows(x), has(x,claws)
furry(Mooshke) :-
has(Mooshke,claws) :-
:- cat(Mooshke)

The first line above is a rule. It tells us that if something is furry, meows, and has claws, then it must be a cat. The next two lines are facts which tell us that Mooshke is furry and has claws. The final line is a goal which asks PROLOG to prove that Mooshke is a cat. Actually, in this case, PROLOG would not be able to prove that Mooshke is a cat, because it lacks the needed information that Mooshke has claws.

Lisp takes a somewhat different approach than PROLOG. Whereas PROLOG tries to prove particular results, and thus is geared towards solving particular types of problems, Lisp is more of a general purpose programming language. The main distinguishing point of Lisp is that in Lisp, everything is a list (the name "Lisp" means "List Processing"). It was found that artificial intelligence applications often required the use of many lists of items; hence in Lisp essentially everything is a list. Even things like functions and methods are written as lists enclosed in parentheses. Thus Lisp code tends to have a very particular appearance to it. Following is an example of Lisp code:

(forall ?x
(implies (and (furry ?x) (meows ?x) (has ?x claws))
(cat ?x)))

Lisp is a very old language--indeed, it is not only the oldest AI language but it is one of the oldest programming languages in existence. Some books to read on Lisp and PROLOG include:

PROLOG Programming for Artificial Intelligence
Common Lisp : The Language
Lisp

If neither of these languages is used all that much in industry, what is the point of learning them? Well, most AI languages that are actually used in industry combine elements of both Lisp and PROLOG, so in a sense they are the underlying building blocks which go together to make up most rule-based systems. Designers of expert system shells have generally speaking found that you need some rule processing, which PROLOG provides, and also that the list processing capabilities of something like Lisp are nice to have. So what they do is that they generally design their own language which is based on both Lisp and PROLOG. A good example of such a language is Jess, which is available for free download off the Internet (Jess) although a commerical license is needed for commercial applications. Jess was discussed a little when we talked about rule-based systems. Jess is based on an earlier AI language called CLIPS, and both CLIPS and Jess look a lot like Lisp. Following is an example of Jess code:

(defrule is-a-cat ""
?animal <- (animal)
(furry (a ?animal))
(has (a ?animal)
(attr claws))
(meows (a ?animal))
=>
(assert (cat (a ?animal)))
)

This will successfully determine that an animal is a cat if it is furry, has claws, and meows.

Other rules engines, such as ART*Enterprise and ILOG JRules, also use their own AI languages.

PROLOG and Lisp were really too special purpose to be useful outside of academic circles. With the more recent AI languages such as CLIPS and ART*Script, a serious effort was made to make the languages versatile enough to be used in commercial applications. However, they still suffered from the problem that they were difficult to integrate into a larger enterprise. The AI system became a black box, and a great deal of effort needed to be expended to map from, say, databases such as Sybase and Oracle or languages like C++ into the AI languages, and then back out again. This was very costly in terms of both developer effort and system performance.

What has happened more recently is that languages such as Jess are directly integrated into the Java virtual machine, and as a result they can directly gain access to Java classes. This eliminates most of the overhead involved in using a rules engine, and should make AI much more accessible to the average programmer.

 

Next Edition: Time Series Prediction

 

 
  Home

Home: Ramalila.NET

 

 

Legals:
All copyrights are maintained by respective contributors and may not be reused without permission. Graphics and scripts may not be directly linked to. Site assets copyright © 2000 RamaLila.com and respective authors.
By using this site, you agree to relinquish all liabilities and claims financial or otherwise against RamaLila and its contributors. Visit this site at your own risk.