computer science 101 more theory of computing. another example: odd parity a parity bit is added to...

14
Computer Science 101 More Theory of Computing

Upload: phebe-short

Post on 11-Jan-2016

215 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Computer Science 101

More Theory of Computing

Page 2: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Another Example: Odd Parity

• A parity bit is added to the right end of a string of bits if it makes the total number of 1’s odd; otherwise, add a 0

• 100011 ->• 100010 ->• 000000 ->

Page 3: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Design Strategy

• Three states– Even parity: if we read a blank here, we have

an even number of 1s, so we write a 1 and goto the halt state

– Odd parity: if we read a blank here, we have an odd number of 1s, so we write a 0 and goto the halt state

– Halt

Page 4: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Design Strategy

• Even parity– We stay here while we keep reading 0s– Otherwise, we goto odd parity

• Odd parity– We stay here while we keep reading 0s– Otherwise, we goto even parity

Page 5: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

State Diagram for Odd Parity TM

Even parity Odd parity

Halt

Page 6: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Tuples for Transitions

• The Turing machine program – (1,1,1,2,R) Even parity state reading 1, change state– (1,0,0,1,R) Even parity state reading 0, don’t change state– (2,1,1,1,R) Odd parity state reading 1, change state– (2,0,0,2,R) Odd parity state reading 0, don’t change state– (1,b,1,3,R) End of string in even parity state, write 1 and

go to state 3– (2,b,0,3,R) End of string in odd parity state, write 0 and go

to state 3

Page 7: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

The Church-Turing Thesis

• Church-Turing Thesis– If there exists an algorithm to do a symbol manipulation

task, then there exists a Turing machine to do that task

• Thesis– Statement advanced for consideration and maintained by

argument

• Theorem– Ideas that can be proved in a formal, mathematical way

Page 8: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Emulating an Algorithm on a TM

Page 9: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

A Universal TM

• Represent the algorithm as symbols on the tape

• Put the algorithm’s inputs on the tape as well

• Run the universal TM to run the algorithm

• The universal TM is like a stored program computer (von Neumann machine)

Page 10: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Unsolvable Problems

• Problem to investigateDecide, given any collection of Turing machine instructions together with any initial tape contents, whether that Turing machine will ever halt if started on that tape

Page 11: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

The Proposed Solution

T* = TM being testedt = T’s inputP = The testing TM

Page 12: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

A Proposed Counterexample

T* = TM being testedt = T’s inputQ = The testing TM

Page 13: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

An Actual Counterexample

S* = TM being testedS*bS* = S’s inputS = The testing TM

Page 14: Computer Science 101 More Theory of Computing. Another Example: Odd Parity A parity bit is added to the right end of a string of bits if it makes the

Other Unsolvable Problems

• Unsolvable problems, related to the halting problem, have the following consequences

– No program can be written to decide whether any given program always stops eventually, no matter what the input

– No program can be written to decide whether any two programs are equivalent

– No program can be written to decide whether any given program run on any given input will ever produce some specific output