1 / 23

The Meaning of Truth in Lambda Calculus

Explore the concept of truth in Lambda Calculus, including evaluation of lambda expressions and the simulation of Turing Machines. Discover how Lambda Calculus can be a universal computer and its relationship with finite state machines.

Download Presentation

The Meaning of Truth in Lambda Calculus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Class 28: The Meaning of Truth David Evans http://www.cs.virginia.edu/evans http://chandra.harvard.edu/photo/2001/0094true/0094true_hand.html CS150: Computer Science University of Virginia Computer Science

  2. -calculus Alonzo Church, 1940 (LISP was developed from -calculus, not the other way round.) term = variable | term term | (term) |  variable .term

  3. Reduction (Uninteresting Rules) y. M v. (M [y  v]) where v does not occur in M. M  M M  N  PM  PN M  N  MP  NP M  N  x. M  x. N M  N and N  P  M  P

  4. -Reduction (the source of all computation) (x. M)N  M [ xN ]

  5. Evaluating Lambda Expressions • redex: Term of the form (x. M)N Something that can be -reduced • An expression is in normal form if it contains no redexes (redices). • To evaluate a lambda expression, keep doing reductions until you get to normal form.

  6. Recall Apply in Scheme “To apply a procedure to a list of arguments, evaluate the procedure in a new environment that binds the formal parameters of the procedure to the arguments it is applied to.” • We’ve replaced environments with substitution. • We’ve replaced eval with reduction.

  7. Some Simple Functions I x.x Cxy.yx Abbreviation for x.(y. yx) CII = (x.(y. yx)) (x.x) (x.x)  (y. y (x.x))(x.x) x.x (x.x) x.x = I

  8. Example  f. (( x.f (xx))( x. f (xx))) Try this one at home...

  9. 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)) ...

  10. 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) ...

  11. Be Very Afraid! • Some -calculus terms can be -reduced forever! • The order in which you choose to do the reductions might change the result!

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. Making “Primitives”from Only Glue ()

  18. 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

  19. Don’t search for T, search for if T  x (y. x)  xy. x F  x ( y. y)) if pca . pca

  20. Finding the Truth T  x . (y. x) F  x . (y. y) if p . (c . (a . pca))) if T M N ((pca . pca) (xy. x)) M N  (ca . (x.(y. x)) ca)) M N   (x.(y. x))M N  (y. M ))N  M Is the if necessary?

  21. and and or? and x (y. ifxyF)) or x (y. ifxTy))

  22. Lambda Calculus is a Universal Computer? z z z z z z z z z z z z z z z z z z z z ), X, L ), #, R (, #, L 2: look for ( 1 • 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 Start (, X, R HALT #, 0, - #, 1, - Finite State Machine

  23. Charge • PS6 Due Monday • Start thinking about web application ideas for PS8 • If you find a team and idea quickly (by Nov 2), you can negotiate what you need to do for PS7 • Week after: we will finish this proof • How to make the other things we need to simulate a Turing machine using only Lambda Calculus

More Related