Computability and Complexity 5-1 Classifying Problems Computability and Complexity Andrei Bulatov Computability and Complexity Problems and Languages We have seen that every decision problem has an associated language L(,e) (via a suitable encoding e) Hence, to classify decision problems we will develop methods to classify languages 5-2 Computability and Complexity Decidable Languages Definition A language L is decidableª if there exists a TM T, with 2 final states q A and qR , such that • If x L then T(x) halts in state q A • If x L then T(x) halts in state qR ªalso known as recursive T is said to decide the language L — it gives a yes or no answer for each possible string from * 5-3 Computability and Complexity Examples The following languages are decidable: • * • • {x| |x| = 20} • {x | x is prime} • {x | x encodes a graph G, and a Hamilton circuit of G} • {x | x is a valid encoding of a TM} 5-4 Computability and Complexity 5-5 Examples All languages accepted by finite automata, or generated by context-free grammars are decidable Decidable Languages Regular Languages All Languages Context-free Languages (for finite automata see Discrete Mathematics course or Sipser) (for context-free grammars see Compilers course or Sipser) Computability and Complexity Acceptable Languages Definition A language L is acceptableª if there exists a TM T, with 2 final states q A and qR , such that • If x L then T(x) halts in state q A • If x L then T(x) halts in state qR or infinite ªalso known as Turing-acceptable or Turing-recognizable T is said to accept the language L — it gives a yes answer for each string in L, in all other cases it gives a no answer or fails to halt 5-6 Computability and Complexity Acceptable vs. Decidable • If a language is decidable, then it is acceptable. • If a language, L, is acceptable, and its complement L is also acceptable, the it is decidable. (Proof: run the two acceptor machines alternately until one halts) So, to show that there are languages that are not decidable, we must find a language that is not acceptable … 5-7 Computability and Complexity The Halting Problem Halting Instance: A Turing Machine T and an input string x. Question: Does T(x) halt? Once we choose an encoding for Turing machines, the corresponding language is: LHalting {" T ; x" | T ( x ) terminates} • LHalting is acceptable - use a universal TM U to simulate T on x and modify it so that that if it halts then it moves to “Accept” state • LHalting is not decidable - see next slide 5-8 Computability and Complexity • Assume, for contradiction, that there is a TM TH that decides LHalting • Construct a new T from TH so that for input x, T simulates TH ( x; x ) but - if TH accepts “x;x” then T goes into an infinite loop, - if TH rejects “x;x” then T accepts x. 5-9 Computability and Complexity 5-10 I N P U T A? R? T Computability and Complexity 5-11 I N P U T A? R? I N P U T ; I N P U T T A? R? TH Computability and Complexity • Consider the computation T(T) - if T(T) halts this implies that TH rejects “T;T”, implying that T(T) does not halt! - if T(T) does not halt this implies that TH accepts “T;T”, implying that T(T) halts! • Hence TH cannot exist, so LHalting is undecidable. 5-12 Computability and Complexity Consequences • The language LHalting is not acceptable. • There is no Turing machine that can give correct answers to the Halting problem on all inputs. • Hence, by Turing’s Thesis: The Halting problem cannot be solved by any algorithm! This result was first announced in Turing’s 1936 paper 5-13 Computability and Complexity Reducibility A major tool in analysing and classifying problems is the idea of “reducing one problem to another” Informally, a problem is reducible to a problem if we can somehow use methods that solve in order to solve 5-14 Computability and Complexity Many-One Reducibility Definition A language A is many-one reducible (or m-reducible, or mapping reducible) to a language B if there exists a total and computable function f such that for all x * x A f (x) B • We denote this by writing A m B • We can use a machine that decides B (plus a machine that reduces A) • So, in a sense, A is “no harder than” B 5-15 Computability and Complexity Properties of Many-One Reducibility • If L1 m L2 and L2 is decidable, then so is L1 (Just build a machine that computes f(x) and then behaves like the machine that decides L2 ) • m is reflexive and transitive • If L2 is any language (apart from and *) and L1 is decidable, then L1 m L2 The first property can be used when trying to prove that a language is decidable (or undecidable). The last property implies that many-one reducibility is too weak to distinguish between decidable languages — they are pretty much All reducible to each other! 5-16 Computability and Complexity Other Undecidable Problems ACCEPTANCE Instance: A Turing Machine (acceptor) T and an input string x. Question: Does T accept x? The corresponding language is: Theorem LAccept Proof see next slide LAccept {" T ; x" | T accepts x} is undecidable. 5-17 Computability and Complexity We show that LHalting m LAccept For every input “T;x” of LHalting , we do: • Add to T two new states q A and qR (to guarantee that they are not in T already we may need to rename the states of T) • Change the transition function by adding transition from every final state to q A • Denote the obtained machine T’ Note that T’ accepts x if and only if T halts on x Therefore, the function f : * * which maps “T;x” to “T’;x” is computable and provides a mapping reduction from LHalting to LAccept 5-18 Computability and Complexity Regularity Instance: A Turing Machine T. Question: Can T be simulated by a finite automaton? Ambiguous Grammars Instance: A context-free grammar G. Question: Is G ambiguous? 5-19 Computability and Complexity Diophantine Equations Instance: A multivariate polynomial equation such as x 2 y 3xy y 2 17 0 Question: Does this equation have an integer-valued solution? See “Hilbert’s Tenth Problem is Unsolvable” M.Davis, American Mathematical Monthly 80 (1973) pp.233-269 5-20