views:

296

answers:

9

Possible Duplicate:
Why is Lisp used for AI?

Hey guys,im kind of curious as to what makes a language suitable for Artificial Intelligence development. Ive heard that LISP and Prolog are widely used in this field, but what features do they have that makes them suitable for AI development?.By the way sorry if this has already been asked,I couldnt find it.

A: 

As far as I know from LISP is that is a Functional Programming Language, and with it you are able to make "programs that make programs. I don't know if my answer suits your needs, see above links for more information.

rlbisbe
A: 

Languages per se (without libraries) are suitable/comfortable for specific areas of research/investigation and/or learning/studying ("how to do the simplest things in the hardest way").
Suitability for commercial development is determined by availability of frameworks, libraries, development tools, communities of developers, adoption by companies. For ex., in internet you shall find support for any, even the most exotic issue/areas (including, of course, AI areas), for ex., in C# because it is mainstream.

BTW, what specifically is context of question? AI is so broad term.


Update:
Oooops, I really did not expect to draw attention and discussion to my answer.

Under ("how to do the simplest things in the hardest way"), I mean that studying and learning, as well as academic R&D objectives/techniques/approaches/methodology do not coincide with objectives of (commercial) development.

In student (or even academic) projects one can write tons of code which would probably require one line of code in commercial RAD (using of component/service/feature of framework or library).

Because..! oooh! Because, there is no sense to entangle/develop any discussion without first agreeing on common definitions of terms... which are subjective and depend on context... and are not so easy to be formulate in general/abstract context. And this is inter-disciplinary matter of whole areas of different sciences

The question is broad (philosophical) and evasively formulated... without beginning and end... having no definitive answers without of context and definitions...

Are we going to develop here some spec proposal?

vgv8
What do you mean by "how to do the simplest things in the hardest way"?
Ken
A: 

Functional programming languages are easier to parallelise due to their stateless nature. There seems to already be a subject about it with some good answers here: http://stackoverflow.com/questions/844536/advantages-of-stateless-programming

As said, its also generally simpler to build programs that generate programs in LISP due to the simplicity of the language, but this is only relevant to certain areas of AI such as evolutionary computation.

Edit:

Ok, I'll try and explain a bit about why parallelism is important to AI using Symbolic AI as an example, as its probably the area of AI that I understand best. Basically its what everyone was using back in the day when LISP was invented, and the Physical Symbol Hypothesis on which it is based is more or less the same way you would go about calculating and modelling stuff in LISP code. This link explains a bit about it: http://www.cs.st-andrews.ac.uk/~mkw/IC_Group/What_is_Symbolic_AI_full.html

So basically the idea is that you create a model of your environment, then searching through it to find a solution. One of the simplest to algorithms to implement is a breadth first search, which is an exhaustive search of all possible states. While producing an optimal result, it is usually prohibitively time consuming. One way to optimise this is by using a heuristic (A* being an example), another is to divide the work between CPUs.

Due to statelessness, in theory, any node you expand in your search could be ran in a separate thread without the complexity or overhead involved in locking shared data. In general, assuming the hardware can support it, then the more highly you can parallelise a task the faster you will get your result. An example of this could be the folding@home project, which distributes work over many GPUs to find optimal protein folding configurations (that may not have anything to do with LISP, but is relevant to parallelism).

DrDipshit
You need to explain why parallelism is important to AI in particular.
Nathan Sanders
Just updated my post. Hopefully that explains things a little better. Cheers.
DrDipshit
That stateless functional programs are easy to parallize is a myth. It maybe 'easier' than something else but remaims far from easy in general.
Rainer Joswig
Just edited it to say 'easier' and yes its not easy, but its certainly easier when you don't have to deal with locks.
DrDipshit
I found locks in Lisp relatively easy to use.
Rainer Joswig
Yeah, I was not really referring to the difficulty of using locks but the added possibility of deadlock if your code is b0rked. It just gives you one less thing to worry about.
DrDipshit
So stateless concurrent functional languages are deadlock free? Also given that stateless functional languages still might need to refer to external state via I/O. Also one gets new problems: for example how to constrain the creation of possible zillions of concurrent running calculations in a functional calculation, when each argument in a function call can be calculated concurrently to the others. If all you tackle with such a language are toy problems, than things get easy for sure.
Rainer Joswig
"Also given that stateless functional languages still might need to refer to external state via I/O." Good point; had not considered that. "how to constrain the creation of possible zillions of concurrent running calculations" I would have though of generating them all in the initial thread. Granted using pooling to reallocate threads for completed tasks would be a problematic.
DrDipshit
+3  A: 

The main calling card of both Lisp and Prolog in this particular field is that they support metaprogramming concepts like lambdas. The reason that is important is that it helps when you want to roll your own programming language within a programming language, like you will commonly want to do for writing expert system rules.

To do this well in a lower-level imperative language like C, it is generally best to just create a separate compiler or language library for your new (expert system rule) language, so you can write your rules in the new language and your actions in C. This is the principle behind things like CLIPS.

T.E.D.
+2  A: 

What do you mean by "AI"? The field is so broad as to make this question unanswerable. What applications are you looking at?

LISP was used because it was better than FORTRAN. Prolog was used, too, but no one remembers that. This was when people believed that symbol-based approaches were the way to go, before it was understood how hard the sensing and expression layers are.

But modern "AI" (machine vision, planners, hell, Google's uncanny ability to know what you 'meant') is done in more efficient programming languages that are more sustainable for a large team to develop in. This usually means C++ these days--but it's not like anyone thinks of C++ as a good language for AI.

Hell, you can do a lot of what was called "AI" in the 70s in MATLAB. No one's ever called MATLAB "a good language for AI" before, have they?

Alex Feinman
For me, in the past year, Google has discovered an uncanny ability to say "Did you mean {completely unrelated term}?".
Ken
@Ken, like most learning systems it's probably found a correlation that doesn't match your expectations. It doesn't meant the correlation isn't there--just that it's nonsensical from your perspective. Like how Cyc once assumed all humans were famous--because they were only populating it with info about famous people.
Alex Feinman
Alex: The correlation is frequently "a much more common word that's spelled similarly". Google seems to assume I'm a terrible (average?) speller/typist. I certainly *believe* there's a strong correlation, but that doesn't mean showing me the correlation is at all useful. Sadly, Google seems to have no ability to learn that I never accept its "typo corrections", and that I tend to say exactly what I mean.
Ken
That highlights another great weakness of correlation-based learning--it tends to assume that the most common case is the only valid one. Google's implementation is nice enough to only suggest, not override, unlike (for example) MS Word's spellchecker.
Alex Feinman
This is a contentious answer, I can see! 4 up, 2 down...
Alex Feinman
How do you know Google's implementation isn't always applied? When I search, it underlines and highlights these typo-corrections in the search results, even if I don't click the "did you mean" link. It sure looks to me like it's automatically doing what it thinks is right, regardless of what I want.
Ken
@Ken, what I meant was that it doesn't block you from searching on "colour" or whatever--it just also searches on "color", and shows both sets of results. This is in contrast to MS Word circa 2005 where you had to undo the correction, inserting an extra step.
Alex Feinman
Alex: I think that's *worse*! If MS Word changes a word by mistake, I can just erase and redo it: a few keystrokes. If Google.com adds search results for a term I don't want, the results I want might be pushed thousands of ranks lower, effectively hiding them entirely. And I haven't used MS Word in a while, but you used to be able to turn that off -- you can't turn off spellcheck (or any other such functionality) in Google.
Ken
A: 

thanks for the answers guys,and sorry,by AI I mean areas like robotics, and software AI

Ishihara
edit your post and put it in there instead.
wheaties
sorry,all this is kinda new to me
Ishihara
No problem at all! Welcome!
Isaac Hodes
What is "software AI"? Do you mean, for example, the rules that govern behavior of enemies in a computer game?
Alex Feinman
not exactly, kinda like genetic algorithms
Ishihara
A: 

Pattern matching constructs with instantiation (or the ability to easily construct pattern matching code) are a big plus. Pattern matching is not totally necessary to do A.I., but it can sure simplify the code for many A.I. tasks. I'm finding this also makes F# a convenient language for A.I.

TechNeilogy
Why is pattern matching an advantage for AI in particular? Maybe it's an advantage for all programming, in which case your advice is really "use the most powerful language possible for AI".
Nathan Sanders
I agree that pattern matching is a very powerful language feature in general, and not just for AI. But for symbolic AI in particular, which often involves partial instantiation, processing of lists, etc., I think pattern matching can really help simplify the source code. Pattern matching can make the symbol constructs apparent in the code itself -- i.e. the code can be made to resemble the problem. For more numeric types of AI (e.g. neural networks), pattern matching is good, but just in a general way.
TechNeilogy
+2  A: 

The two main things you want are the ability to do experimental programming and the ability to do unconventional programming.

When you're doing AI, you by definition don't really know what you're doing. (If you did, it wouldn't be AI, would it?) This means you want a language where you can quickly try things and change them. I haven't found any language I like better than Common Lisp for that, personally.

Similarly, you're doing something not quite conventional. Prolog is already an unconventional language, and Lisp has macros that can transform the language tremendously.

David Thornley
+2  A: 

Overall I would say the main thing I see about languages "preferred" for AI is that they have high order programming along with many tools for abstraction.

It is high order programming (aka functions as first class objects) that tends to be a defining characteristic of most AI languages http://en.wikipedia.org/wiki/Higher-order_programming that I can see. That article is a stub and it leaves out Prolog http://en.wikipedia.org/wiki/Prolog which allows high order "predicates".

But basically high order programming is the idea that you can pass a function around like a variable. Surprisingly a lot of the scripting languages have functions as first class objects as well. LISP/Prolog are a given as AI languages. But some of the others might be surprising. I have seen several AI books for Python. One of them is http://www.nltk.org/book. Also I have seen some for Ruby and Perl. If you study more about LISP you will recognize a lot of its features are similar to modern scripting languages. However LISP came out in 1958...so it really was ahead of its time.

There are AI libraries for Java. And in Java you can sort of hack functions as first class objects using methods on classes, it is harder/less convenient than LISP but possible. In C and C++ you have function pointers, although again they are much more of a bother than LISP.

Once you have functions as first class objects, you can program much more generically than is otherwise possible. Without functions as first class objects, you might have to construct sum(array), product(array) to perform the different operations. But with functions as first class objects you could compute accumulate(array, +) and accumulate(array, *). You could even do accumulate(array, getDataElement, operation). Since AI is so ill defined that type of flexibility is a great help. Now you can build much more generic code that is much easier to extend in ways that were not originally even conceived.

And Lambda (now finding its way all over the place) becomes a way to save typing so that you don't have to define every function. In the previous example, instead of having to make getDataElement(arrayelement) { return arrayelement.GPA } somewhere you can just say accumulate(array, lambda element: return element.GPA, +). So you don't have to pollute your namespace with tons of functions to only be called once or twice.

If you go back in time to 1958, basically your choices were LISP, Fortran, or Assembly. Compared to Fortran LISP was much more flexible (unfortunately also less efficient) and offered much better means of abstraction. In addition to functions as first class objects, it also had dynamic typing, garbage collection, etc. (stuff any scripting language has today). Now there are more choices to use as a language, although LISP benefited from being first and becoming the language that everyone happened to use for AI. Now look at Ruby/Python/Perl/JavaScript/Java/C#/and even the latest proposed standard for C you start to see features from LISP sneaking in (map/reduce, lambdas, garbage collection, etc.). LISP was way ahead of its time in the 1950's.

Even now LISP still maintains a few aces in the hole over most of the competition. The macro systems in LISP are really advanced. In C you can go and extend the language with library calls or simple macros (basically a text substitution). In LISP you can define new language elements (think your own if statement, now think your own custom language for defining GUIs). Overall LISP languages still offer ways of abstraction that the mainstream languages still haven't caught up with. Sure you can define your own custom compiler for C and add all the language constructs you want, but no one does that really. In LISP the programmer can do that easily via Macros. Also LISP is compiled and per the programming language shootout, it is more efficient than Perl, Python, and Ruby in general.

Prolog basically is a logic language made for representing facts and rules. What are expert systems but collections of rules and facts. Since it is very convenient to represent a bunch of rules in Prolog, there is an obvious synergy there with expert systems.

Now I think using LISP/Prolog for every AI problem is not a given. In fact just look at the multitude of Machine Learning/Data Mining libraries available for Java. However when you are prototyping a new system or are experimenting because you don't know what you are doing, it is way easier to do it with a scripting language than a statically typed one. LISP was the earliest languages to have all these features we take for granted. Basically there was no competition at all at first.

Also in general academia seems to like functional languages a lot. So it doesn't hurt that LISP is functional. Although now you have ML, Haskell, OCaml, etc. on that front as well (some of these languages support multiple paradigms...).

Cervo
+1, one nitpick: In C++, you'd normally use function objects (i.e. objects of the classes that overload `operator()`), not function pointers to emulate first class functions.
missingfaktor