computer language theory

41
1 Computer Computer Language Theory Language Theory Chapter 3: The Church- Chapter 3: The Church- Turing Thesis Turing Thesis

Upload: tatiana-stanley

Post on 30-Dec-2015

38 views

Category:

Documents


2 download

DESCRIPTION

Computer Language Theory. Chapter 3: The Church-Turing Thesis. Chapter 3.1. Turing Machines. Turing Machines: Context. Models Finite Automata: Models for devices with little memory Pushdown Automata: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computer Language Theory

1

Computer Computer Language TheoryLanguage Theory

Chapter 3: The Church-Turing Chapter 3: The Church-Turing ThesisThesis

Page 2: Computer Language Theory

2

Chapter 3.1Chapter 3.1

Turing MachinesTuring Machines

Page 3: Computer Language Theory

3

Turing Machines: Turing Machines: ContextContext

ModelsModels Finite Automata:Finite Automata:

Models for devices with little memoryModels for devices with little memory Pushdown Automata:Pushdown Automata:

Models for devices with unlimited memory Models for devices with unlimited memory that is accessible only in Last-In-First-Out that is accessible only in Last-In-First-Out orderorder

Turing Machines:Turing Machines: Only model thus far that can model general Only model thus far that can model general

purpose computerspurpose computers

Page 4: Computer Language Theory

4

Turing Machines Turing Machines OverviewOverview

Introduced by Alan Turing in 1936Introduced by Alan Turing in 1936 Unlimited memoryUnlimited memory

Infinite tape that can be moved left/right and Infinite tape that can be moved left/right and read/writtenread/written

Much less restrictive than stack of a PDAMuch less restrictive than stack of a PDA A Turing Machine can do everything a A Turing Machine can do everything a

real computer can do (even though a real computer can do (even though a simple model!)simple model!)

But a Turing Machine But a Turing Machine cannotcannot solve all solve all problemsproblems

Page 5: Computer Language Theory

5

What is a Turing What is a Turing Machine?Machine?

Informally:Informally: Contains an infinite tapeContains an infinite tape Tape initially contains the input string and Tape initially contains the input string and

blanks everywhere elseblanks everywhere else Machine can read and write from tape and Machine can read and write from tape and

move left and right after each actionmove left and right after each action The machine continues until it enters an The machine continues until it enters an

accept or reject state at which point it accept or reject state at which point it immediatelyimmediately stops and outputs accept or reject stops and outputs accept or reject

Note this is very different from FAs and PDAsNote this is very different from FAs and PDAs The machine can loop foreverThe machine can loop forever

Why can’t a FA or PDA loop forever?Why can’t a FA or PDA loop forever? Answer: it will terminate when input string is fully Answer: it will terminate when input string is fully

processed and will only take one “action” for each processed and will only take one “action” for each input symbolinput symbol

Page 6: Computer Language Theory

6

Turing MachineTuring Machine

Control

a b a b – – – …

Page 7: Computer Language Theory

7

Designing Turing Designing Turing MachinesMachines

Design a TM to recognize the language:Design a TM to recognize the language:B = {w#w| w B = {w#w| w {0,1}*} {0,1}*} Will focus on informal descriptions, as with Will focus on informal descriptions, as with

PDAsPDAs But even more so in this caseBut even more so in this case

Imagine that you are standing on an infinite Imagine that you are standing on an infinite tape with symbols on it and want to check to tape with symbols on it and want to check to see if the string belongs to B?see if the string belongs to B?

What procedure would you use given that you can What procedure would you use given that you can read/write and move the tape in both directions?read/write and move the tape in both directions?

You have a finite control so cannot remember much You have a finite control so cannot remember much and thus must rely on the information on the tapeand thus must rely on the information on the tape

Try it!Try it!

Page 8: Computer Language Theory

8

Turing Machine Example 1Turing Machine Example 1

M1 to Recognize B = {w#w|wM1 to Recognize B = {w#w|w{0,1}*}{0,1}*} M1 loops and in each iteration it matches M1 loops and in each iteration it matches

symbols on each side of the #symbols on each side of the # It does the leftmost symbol remainingIt does the leftmost symbol remaining It thus scans forward and backwardIt thus scans forward and backward It crosses off the symbol it is working on. We can It crosses off the symbol it is working on. We can

assume it replaces it with some special symbol x.assume it replaces it with some special symbol x. When scanning forward, it scans to the “#” then scans When scanning forward, it scans to the “#” then scans

to the first symbol not crossed offto the first symbol not crossed off When scanning backward, it scans past the “#” and When scanning backward, it scans past the “#” and

then to the first crossed off symbol.then to the first crossed off symbol. If it discovers a mismatch, then reject; else if all If it discovers a mismatch, then reject; else if all

symbols crossed off then accept.symbols crossed off then accept. What are the possible outcomes?What are the possible outcomes?

Accept or Reject. Looping is not possible.Accept or Reject. Looping is not possible. Guaranteed to terminate/halt since makes progress each Guaranteed to terminate/halt since makes progress each

iterationiteration

Page 9: Computer Language Theory

9

Sample ExecutionSample Execution What happens for the string What happens for the string

011000#011000?011000#011000?The tape head is at the red symbolThe tape head is at the red symbol

00 1 1 0 0 0 # 0 1 1 0 0 0 - - 1 1 0 0 0 # 0 1 1 0 0 0 - -X X 11 1 0 0 0 # 0 1 1 0 0 0 - - 1 0 0 0 # 0 1 1 0 0 0 - -

……X 1 1 0 0 0 # X 1 1 0 0 0 # XX 1 1 0 0 0 - - 1 1 0 0 0 - -XX 1 1 0 0 0 # X 1 1 0 0 0 - - 1 1 0 0 0 # X 1 1 0 0 0 - -X X XX 1 0 0 0 # X 1 1 0 0 0 - - 1 0 0 0 # X 1 1 0 0 0 - -

……X X X X X X # X X X X X X X X X X X X # X X X X X X - - --

Page 10: Computer Language Theory

10

Formal Definition of a Turing Formal Definition of a Turing MachineMachine

The transition function The transition function δδ is key: is key: Q Q xx ΓΓ → Q → Q xx ΓΓ x x {L, R}{L, R}

A machine is in a state q and the head is A machine is in a state q and the head is over the tape at symbol a, then after the over the tape at symbol a, then after the move we are in a state r with b replacing move we are in a state r with b replacing the a and the head has moved either left or the a and the head has moved either left or rightright

Page 11: Computer Language Theory

11

Formal Definition of a Turing Formal Definition of a Turing MachineMachine

A Turing Machine is a 7-tupleA Turing Machine is a 7-tuple {Q, {Q, ΣΣ, , ΓΓ, , δδ, q, q00, q, qacceptaccept, q, qrejectreject}, where}, where

Q is a set of statesQ is a set of states ΣΣ is the input alphabet not containing the blank is the input alphabet not containing the blank ΓΓ is the tape alphabet, where blank is the tape alphabet, where blankΓΓ and and ΣΣ ΓΓ δδ: Q : Q xx ΓΓ → Q → Q xx ΓΓ x x {L, R} is the transition function{L, R} is the transition function qq00, q, qacceptaccept, and q, and qreject reject are the start, accept, and reject are the start, accept, and reject

statesstates Do we need more than one reject or accept state?Do we need more than one reject or accept state? No: since once enter such a state you terminateNo: since once enter such a state you terminate

Page 12: Computer Language Theory

12

TM ComputationTM Computation

As a TM computes, changes occur As a TM computes, changes occur in:in: the statethe state the content of the current tape locationthe content of the current tape location the current head locationthe current head location

A specification of these three things A specification of these three things is a configurationis a configuration

Page 13: Computer Language Theory

13

Turing Recognizable & Decidable Turing Recognizable & Decidable LanguagesLanguages

The set of strings that a Turing Machine M The set of strings that a Turing Machine M accepts is the language of M, or the language accepts is the language of M, or the language recognized by M, L(M)recognized by M, L(M)

Definitions:Definitions: A language is A language is Turing-recognizableTuring-recognizable if some Turing if some Turing

machine recognizes itmachine recognizes it Called recursively enumerable by some textsCalled recursively enumerable by some texts

A Turing machine that halts on all inputs is a A Turing machine that halts on all inputs is a deciderdecider. A . A decider that recognizes a language decides it.decider that recognizes a language decides it.

A language is A language is Turing-decidableTuring-decidable or simply or simply decidabledecidable if if some Turing machine decides it.some Turing machine decides it.

Called recursive by some textsCalled recursive by some texts Notes:Notes:

Decidable if Turing-recognizable and always halts Decidable if Turing-recognizable and always halts (decider)(decider)

Every decidable language is Turing-recognizableEvery decidable language is Turing-recognizable It is possible for a TM to halt only on those strings it It is possible for a TM to halt only on those strings it

acceptsaccepts

Page 14: Computer Language Theory

14

Turing Machine Example Turing Machine Example IIII

Design a TM M2 that decides A = {0Design a TM M2 that decides A = {022nn|n≥0}, the |n≥0}, the

language of all strings of 0s with length 2language of all strings of 0s with length 2nn.. Without designing it, do you think this can be done? Without designing it, do you think this can be done?

Why?Why? Simple answer: we could write a program to do it and Simple answer: we could write a program to do it and

therefore we know a TM could do it since we said a TM can therefore we know a TM could do it since we said a TM can do anything a computer can dodo anything a computer can do

Now, how would you design it?Now, how would you design it? Solution:Solution:

English: divide by 2 each time and see if result is a oneEnglish: divide by 2 each time and see if result is a one1.1. Sweep left to right across the tape, crossing off every Sweep left to right across the tape, crossing off every

other 0.other 0.2.2. If in step 1:If in step 1:

the tape contains exactly one 0, then acceptthe tape contains exactly one 0, then accept the tape contains an odd number of 0’s, reject immediatelythe tape contains an odd number of 0’s, reject immediately Only alternative is even 0’s. In this case return head to start Only alternative is even 0’s. In this case return head to start

and loop back to step 1.and loop back to step 1.

Page 15: Computer Language Theory

15

Sample Execution of TM Sample Execution of TM M2M2

00 0 0 0 - - 0 0 0 - - Number is 4, which is 2Number is 4, which is 222

xx 0 0 0 - - 0 0 0 - -

x 0 x 0 xx 0 - - 0 - - Now we have 2, or 2Now we have 2, or 211

xx 0 x 0 - - 0 x 0 - -

x x 00 x 0 - - x 0 - -

x x xx x 0 - - x 0 - -

x x x x x x 00 - - - - Now we have 1, or 2Now we have 1, or 200

xx x x 0 - - x x 0 - - Seek back to startSeek back to start

x x x x x x 00 - - - - Scan right; one 0, so acceptScan right; one 0, so accept

Page 16: Computer Language Theory

16

Turing Machine Example Turing Machine Example IIIIII

Design TM M3 to decide the language:Design TM M3 to decide the language:

C = {aC = {aiibbjjcckk|i |i xx j = k and i, j, k ≥1} j = k and i, j, k ≥1} What is this testing about the capability of a What is this testing about the capability of a

TM?TM? That it can do (or at least check) multiplicationThat it can do (or at least check) multiplication As we have seen before, we often use unaryAs we have seen before, we often use unary

How would you approach this?How would you approach this? Imagine that we were trying 2 x 3 = 6Imagine that we were trying 2 x 3 = 6

Page 17: Computer Language Theory

17

Turing Machine Example Turing Machine Example IIIIII

Solution:Solution:1.1. First scan the string from left to right to verify First scan the string from left to right to verify

that it is of form athat it is of form a++bb++cc++; if it is scan to start of ; if it is scan to start of tape* and if not, reject. Easy to do with finite tape* and if not, reject. Easy to do with finite control/FA.control/FA.

2.2. Cross off the first a and scan until the first b Cross off the first a and scan until the first b occurs. Shuttle between b’s and c’s crossing off occurs. Shuttle between b’s and c’s crossing off one of each until all b’s are gone. If all c’s have one of each until all b’s are gone. If all c’s have been crossed off and some b’s remain, reject.been crossed off and some b’s remain, reject.

3.3. RestoreRestore**** the crossed off b’s and repeat step 2 if the crossed off b’s and repeat step 2 if there are a’s remaining. If all a’s gone, check if there are a’s remaining. If all a’s gone, check if all c’s are crossed off; if so, accept; else reject.all c’s are crossed off; if so, accept; else reject.

* * Some subtleties here. See book. Can use special symbol or Some subtleties here. See book. Can use special symbol or backup until realize tape is stuck and hasn’t actually backup until realize tape is stuck and hasn’t actually moved left.moved left.

**How restore? Have a special cross-off symbol that **How restore? Have a special cross-off symbol that incorporates the original symbol– put an X thru the incorporates the original symbol– put an X thru the symbolsymbol

Page 18: Computer Language Theory

18

TransducersTransducers We keep talking about recognizing a language, We keep talking about recognizing a language,

not generating a language. This is common in not generating a language. This is common in language theory.language theory.

But now that we are talking about computation, But now that we are talking about computation, this may seem strange and limiting.this may seem strange and limiting. Computers typically transform input into outputComputers typically transform input into output For example, we are more likely to have a computer For example, we are more likely to have a computer

perform multiplication than check that the equation perform multiplication than check that the equation is correct.is correct.

Turing Machines can also generate/transduceTuring Machines can also generate/transduce How would you compute cHow would you compute ckk given a given aiibbj j and iand ixxj = kj = k

In a similar manner. For every a, you scan through the b’s In a similar manner. For every a, you scan through the b’s and for each you go to the end of the string and add a c. and for each you go to the end of the string and add a c. Thus by zig-zagging a times, you can generate the Thus by zig-zagging a times, you can generate the appropriate number of c’s.appropriate number of c’s.

Page 19: Computer Language Theory

19

Turing Machine Example Turing Machine Example IVIV

Solve the element distinctness Solve the element distinctness problem:problem:

Given a list of strings over {0, 1} each Given a list of strings over {0, 1} each separated by a #, accept if all strings separated by a #, accept if all strings are different.are different.

E = {#x1#x2# … # xn|each xi E = {#x1#x2# … # xn|each xi {0,1}* and xi ≠ xj for each i ≠ j}{0,1}* and xi ≠ xj for each i ≠ j}

How would you do this?How would you do this?

Page 20: Computer Language Theory

20

Turing Machine Example Turing Machine Example IVIV

Solution:Solution:1.1. Place a mark on top of the left-most symbol. If it Place a mark on top of the left-most symbol. If it

was a blank, accept. If it was a # continue; else was a blank, accept. If it was a # continue; else rejectreject

2.2. Scan right to next # and place a mark on it. If no # Scan right to next # and place a mark on it. If no # is encountered, we only had x1 so accept.is encountered, we only had x1 so accept.

3.3. By zig-zagging, compare the two string to the right By zig-zagging, compare the two string to the right of the two marked #s. If they are equal, reject.of the two marked #s. If they are equal, reject.

4.4. Move the rightmost of the two marks to the next # Move the rightmost of the two marks to the next # symbol to the right. If no # symbol is encountered symbol to the right. If no # symbol is encountered before a blank, move the leftmost mark to the next before a blank, move the leftmost mark to the next # to its right and the rightmost mark to the # after # to its right and the rightmost mark to the # after that. This time, if no # is available for the that. This time, if no # is available for the rightmost mark, all the strings have been rightmost mark, all the strings have been compared, so accept.compared, so accept.

5.5. Go to step 3Go to step 3

Page 21: Computer Language Theory

21

DecidabilityDecidability

All of these examples have been decidable.All of these examples have been decidable. Showing that a language is Turing recognizable Showing that a language is Turing recognizable

but not decidable is more difficultbut not decidable is more difficult We cover that in Chapter 4We cover that in Chapter 4

How do we know that these examples are How do we know that these examples are decidable?decidable? You can tell that each iteration you make progress You can tell that each iteration you make progress

toward the ultimate goal, so you must reach the goaltoward the ultimate goal, so you must reach the goal This would be clear just from examining the This would be clear just from examining the

“algorithm”“algorithm” Not hard to prove formally. For example, perhaps Not hard to prove formally. For example, perhaps nn

symbols to start and if erase a symbol each and symbols to start and if erase a symbol each and every iteration, will be done in every iteration, will be done in nn iterations iterations

Page 22: Computer Language Theory

22

Chapter 3.2Chapter 3.2

Variants of Turing MachinesVariants of Turing Machines

Page 23: Computer Language Theory

23

Variants of Turing Variants of Turing MachinesMachines

We saw only a few variants of FA and PDAWe saw only a few variants of FA and PDA Deterministic and non-deterministicDeterministic and non-deterministic

There are many variants of Turing There are many variants of Turing MachinesMachines Mainly because they are all equivalent, so Mainly because they are all equivalent, so

that makes things more convenient without that makes things more convenient without really changing anythingreally changing anything

This should not be surprising, since we This should not be surprising, since we already stated that a Turing Machine can already stated that a Turing Machine can compute anything that is computablecompute anything that is computable

Page 24: Computer Language Theory

24

TM Variant ITM Variant I Our current TM model Our current TM model mustmust move the tape move the tape

head left or right after each step. Often it is head left or right after each step. Often it is convenient to have it convenient to have it staystay putput. Is the variant . Is the variant that has this capability equivalent to our that has this capability equivalent to our current TM model? Prove it!current TM model? Prove it! This one is quite trivialThis one is quite trivial

Proof: we can convert any TM with the “stay Proof: we can convert any TM with the “stay put” feature to one without it by adding two put” feature to one without it by adding two transitions: move “right” then “left”transitions: move “right” then “left” To show that two models are equivalent, we only To show that two models are equivalent, we only

need to show that one can simulate anotherneed to show that one can simulate another Two machines are equivalent if they recognize the Two machines are equivalent if they recognize the

same languagesame language

Page 25: Computer Language Theory

25

Variant II: MultiTape Variant II: MultiTape TMsTMs

A multitape Turing machine is like an A multitape Turing machine is like an ordinary TM with several tapes.ordinary TM with several tapes. Each tape has its own head for reading and Each tape has its own head for reading and

writingwriting Initially tape 1 has input string and rest are Initially tape 1 has input string and rest are

blankblank The transition function allows reading, The transition function allows reading,

writing, and moving the heads on some or all writing, and moving the heads on some or all tapes simultaneouslytapes simultaneously

Multitape is convenient (think of extra tapes Multitape is convenient (think of extra tapes as scratch paper) but does not add power.as scratch paper) but does not add power.

Page 26: Computer Language Theory

26

Proof of Equivalence of Proof of Equivalence of Variant IIVariant II

We show how to convert a multitape We show how to convert a multitape TM M with k tapes to an equivalent TM M with k tapes to an equivalent single-tape TM Ssingle-tape TM S S simulates the k tapes of M using a single S simulates the k tapes of M using a single

tape with a # as a delimiter to separate the tape with a # as a delimiter to separate the contents of the k tapescontents of the k tapes

S marks the location of the k heads by S marks the location of the k heads by putting a dot above the appropriate putting a dot above the appropriate symbols.symbols.

Using powerpoint I will use the color red insteadUsing powerpoint I will use the color red instead

Page 27: Computer Language Theory

27

Proof of Equivalence of Proof of Equivalence of Variant IIVariant II

On input of w = w1, w2…, wn, S will look like:On input of w = w1, w2…, wn, S will look like:##w1w1w2…wn#w2…wn#--##--# …. ## …. #

To simulate a single move, S scans its tape from the To simulate a single move, S scans its tape from the first # to the (k+1)st # in order to determine the first # to the (k+1)st # in order to determine the symbols under the virtual heads. The S makes a symbols under the virtual heads. The S makes a second pass to update the heads and contents based second pass to update the heads and contents based on M’s transition functionon M’s transition function

If at any point S moves one of the virtual heads to the If at any point S moves one of the virtual heads to the right of a #, this action means that M has moved the right of a #, this action means that M has moved the head to a previously blank portion of the tape. S write head to a previously blank portion of the tape. S write a blank symbol onto this cell and shifts everything to a blank symbol onto this cell and shifts everything to the right on the entire tape one unit to the right.the right on the entire tape one unit to the right. Not very efficient. I suppose you could start with blank space Not very efficient. I suppose you could start with blank space

on each virtual tape but since there is no finite limit to the on each virtual tape but since there is no finite limit to the physical tape length, one still needs to handle the case that physical tape length, one still needs to handle the case that one runs out of spaceone runs out of space

Page 28: Computer Language Theory

28

Variant III: Variant III: Nondeterministic TMNondeterministic TM

Proof of Equivalence: simulate any non-Proof of Equivalence: simulate any non-deterministic TM N with a deterministic TM deterministic TM N with a deterministic TM D (proof idea only)D (proof idea only) D will try all possible branches D will try all possible branches We can view the branches as representing a tree We can view the branches as representing a tree

and we can explore this treeand we can explore this tree Using depth-first search is a bad idea. Will fully explore Using depth-first search is a bad idea. Will fully explore

one branch before going to the next. If that one loops one branch before going to the next. If that one loops forever, will never even try most branches.forever, will never even try most branches.

Use breadth-first search. This method guarantees that all Use breadth-first search. This method guarantees that all branches will be explored to any finite depth and hence branches will be explored to any finite depth and hence will accept if any branch accepts.will accept if any branch accepts.

The DTM will accept if the NTM doesThe DTM will accept if the NTM does Text then goes on to show how this can be done Text then goes on to show how this can be done

using 3 tapes, one tape for input, one tape for using 3 tapes, one tape for input, one tape for handling current branch, and one tape for handling current branch, and one tape for tracking position in computation treetracking position in computation tree

Page 29: Computer Language Theory

29

EnumeratorsEnumerators

An enumerator E is a TM with a printer An enumerator E is a TM with a printer attachedattached The TM can send strings to be output to the The TM can send strings to be output to the

printerprinter The input tape is initially blankThe input tape is initially blank The language enumerated by E is the collection The language enumerated by E is the collection

of strings printed outof strings printed out E may not halt and print out infinite numbers of E may not halt and print out infinite numbers of

stringsstrings Theorem: A language is Turing-recognizable if Theorem: A language is Turing-recognizable if

and only if some enumerator enumerates itand only if some enumerator enumerates it

Page 30: Computer Language Theory

30

Proof of Enumerator Proof of Enumerator EquivalenceEquivalence

First we prove one directionFirst we prove one direction If an enumerator E enumerates a language A If an enumerator E enumerates a language A

then a TM M recognizes itthen a TM M recognizes it For every w generated by EFor every w generated by E

The TM M will run E (a TM) and check to see if the The TM M will run E (a TM) and check to see if the output matches w. If it ever matches, then accept.output matches w. If it ever matches, then accept.

If a TM M recognizes a language A, we can If a TM M recognizes a language A, we can construct an enumerator E for A as follows:construct an enumerator E for A as follows:

Let s1, s2, s3, … be the list of all possible strings in Let s1, s2, s3, … be the list of all possible strings in ∑*∑*

For i = 1, 2, …For i = 1, 2, … Run M for i steps on each input s1, s2, …, si.Run M for i steps on each input s1, s2, …, si. If a string is accepted, then print it.If a string is accepted, then print it.

Why do we need to loop over i? Why do we need to loop over i? We need to do breadth first search so eventually We need to do breadth first search so eventually

generate everything without getting stuck. generate everything without getting stuck.

Page 31: Computer Language Theory

31

Equivalence with Other Equivalence with Other ModelsModels

Many variants of TM proposed, some of Many variants of TM proposed, some of which may appear very differentwhich may appear very different All have unlimited access to unlimited memoryAll have unlimited access to unlimited memory All models with this feature turn out to be All models with this feature turn out to be

equivalent assuming reasonable assumptionsequivalent assuming reasonable assumptions Assume only can perform finite work in one stepAssume only can perform finite work in one step

Thus TMs are universal model of Thus TMs are universal model of computationcomputation The classes of algorithms are same independent The classes of algorithms are same independent

of specific model of computationof specific model of computation To get some insight, note that all To get some insight, note that all

programming languages are equivalentprogramming languages are equivalent For example, assuming basic constructs can For example, assuming basic constructs can

write a compiler for any language with any other write a compiler for any language with any other languagelanguage

Page 32: Computer Language Theory

32

Chapter 3.3Chapter 3.3

Definition of an AlgorithmDefinition of an Algorithm

Page 33: Computer Language Theory

33

What is an Algorithm?What is an Algorithm?

How would you describe an How would you describe an algorithm?algorithm?

An algorithm is a collection of simple An algorithm is a collection of simple instructions for carrying out some taskinstructions for carrying out some task A procedure or recipeA procedure or recipe Algorithms abound in mathematics and Algorithms abound in mathematics and

have for thousands of yearshave for thousands of years Ancient algorithms for finding prime numbers Ancient algorithms for finding prime numbers

and greatest common divisorsand greatest common divisors

Page 34: Computer Language Theory

34

Hilbert’s ProblemsHilbert’s Problems

In 1900 David Hilbert proposed 23 In 1900 David Hilbert proposed 23 mathematical problems for next centurymathematical problems for next century

Hilbert’s 10Hilbert’s 10thth problem: problem: Devise an algorithm for determining if a Devise an algorithm for determining if a

polynomial has an integral root (i.e., polynomial polynomial has an integral root (i.e., polynomial will evaluate to 0 with this root)will evaluate to 0 with this root)

Instead of algorithm Hilbert said “a process by Instead of algorithm Hilbert said “a process by which it can be determined by a finite number of which it can be determined by a finite number of operations”operations”

For example, 6xFor example, 6x33yzyz22 + 3xy + 3xy22 – x – x33 -10 has integral -10 has integral root x=5, y=3, and z=0.root x=5, y=3, and z=0.

He assumed that a method exists.He assumed that a method exists. He was wrongHe was wrong

Page 35: Computer Language Theory

35

Church-Turing Thesis Church-Turing Thesis It could not really be proved that an algorithm did It could not really be proved that an algorithm did

not exist without a clear definition of what an not exist without a clear definition of what an algorithm isalgorithm is

Definition provided in 1936Definition provided in 1936 Alonzo Church’s Alonzo Church’s λλ-calculus-calculus Alan Turing’s Turing MachinesAlan Turing’s Turing Machines The two definitions were shown to be equivalentThe two definitions were shown to be equivalent Connection between the information notion of an Connection between the information notion of an

algorithm and the precise one is the Church-Turing algorithm and the precise one is the Church-Turing thesisthesis

The thesis: the intuitive notion of algorithm equals Turing The thesis: the intuitive notion of algorithm equals Turing machinemachine

In 1970 it was shown that no algorithm exists for In 1970 it was shown that no algorithm exists for testing whether a polynomial has integral rootstesting whether a polynomial has integral roots But of course there is an answer: it does or doesn’tBut of course there is an answer: it does or doesn’t

Page 36: Computer Language Theory

36

More on Hilbert’s 10More on Hilbert’s 10thth ProblemProblem

Hilbert essentially asked if the language D is Hilbert essentially asked if the language D is decidable (not just Turing-recognizable)decidable (not just Turing-recognizable) D = {p| p is a polynomial with an integral root}D = {p| p is a polynomial with an integral root} Can you come up with a procedure to answer this Can you come up with a procedure to answer this

question? question? Try all possible integers. Starting from negative infinity is Try all possible integers. Starting from negative infinity is

hard, so start and 0 and loop out: 0, 1, -1, 2, -2, …hard, so start and 0 and loop out: 0, 1, -1, 2, -2, … For multivariate case, just lots of combinationsFor multivariate case, just lots of combinations What is the problem here?What is the problem here?

May never terminateMay never terminate You will never You will never knowknow whether it will not terminate or if it will whether it will not terminate or if it will

accept shortlyaccept shortly So, based on this method Turing-recognizable but not decidableSo, based on this method Turing-recognizable but not decidable

Could be other method that is decidable, but does not existCould be other method that is decidable, but does not exist

Page 37: Computer Language Theory

37

More on Hilbert’s 10More on Hilbert’s 10thth ProblemProblem

For univariate case, there is actually an For univariate case, there is actually an upper bound on the root of the upper bound on the root of the polynomialpolynomial So in this case there is an algorithm and the So in this case there is an algorithm and the

problem is decidableproblem is decidable Think about how significant it is that Think about how significant it is that

you can prove something cannot be you can prove something cannot be computedcomputed Does not just mean that you are not smart Does not just mean that you are not smart

or clever enoughor clever enough We will look into this in Chapter 4We will look into this in Chapter 4

Page 38: Computer Language Theory

38

Ways of Describing Turing Ways of Describing Turing MachinesMachines

As we have seen before, we can specify the As we have seen before, we can specify the design of a machine (FA, PDA) formally or design of a machine (FA, PDA) formally or informally.informally. The same hold true with a Turing MachineThe same hold true with a Turing Machine The informal description still describes the The informal description still describes the

implementation of the machine– just more informallyimplementation of the machine– just more informally With a TM we can actually go up one more level With a TM we can actually go up one more level

and not describe the machine (e.g., tape heads, and not describe the machine (e.g., tape heads, etc.).etc.). Rather, we can describe in algorithmicallyRather, we can describe in algorithmically We will either describe them informally, but at the We will either describe them informally, but at the

implementation level, or algorithmicallyimplementation level, or algorithmically

Page 39: Computer Language Theory

39

Turing Machine Turing Machine TerminologyTerminology

This is for the algorithmic levelThis is for the algorithmic level The input to a TM is always a stringThe input to a TM is always a string

Other objects (e.g., graphs, lists, etc) must Other objects (e.g., graphs, lists, etc) must be encoded as a stringbe encoded as a string

The encoding of object O as a string is <O>The encoding of object O as a string is <O> We implicitly assume that the TM We implicitly assume that the TM

checks the input to make sure it follows checks the input to make sure it follows the proper encoding and rejects if not the proper encoding and rejects if not properproper

Page 40: Computer Language Theory

40

Example: Algorithmic LevelExample: Algorithmic Level

Let A be the language of all strings Let A be the language of all strings representing graphs that are representing graphs that are connected (i.e., any node can be connected (i.e., any node can be reached by any other).reached by any other).

A = {<G>| G is a connected A = {<G>| G is a connected undirected graphundirected graph

Give me a high level description of Give me a high level description of TM MTM M

Page 41: Computer Language Theory

41

Example ContinuedExample Continued

M = “On input <G> the encoding of a M = “On input <G> the encoding of a graph G:graph G:

1.1. Select and mark the first node in GSelect and mark the first node in G

2.2. Repeat the following until no new nodes are Repeat the following until no new nodes are markedmarked

3.3. For each node in G, mark it if it is attached For each node in G, mark it if it is attached by an edge to a node that is already markedby an edge to a node that is already marked

4.4. Scan all nodes of G to determine whether Scan all nodes of G to determine whether they are all marked. If they are, then they are all marked. If they are, then accept; else rejectaccept; else reject