1 The Chomsky Hierarchy
2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals
3 Example grammar:
4 A language is generated by an unrestricted grammar if and only if is recursively enumerable
5 Context-Sensitive Grammars: Rules have form String of variables and terminals String of variables and terminals And:
6 The language is context-sensitive:
7 A language is context sensistive if and only if is accepted by a Linear-Bounded automaton
8 There is a language which is context-sensitive but not recursive
9 Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free regular
10 Decidability
11 Consider problems with answer YES or NO Examples: Does Machine have three states ? Is string a binary number? Does DFA accept any input?
12 A problem is decidable if some Turing machine solves the problem
13 Some decidable problems: Does Machine have three states ? Is string a binary number? Does DFA accept any input?
14 The machine that decides the problem: If the answer is YES then halts in a yes state If the answer is NO then halts in a no state These states may not be final states
15 Difference between Recursive Languages and Decidable problems The YES halting states may not be final states For decidable problems:
16 There are some problems which are undecidable: There is no Turing Machine that solves all instances of the problem
17 A famous undecidable problem: The halting problem
18 The Halting Problem Inputs: Turing Machine String Question: Does halt on ?
19 THEOREM The halting problem is undecidable
20 THEOREM The halting problem is undecidable PROOF Assume for contradiction that the halting problem is decidable
21 There exists Turing Machine that solves the halting problem YES or NO YES:accepts NO: Doesn’t accept
22 Initial tape contents Encoding of String YES NO
23 Construct machine : If returns YES then loop forever If returns NO then halt
24 NO Loop forever
25 Construct machine Input: If halts on input then loop forever Else halt : (machine )
26 repeat
27 Run machinewith input itself
28 Run machine Input: If halts on input then loop forever Else halt : (machine )
29 on input If halts then loops forever If doesn’t halt then it halts : NONSENSE !!!!!
30 Therefore, we have contradiction The halting problem is undecidable END OF PROOF
31 Another proof of the same theorem If the halting problem was decidable then every recursively enumerable language would be recursive
32 THEOREM The halting problem is undecidable PROOF Assume for contradiction that the halting problem is decidable
33 Turing Machine solves the halting problem For inputs:machineand string Returns: halts on input YES: if doesn’t halt on input NO: if
34 Let be a recursively enumerable language Let be the Machine that accepts We will prove that is recursive We will describe a membership algorithm
35 Run with inputs: and If Returns: doesn’t halt on inputNO: Thendoesn’t accept
36 If Returns: halts on input YES: Run with input will halt, and either accept or reject
37 Thereforeis recursive But there are recursively enumerable languages which are not recursive Contradiction!!!!
38 Therefore, the halting problem is undecidable END OF PROOF
39 Reducibility
40 Problem is reduced to problem If is decidable then is decidable means
41 Problem is reduced to problem If is undecidable then is undecidable also means
42 Example: The halting problem is reduced to The state-entry problem
43 The state-entry problem Inputs: Turing Machine State Question: Does String enter state on input ?
44 THEOREM The state-entry problem is undecidable
45 THEOREM The state-entry problem is undecidable PROOF Reduce the halting problem to the state-entry problem
46 Suppose we have an algorithm for the state-entry problem We will construct an algorithm for the halting problem
47 Inputs for the halting problem A machine A string Algorithm for halting problem must determine if halts on input
48 Modify machine : Add new state From any halting state add transitions to halting states Single halt state
49 halts if and only if halts on state
50 Algorithm for halting problem: Inputs:and 1. Construct with state 2. Run algorithm for state-entry problem with inputs:,,
51 GenerateState-entry machine Halting problem machine YES NO
52 Since the halting problem is undecidable, the state-entry problem is also undecidable END OF PROOF
53 Another example: The halting problem is reduced to The blank-tape halting problem
54 The blank-tape halting problem Input: Turing Machine Question: Doeshalt when started with a blank tape?
55 THEOREM The blank-tape halting problem is undecidable
56 THEOREM PROOF Reduce halting problem to Blank-tape halting problem The blank-tape halting problem is undecidable
57 Suppose we have an algorithm for the blank-tape halting problem We will construct an algorithm for the halting problem
58 Inputs for the halting problem A machine A string Algorithm for halting problem must determine if halts on input
59 Construct a new machine On blank tape writes Then continues execution like
60 halts if and only if halts when started with blank tape
61 Algorithm for halting problem: Inputs:and 1. Construct 2. Run algorithm for blank-tape halting problem with input,,
62 Generate blank-tape halting machine Halting problem machine YES NO
63 Since the halting problem is undecidable, the blank-tape halting problem is also undecidable END OF PROOF