cse-321 programming languages -calculus (ii) postech march 27, 2006 박성우
TRANSCRIPT
4
Outline• Abstract syntax of the -calculus V• Operational semantics of the -calculus V• Substitutions• Programming in the -calculus
9
• "Names of bound variables do not matter."
• Hence
• Because, for a fresh variable y,
Bound Variables
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.
outside observer
? variable capture
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!
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 -calculus V• Substitutions V• Programming in the -calculus
– A LOT OF FUN!
21
• A boolean value– "Give me two options and I will choose one for
you!"
• Syntactic sugar
Booleans
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 "
28
Others• Pairs• Natural numbers
– predecessor: DIFFICULT– subtraction– exponentiation– ...
• Lists
See Course Notes and Pierce Chapter 5 for more examples.