University of Virginia Computer Science CS150: Computer Science, Fall 2005 (none) 7 November 2005

## CS150 Notes 32 (7 November 2005)

#### Upcoming Schedule

• Now: Problem Set 7
• Tuesday, 8 November (11:59pm): Problem Set 8 project descriptions (note: extended one day from PS8 handout)
• Wednesday, 9 November, 7pm: Exam 2 review session
• Monday, 14 November: Exam 2 (out Friday 11 November)
• Monday, 5 December: Problem Set 8 Presentations/Final Reports
Exam 2
Exam 2 will be handed out Friday, November 11 and due Monday, November 14. It will cover everything in the course through the end of today's lecture. It can include questions about material from the entire course up through today, but will focus primarily on material that was not covered on Exam 1. Exam 2 will be open book and open notes.

The Exam 2 Study Guide contains sample questions from previous Exams on the topics your Exam 2 will cover.

Notes

How do we prove a model of computation is equivalent to a Turing Machine?

Lambda Calculus

term ::= variable | term term | ( term ) | λ variable . term

Alpha Reduction: (renaming variables)

λ 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 ]
Example

f . ((λ x . f (xx)) (λ x . f (xx)))) λ x . x

Making "Primitives" out of nothing but Glue

T ≡ λ xy . x)
F ≡ λ xy . y
if ≡ λ pca . pca

cons ≡ λ xy .z . zxy)
car ≡ λ p . p T
cdr ≡ λ p . p F

null ≡ λ p . T
null? ≡ λ x . (x λ y . λ z . F)

zero?null?
predcdr
succ ≡ λ x . cons F x

0null
1succ 0cons F null
2succ 1cons F (cons F null)