lecture slides for mat 73006 theoretical computer science
play

Lecture Slides for MAT-73006 Theoretical computer science PART IIb: - PowerPoint PPT Presentation

Lecture Slides for MAT-73006 Theoretical computer science PART IIb: Decidability Henri Hansen February 3, 2014 1 Decidability We introduced the TM as a general purpose model of com- putation. An algorithm was basically defined


  1. Lecture Slides for MAT-73006 Theoretical computer science PART IIb: Decidability Henri Hansen February 3, 2014 1

  2. Decidability • We introduced the TM as a general purpose model of com- putation. • An ”algorithm” was basically defined as a Turing machine that decides a language. • We shall now investigate the limitations of turing machines – of algorithms, in so far as we believe the Church-Turing thesis. • There are some surprising problems that simply cannot be solved, and it is important to understand the limitations that this imposes on computation 2

  3. • In order to understand what computation is, you must un- derstand its limits!

  4. Decidable languages • We started with finite automata and it is only natural that we state some computational problems related to these au- tomata. • We shall engage a lot in a sort of ”self study” by computa- tional models: We try to find out, to what extent are turing machines able to decide computational properties of other computational models (including turing machines themself!) • Given a DFA B and a string w , we define the decision prob- lem: Does B accept w . 3

  5. • As a language, supposing that we can describe DFAs as strings, define the language A DFA = { ( B, w ) | B is a DFA that accepts w } • Theorem: A DFA is a decidable language. Proof is a con- struction of a turing machine M that does the following – Follow the computation steps on input w – if the computation steps end in an accepting state, then accept, if not, reject • Obviously the TM is going to be somewhat complicated, so we simply look at some of the more important details

  6. • The input is a representation of B and w . When M re- ceives the input, it first determines whether it describes a turing machine. For instance, the representation of B could consist of ”lists” for states, alphabet, transitions and accept states. • The simulation keeps track of which state is being simu- lated. It crosses the next letter from w and checks where it should move next. • When all letters have been crossed it checks whether the simulated state is accepting. If it is, then it accepts.

  7. More decidable languages • Given an NFA and a string, does it accept? A NFA = { ( B, w ) | B is an NFA that accepts w } • Theorem: A NFA is a decidable language. • Again, the proof is a TM that decides the language. On input ( B, w ) where B is an NFA: 1. Convert the NFA B into a DFA D 2. Run the TM M of the previous theorem on ( D, w ) 4

  8. 3. accept accordingly • It is very common to use already established turing ma- chines as ”subroutines”; we shall do so whenever we can solve a problem easier using some problem that we have already solved • The conversion of an NFA to a DFA is nontrivial, but we already know how to do it. The states are subsets of the NFA states and transitions are defined as leading to the set of all possible states in the NFA (this set is a unique state). Accepting states are those that contain an accepting state of the original, and initial state contains the inital state and nothing else.

  9. • Given a regular expression, does it match a given word? A REX = { ( R, w ) | R is a regular expression that generates w } • Theorem A REX is decidable: Convert R to an NFA, and check with the TM given in the previous theorem • E DFA = { ( D ) | L ( D ) = ∅} is the language of DFAs with an empty language. It is decidable 1. Mark the start state of D 2. Repeat 3 until no state gets marked: 3. Mark a state that has a transition coming in from a marked state

  10. 4. If no accept state is marked, accept. Otherwise, reject. • EQ DFA = { ( A, B ) | A and B are DFAs and L ( A ) = L ( B ) } is a decidable language 1. Generate a DFA C that accepts strings that are accepted by A or B but not both (question: How and why?) 2. Check that L ( C ) = ∅ using the previous theorem 3. Accept accordingly. • Let A CFG = { ( G, w ) | G is a CFG that generates w } . This language is decidable

  11. • The proof needs another concept for CFG’s, that of Chom- sky normal form , of ChNF. ChNF is a canonical form for CFG’s, and it guarantees that there are exactly 2 n − 1 steps in every derivation of a word w whose length is n . • The TM that decides the language first converts G into ChNF, then tries all derivations with the appropriate number of steps. • E CFG = { ( G ) | G is a CFG and L ( G ) = ∅} is also de- cidable • Nonempty languages are ”easy” to recognize, simply try all possible strings until one is generated by the grammar.

  12. • Such a TM however runs forever if G generates the empty language. So we propose a different algorithm, which is, in fact, easy: 1. Mark all terminal symbols in G 2. Repeat 3 until no variables get marked 3. If there is a rule A → U 1 , . . . , U k such that each U i is marked and A is unmarked, mark A 4. If the start variable is not marked, accept, otherwise re- ject. • Theorem: Every context free language is decidable.

  13. • Proof: Let G be a CFG for some language A . Let M be the turing machine that decides A CFG . We generate M G that reads input w and does the following: 1. M G transforms the tape so that it contains ( G, w ) (re- member, G is fixed, so we can do this easily) 2. Then M G behaves exactly as M does.

  14. Undecidability • We saw examples of languages that are decidable. • Proving decidability is often straightforward: simply give the Turing machine that decides the language. • Proving that a language is not decidable, is much harder. • Why would we want to explore languages that ar undecid- able? • Are undecidable languages merely theoretical curiosities that are of no practical value? 5

  15. An undecidable language • Remember that the languages A DFA and A CFG were de- cidable. • In the same way, consider the following language A TM = { ( M, w ) | M is a TM that accepts w } • Theorem: A TM is undecidable. • The proof of this theorem is not straightforward directly, so we do it in steps. 6

  16. • Before showing that A TM is undecidable, it is worth noting that it is Turing-recognizeble, because one can simply run M on w , and behave accordingly. • The trouble comes from infinite executions that M might have. • To be able to cover the theorem and understand it, we must explore a little bit more theory.

  17. Diagonalization • Cantor used diagnolization in 1873, when he was studying the infinite sets and their ”sizes” • Consider two sets A and B , and a function f : A �→ B . – f is one-to-one if f never maps two elements of A to the same value, i.e., a � = b implies f ( a ) � = f ( b ) – f is onto if for every x ∈ B there is some a ∈ A such that f ( a ) = x – A function that is both one-to-one and onto is called a bijection, or a correspondence 7

  18. – We say that A and B have the same size if there is a bijection between them • For example, the set of natural numbers without zero { 1 , 2 , · · · } and the set of even numbers without zero { 2 , 4 , 6 , . . . } have the same size • In general, a set is countable if it has the same size as the set of natural numbers. • For example: The rational numbers have the same size as natural numbers:

  19. – Considerthe sequence of sequences L 1 , L 2 , . . . where L i is the sequence i 1 , i 2 , i 3 , . . . , so that L i j = i j . Clearly every rational number appears in one of these sequences. – Consider the sequence L 1 1 , L 2 1 , L 1 2 , L 3 1 , L 2 2 , L 1 3 , . . . . This sequence lists all the L i j at some point, and if f ( k ) is the k th element in this sequence, then f gives the correspondence between rational and natural numbers • The set of real numbers is not countable – Let us express real numbers as infinite decimal, such as 3 . 14159 · · · – Assume that f is some correspondence between real numbers and natural numbers

  20. – We can construct a number that does not appear in the sequence f (1) , f (2) , . . . – Let x be defined as follows: it is of the form 0 .d 1 d 2 · · · , such that d i is f ( i ) ’s i th digit plus one or minus one, as long as it is never 0 or 9 . – By construction x � = f ( i ) for every i , because f ( i ) and x differn on the i th place – The assumption that f is a correspondence, results in contradiction, so there is no correspondence • Corollary to this: There exists a language that is not decid- able

  21. • The proof is as follows: The set of all turing machines is countable, whereas the set of all languages is not • Turing machines are countable, because every turing ma- chine has a finite descrption, and therefore is expressible by a string in Σ ∗ . This language is countable, because Σ ∗ is countable: it does not contain infinite words • The set L of all languages is uncountable, because we can build a correspondence between L and real numbers: con- sider binary representations of real numbers. Then con- sider Σ ∗ . List all strings in Σ ∗ , and each infinite binary dec- imal denotes one language: the i th bit is 1 if the i th word in the list is in the language and 0 if it is not.

  22. A proof for the undecidability of A TM • Let us assume A TM is decidable, and that H decides it, i.e, for every TM M , H ( M, w ) accepts if M accepts w and rejects if M does not accept w . • Consider the Turing machine D whose input is a description of a turing machine M 1. Run H on input M, w where w is the description of M . 2. Output exactly the opposite of what H outputs • What happens when D is given its own description as an input? 8

Recommend


More recommend