Computability ad computatioal complexity Lecture 4: Uiversal Turig machies. Udecidability Io Petre Computer Sciece, Åbo Akademi Uiversity Fall 2015 http://users.abo.fi/ipetre/computability/ 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 1
Cotet Uiversal Turig machies Udecidability 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 2
UNIVERSAL TURING MACHINES 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 3
Uiversal Turig machies Ay TM has a fixed program, solvig a sigle problem Questio: Is there a programmable Turig machie? A uiversal Turig machie U takes as iput the descriptio of aother Turig machie M ad a iput x for M, ad the simulates M o x: U(M,x)=M(x) Assume that the alphabet ad the states of all Turig machies are itegers ={1,2,, } K={ +1,, + K, + K +1,, + K +6}, where the last 6 symbols stad for the directioal istructios, for h, yes, ad o the iitial state is +1 all umbers are represeted i biary, each with eough leadig 0s so that they are of the same legth 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 4
Uiversal Turig machies Descriptio of a UTM start with K ad i biary a descriptio of d follows: ( (,s), (p,r,d) ) the add a separator symbol the add a descriptio of x, with each symbol of x as a biary umber, separated with aother separator symbol o tape S 1 U keeps a descriptio of M o tape S 2 it keeps the curret cofiguratio of M U simulates M Sca S 2 to fid a iteger correspodig to a state Search S 1 for a rule of d matchig the curret state ad the scaed symbol Apply the rule 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 5
Smallest uiversal Turig machie 1962, M.Misky: 7-state, 4-symbol UTM; i short (7,4) Later proposals: (15,2), (9,3), (6,4), (5,5), (4,6), (3,9), (2,18) Smallest kow UTM (i terms of descriptioal complexity) is by Yurii Rogozhi: (4,6)-machie usig oly 22 istructios 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 6
Towards udecidability ON RE LANGUAGES 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 7
Recall: acceptig vs. decidig Let LÌ(S-{#})* A Turig machie decides L iff for every xî (S-{#})*, if xîl, the M(x)= yes if xïl, the M(x)= o I this case, we say that L is a recursive laguage A Turig machie accepts L iff for every xî (S-{#})*, xîl iff M(x)= yes if xïl, M might ot termiate o x we could ask that M(x)= for all xïl I this case we say that L is a recursively eumerable laguage Note: ay recursive laguage is recursively eumerable 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 8
Recursively eumerable The laguage E(M) eumerated by a Turig machie M: E(M)={x: (s,>,1)"*(,y#x#,1), for some x,y} I other words: all strigs x such that at some poit durig the operatio of M, there is a time whe the tape eds with #x# 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 9
L is recursively eumerable iff there is a TM M such that L=E(M) This machie E eumerates the strigs i laguage L This machies M accepts laguage L: for ay iput strig x, wait to see whether it is eumerated by E; if it comes out, the M accepts x This machie M accepts laguage L This machies E eumerates the strigs i L: for each i>0, simulate M up to i steps o each of the first i strigs (lexicographic order); output ay strig that gets accepted 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 11
Strigs i lexicographic order w 1 w 2 w 3 w 4 w 5 1 Number of steps 2 2 3 3 3 4 4 4 4 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 12
No recursively eumerable laguages Recursively eumerable laguages Recursive laguages 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 13
Fiite Ifiite coutable Ifiite ucoutable Alphabet! All strigs over! All sets of strigs (laguages) over! 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 14
Fiite Ifiite coutable Ifiite ucoutable S Powerset 2 S of S S is coutable: S={s 1, s 2, s 3, } Elemets of the powerset: {s 5, s 19, s 34 }, {s 1, s 729, s 1234, s 2459, s 57990 } Each of them ca be writte as a ifiite seuece of 0/1: 1 o positio i iff s i is i that set Assume that the powerset is coutable: L 1, L 2, L 3, L 4, Cosider the followig elemet D of the powerset: Iclude s i i D iff s i is ot i L i, for all i>0 Observe that D is ot i our eumeratio If D=L k, the the k-th bit should be its ow complemet!!! Powerset Ecodig s 1 s 2 s 3 L 1 1 0 1 L 2 0 0 1 L 3 1 1 0 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 15
No-RE laguages Follow-up from the previous slide: there are (far) more laguages tha Turig machies Ucoutable umber of laguages vs. coutable umber of TM Coclusio: there exist o-recursively eumerable laguages (caot be described by algorithms) No recursively eumerable laguages Recursively eumerable laguages Recursive laguages 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 16
What about udecidable laguages Questio 1: are there udecidable laguages? I other words, laguages that are RE, but ot recursive Questio 2: are there also atural udecidable problems? Aswer: YES!!! No recursively eumerable laguages Recursively eumerable laguages Recursive laguages 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 17
UNDECIDABILITY 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 18
Haltig problem HALTING. Give the descriptio of Turig machie M ad a iput x, will M halt o x? We prove that HALTING is a udecidable problem We prove that H is ot a recursive laguage, i.e., there is o Turig machie to decide it We prove also that H is recursively eumerable Deote H={M;x: M(x)¹ } the set of YES istaces of HALTING 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 19
Haltig problem H={M;x: M(x)¹ } Propositio. H is recursively eumerable. Proof. Cosider a uiversal Turig machie U ad modify it so that wheever it halts, it does so i a acceptig state. Let U be the ew machie. Note ow that U accepts H: If M,xÎH, the M(x)¹ ad so, U(M,x)¹, i.e., U (M,x)= yes If M,xÏH, the M(x)= ad so, U(M,x)=, i.e., U (M,x)= 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 20
HALTING is udecidable Theorem. H is ot recursive. I other words: HALTING is udecidable Proof: Assume that H is recursive: there is a TM M H decidig H. This meas that for ay TM M ad iput x, we ca decide if M halts o x. Techiue of the proof: diagoalizatio. Ituitive idea: All iput strigs s 1 s 2 s 3 All Turig machies M 1 1 0 1 M 2 0 0 1 M 3 1 1 0 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 22
Formal proof Costruct a TM D as follows: O iput M, D first simulates M H o iput M;M util it is about to halt If M H is about to accept, the D eters ito a ifiite loop If M H is about to reject, the D halts i a acceptig state I other words: D(M)= if M H (M;M)= yes ad D(M)= yes otherwise Questio: What is D(D)? I other words, does machie D halt o iput D? If D(D)=, the M H (D;D)= yes, i.e., D;DÎH, i.e., D halts o iput D, i.e. D(D)¹ ; cotradictio If D(D)¹, the M H (D;D)¹ yes, i.e., D;DÏH, i.e., D does ot halt o iput D, i.e., D(D)= ; cotradictio Coclusio: there is o TM decidig H 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 23
More udecidability results May other properties ca be show to be udecidable usig the techiue of reductio ad our proof of HALTING beig udecidable HALTING Trasformatio computable by a TM The A must be udecidable PROBLEM A If A were decidable, the HALTING would also be decidable decide M o x by decidig whether t(m,x)îa 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 24
More udecidability Propositio. The followig laguages are ot recursive: {M: M halts o all iputs} {M;x: there is y such that M(x)=y} {M;x: the computatio of M o x uses all states of M} {M;x;y: M(x)=y} I other words: it is udecidable whether: (i) M halts o all iputs, (ii) M gives a output o x; Proof. Oly show here the first property, usig the reductio techiue Let M be a TM ad x a strig Costruct TM M that o a iput y works as follows: if y=x, the it simulates M o x, otherwise it halts Clearly, M halts o x iff M halts o all iputs 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 26
Ay o-trivial property of TM is udecidable! Very geeral result: Rice s theorem Deote by L(M) the laguage accepted by a Turig machie M Rice s theorem. Suppose that C is a proper, o-empty subset of the set of all recursively eumerable laguages. The the followig problem is udecidable: Give a Turig machie M, is L(M)ÎC? Proof. We ca assume ÆÏC (otherwise repeat the argumet below for the complemet of C, also a proper, o-empty subset of RE laguages). Also, there is LÎC, accepted by TM M L Cosider a arbitrary TM M ad a strig x. Costruct a TM M x such that M halts o x iff L(M x )ÎC M x o iput y: first it simulates M o x ad if it halts, the it cotiues by simulatig M L o y Note: L(M x )=L if M halts o x ad it is Æ otherwise I other words, sice ÆÏC: L(M x )ÎC iff M halts o x 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 27
More o recursive laguages Propositio. If L is recursive, the so is its complemet. Proof: make all acceptig states be rejectig states ad the other way aroud Propositio. L is recursive iff both L ad its complemet are recursively eumerable Proof. Direct implicatio clear by the previous result Reverse implicatio Let L be accepted by a TM M ad its complemet by a TM M Build a TM decidig L: O a secod tape make a copy of the iput Simulate o the two tapes machies M ad M o iput x Oe step of oe machie, followed by oe step of the other machie x must be i either L or L evetually oe of the machies will accept it Give aswer yes if it was accepted o the first tape, o if it was accepted o the secod tape Coseuece: the complemet of HALTING is ot recursively eumerable The set of Turig machies M ad iputs x for which M does ot halt o x 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 28
Learig objectives Uderstad the cocept of udecidability Ability to prove udecidability results through reductios 21. toukokuu 2018 http://users.abo.fi/ipetre/computability/ 29