CSE-321 Programming Languages ?-Calculus (II) - PowerPoint PPT Presentation

About This Presentation
Title:

CSE-321 Programming Languages ?-Calculus (II)

Description:

Abstract syntax of the -calculus V. Operational semantics of the l-calculus V. Substitutions ... 29. Next Lecture. Recursion in the -calculus. Read Course Notes! ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 30
Provided by: sungwo8
Category:

less

Transcript and Presenter's Notes

Title: CSE-321 Programming Languages ?-Calculus (II)


1
CSE-321 Programming Languages?-Calculus (II)
???
  • POSTECH
  • March 27, 2006

2
Values and Reductions
3
Call-by-name Call-by-value

4
Outline
  • Abstract syntax of the ?-calculus V
  • Operational semantics of the l-calculus V
  • Substitutions
  • Programming in the ?-calculus

5
e' / x e
  • Informally"substitute e' for every occurrence of
    x in e."
  • Examples

6
Easy Cases First
7
Two Remaining Cases
8
  • First (stupid) attempt
  • Second attempt
  • But wait

9
Bound Variables
  • "Names of bound variables do not matter."
  • Hence
  • Because, for a fresh variable y,

10
One Remaining Case
11
A Naive Attempt
  • An anomaly

something for y
12
Free Variables
  • Those variables that are bound nowhere
  • FV(e) set of free variables in e

13
Free Variables vs. Bound Variables
  • An outside observer does care about free
    variables.
  • An outside observer does not care about
    bound variables.
  • From the point of view of an outside observer

14
Free Variables Remain Free
  • From the point of view of an outside observer,a
    free variable remains free until it is
    explicitly replaced.

variable capture
outside observer
15
Capture-Avoiding Substitution
  • What happens if
  • the free variable y is captured and becomes a
    bound variable.
  • To an outside observer, it suddenly disappears!

16
Substitution Completed
17
Capture-Avoiding Substitution in Action
  • We have to rename bound variables as necessary.

18
?-Conversion
  • Renaming bound variables when necessary
  • Okay because the names of bound variables do not
    matter.
  • Examples

19
Formalization of ?-Conversion
  • See the course notes!
  • It's more interesting than you might think.

20
Outline
  • Abstract syntax of the ?-calculus V
  • Operational semantics of the l-calculus V
  • Substitutions V
  • Programming in the ?-calculus
  • A LOT OF FUN!

21
Booleans
  • A boolean value
  • "Give me two options and I will choose one for
    you!"
  • Syntactic sugar

22
Examples
  • Under the call-by-name strategy,

23
Logical Operators
24
Natural Numbers
  • A natural number n
  • has the capability to repeat a given process
    n times.
  • "Give me a function f and I will return f
    n f o f ... f o f "

25
Church Numerals
26
Addition
  • Key observation

27
Multiplication
  • Key observation
  • Alternatively

28
Others
  • Pairs
  • Natural numbers
  • predecessor DIFFICULT
  • subtraction
  • exponentiation
  • ...
  • Lists
  • See Course Notes and Pierce Chapter 5 for more
    examples.

29
Next Lecture
  • Recursion in the ?-calculus
  • Read Course Notes!
Write a Comment
User Comments (0)
About PowerShow.com