Lambda Calculus Dr. Mattox Beckman University of Illinois at - - PowerPoint PPT Presentation

lambda calculus
SMART_READER_LITE
LIVE PREVIEW

Lambda Calculus Dr. Mattox Beckman University of Illinois at - - PowerPoint PPT Presentation

Objectives Lambda Calculus Lambda Calculus Dr. Mattox Beckman University of Illinois at Urbana-Champaign Department of Computer Science Objectives Lambda Calculus Objectives You should be able to ... The purposes of this lecture is to


slide-1
SLIDE 1

Objectives Lambda Calculus

Lambda Calculus

  • Dr. Mattox Beckman

University of Illinois at Urbana-Champaign Department of Computer Science

slide-2
SLIDE 2

Objectives Lambda Calculus

Objectives

You should be able to ...

The purposes of this lecture is to introduce lambda calculus and explain the role it has in programming languages.

◮ Explain the three constructs of λ-calculus. ◮ Given a syntax tree diagram, write down the equivalent λ-calculus term. ◮ Perform a beta-reduction.

slide-3
SLIDE 3

Objectives Lambda Calculus

The λ-Calculus

◮ Contains three kinds of things:

  • 1. Variables: x y z – usually we assume they are all one letter long.
  • 2. Function application:

fy abc x fy fg

  • 3. Functions (Also called abstractions.)

x x ab fab xy g z zf yx

Used extensively in research. The “little white mouse” of computer science. We can implement this trivially in Haskell. x x = \x -> x.

slide-4
SLIDE 4

Objectives Lambda Calculus

The λ-Calculus

◮ Contains three kinds of things:

  • 1. Variables: x y3 z′ – usually we assume they are all one letter long.
  • 2. Function application:

fy abc x fy fg

  • 3. Functions (Also called abstractions.)

x x ab fab xy g z zf yx

Used extensively in research. The “little white mouse” of computer science. We can implement this trivially in Haskell. x x = \x -> x.

slide-5
SLIDE 5

Objectives Lambda Calculus

The λ-Calculus

◮ Contains three kinds of things:

  • 1. Variables: x y3 z′ – usually we assume they are all one letter long.
  • 2. Function application:

fy abc x(fy)(fg)

  • 3. Functions (Also called abstractions.)

x x ab fab xy g z zf yx

Used extensively in research. The “little white mouse” of computer science. We can implement this trivially in Haskell. x x = \x -> x.

slide-6
SLIDE 6

Objectives Lambda Calculus

The λ-Calculus

◮ Contains three kinds of things:

  • 1. Variables: x y3 z′ – usually we assume they are all one letter long.
  • 2. Function application:

fy abc x(fy)(fg)

  • 3. Functions (Also called abstractions.)

λx.x λab.fab λxy.g(λz.zf)yx

Used extensively in research. The “little white mouse” of computer science. We can implement this trivially in Haskell. x x = \x -> x.

slide-7
SLIDE 7

Objectives Lambda Calculus

The λ-Calculus

◮ Contains three kinds of things:

  • 1. Variables: x y3 z′ – usually we assume they are all one letter long.
  • 2. Function application:

fy abc x(fy)(fg)

  • 3. Functions (Also called abstractions.)

λx.x λab.fab λxy.g(λz.zf)yx

◮ Used extensively in research. The “little white mouse” of computer science. ◮ We can implement this trivially in Haskell.

λx.x = \x -> x.

slide-8
SLIDE 8

Objectives Lambda Calculus

Examples

λx.x “The identity” λx.xx “Delta” λab.fabxy (λab.fab)xy (λa.λb.fab)xy (λfx.xf)(λg.gx)(λf.f)zy

slide-9
SLIDE 9

Objectives Lambda Calculus

Syntax Trees

Example 1 Example 2 Example 3 Example 4 λx x λy @ y x @ @ λy y x z λz @ λx @ x z λy @ y z λx.x λy.yx (λy.y)xz λz.(λx.xz)(λy.yz)

slide-10
SLIDE 10

Objectives Lambda Calculus

Bound and Free

◮ The λ creates a binding. ◮ An occurance of the the variable inside the function body is said to be bound. ◮ Bound variables occur “under the λ” that binds them.

Examples: Where are the free variables? To which lambdas are bound variables bound? λz @ λx @ x z λy @ y z λx @ λz @ x z λy @ y z λz @ λz @ x z λy @ y z λz.(λx.xz)(λy.yz) λx.(λz.xz)(λy.yz) λz.(λz.xz)(λy.yz)

slide-11
SLIDE 11

Objectives Lambda Calculus

Function Application

(λx.M)N → [N/x]M [N/x] y = y [N/x] x = N [N/x] (M P) = ([N/x]M [N/x]P) [N/x] (λy.M) = λy.[N/x]M [N/x] (λx.M) = λx.M