Title: CSE-321%20Programming%20Languages%20Fixed%20Point%20Combinator
1CSE-321 Programming LanguagesFixed Point
Combinator
???
2Values and Reductions
3Substitution Completed
avoid variable captures
4Outline
- Abstract syntax of the ?-calculus V
- Operational semantics of the l-calculus V
- Substitutions V
- Programming in the ?-calculus V
- Fixed point combinator
- non-termination in the ?-calculus
- recursive functions in the ?-calculus
5Non-termination in ?-calculus
6Recursive Functions in ?-calculus
- Plan of attack
- Assume a recursive function construct fun f
x. e - Rewrite it as an expression in the
?-calculusi.e., show that it is syntactic sugar.
7Example Factorial
- Plan of attack
- Assume a recursive function construct
- Rewrite it as an expression in the
?-calculusi.e., show that it is syntactic sugar.
8fac to FAC
9FAC produces a new function from f
10KEY Observation on FAC
11FAC improves the input function f
computes fac(0), fac(1), ..., fac(k)
computes fac(0), fac(1), ..., fac(k), fac(k 1)
12Special Case
no matter what
13Invariant
14FAC fac
15Key Equation
16What is f ?
17(No Transcript)
18(Earlier Slide)
19(No Transcript)
20(No Transcript)
21Now we only need to solve
22Fixed 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)
23Now we only need to solve
Now we only need to find a fixed point of
24Magic Revealed
- Fixed point combinator / Y combinator
(call-by-value) - fix F returns a fixed point of F.
25Magic Explained
26Now we only need to solve
Now we only need to find a fixed point of
Now we only need to compute
27Answer
28If you are a masochist,
- See the course notes to learn how to derive the
fixed point combinator! - There is a really crazy idea!