David Evans CS150: Computer Science University of Virginia Computer Science Lecture 39: Lambda Calculus.

Slides:



Advertisements
Similar presentations
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
Advertisements

David Evans CS150: Computer Science University of Virginia Computer Science Lecture 26: Proving Uncomputability Visualization.
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
David Evans CS200: Computer Science University of Virginia Computer Science Class 30: Models of Computation.
Class 39: Universality cs1120 Fall 2009 David Evans University of Virginia.
David Evans CS200: Computer Science University of Virginia Computer Science Class 27: Modeling Computation.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 40: Computing with Glue and Photons.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
CS 310 – Fall 2006 Pacific University CS310 Turing Machines Section 3.1 November 6, 2006.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Turing Machines CS 105: Introduction to Computer Science.
Class 19: Undecidability in Theory and Practice David Evans cs302: Theory of Computation University of Virginia Computer.
Prof. Busch - LSU1 Turing Machines. Prof. Busch - LSU2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
David Evans CS200: Computer Science University of Virginia Computer Science Class 31: Universal Turing Machines.
Lecture 14: Church-Turing Thesis Alonzo Church ( ) Alan Turing ( )
Lecture 20: λ Calculus λ Calculus & Computability Yan Huang Dept. of Comp. Sci. University of Virginia.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
Class 37: Computability in Theory and Practice cs1120 Fall 2011 David Evans 21 November 2011 cs1120 Fall 2011 David Evans 21 November 2011.
Functional Programming Universitatea Politehnica Bucuresti Adina Magda Florea
10/12/20151 GC16/3C11 Functional Programming Lecture 3 The Lambda Calculus A (slightly) deeper look.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Fixed Points and Biological Computing.
Lecture 8: The Meaning of Life, Searching for Truth and The Stuff Primitives are Made Of (and a smattering of Quantum Physics) David Evans
David Evans CS150: Computer Science University of Virginia Computer Science Class 33: Computing with Photons From The.
CSE 311 Foundations of Computing I Lecture 26 Computability: Turing machines, Undecidability of the Halting Problem Spring
CSE 311 Foundations of Computing I Lecture 29 Computability: Turing machines, Undecidability of the Halting Problem Autumn 2012 CSE 3111.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 36: Modeling Computing.
Logical and Functional Programming
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Boolean Functions and Boolean Algebra Laxmikant Kale.
Computer Theory Michael J. Watts
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
David Evans CS150: Computer Science University of Virginia Computer Science Class 32: Computability in Theory and Practice.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
MA/CSSE 474 Theory of Computation Universal Turing Machine Church-Turing Thesis (Winter 2016, these slides were also used for Day 33)
David Evans CS200: Computer Science University of Virginia Computer Science Class 26: Halting Problem It is plain at any.
Fall 2013 Lecture 27: Turing machines and decidability CSE 311: Foundations of Computing.
Lecture 6: Lambda Calculus
Class 27: Universal Turing Machines CS150: Computer Science
Busch Complexity Lectures: Turing Machines
CSE 311 Foundations of Computing I
Lecture 37: A Universal Computer
Lambda Calculus Revisited
Turing Machines 2nd 2017 Lecture 9.
Decidable Languages Costas Busch - LSU.
Functions Computers take inputs and produce outputs, just like functions in math! Mathematical functions can be expressed in two ways: We can represent.
Class 36: The Meaning of Truth CS200: Computer Science
Class 37: Making Lists, Numbers and Recursion from Glue Alone
Lecture 27: In Praise of Idleness CS200: Computer Science
Formal Languages, Automata and Models of Computation
Class 33: Making Recursion M.C. Escher, Ascending and Descending
From now on: Combinatorial Circuits:
Class 24: Computability Halting Problems Hockey Team Logo
Class 31: Universal Turing Machines CS200: Computer Science
Class 34: Models of Computation CS200: Computer Science
Class 33: Learning to Count CS200: Computer Science
Class 26: Modeling Computing CS150: Computer Science
The Church-Turing Thesis and Turing-completeness
Presentation transcript:

David Evans CS150: Computer Science University of Virginia Computer Science Lecture 39: Lambda Calculus

2 Lecture 39: Lambda Calculus Equivalent Computers zzzzzzz 1 Start HALT ), X, L 2: look for ( #, 1, -  ), #, R  (, #, L (, X, R #, 0, - Finite State Machine... Turing Machine  term = variable | term term | (term) | variable. term y. M   v. (M [y v]) where v does not occur in M. ( x. M)N   M [ x N ] Lambda Calculus

3 Lecture 39: Lambda Calculus What is Calculus? In High School: d/dx x n = nx n-1 [Power Rule] d/dx (f + g) = d/dx f + d/dx g [Sum Rule] Calculus is a branch of mathematics that deals with limits and the differentiation and integration of functions of one or more variables...

4 Lecture 39: Lambda Calculus Real Definition A calculus is just a bunch of rules for manipulating symbols. People can give meaning to those symbols, but that’s not part of the calculus. Differential calculus is a bunch of rules for manipulating symbols. There is an interpretation of those symbols corresponds with physics, slopes, etc.

5 Lecture 39: Lambda Calculus Lambda Calculus Rules for manipulating strings of symbols in the language: term = variable | term term | (term) | variable. term Humans can give meaning to those symbols in a way that corresponds to computations.

6 Lecture 39: Lambda Calculus Why? Once we have precise and formal rules for manipulating symbols, we can use it to reason with. Since we can interpret the symbols as representing computations, we can use it to reason about programs.

7 Lecture 39: Lambda Calculus Evaluation Rules  -reduction(renaming) y. M   v. (M [y v]) where v does not occur in M.  -reduction(substitution) ( x. M)N   M [ x N ] Note the syntax is different from Scheme: ( x.M)N  ((lambda (x) M) N)

8 Lecture 39: Lambda Calculus  - Reduction (the source of all computation) ( x. M)N  M [ x N ] Replace all x ’s in M witn N

9 Lecture 39: Lambda Calculus 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.

10 Lecture 39: Lambda Calculus 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

11 Lecture 39: Lambda Calculus Example f. (( x. f (xx)) ( x. f (xx)))

12 Lecture 39: Lambda Calculus Possible 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))  ...

13 Lecture 39: Lambda Calculus Alternate 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)  ...

14 Lecture 39: Lambda Calculus Be Very Afraid! Some -calculus terms can be  -reduced forever! The order in which you choose to do the reductions might change the result!

15 Lecture 39: Lambda Calculus 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

16 Lecture 39: Lambda Calculus 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

17 Lecture 39: Lambda Calculus 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

18 Lecture 39: Lambda Calculus Simulating Computation zzzzzzzzzzzzzzzzzzzz 1 Start HALT ), X, L 2: look for ( #, 1, -  ), #, R  (, #, L (, X, R #, 0, - Finite State Machine 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?

19 Lecture 39: Lambda Calculus Simulating Computation zzzzzzzzzzzzzzzzzzzz 1 Start HALT ), X, L 2: look for ( #, 1, -  ), #, R  (, #, L (, X, R #, 0, - Finite State Machine Read/Write Infinite Tape Mutable Lists Finite State Machine Numbers Processing Way to make decisions (if) Way to keep going

20 Lecture 39: Lambda Calculus Making “Primitives” from Only Glue ( )

21 Lecture 39: Lambda Calculus In search of the truth? 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: if T M N  M

22 Lecture 39: Lambda Calculus Don’t search for T, search for if T  x ( y. x)  xy. x F  x ( y. y)) if  pca. pca

23 Lecture 39: Lambda Calculus 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?

24 Lecture 39: Lambda Calculus and and or? and  x ( y. if x y F)) or  x ( y. if x T y))

25 Lecture 39: Lambda Calculus Lambda Calculus is a Universal Computer? zzzzzzzzzzzzzzzzzzzz 1 Start HALT ), X, L 2: look for ( #, 1, -  ), #, R  (, #, L (, X, R #, 0, - Finite State Machine Read/Write Infinite Tape Mutable Lists Finite State Machine Numbers Processing Way to make decisions (if) Way to keep going...to be continued Wednesday...