






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of the lambda calculus, a mathematical formalism for expressing computation by functions. It covers church's thesis, the definition and rules of the lambda calculus, binding, free and bound variables, beta and eta reduction, currying, normal forms, and applicative-order reduction.
Typology: Study notes
1 / 38
This page cannot be seen from the preview
Don't miss anything!































Overview:^ ^
What is Computability? – Church’s Thesis The Lambda Calculus Scope and lexical address The Church-Rosser Property References:^ ^
Daniel P. Friedman et al., “Essentials of Programming Languages”, Second Edition,MIT Press, 2001 H.P. Barendregt, “The Lambda Calculus – Its Syntax and Semantics”, North-Holland, 1984 David A. Schmidt, “The Structure of Typed Programming Languages”, MIT Press, (^1994) Carl A. Gunter, “Semantics of Programming Languages”, MIT Press, 1992
Com S 342
yes no output
“effectivelycomputable”functionprogram/machine
the state the machine is in, the number on the square it is scanning, and a table of instructions.
Com S 342
^ The Ackermann function is the simplest example of a well-defined totalfunction which is computable but not primitive recursive. ^ The function f(x) = A(x, x), while Turing computable, grows much faster thanpolynomials or exponentials. The definition is:
A(0, y) = y + 1A(m+1, 0) = A(m, 1)A(m+1, n+1) = A(m, A(m+1, n)) Examples:
^ Lambda calculus is a language with clear operational and denotationalsemantics capable of expressing algorithms. Also it forms a compactlanguage to denote mathematical proofs. ^ Logic provides a formal language in which mathematical statements can beformulated and provides deductive power to derive these. Type theory is aformal system, based on lambda calculus and logic, in which statements,computable functions and proofs all can be naturally represented. ^ The lambda calculus is a good medium to represent mathematics on acomputer with the aim to exchange and store reliable mathematicalknowledge.
as declarations: (lambda (x) …) or (let ((x …)) …)The occurrence of x in both the lambda-abstraction and the let-clauseintroduces the variable as a name for some value. In particular, in thelambda expression, the value of the variable x will be supplied when theprocedure is called, whereas in the let expression the value of the variableis determined by the value of the first “…” (init expression). as references: (f x y)Here all variables, f, x, y, appear as references, whose meanings aredefined by an enclosing declaration.
^ A variable x occurs free in e if and only if there is some use of x in e, that isnot bound by any declaration of x in e. ^ A variable x occurs bound in an expression e if and only if there is some useof x in e that is bound by a declaration of x in e.Examples:((lambda (x) x) y): x is bound, but y is free(lambda (f) (lambda (x) (f x))): both f and x are boundNote: Lambda expressions with no free variables are called combinators. Everyprocedure, when applied to all its necessary arguments, is a combinator.Therefore, procedure calls are called combinations in Scheme.
^ Problem:
For each variable reference find the corresponding declarationto which it refers. ^ This problem is easier to solve, when we ask:
Given a declaration, which variable references refer to it? ^ In the definition of programming languages, binding rules for variablestypically associate with each declaration of a variable a region of the programwithin the declaration is effective.Examples:
(lambda (x) …): The region of x is the body of the lambda expression.(define x …): The region of x is the whole program.
^ In lambda-calculus as in many modern programming languages regions canbe nested within each other. We call these languages block-structured, andregions are also called blocks.> (define x
; first declaration of x
(lambda (x)
; second declaration of x
(map(lambda (x)
; third declaration of x (+ x 1))
; refers to third
x)))^
; refers to second
(x `( 1 2 3))
; refers to first
Com S 342
^ We use contour diagrams to picture the borders of a region: ^ The lexical (or static) depth of a variable reference is the number of contourscrossed to find the associated declaration. ^ The lexical depth is used in compilers to tell how many static links to traverseto find a variable.
Environment
^ The declarations associated with a region may be numbered in the order oftheir appearance in the text. Each variable reference may then be associatedwith two numbers: its lexical depth and its position (both start with 0). ^ To illustrate lexical addresses, we replace every variable reference x with anexpression (x : d p), where d is the lexical depth and p is the declarationposition of v.
(lambda (x y)((lambda (a)((x : 1 0) ((a : 0 0) (y : 1 1))))(x : 0 0))) Note: The lexical address can be used by a compiler: lexical depth = number ofstatic links, and the lexical position = offset within activation frame.