200 likes | 325 Views
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. The Universal TM. Any (hardware) TM M can be encoded as a formatted string (software)
E N D
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) • Encoding details below • The UTM U readsand simulates the action of M on x • The UTM U is one, fixed, finite machine, capable of simulating any TM (an interpreter) • For example, U reads and gives the same result as for input • We shall see that, whenever universality exists for a class of machines (like the TMs), unsolvability is an inevitable consequence Theory of Computation, NTUEE
n bin(n) 2-adic construction 0 0,00,000,… (defn; unique string) 1 1,01,001, … 1 2 10,010,0010,… 2 3 11,011,0011, …11 4 100,0100,… 12 5 101,0101, … 21 6 110,0110,… 22 7 111,0111, …111 8 1000,01000,… 112 9 1001,01001, … 121 10 1010,01010,… 122 k-adic representation base k Theory of Computation, NTUEE
k-adic Representation • If 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
Canonical Encoding of TM M • Let • Encode over 9 symbol alphabet object in Mencoding in Theory of Computation, NTUEE
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 machineencoding 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
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
UTM Construction • Use 4 tapes: input program with left endmarker B, state tape with left endmarker & worktape of M being simulated • 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 • While the state tape [1] do { • If the state tape contains count over totuples 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
UTM Construction 4 tapes: eBx input to U, tape to hold e, tape to hold state of worktape of read-only input B eBx . . . read-only program B B [ 2 ] B B . . . B [ ] [ 1 ] . . . state of M worktape of M Thus UTM is also a TM. Theory of Computation, NTUEE
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
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. 1 iff Mi accepts j (Mi,j) = 0 iff Mi does not accept j Theory of Computation, NTUEE
Digression: Pairing Functions • k-tuples of can be encoded as single integers in by a computable bijection. Case k=2: 3 • (0,2) 4 1 • • (0,1) (1,1) “antidiagonal” construction 5 2 0 • • • (0,0) (2,0) (1,0) Theory of Computation, NTUEE
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. Thus M cannot be a TM! Theory of Computation, NTUEE
But M is a TM! According to our assumption that UTM halting problem is decidable, …… M i halting i UTM(Mi,i) non-halting halting Thus M is a TM! A contradiction! Thus UTM halting problem is undecidable! Theory of Computation, NTUEE
CE co-CE Arithmetic Hierarchy • For every class C, a class co-C C} • Ladder of complexity DEC=CEco-CE DEC=Decidable Sets Theory of Computation, NTUEE
Some undecidabilities … Two-stack machine halting problem is undecidable! Theory of Computation, NTUEE
Counter machines Theory of Computation, NTUEE
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: One counter recording j=im+kim-1+k2im-2+…+km-1i1 i1 … … im im-2 im-1 Theory of Computation, NTUEE
Some decidabilities … 2-counter machine halting problem is undecidable! It suffices to show that two counters can simulate four counters. • One counter holds 2i3j5h7k • The other one as workpad. Theory of Computation, NTUEE