+ All Categories
Home > Documents > David Evans

David Evans

Date post: 24-Feb-2016
Category:
Upload: ojal
View: 291 times
Download: 0 times
Share this document with a friend
Description:
Class 32: Computability in Theory and Practice. David Evans http://www.cs.virginia.edu/evans. CS150: Computer Science University of Virginia Computer Science. Menu. Lambda Calculus Review Computability in Theory and Practice Learning to Count. Universal Computation. z. z. z. z. z. - PowerPoint PPT Presentation
Popular Tags:
34
David Evans http://www.cs.virginia.edu/ evans CS150: Computer Science University of Virginia Computer Science Class 32: Computabil ity in Theory and Practice
Transcript
Page 1: David Evans

David Evanshttp://www.cs.virginia.edu/evans

CS150: Computer ScienceUniversity of VirginiaComputer Science

Class 32:Computability in Theory and Practice

Page 2: David Evans

2CS150 Fall 2005: Lecture 32: Computability

Menu• Lambda Calculus Review• Computability in Theory and Practice• Learning to Count

Page 3: David Evans

3CS150 Fall 2005: Lecture 32: Computability

Universal Computationz z z z z z z z z z z z z z z zz z z z

1

Start

HALT

), X, L

2: look for (

#, 1, -

), #, R

(, #, L

(, X, R

#, 0, -

Finite State Machine

Read/Write Infinite TapeMutable Lists

Finite State MachineNumbers to keep track of state

ProcessingWay of making decisions (if)Way to keep going

To prove Lambda Calculus is as powerful as a UTM, we must show we can make everything we need to simulate any TM.

Page 4: David Evans

4CS150 Fall 2005: Lecture 32: Computability

Don’t search for T, search for ifT x (y. x)

xy. xF x ( y. y))if pca . pca

Page 5: David Evans

5CS150 Fall 2005: Lecture 32: Computability

Finding the TruthT 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?

Page 6: David Evans

6CS150 Fall 2005: Lecture 32: Computability

and and or?and x (y. if x y F))or x (y. if x T y))

Page 7: David Evans

7CS150 Fall 2005: Lecture 32: Computability

Lambda Calculus is a Universal Computer?

z z z z z z z z z z z z z z z zz z z z

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 to keep track of state• Processing Way of making decisions (if)? Way to keep going

Page 8: David Evans

8CS150 Fall 2005: Lecture 32: Computability

Computability in Theory and Practice

(Intellectual Computability Discussion on TV Video)

Page 9: David Evans

9CS150 Fall 2005: Lecture 32: Computability

Ali G Multiplication Problem• Input: a list of 2 numbers with up to d

digits each• Output: the product of the 2 numbersIs it decidable?

Yes – a straightforward algorithmsolves it.

Is it tractable? (how much work?)Yes – it using elementary

multiplication techniques it is O(d2)Can real computers solve it?

Page 10: David Evans
Page 11: David Evans
Page 12: David Evans

12CS150 Fall 2005: Lecture 32: Computability

What about C++?int main (void){ int alig = 999999999;

printf ("Value: %d\n", alig); alig = alig * 99; printf ("Value: %d\n", alig); alig = alig * 99; printf ("Value: %d\n", alig); alig = alig * 99; printf ("Value: %d\n", alig);}

Value: 999999999Value: 215752093Value: -115379273Value: 1462353861

Results from SunOS 5.8:

Page 13: David Evans

13CS150 Fall 2005: Lecture 32: Computability

Ali G was Right!• Theory assumes ideal computers:

– Unlimited, perfect memory– Unlimited (finite) time

• Real computers have:– Limited memory, time, power outages, flaky

programming languages, etc.– There are many decidable problems we

cannot solve with real computer: the numbers do matter

Page 14: David Evans

14CS150 Fall 2005: Lecture 32: Computability

Lambda Calculus is a Universal Computer?

z z z z z z z z z z z z z z z zz z z z

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 to keep track of state• Processing Way of making decisions (if)? Way to keep going

Page 15: David Evans

15CS150 Fall 2005: Lecture 32: Computability

What is 42?

42forty-two

XLIIcuarenta y dos

Page 16: David Evans

16CS150 Fall 2005: Lecture 32: Computability

Meaning of Numbers• “42-ness” is something who’s

successor is “43-ness”• “42-ness” is something who’s

predecessor is “41-ness”• “Zero” is special. It has a successor

“one-ness”, but no predecessor.

Page 17: David Evans

17CS150 Fall 2005: Lecture 32: Computability

Meaning of Numberspred (succ N)

Nsucc (pred N)

Nsucc (pred (succ N))

succ N

Page 18: David Evans

18CS150 Fall 2005: Lecture 32: Computability

Meaning of Zerozero? zero

T zero? (succ zero)

F zero? (pred (succ zero))

T

Page 19: David Evans

19CS150 Fall 2005: Lecture 32: Computability

Is this enough?• Can we define add with pred, succ, zero?

and zero?

add xy.if (zero? x) y (add (pred x) (succ y))

Page 20: David Evans

20CS150 Fall 2005: Lecture 32: Computability

Can we define lambda terms that behave likezero, zero?, pred and succ?

Hint: what if we had cons, car and cdr?

Page 21: David Evans

21CS150 Fall 2005: Lecture 32: Computability

Numbers are Lists...

zero? null?pred cdr succ x . cons F x

Page 22: David Evans

22CS150 Fall 2005: Lecture 32: Computability

Making Pairs

(define (make-pair x y) (lambda (selector) (if selector x y)))

(define (car-of-pair p) (p #t)) (define (cdr-of-pair p) (p #f))

Page 23: David Evans

23CS150 Fall 2005: Lecture 32: Computability

cons and carcons x.y.z.zxy

cons M N = (x.y.z.zxy) M N (y.z.zMy) N z.zMN

car p.p Tcar (cons M N) car (z.zMN) (p.p T) (z.zMN)

(z.zMN) T TMN (x . y. x) MN (y. M)N M

T x . y. x

Page 24: David Evans

24CS150 Fall 2005: Lecture 32: Computability

cdr too!cons xyz.zxy car p.p Tcdr p.p F

cdr cons M Ncdr z.zMN = (p.p F) z.zMN

(z.zMN) F

FMN N

Page 25: David Evans

25CS150 Fall 2005: Lecture 32: Computability

Null and null?null x.T null? x.(x y.z.F)

null? null x.(x y.z.F) (x. T) (x. T)(y.z.F) T

Page 26: David Evans

26CS150 Fall 2005: Lecture 32: Computability

Null and null?null x.T null? x.(x y.z.F)

null? (cons M N) x.(x y.z.F) z.zMN (z.z MN)(y.z.F) (y.z.F) MN F

Page 27: David Evans

27CS150 Fall 2005: Lecture 32: Computability

Counting0 null1 cons F 02 cons F 13 cons F 2...succ x.cons F xpred x.cdr x

Page 28: David Evans

28CS150 Fall 2005: Lecture 32: Computability

42 = xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy) xy. y xy.(z.z xy)

xy. y x.T

Page 29: David Evans

29CS150 Fall 2005: Lecture 32: Computability

Arithmeticzero? null?succ x. cons F xpred x.x F

pred 1 = (x.x F) cons F null (cons F null) F (xyz.zxy F null) F (z.z F null) F F F null null 0

Page 30: David Evans

30CS150 Fall 2005: Lecture 32: Computability

Lambda Calculus is a Universal Computer

z z z z z z z z z z z z z z z zz z z z

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 to keep track of state• Processing Way of making decisions (if) Way to keep going

We have this, butwe cheated using to make recursive definitions!

Page 31: David Evans

31CS150 Fall 2005: Lecture 32: Computability

Way to Keep Going

( 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)) ...

This should give you some belief that we mightbe able to do it. We won’t cover the details of whythis works in this class. (CS655 sometimes does.)

Page 32: David Evans

32CS150 Fall 2005: Lecture 32: Computability

Lambda Calculus is a Universal Computer

z z z z z z z z z z z z z z z zz z z z

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 to keep track of state• Processing Way of making decisions (if) Way to keep going

Page 33: David Evans

33CS150 Fall 2005: Lecture 32: Computability

Universal Computer• Lambda Calculus can simulate a Turing

Machine– Everytime a Turing Machine can compute, Lambda

Calculus can compute also• Turing Machine can simulate Lambda

Calculus (we didn’t prove this)– Everything Lambda Calculus can compute, a

Turing Machine can compute also• Church-Turing Thesis: this is true for any

other mechanical computer also

Page 34: David Evans

34CS150 Fall 2005: Lecture 32: Computability

Charge• Exam 2 out Friday

– Covers through today– Links to example exams on the web– Review session Wednesday, 7pm

• PS8 Project Ideas due tomorrow (11:59pm)– Short email is fine, just explain who your

team is and what you plan to do


Recommended