CS 541 Lecture -*- Outline -*- * Reductions advert: computational aspect of the lambda calculus ** Operational semantics (rewrite rules) --------------- LAMBDA CALCULUS: REDUCTION def: reduction, denoted --> (or red), relates the lhs to rhs of equational rules beta and eta. Examples: (\x.y) z --> y (\x.inc x) --> inc def: a redex is a subexpression where a beta or eta-reduction can take place def: the relation -->* is the reflexive, transitive closure of --> ----------------- ** Normal form ---------------- NORMAL FORM def: a term is in (beta,eta) normal form if does not contain beta or eta redexes e.g., x, \x.x but not: (\x.y) z or (\x.y x) ------------------------- beta normal form if no beta-redexes *** Not every term has a normal form in the untyped langauge ------------------ (\x.x x) (\x.x x) ------------------ although every term does in the typed language! note why the above doesn't work in typed language *** Normal-order reduction strategy like call by name, call by need, lazy evaluation ----------------- REDUCTION STRATEGIES def: normal-order evaluation strategy is to always reduce the leftmost, outermost redex example: ((\b.c)((\x.x x)(\x.x x))) --> c ----------------- *** Applicative-order reduction strategy like Scheme, most programming languages ------------------ def: applicative-order evaluation strategy is to always reduce both operator and operand of leftmost, outermost beta redex before reducing term example: ((\b.c)((\x.x x)(\x.x x))) --> (\b.c)((\x.x x)(\x.x x)) --> ... ------------------- ** Church-rosser theorems: ------------------------- CHURCH ROSSER THEOREMS 1. If X <--> Y, then there is some Z such that X -->* Z and Y -->* Z (this property is called *confluence*) ------------------------- corollary: a term cannot have 2 incongruent normal forms. Pf: Suppose A has normal forms N1 and N2, i.e. A -->* N1 and A -->* N2. Then N1 <--> N2. By CR1, exists Z such that N1 -->* Z and N2 -->*Z. But N1 and N2 are in normal form, so have no B or H redexes. Hence N1 and N2 must be congruent to Z and hence are congruent. ------------------------- 2. If X has a normal form Y, there is a normal order reduction from X to Y. corollary: if want to find normal form, use normal order eval. ------------------------- ** Normalization, comparison of simply typed and untyped calculus ------------------------- NORMALIZATION def: a system is * weakly normalizing (or church-rosser, confluent): if only one normal form for a term * strong normalizing (terminating): if every term has a normal form ------------------------- untyped calculus is weakly normalizing. simply typed calculus is strongly normalizing