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 beta-reduction. ◮ Detect α -capture and use α -renaming to avoid it. ◮ Normalize any given λ -calculus term.
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
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 @ → β a a λ x x
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 @ → β @ a a a λ x @ x x
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 @ → β @ y a a λ x @ y x
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 @ λ a → α,β λ a ′ �→ a a a λ x λ a x
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 a x λ x λ x x
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 @ @ a a λ x λ y y @ λ y x y
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 → β → β → β a @ @ a a λ x λ y y @ λ y x y
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 .
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. @ @ λ a λ q λ x @ λ f f a a @ f x
Objectives Examples Solution @ @ λ a λ q @ λ x a a λ f f @ x f ( λ xf . fx )( λ q . f )( λ a . aa ) ◮ There is one free variable ....
Objectives Examples Solution, Step 1 @ 1 @ 1 @ 2 λ a @ 2 λ a λ q λ x @ 4 λ q λ x @ 4 a a a a λ f ′ f λ f f @ 3 @ 3 x f x f ′ ( λ xf . fx )( λ q . f )( λ a . aa ) ( λ xf ′ . f ′ x )( λ q . f )( λ a . aa ) → α
@ f a @ @ q a a f f f f q f a aa Objectives Examples Solution, Step 2 @ 1 @ 2 λ a λ q λ x @ 4 a a λ f ′ f @ 3 x f ′ ( λ xf ′ . f ′ x )( λ q . f )( λ a . aa ) → β
Objectives Examples Solution, Step 2 @ 1 @ 1 @ 2 λ a λ f ′ λ a λ q λ x @ 3 @ 4 @ 4 a a λ q a a λ f ′ f f ′ f @ 3 x f ′ ( λ xf ′ . f ′ x )( λ q . f )( λ a . aa ) ( λ f ′ . f ′ ( λ q . f ))( λ a . aa ) → β
@ q a @ f a a a aa q f Objectives Examples Solution, Step 3 @ 1 λ f ′ λ a @ 3 @ 4 λ q a a f ′ f ( λ f ′ . f ′ ( λ q . f ))( λ a . aa ) → β
Objectives Examples Solution, Step 3 @ 1 @ 3 λ q λ f ′ λ a λ a @ 3 @ 4 f @ 4 a a λ q a a f ′ f ( λ f ′ . f ′ ( λ q . f ))( λ a . aa ) ( λ a . aa )( λ q . f ) → β
@ q q f f q f q f Objectives Examples Solution, Step 4 @ 3 λ q λ a @ 4 f a a ( λ f ′ . f ′ ( λ q . f ))( λ a . aa ) → β
Objectives Examples Solution, Step 4 @ 3 @ 4 λ q λ q λ q λ a f f @ 4 f a a ( λ f ′ . f ′ ( λ q . f ))( λ a . aa ) ( λ q . f )( λ q . f ) → β
f f Objectives Examples Solution, Step 5 @ 4 λ q λ q f f ( λ q . f )( λ q . f ) → β
Objectives Examples Solution, Step 5 f @ 4 λ q λ q f f ( λ q . f )( λ q . f ) f → β
Recommend
More recommend