View
35
Download
2
Category
Preview:
DESCRIPTION
CSE-321 Programming Languages -Calculus (II). 박성우. POSTECH March 26, 2007. : -reduction. redex = reducible expression. Values and Reductions. Call-by-name Call-by-value. Outline. Abstract syntax of the -calculus V Operational semantics of the l -calculus V Substitutions - PowerPoint PPT Presentation
Citation preview
4
Outline• Abstract syntax of the -calculus V• Operational semantics of the -calculus V• Substitutions• Programming in the -calculus
13
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
14
Capture-Avoiding Substitution
• What happens if– the free variable y is captured and becomes a
bound variable. – To an outside observer, it suddenly disappears!
17
Conversion• Renaming bound variables when necessary• Okay because the names of bound variables do not
matter.• Examples
18
Formalization of -Conversion• See the course notes!
– It's more interesting than you might think.
19
Outline• Abstract syntax of the -calculus V• Operational semantics of the -calculus V• Substitutions V• Programming in the -calculus
20
• A boolean value– "Give me two options and I will choose one for
you!"
• Syntactic sugar
Booleans
23
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 "
27
Recursive Functions in -Calculus• Plan of attack
1. Assume a recursive function construct
fun f x. e
2. Rewrite it as an expression in the -calculusi.e., show that it is syntactic sugar.
28
• Plan of attack
1. Assume a recursive function construct
2. Rewrite it as an expression in the -calculusi.e., show that it is syntactic sugar.
Example: Factorial
32
Fixed Point• Fixed point of function f
V such that V = f (V)
• Ex.
f (x) = 2 - x
fixed point of f = 1
1 = f (1)
33
Magic Revealed• Fixed point combinator / Y combinator
(call-by-value)
• fix F returns a fixed point of F.
Recommended