280 likes | 403 Vues
This presentation discusses fixed-point combinators within the framework of lambda calculus, focusing on $beta$-reduction, the definition of reducible expressions, and the concept of values and substitutions without variable captures. The abstract syntax, operational semantics, and recursive functions in lambda calculus are explored, with emphasis on the Y combinator and its applications, including non-termination scenarios. Illustrative examples, like the factorial function, clarify these concepts, showcasing the power of fixed points in recursive function definitions.
E N D
CSE-321 Programming LanguagesFixed Point Combinator 박성우 POSTECH March 29, 2006
: -reduction redex = reducible expression Values and Reductions
Substitution Completed avoid variable captures
Outline • 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
Recursive Functions in -calculus • Plan of attack • Assume a recursive function constructfun f x. e • Rewrite it as an expression in the -calculusi.e., show that it is syntactic sugar.
Example: Factorial • Plan of attack • Assume a recursive function construct • Rewrite it as an expression in the -calculusi.e., show that it is syntactic sugar.
new! KEY Observation on FAC
FAC improves the input function f :computes fac(0), fac(1), ..., fac(k) :computes fac(0), fac(1), ..., fac(k), fac(k + 1)
Special Case no matter what
Fixed Point • Fixed point of function f V such that V = f (V) • Ex. f (x) = 2 - x fixed point of f = 11 = f (1)
Now we only need to solve: Now we only need to find a fixed point of:
Magic Revealed • Fixed point combinator / Y combinator (call-by-value) • fix F returns a fixed point of F.
Now we only need to solve: Now we only need to find a fixed point of: Now we only need to compute:
If you are a masochist, • See the course notes to learn how to derive the fixed point combinator! • There is a really crazy idea!