Theory of Computation Lecture 04 Undecidability Part of
Theory of Computation Lecture 04 Undecidability Part of the materials are from Courtesy of Prof. Peter J. Downey Department of Computer Science, University of Arizona Theory of Computation, NTUEE
The Universal TM • Any (hardware) TM M can be encoded as a formatted string (software) n Encoding details below • The UTM U reads and simulates the action of M on x • The UTM U is one, fixed, finite machine, capable of simulating any TM (an interpreter) n For example, U reads for input and gives the same result as • We shall see that, whenever universality exists for a class of machines (like the TMs), unsolvability is an inevitable consequence Theory of Computation, NTUEE 2
k-adic representation base k n 0 bin(n) 0, 000, … 1 2 1, 001, … 1 10, 0010, … 3 4 11, 0011, … 11 100, 0100, … 12 5 6 101, 0101, … 110, 0110, … 7 8 111, 0111, … 1000, 01000, … 112 9 10 1001, 01001, … 1010, 01010, … 121 122 Theory of Computation, NTUEE 2 -adic construction (defn; unique string) 2 21 22 111 3
k-adic Representation • If n k-adic notation provides a bijection 1 -to-1 and onto unique in both directions • Let • A string x over ``is’’ a natural number • A natural number n ``is’’ a -string Quotient-Remainder Algorithm Theory of Computation, NTUEE 4
Canonical Encoding of TM M • Let • Encode over 9 symbol alphabet object in M encoding in Theory of Computation, NTUEE 5
Canonical Encoding of TM M (cont. ) • • String is a word over Identify these 9 symbols with So string is the 9 -adic repn of number Final encoding is a 2 -adic string over machine encoding in 2 -adic over • Notational convention: an encoding of a TM M ``is” (2 adic representation of) a natural number • is called the Gödel number of M • Conversely if e is a natural number, is the TM with that Gödel number • If e is a syntactically invalid code, is a TM that halts and prints 0 on every input Theory of Computation, NTUEE 6
Example Scan R erasing 0 until first blank. If encounter 1 loop forever. 1/1 0/B B */* B/- Valid encodings form a regular set over {1, 2, … 9}, so FSA can check syntax Theory of Computation, NTUEE 7
UTM Construction • Use 4 tapes: input program with left endmarker B, state tape with left endmarker & worktape of M being simulated 1. Parse input, copying to program tape. If e is invalid, put [] on worktape and halt. Else copy x to worktape & put [] on state tape simulating state 2. While the state tape [1] do { 1) 2) 3) If the state tape contains count over to tuples for that state in program e. Use the character a under scan on the worktape ([], [1], …) to scan to the correct 5 -tuple Overwrite the scanned character c(a) on the worktape by c(b) and move the head direction D on the worktape. Copy the new state string from the program tape to the state tape (after erasing the previous state string) } Theory of Computation, NTUEE 8
UTM Construction 4 tapes: e. Bx input to U, tape to hold e, tape to hold state of worktape of B e. Bx read-only input . . . read-only program B B [ ] [ 1 ] . . . worktape of M B [ 2 ] B B . . . state of M Thus UTM is also a TM. Theory of Computation, NTUEE 9
Turing Machine Index (Gödel Number) • • For each TM M, is the word encoding M Since every word in 2 -adic is a number (and conversely), we may consider to be a natural number e e is called the Gödel number of M is the TM with Gödel number e A procedure that enumerates all TMs. for w: = 0, 1, 2, ……, do { if (w matches the syntax of TM), output w. } /* syntax checking is algorithmic. */ Theory of Computation, NTUEE 10
UTM halting problem is undecidable! Proof by contradiction. Assume that UTM halting problem is decidable (with an algorithm). Then we can construct the following table. M 0 M 1 M 2 M 3 M 4 M 5 …… 0 0 1 1 1 1 1 0 2 0 1 1 0 1 3 1 0 1 1 0 0 0 … 1 0 0 1 0 1 iff Mi accepts j (Mi, j) = 0 iff Mi does not accept j Theory of Computation, NTUEE 11
Digression: Pairing Functions • k-tuples of can be encoded as single integers in by a computable bijection. Case k=2: 3 (0, 2) • “antidiagonal” construction (0, 1) • 1 (0, 0) • Theory of Computation, NTUEE 4 • (1, 1) 0 2 • (1, 0) 5 • (2, 0) 12
PROGRAM TERMINATION (cont. ) However, there is one language recognizer M that is not in the table. M accepts i iff Mi does not accept I. M 0 M 1 M 2 M 3 M 4 M 5 …… 0 0/acc 1 1 0 1 1 1 0/acc 1 1 0 2 0 1 1/rej 1 1 0 1 3 1 0 1 1/rej 0 0 0 … 1 0 0/acc 1 0 Thus M cannot be a TM! Theory of Computation, NTUEE 13
But M is a TM! According to our assumption that UTM halting problem is decidable, …… i M halting i UTM(Mi, i) non-halting Thus M is a TM! A contradiction! Thus UTM halting problem is undecidable! Theory of Computation, NTUEE 14
Arithmetic Hierarchy • For every class C, a class co-C • Ladder of complexity CE C} co-CE DEC=CE co-CE DEC=Decidable Sets Theory of Computation, NTUEE 15
Some undecidabilities … Two-stack machine halting problem is undecidable! Theory of Computation, NTUEE 16
Counter machines Theory of Computation, NTUEE 17
Some undecidabilities … 4 -counter machine halting problem is undecidable! Assume the alphabet of a two-stack machine M is {0, 1, . . , k-1}. For stack configuration: im im-1 im-2 i 1 …… One counter recording j=im+kim-1+k 2 im-2+…+km-1 i 1 Theory of Computation, NTUEE 18
Some decidabilities … 2 -counter machine halting problem is undecidable! It suffices to show that two counters can simulate four counters. • One counter holds 2 i 3 j 5 h 7 k • The other one as workpad. Theory of Computation, NTUEE 19
- Slides: 19