This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 10/27/06 From materials Copyright N. Ramsey 1 DPL6: Î»calculus This tries to give a general idea of the relation between various considerations in language design. 10/27/06 From materials Copyright N. Ramsey 2 DPL6: Î»calculus A view of theory : it tries to provide a precise answer to the question " what does this program mean "? It can thus be used as a guide to implementors. Various topics of interest are: lambda calculus type systems partial orders and lattices denotational semantics algebraic equivalence logical assertions 10/27/06 From materials Copyright N. Ramsey 3 DPL6: Î»calculus The lambda calculus . It provides us with the world's simplest programming language. It supports variables , abstraction and application . exp ::= var  Î» var.exp  exp exp Typically M , N , â€¦ stand for exps ( Î»terms) x , y , z , â€¦ stand for variables Application associates to the left (: M N O = ((M N) O)), and binds tighter than abstraction  so use parentheses as needed. 10/27/06 From materials Copyright N. Ramsey 4 DPL6: Î»calculus It can encode any data structures . Recall from 91.301 that data can be encoded as functions: (define cons (x y) (lambda (msg) (if (= msg 1) x (if (= msg 2) y)))) (define car (p) (p 1)) (define cdr (p) (p 2)) Î¼ Scheme cons cell as function . 10/27/06 From materials Copyright N. Ramsey 5 DPL6: Î»calculus We need to add deÂ¡nitions for if , = , 1 , 2 , + , in Î»calculus: it is possible to do it (we will see how to do it). Given these (call them constants ), we can deÂ¡ne more functions: add2 = Î» x .+ x 2 add2 ' = Î» x .+2 x add2 '' = +2 revapply = Î» x. Î» y.yx The lambda calculus turns out to be as powerful as any programming language, even without constants . It is thus an ideal vehicle for Proving theorems Experimenting with features 10/27/06 From materials Copyright N. Ramsey 6 DPL6: Î»calculus We have another functional language to add to our list Î»calculus Scheme ML The advantages of this last introduced one include: no need to evaluate before applying no need for recursive deFnitions no need for if as a "special form" we can do everything with just functions 2 10/27/06 From materials Copyright N. Ramsey 7 DPL6: Î»calculus Abstract syntax : application, abstraction, variable Values : values are terms ! typically in normal form (we'll see what that means) justiÂ¡es the name "calculus" ( calculus : rules on how to push squiggles around a piece of paper to compute something) Environments : not used but names stand for terms (so, fake it, but for convenience only) Evaluation rules : coming up Initial basis : sometimes empty, sometimes constants 10/27/06 From materials Copyright N....
View
Full Document
 Fall '09
 Giam
 N. Ramsey, Copyright N. Ramsey, materials Copyright N.

Click to edit the document details