函数式编程Y Combinator解疑

      偶然在一篇文章中看到Y Combinator,对于其对lambda函数的不动点的证明,从两条非常简洁的公理出发,巧妙地得出了匿名函数的递归表示,表示非常的感兴趣。但是,对于计算机理论没什么研究的人来说,虽然好像看懂了它是怎么证明出匿名函数的递归,但是如果不深入了解下Y Combinator的背景,就不知道它到底是用来干嘛的,对于个人知识体系来说,它就是一个孤立的点,没法与学到的计算机知识建立任何联系。
为了彻底弄清Y Combinator的来龙去脉,只能去问度娘了。所幸,这个知识点虽然比较偏,但是还是在知乎上找到了答案。这一看答案,简直就像是发现了新大陆一样(博主读书不努力,井底之蛙)。原来,在计算科学领域有一种跟图灵机具有相同计算能力的更加简单的计算模型叫做“lambda演算”。lambda演算是函数式编程的理论基础。而Y Combinator是lambda演算的一部分,用于构造一个匿名递归函数。
对于lambda演算模型,它只有alpha变换和beta规约两种操作,远比图灵机纸带模型要简单,但是却有着和图灵机一样的计算能力。光从数学上证明这一点还不甘心,于是,就有人开始试着用lambda演算构建一个完整的形式逻辑系统,比如著名的“邱奇计数法”(church numeral)。接着很快就遇到了一个问题:lambda演算如何定义递归(或者循环)。我们都知道,递归的意思是一个函数“直接或间接地调用自身”。通俗点理解,就是在函数内部调用函数本身。但是,lambda演算中函数是没名字的,那么如何调用自己呢?这个问题,也可以归结为:“如何构建一个匿名递归函数”。于是,就有了Y Combinator。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The λ-calculus and combinatory logic are two systems of logic which can also serve as abstract programming languages. They both aim to describe some very general properties of programs that can modify other programs, in an abstract setting not cluttered by details. In some ways they are rivals, in others they support each other. The λ-calculus was invented around 1930 by an American logician Alonzo Church, as part of a comprehensive logical system which included higher-order operators (operators which act on other operators). In fact the language of λ-calculus, or some other essentially equivalent notation, is a key part of most higher-order languages, whether for logic or for computer programming. Indeed, the first uncomputable problems to be discovered were originally described, not in terms of idealized computers such as Turing machines, but in λ-calculus. Combinatory logic has the same aims as λ-calculus, and can express the same computational concepts, but its grammar is much simpler. Its basic idea is due to two people: Moses Sch¨onfinkel, who first thought of it in 1920, and Haskell Curry, who independently re-discovered it seven years later and turned it into a workable technique. The purpose of this book is to introduce the reader to the basic methods and results in both fields. The reader is assumed to have no previous knowledge of these fields, but to know a little about propositional and predicate logic and recursive functions, and to have some experience with mathematical induction. Exercises are included, and answers to most of them (those marked ∗) are given in an appendix at the end of the book. In the early chapters there are also some extra exercises without answers, to give more routine practice if needed.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值