本文介绍了人工智能开发的语言要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么使语言适合人工智能开发?

What makes a language suitable for Artificial Intelligence development?

我听说LISP和Prolog在这一领域得到了广泛的使用.哪些功能使其适合AI?

I've heard that LISP and Prolog are widely used in this field. What features make them suitable for AI?

推荐答案

总的来说,我对AI首选"语言的主要了解是,它们具有高级编程以及许多抽象工具.

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.

高级编程(也称为一流对象)通常是大多数AI语言的定义特征 http://en.wikipedia.org/wiki/Higher-order_programming .该文章是存根,省略了Prolog http://en.wikipedia.org/wiki/Prolog允许高阶谓词".

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".

但是从根本上说,高阶编程是一种想法,您可以像传递变量一样传递函数.令人惊讶的是,许多脚本语言也具有作为一流对象的功能. LISP/Prolog是AI语言.但是其他一些也许令人惊讶.我看过几本关于Python的AI书.其中之一是 http://www.nltk.org/book .我也看到了一些针对Ruby和Perl的内容.如果您对LISP进行更多的研究,您将认识到LISP的许多功能与现代脚本语言相似.但是LISP于1958年问世,所以它确实领先于时代.

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.

有用于Java的AI库.而且在Java中,您可以使用类上的方法将黑客功能归类为第一类对象,这比LISP难/不方便,但有可能.在C和C ++中,您具有函数指针,尽管它们又比LISP麻烦得多.

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.

一旦您具有作为一等对象的功能,就可以比其他方式进行更多的通用编程.如果没有将函数作为第一类对象,则可能必须构造sum(array)product(array)来执行不同的操作.但是使用函数作为第一类对象,您可以计算accumulate(array, +)accumulate(array, *).您甚至可以执行accumulate(array, getDataElement, operation).由于AI的定义不明确,因此灵活性的类型非常有帮助.现在,您可以构建更多的通用代码,以原本没有想到的方式更容易扩展.

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.

Lambda(现在可以在各处找到它的方式)成为保存键入的一种方式,因此您不必定义每个函数.在前面的示例中,您不必说getDataElement(arrayelement) { return arrayelement.GPA },而只需说accumulate(array, lambda element: return element.GPA, +).因此,您不必使用大量函数来污染名称空间,而只需调用一次或两次即可.

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.

如果您回到1958年,基本上可以选择LISP,Fortran或Assembly.与Fortran相比,LISP灵活得多(不幸的是效率也较低),并且提供了更好的抽象方法.除了作为一流对象的功能之外,它还具有动态类型,垃圾回收等功能(目前,任何脚本语言都具有这种功能).尽管LISP得益于率先成为每个人都恰巧用于AI的语言,但现在有更多选择可以用作语言.现在看一下Ruby/Python/Perl/JavaScript/Java/C#/,甚至是最新提出的C标准,您也开始看到LISP的功能(映射/减少,lambda,垃圾收集等). LISP早于1950年代.

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.

即使是现在,LISP在大多数比赛中仍保持一些高手优势. LISP中的宏系统确实非常先进.在C语言中,您可以使用库调用或简单的宏(基本上是文本替换)来扩展语言.在LISP中,您可以定义新的语言元素(想想您自己的if语句,现在考虑您自己的用于定义GUI的自定义语言).总体而言,LISP语言仍提供了主流语言尚未掌握的抽象方法.当然,您可以为C定义自己的自定义编译器,并添加所需的所有语言构造,但是没有人真正做到这一点.在LISP中,程序员可以通过宏轻松地做到这一点. LISP也是经过编译的,并且按照编程语言的较量,通常比Perl,Python和Ruby更有效.

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基本上是一种逻辑语言,用于表示事实和规则.什么是专家系统,但规则和事实的集合.由于在Prolog中表示一堆规则非常方便,因此与专家系统有着明显的协同作用.

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.

现在我认为对于每个AI问题都没有使用LISP/Prolog.实际上,只需看一下可用于Java的众多机器学习/数据挖掘库.但是,当您由于不知道自己在做什么而对新系统进行原型设计或进行实验时,使用脚本语言比使用静态类型的语言要容易得多. LISP是最早拥有所有我们认为理所当然的功能的语言.基本上一开始根本没有竞争.

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.

在一般学术界中,似乎也很喜欢函数式语言.因此,LISP可以正常工作也没有什么坏处.尽管现在在这方面也有ML,Haskell,OCaml等(其中某些语言支持多种范例...).

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...).

这篇关于人工智能开发的语言要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 21:32