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

lambda calculus examples
SMART_READER_LITE
LIVE PREVIEW

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

Objectives Examples Lambda Calculus Examples Dr. Mattox Beckman University of Illinois at Urbana-Champaign Department of Computer Science Objectives Examples Objectives You should be able to ... Here are some examples! Perform a


slide-1
SLIDE 1

Objectives Examples

Lambda Calculus Examples

  • Dr. Mattox Beckman

University of Illinois at Urbana-Champaign Department of Computer Science

slide-2
SLIDE 2

Objectives Examples

Objectives

You should be able to ...

Here are some examples!

◮ Perform a beta-reduction. ◮ Detect α-capture and use α-renaming to avoid it. ◮ Normalize any given λ-calculus term.

slide-3
SLIDE 3

Objectives Examples

Examples

(λx.x) a (λx.x x) a (λx.y x) a (λx.λa.x) a (λx.λx.x) a (λx.(λy.y) x) a

slide-4
SLIDE 4

Objectives Examples

Examples

(λx.x) a →β a (λx.x x) a (λx.y x) a (λx.λa.x) a (λx.λx.x) a (λx.(λy.y) x) a @ λx x a →β a

slide-5
SLIDE 5

Objectives Examples

Examples

(λx.x) a →β a (λx.x x) a →β a a (λx.y x) a (λx.λa.x) a (λx.λx.x) a (λx.(λy.y) x) a @ λx @ x x a →β @ a a

slide-6
SLIDE 6

Objectives Examples

Examples

(λx.x) a →β a (λx.x x) a →β a a (λx.y x) a →β y a (λx.λa.x) a (λx.λx.x) a (λx.(λy.y) x) a @ λx @ y x a →β @ y a

slide-7
SLIDE 7

Objectives Examples

Examples

(λx.x) a →β a (λx.x x) a →β a a (λx.y x) a →β y a (λx.λa.x) a →α (λx.λa′.x) →β λa′.a (λx.λx.x) a (λx.(λy.y) x) a @ λx λa x a → λa a →α,β λa′ a

slide-8
SLIDE 8

Objectives Examples

Examples

(λx.x) a →β a (λx.x x) a →β a a (λx.y x) a →β y a (λx.λa.x) a →α (λx.λa′.x) →β λa′.a (λx.λx.x) a →β λx.x (λx.(λy.y) x) a @ λx λx x a →β λx x

slide-9
SLIDE 9

Objectives Examples

Examples

(λx.x) a →β a (λx.x x) a →β a a (λx.y x) a →β y a (λx.λa.x) a →α (λx.λa′.x) →β λa′.a (λx.λx.x) a →β λx.x (λx.(λy.y) x) a →β (λy.y) a @ λx @ λy y x a →β @ λy y a →β a

slide-10
SLIDE 10

Objectives Examples

Examples

(λx.x) a →β a (λx.x x) a →β a a (λx.y x) a →β y a (λx.λa.x) a →α (λx.λa′.x) →β λa′.a (λx.λx.x) a →β λx.x (λx.(λy.y) x) a →β (λy.y) a →β a @ λx @ λy y x a →β @ λy y a →β a

slide-11
SLIDE 11

Objectives Examples

α capture

(λx.λa.x) a →α (λx.λa′.x) →β λa′.a

◮ If a free occurrence of a variable gets placed under a λ that binds it, this is called α

capture.

◮ To resolve this, rename the binder.

slide-12
SLIDE 12

Objectives Examples

Here’s One for You to Try!

◮ Convert this tree into an equivalent λ term. ◮ Identify the free variables. ◮ Simplify it by performing as many β reductions (and necessary α renamings) as possible.

@ @ λx λf @ f x λq f λa @ a a

slide-13
SLIDE 13

Objectives Examples

Solution

@ @ λx λf @ f x λq f λa @ a a (λxf.fx)(λq.f)(λa.aa)

◮ There is one free variable ....

slide-14
SLIDE 14

Objectives Examples

Solution, Step 1

@1 @2 λx λf @3 f x λq f λa @4 a a @1 @2 λx λf′ @3 f′ x λq f λa @4 a a (λxf.fx)(λq.f)(λa.aa) →α (λxf′.f′x)(λq.f)(λa.aa)

slide-15
SLIDE 15

Objectives Examples

Solution, Step 2

@1 @2 λx λf′ @3 f′ x λq f λa @4 a a @ f @ f q f a @ a a (λxf′.f′x)(λq.f)(λa.aa) →β f f q f a aa

slide-16
SLIDE 16

Objectives Examples

Solution, Step 2

@1 @2 λx λf′ @3 f′ x λq f λa @4 a a @1 λf′ @3 f′ λq f λa @4 a a (λxf′.f′x)(λq.f)(λa.aa) →β (λf′.f′(λq.f))(λa.aa)

slide-17
SLIDE 17

Objectives Examples

Solution, Step 3

@1 λf′ @3 f′ λq f λa @4 a a @ a @ a a q f (λf′.f′(λq.f))(λa.aa) →β a aa q f

slide-18
SLIDE 18

Objectives Examples

Solution, Step 3

@1 λf′ @3 f′ λq f λa @4 a a @3 λa @4 a a λq f (λf′.f′(λq.f))(λa.aa) →β (λa.aa)(λq.f)

slide-19
SLIDE 19

Objectives Examples

Solution, Step 4

@3 λa @4 a a λq f @ q f q f (λf′.f′(λq.f))(λa.aa) →β q f q f

slide-20
SLIDE 20

Objectives Examples

Solution, Step 4

@3 λa @4 a a λq f @4 λq f λq f (λf′.f′(λq.f))(λa.aa) →β (λq.f)(λq.f)

slide-21
SLIDE 21

Objectives Examples

Solution, Step 5

@4 λq f λq f f (λq.f)(λq.f) →β f

slide-22
SLIDE 22

Objectives Examples

Solution, Step 5

@4 λq f λq f f (λq.f)(λq.f) →β f