This preview shows pages 1–3. Sign up to view the full content.
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 denitions 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 dene 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) justies 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
This note was uploaded on 02/13/2012 for the course CS 91.531 taught by Professor Giam during the Fall '09 term at UMass Lowell.
 Fall '09
 Giam

Click to edit the document details