CS200: Computer Science, Spring 2002

Notes: 17 April 2002
Schedule
 Today, noon: Selvin George, How to Make a Sea Urchin (Olsson 228E conference room). How does biology program?
 Monday, 22 April: Problem Set 8 (Progress Meetings)
 Monday, 29 April: Problem Set 8 (Final)
Optional Readings Guy L. Steele, Growing a Language, OOPSLA 1998 Keynote. Guy Steele was a codesigner of Scheme, and one of the leading proponents of Java (and a coauthor of the Java Language Specificaion). The second page shows a machine that is equivalent to a Turing Machine. If you are bothered by the sexist language in this paper, read Douglas Hofstadter's A Person Paper on Purity in Language (attached to Steele's paper). If you weren't bothered by the sexist language in this paper, you should especially read Douglas Hofstadter's A Person Paper on Purity in Language. Read the Post Scriptum on this essay before you find it offensive.
Unlike most authors, Guy Steele had a good excuse for using sexist language because of the unusual writing constraint he imposed (which will be made clear if you read the paper). You, on the other hand, have no such excuse. I will be intolerant of sexist language in your project reports.
Lambda Calculus — you don't need to read these, but if you want more information on Lambda Calculus, here are some good sources:
 Prakash Panangaden's Notes on the LambdaCalculus, August 2000.
 David Keenan, To Dissect a Mockingbird. 1996.
 Raymond Smullyan. To Mock a Mockingbird and other logic puzzles including an amazing adventure in combinatory logic, Chapters 911. Alfred Knopf, 1985. (Unfortunately, this book is out of print. If you want to read it after reading David Keenan's paper, I can loan you a copy.)
Lambda Calculus What is a calculus?
What properties make Scheme too complex to be a good model of computation?
Lambda Calculus is a set of rules for manipulating symbols. They can be given meanings that map well to computation.
Lambda Calculus Term Grammar
term ::= variable
term ::= term term
term ::= ( term )
term ::= λ variable . termRules
Alpha Reduction: (renaming variables)Identityλ y . M ⇒_{α} λ v . M [y → v]) where v does not occur in M.We can can change the name of a lambda variable, but replacing all occurances of the variable in the body term with a new name that does not appear in the body term.Beta Reduction: (substitution)
(λ x . M) N ⇒_{β} M [ x → N ]Two lambda calculus terms are (syntactically) identical (≡) only if one of these is true:
x ≡ y if x and y are same nameHow can we know those are all the rules we need to determine if any two lambda calculus terms are equivalent?
M_{1} M_{2} ≡ N_{1} N_{2}N2 if M_{1} ≡ N_{1} and M_{2} ≡ N_{2}
(M) ≡ (N) if M ≡ N
λ x. M ≡ λ y . N if x ≡ y and M ≡ N.
Substitution
Uninteresting Reduction Rules
 For term ::= variable:
 y [x → N] = N where x ≡ y
 y [x → N] = y where x ≠ y
 For term ::= term term:
 M_{1} M_{2} [x → N] = M_{1} [x → N] M_{2} [x → N]
 For term ::= ( term ):
 (M) [x → N] ::= (M [x → N])
 For λ variable . term (we need a lot of complicated rules in case variable names are reused, otherwise it would be easy)
 (λx . M) [x → N] = λ x . M
 (λy . M) [x → N] = λy . (M [x → N]) where x ≠ y and y does not appear free in N and x appears free in M.
 (λy . M) [x → N] = λy . M where x ≠ y and x does not appear free in M.
 (λy . M) [x → N] = λy . (M [x → N]) where x ≠ y and y does not appear free in N or x does not appear free in M.
 (λ y . M) [x → N] = λz . (M [y → z) [x → N] where x &neq; y, z ≠ x and z ≠ y and z does not appear in M or N, x does occur free in M and y does occur free in N.
M ⇒ M
PM ⇒ PN if M ⇒ N
MP ⇒ NP if M ⇒ N
λ x . M ⇒ λ x . N ⇒ if M ⇒ N
M ⇒ P if M ⇒ N and N ⇒ PExample
λ f . ((λ x . f (xx)) (λ x . f (xx)))
University of Virginia Department of Computer Science CS 200: Computer Science 
David Evans evans@cs.virginia.edu Using these Materials 