AI开发的语言要求

发布于 2024-09-14 21:43:44 字数 238 浏览 2 评论 0原文

可能的重复:
为什么 Lisp 用于人工智能?

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

我听说LISP和Prolog在这个领域被广泛使用。哪些特征使它们适合人工智能?

Possible Duplicate:
Why is Lisp used for AI?

What makes a language suitable for Artificial Intelligence development?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

谢绝鈎搭 2024-09-21 21:43:44

总的来说,我认为人工智能“首选”语言的主要特点是它们具有高阶编程以及许多抽象工具。

高阶编程(又称为第一类对象的函数)往往是大多数人工智能语言的定义特征 http://en.wikipedia.org/wiki/Higher-order_programming 我可以看到。那篇文章是一个存根,它遗漏了 Prolog http://en.wikipedia.org/wiki/Prolog 允许高阶“谓词”。

但基本上,高阶编程的思想是可以像变量一样传递函数。令人惊讶的是,许多脚本语言也具有作为第一类对象的功能。 LISP/Prolog 是公认的人工智能语言。但其他一些可能会令人惊讶。我看过几本关于Python的人工智能书籍。其中之一是http://www.nltk.org/book。我还看到了 Ruby 和 Perl 的一些。如果您更多地研究 LISP,您会发现它的许多功能与现代脚本语言相似。然而 LISP 于 1958 年问世……所以它确实超前于时代。

有适用于 Java 的 AI 库。在 Java 中,您可以使用类上的方法将函数作为第一类对象进行排序,这比 LISP 更难/不太方便,但也是可能的。在 C 和 C++ 中,有函数指针,尽管它们比 LISP 更麻烦。

一旦您拥有作为第一类对象的函数,您就可以比其他方式更通用地进行编程。如果没有函数作为第一类对象,您可能必须构造 sum(array)product(array) 来执行不同的操作。但是,使用函数作为第一类对象,您可以计算accumulate(array, +) 和accumulate(array, *)。您甚至可以执行accumulate(array, getDataElement, operation)。由于人工智能的定义如此不明确,因此灵活性是一个很大的帮助。现在,您可以构建更通用的代码,这些代码更容易以最初未设想的方式进行扩展。

Lambda(现在已经无处不在)成为一种节省打字的方法,这样您就不必定义每个函数。在前面的示例中,您不必在某个地方创建 getDataElement(arrayelement) { return arrayelement.GPA } ,只需说 accumulate(array, lambda element: return element.GPA, +)< /代码>。因此,您不必使用大量只被调用一次或两次的函数来污染您的名称空间。

如果你回到 1958 年,基本上你的选择是 LISP、Fortran 或 Assembly。与 Fortran 相比,LISP 更加灵活(不幸的是效率也较低)并且提供了更好的抽象方法。除了作为第一类对象的功能之外,它还具有动态类型、垃圾收集等功能(当今任何脚本语言都具有这些功能)。现在,作为一种语言,有更多的选择,尽管 LISP 受益于成为第一个并成为每个人碰巧用于 AI 的语言。现在看看 Ruby/Python/Perl/JavaScript/Java/C#/甚至最新提出的 C 标准,您会开始看到 LISP 的特性(map/reduce、lambda、垃圾收集等)。在 20 世纪 50 年代,LISP 远远领先于时代。

即使现在,LISP 在大部分比赛中仍然保持着一些王牌。 LISP 中的宏系统非常先进。在 C 中,您可以通过库调用或简单的宏(基本上是文本替换)来扩展语言。在 LISP 中,您可以定义新的语言元素(想想您自己的 if 语句,现在想想您自己的用于定义 GUI 的自定义语言)。总体而言,LISP 语言仍然提供了主流语言尚未赶上的抽象方法。当然,您可以为 C 定义自己的自定义编译器并添加您想要的所有语言结构,但没有人真正这样做。在 LISP 中,程序员可以通过宏轻松地做到这一点。 LISP 也是经过编译的,根据编程语言的对比,它通常比 Perl、Python 和 Ruby 更高效。

Prolog 基本上是一种用于表示事实和规则的逻辑语言。专家系统不过是规则和事实的集合。由于在 Prolog 中表示一堆规则非常方便,因此与专家系统有明显的协同作用。

现在我认为使用 LISP/Prolog 来解决每个人工智能问题并不是必然的。事实上,只要看看众多可用于 Java 的机器学习/数据挖掘库即可。然而,当您正在设计一个新系统的原型或因为不知道自己在做什么而进行试验时,使用脚本语言比静态类型的语言要容易得多。 LISP 是最早拥有所有这些我们认为理所当然的功能的语言。基本上一开始根本没有竞争。

一般来说,学术界似乎也非常喜欢函数式语言。所以 LISP 的功能并没有什么坏处。尽管现在在这方面也有 ML、Haskell、OCaml 等(其中一些语言支持多种范例......)。

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

み零 2024-09-21 21:43:44

Lisp 和 Prolog 在这个特定领域的主要名片是它们支持 lambda 等元编程概念。这很重要的原因是,当您想要在编程语言中使用自己的编程语言时,它会有所帮助,就像您通常希望编写专家系统规则一样。

要在 C 等较低级别的命令式语言中很好地做到这一点,通常最好为您的新(专家系统规则)语言创建一个单独的编译器或语言库,以便您可以用新语言和您的操作编写规则这就是 CLIPS 等事物背后的原理。

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.

日裸衫吸 2024-09-21 21:43:44

您想要的两个主要东西是进行实验性编程的能力和进行非常规编程的能力。

当你在做人工智能时,根据定义,你并不真正知道自己在做什么。 (如果你这样做了,那就不是人工智能了,不是吗?)这意味着你想要一种可以快速尝试并改变它们的语言。就我个人而言,我还没有找到比 Common Lisp 更喜欢的语言。

同样,你正在做一些不太传统的事情。 Prolog 已经是一种非常规语言,而 Lisp 的宏可以极大地改变这种语言。

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.

昨迟人 2024-09-21 21:43:44

“人工智能”是什么意思?这个领域如此广泛,以至于这个问题无法回答。您正在寻找哪些应用程序?

使用 LISP 是因为它比 FORTRAN 更好。 Prolog 也被使用过,但没有人记得这一点。当时人们认为基于符号的方法是可行的方法,当时人们还没有意识到感知层和表达层有多难。

但现代“AI”(机器视觉、规划器、谷歌神奇的能力来知道你的“意思”)是用更高效的编程语言完成的,这些语言更适合大型团队的开发。这通常意味着现在的 C++—— - 但并不是有人认为 C++ 是人工智能的好语言。

天啊,你可以在 MATLAB 中完成很多 70 年代所谓的“AI”的事情。以前没有人称 MATLAB 为“人工智能的好语言”,不是吗?

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?

流年里的时光 2024-09-21 21:43:44

函数式编程语言由于其无状态特性而更容易并行化。似乎已经有一个关于它的主题,这里有一些很好的答案:无状态编程的优点?

如前所述,由于 LISP 语言的简单性,通常更容易构建用 LISP 生成程序的程序,但这仅与人工智能的某些领域相关,例如进化计算。

编辑:

好的,我将尝试以符号 AI 为例解释一下为什么并行性对于 AI 很重要,因为它可能是我最了解的 AI 领域。基本上,它是 LISP 发明时每个人都在使用的东西,它所基于的物理符号假设或多或少与您在 LISP 代码中计算和建模的方式相同。此链接对此进行了一些解释:
http://www.cs.st-andrews.ac .uk/~mkw/IC_Group/What_is_Symbolic_AI_full.html

所以基本上的想法是创建一个环境模型,然后搜索它以找到解决方案。最容易实现的算法之一是广度优先搜索,这是对所有可能状态的穷举搜索。虽然产生最佳结果,但通常非常耗时。优化此问题的一种方法是使用启发式方法(A* 就是一个例子),另一种方法是在 CPU 之间划分工作。

由于无状态性,理论上,您在搜索中扩展的任何节点都可以在单独的线程中运行,而不需要锁定共享数据所涉及的复杂性或开销。一般来说,假设硬件可以支持它,那么任务的并行度越高,获得结果的速度就越快。 Folding@home 项目就是一个例子,该项目将工作分配到许多 GPU 上,以找到最佳的蛋白质折叠配置(可能与 LISP 没有任何关系,但与并行性相关)。

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

掩于岁月 2024-09-21 21:43:44

据我所知, LISP 是一个 函数式编程语言,用它你可以制作“制作程序的程序”,我不知道我的答案是否适合您的需求。 ,请参阅上面的链接以获取更多信息。

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.

腹黑女流氓 2024-09-21 21:43:44

具有实例化的模式匹配构造(或轻松构建模式匹配代码的能力)是一个很大的优势。模式匹配对于人工智能来说并不是完全必要的,但它确实可以简化许多人工智能任务的代码。我发现这也使得 F# 成为 AI 的便捷语言

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.

暮倦 2024-09-21 21:43:44

语言本身(没有图书馆)适合/适合特定领域的研究/调查和/或学习/学习(“如何以最困难的方式做最简单的事情”)。
商业开发的适用性取决于框架、库、开发工具、开发人员社区以及公司采用的可用性。例如,在互联网上,您将找到对任何甚至是最奇特的问题/领域(当然包括人工智能领域)的支持,例如 C#,因为它是主流。

顺便说一句,问题的背景具体是什么?人工智能这个词太宽泛了。


更新:
哎呀,我真的没想到我的回答会引起关注和讨论。

在(“如何用最难的方式做最简单的事情”)下,我的意思是学习和学习以及学术研发目标/技术/途径/方法与(商业)发展的目标不一致。

在学生(甚至学术)项目中,人们可以编写大量代码,这可能需要商业 RAD 中的一行代码(使用框架或库的组件/服务/功能)。

因为..!噢!
因为,如果不首先就术语的共同定义达成一致,就没有必要纠缠/展开任何讨论……这些定义是主观的并且取决于上下文……并且在一般/抽象上下文中不容易制定。
这是不同科学的整个领域的跨学科问题

这个问题是广泛的(哲学的)并且含糊其辞...没有开始和结束...没有上下文和定义没有明确的答案...

我们是否要发展这里有一些规格建议吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文