南京大学:高等数学微积分课程教学资源(PPT课件讲稿)拉姆达演算 Lambda Calculus(λ演算 λ-calculus)

Lambda calculus
Lambda Calculus

What is入- calculus Programming language Invented in 1930s, by alonzo Church and stephen cole Kleene Model for computation lan Turing, 1937 Turing machines equal n-calculus in expressiveness
What is -calculus • Programming language • Invented in 1930s, by Alonzo Church and Stephen Cole Kleene • Model for computation • Alan Turing, 1937: Turing machines equal -calculus in expressiveness

Why learn n-calculus Foundations of functional programming Lisp, ML, Haskell often used as a core language to study language theories ype system intx=0: Scope and binding for(inti=0;i<10;i++){x++;} Higher-order functions x="abcd"; // bug(mistype) Denotational semantics i+;∥bug( out of scope) Program equivalence How to formally define and rule out these bugs?
Why learn -calculus • Foundations of functional programming • Lisp, ML, Haskell, … • Often used as a core language to study language theories • Type system • Scope and binding • Higher-order functions • Denotational semantics • Program equivalence • … int x = 0; for (int i = 0; i < 10; i++) { x++; } x = “abcd”; // bug (mistype) i++; // bug (out of scope) How to formally define and rule out these bugs?

Overview: -calculus as a language Syntax How to write a program? Keyword ?"for defining functions Semantics How to describe the executions of a program? Calculation rules called reduction Others Type system next class Model theory (not covered
Overview: -calculus as a language • Syntax • How to write a program? • Keyword “” for defining functions • Semantics • How to describe the executions of a program? • Calculation rules called reduction • Others • Type system (next class) • Model theory (not covered) • …

Syntax n terms or 2 expressions (Terms)M,N: =X AX.M MN Lambda abstraction(x. M: anonymous"functions ntf(ntx){ return x;}→λx.x Lambda application (M n) int f (int x)i return x; y f(3) (xx)3=3
Syntax • terms or expressions: (Terms) M, N ::= x | x. M | M N • Lambda abstraction (x.M): “anonymous” functions int f (int x) { return x; } ➔ x. x • Lambda application (M N): int f (int x) { return x; } f(3); ➔ (x. x) 3 = 3

Syntax ·^ terms orλ expressions: erms)M,N:=X|λx.M|MN pure n-calculus Add extra operations and data types X.(X+1) AZ.(x+2*y+2) (入.(x+1)3=3+1 ·(2.(X+2*y+z)5=x+2*y+5
Syntax • terms or expressions: (Terms) M, N ::= x | x. M | M N • pure -calculus • Add extra operations and data types • x. (x+1) • z. (x+2*y+z) • (x. (x+1)) 3 = 3+1 • (z. (x+2*y+z)) 5 = x+2*y+5

Conventions Body of n extends as far to the right as possible nx MN means Ax(M N, not(x M)N 入X.fx=λx.(fx) 入X.f.fx=x.(ffx) Function applications are left-associative MNP means(M N)P, not M(N P (入X.y.X-y)53=(x.y.x-y)5)3 (fx.fx)(X.X+1)2=((千.AX.fx)(^x,X+1))2
Conventions • Body of extends as far to the right as possible x. M N means x. (M N), not (x. M) N • x. f x = x. ( f x ) • x. f. f x = x. ( f. f x ) • Function applications are left-associative M N P means (M N) P, not M (N P) • (x. y. x - y) 5 3 = ( (x. y. x - y) 5 ) 3 • (f. x. f x) (x. x + 1) 2 = ( (f. x. f x) (x. x + 1) ) 2

Higher-order functions Functions can be returned as return values 入xyx-y Functions can be passed as arguments 06×.×)(xx+1)2 Think about function pointers in C/C++
Higher-order functions • Functions can be returned as return values • Functions can be passed as arguments Think about function pointers in C/C++. x. y. x - y (f. x. f x) (x. x + 1) 2

Higher-order functions Given function f return function fo f 入.X.f(fx) · How does this work? xf.2.f(fx)y+1)5 =(x、+)(x.y+1)×)5 (X.(y+1)(x+1)5 (入X.(x+1)+1)5 5+1+1=7
Higher-order functions • Given function f, return function f ∘ f f. x. f (f x) • How does this work? (f. x. f (f x)) (y. y+1) 5 = (x. (y. y+1) ((y. y+1) x)) 5 = (x. (y. y+1) (x+1)) 5 = (x. (x+1)+1) 5 = 5+1+1 = 7

Curried functⅰonS Note difference between 入X.xy.x-y and int f (int x, int yi return x-y; n abstraction is a function of 1 parameter But computationally they are the same(can be transformed into each other Curry: transform n(x,y). x-y to nx. ny x-y Uncurry: the reverse of curry
Curried functions • Note difference between • abstraction is a function of 1 parameter • But computationally they are the same (can be transformed into each other) • Curry: transform (x, y). x-y to x. y. x - y • Uncurry: the reverse of Curry x. y. x - y and int f (int x, int y) { return x - y;}
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《数学教学论》课程教学大纲(适用专业:数学与应用数学专业).pdf
- 马尔可夫链蒙特卡洛手册:Handbook of Markov Chain Monte Carlo(Chap. 1&5).pptx
- 《微积分》课程教学资源(PPT课件讲稿)期末小结.ppt
- 《中学代数研究》课程教学资源(PPT课件讲稿)第四章 函数.ppt
- 《高等数学》课程教学资源(PPT课件讲稿)换元积分法.ppt
- 中国科学技术大学:《数值计算方法》课程教学资源(PPT课件讲稿)第二章 数值微分和数值积分.ppt
- 南京大学:Mathematical Preliminaries Strings and Languages(PPT讲稿).ppt
- 《线性代数》英文专业词汇(中英文对照).doc
- 《图论初步》课程教学资源(PPT课件讲稿)图论初步.pptx
- 《高等数学》课程教学资源(PPT课件讲稿)第七章 微分方程.ppt
- 山东大学:《运筹学》课程教学资源(PPT课件讲稿)第2章 线性规划(模型与基本定理).pptx
- 《数学模型》课程教学资源(PPT课件讲稿)第六章 代数方程与差分方程模型.ppt
- 复旦大学:《科学计算选讲 Course Information》课程教学资源:教学大纲.pdf
- 《离散数学》课程教学资源(PPT课件讲稿)第十三章 几种特殊的图.ppt
- 唐敖庆实验班荣誉课程:数学分析(PPT讲稿)物理、化学、生命科学、计算机与数学.pptx
- 《数学模型》课程教学资源(PPT课件讲稿)第四章 数学规划模型.ppt
- 《离散数学》课程PPT教学课件讲稿(数理逻辑)第二章 命题逻辑的等值和推理演算.ppt
- 《离散数学》课程教学资源(PPT课件讲稿)图的连通性.pptx
- 《数学分析》课程教学资源(PPT课件讲稿)多元函数微分学(可微性与偏导数).ppt
- 《离散数学》课程教学资源(PPT课件讲稿)离散概率.pptx
- 新乡学院:《线性代数》课程教学大纲(B).pdf
- 《数学建模基础》课程教学资源(PPT课件讲稿)第六章 稳定性模型.ppt
- Combinatorial interpretations for a class of algebraic equations and uniform partitions.ppt
- 《高等数学》课程教学资源(PPT课件讲稿)换元积分法(题解).ppt
- 《线性代数》课程教学资源(PPT课件讲稿)第2章 线性代数方程组.ppt
- 《高等数学》课程PPT教学课件(习题课)第七章 无穷级数(含自测题及答案).ppt
- 《高等数学》课程教学资源(PPT课件讲稿,习题课)第一章 函数、极限与连续.ppt
- 西安电子科技大学:《运筹学》课程教学资源(PPT课件讲稿)第十章 图与网络分析(赵玮).ppt
- 《数学分析》课程教学资源(PPT课件讲稿)一致收敛性.ppt
- 《数学建模——数学模型》课程教学资源(PPT课件讲稿)第二章 初等模型.ppt
- 《离散数学》课程教学资源(PPT课件讲稿)第四章 二元关系.ppt
- 《数学建模》课程教学资源(PPT课件讲稿)Matlab的使用.ppt
- 清华大学:网络优化模型与算法(PPT讲稿)Network Optimization - Models & Algorithms(数学科学系:谢金星).ppt
- 东南大学:《离散数学》课程教学资源(PPT课件讲稿)第三章 命题逻辑的推理理论.ppt
- 《高等数学》课程教学资源(PPT课件讲稿)多元函数微分法及其应用.ppt
- 《高等数学》课程教学资源(PPT课件讲稿)第五章 定积分及其应用.ppt
- 《数学建模》课程教学资源(PPT课件讲稿)第八章 离散模型.ppt
- 《概率论》课程教学资源(PPT讲稿)几个常用的概率分布.pptx
- 西安电子科技大学:《近世代数》课程教学资源(PPT课件讲稿)有限域.ppt
- 《数学模型》课程教学资源(PPT课件讲稿)第五章 微分方程模型.ppt