140 likes | 146 Views
Explore the concept of truth in Lambda Calculus and its implications in computer science. Discover how Lambda Calculus can simulate Turing Machines and prove its universality. Learn about the process of simulating computation and the role of primitives in Lambda Calculus.
E N D
Class 32: The Meaning of Truth David Evans http://www.cs.virginia.edu/evans CS200: Computer Science University of Virginia Computer Science
Menu • Lambda Calculus Review • How to Prove Something is a Universal Computer • Making “Primitives” CS 200 Spring 2004
Lambda Calculus Review term ::= variable |term term | (term)| variable .term ( f. (( x.f (xx))( x. f (xx)))) (z.z) Parens are just for grouping, not like in Scheme -reduction (renaming) y. M v. (M [yv]) where v does not occur in M. -reduction (substitution) (x. M)N M [ xN ] CS 200 Spring 2004
Alyssa P. Hacker’s Answer ( f. (( x.f (xx))( x. f (xx)))) (z.z) (x.(z.z)(xx))( x. (z.z)(xx)) (z.z) ( x.(z.z)(xx)) ( x.(z.z)(xx)) (x.(z.z)(xx)) ( x.(z.z)(xx)) (z.z) ( x.(z.z)(xx)) ( x.(z.z)(xx)) (x.(z.z)(xx)) ( x.(z.z)(xx)) ... CS 200 Spring 2004
Ben Bitdiddle’s Answer ( f. (( x.f (xx))( x. f (xx)))) (z.z) (x.(z.z)(xx))( x. (z.z)(xx)) (x.xx)(x.(z.z)(xx)) (x.xx)(x.xx) (x.xx)(x.xx) ... CS 200 Spring 2004
Be Very Afraid! • Some -calculus terms can be -reduced forever! • The order in which you choose to do the reductions might change the result! CS 200 Spring 2004
Take on Faith (until CS655) • All ways of choosing reductions that reduce a lambda expression to normal form will produce the same normal form (but some might never produce a normal form). • If we always apply the outermost lambda first, we will find the normal form if there is one. • This is normal order reduction – corresponds to normal order (lazy) evaluation CS 200 Spring 2004
Universal Language • Is Lambda Calculus a universal language? • Can we compute any computable algorithm using Lambda Calculus? • To prove it isn’t: • Find some Turing Machine that cannot be simulated with Lambda Calculus • To prove it is: • Show you can simulate every Turing Machine using Lambda Calculus CS 200 Spring 2004
Simulating Every Turing Machine • A Universal Turing Machine can simulate every Turing Machine • So, to show Lambda Calculus can simulate every Turing Machine, all we need to do is show it can simulate a Universal Turing Machine CS 200 Spring 2004
Simulating Computation z z z z z z z z z z z z z z z z z z z z • Lambda expression corresponds to a computation: input on the tape is transformed into a lambda expression • Normal form is that value of that computation: output is the normal form • How do we simulate the FSM? ), X, L ), #, R (, #, L 2: look for ( 1 Start (, X, R HALT #, 0, - #, 1, - Finite State Machine CS 200 Spring 2004
Simulating Computation z z z z z z z z z z z z z z z z z z z z Read/Write Infinite Tape Mutable Lists Finite State Machine Numbers to keep track of state Processing Way of making decisions (if) Way to keep going ), X, L ), #, R (, #, L 2: look for ( 1 Start (, X, R HALT #, 0, - #, 1, - Finite State Machine CS 200 Spring 2004
Making “Primitives”from Only Glue () CS 200 Spring 2004
In search of thetruth? • What does true mean? • True is something that when used as the first operand of if, makes the value of the if the value of its second operand: ifTMN M CS 200 Spring 2004
Charge • Remember: if you have team requests for PS8, I must receive them before midnight tonight! • Friday: finish discovering truth (and proving lambda calculus is as powerful as a Turing Machine) • Monday: Review session for Exam 2 CS 200 Spring 2004