1 / 40

Complexity and Computability Theory I

Complexity and Computability Theory I. Lecture #14 Instructor: Rina Zviel-Girshin Lea Epstein. Formally: (Q, , , , q 0, q accept, q reject ). Q is the set of states.  is the input alphabet _   .  is the tape alphabet, _ and  .

hija
Télécharger la présentation

Complexity and Computability Theory I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Complexity and Computability Theory I Lecture #14 Instructor: Rina Zviel-Girshin Lea Epstein Computation & Complexity/Y. Moses

  2. Formally: (Q, , , , q0, qaccept, qreject) • Q is the set of states. •  is the input alphabet _. •  is the tape alphabet, _ and . • :Qx  Qxx{R,L} the transition function. • q0, qaccept, qrejectthe start, accept and reject states. qaccept qreject Computation & Complexity/Y. Moses

  3. s s s 1 s 2 s 3 4 5 qaccept Example of TM Computing a Function f1(w)=0|w| For every , (q0, )=(q0,0,R) (q0,_)=(q1,_,R). (q1,_)=(qaccept,_,L). Computation & Complexity/Y. Moses

  4. Computing the Function: f2(w)=w For every , (q0, )=(q0, ,R) (q0,_)=(q1,_,R). (q1,_)=(qaccept,_,L). Computation & Complexity/Y. Moses

  5. States as Memory of Symbols • For each  there exists a state q. • M that returns nof the input w= 12 ...n. • (q0, i)=(qi,#,R) mark left cell+ remember first cell. • (qi, j)=(qj,_,R) erase and remember the current cell. • (qi, _)=(q’i,_,L) end-of-tape + return the last cell. • (q’i, _)=(q’i,_,L) go backward with last cell. • (q’i, #)=(qaccept, i,R) detect left cell write right cell+ stop. Computation & Complexity/Y. Moses

  6. M that Computes the RightCyclic Transformation: f(12 ...n)= n12 ...n-1 • Remember the left cell (using a state), mark it with # and move Right. • Until right-end, _, write the previous cell value, remember the current value, and move right. • When reach the right end, remember the value by the state and move left until reach the first cell, #. • Write the last cell value in the first cell and stop. Computation & Complexity/Y. Moses

  7. B={w#w|w{0,1}*} Computation & Complexity/Y. Moses

  8. Summary • TM: formal definition (Q, , , , q0, qaccept, qreject) • TM: input. • TM: output. • Some examples. Computation & Complexity/Y. Moses

  9. A “Stay” Move Can use: (q0,_)=(q1,_,R) (q1,_)=(qaccept,_,L) • :Qx  Qxx{R,L,S} Computation & Complexity/Y. Moses

  10. Computing the Function: f2(w)=w For every , (q0, )=(q0, ,R) (q0,_)=(qaccept,_,S). Computation & Complexity/Y. Moses

  11. Computers and Intuitive Computation • Every computer has a set of “simple” steps that change the environment. • Can every function be computed by some computer? • Formally: Can every function f:{0,1}* :{0,1}* be computed? Computation & Complexity/Y. Moses

  12. Class 2 • TM Configurations • A Decider • A Language of a TM • More Examples of TM’s Computation & Complexity/Y. Moses

  13. Formally: (Q, , , , q0, qaccept, qreject) • Q is the set of states q0, qaccept, qrejectQ. •  is the input alphabet _  . •  is the tape alphabet, _ and . • :{Q\ qaccept, qreject }x  Qxx{R,L} the transition function. • q0, qaccept, qrejectthe start, accept and rejects states. qaccept qreject Computation & Complexity/Y. Moses

  14. q b b a c b b d a c _ _ u v Configuration • The tape. • The state. • The control location on the tape. • uqrejectv • u,v *u=bbac v=bbdac Computation & Complexity/Y. Moses

  15. q0 ... 0 0 1 0 1 _ _ _ Intial Configuration: q0w • The tape: w(the input)on the leftmost nsquares of the tape. Example: w=00101 • The rest of the tape is blank. • The head starts on the left most square. Computation & Complexity/Y. Moses

  16. Final Configuration: uqw • q {qaccept , qreject} • The tape contains uw: Example: u = 00 w=101, • The rest of the tape is blank. • The output is u. q 0 0 1 0 1 _ _ _ ... Computation & Complexity/Y. Moses

  17. qi C1: b b a c a b b b d a c _ _ u v C2: qj b b a c a c b b d a c _ _ u v C1yieldsC2 if C2can be “reached” from C1by the function. Computation & Complexity/Y. Moses

  18. Special Case: left-hand end • Right transition (qi,b)= (qj,c,R): qibvyieldscqjv • Left transition (qi,b)= (qj,c,L): qibv yieldsqjcv Computation & Complexity/Y. Moses

  19. A Configuration Sequence For a given TM M we denoteby C1* Cnthe existence of a set of configurations. Where Ci yields Ci+1 for i=1,…,n Computation & Complexity/Y. Moses

  20. Macceptw: If a sequence of configurations C1, C2,…,Cn exists where: 1.C1 is a start configuration with w. 2. Each Ci yields Ci+1 3.Cn is an accepting configuration. 1-2:C1 *Cn Computation & Complexity/Y. Moses

  21. Mrejectw: If a sequence of configurations C1, C2,…,Cn exists where: 1.C1 is a start configuration on input w. 2. Each Ciyields Ci+1 3.Cn is a rejecting configuration. 1-2:C1 *Cn Computation & Complexity/Y. Moses

  22. Three possible outcomes of a TM • Accept. • Reject. • Loop. not necessarily repeating the same steps. Computation & Complexity/Y. Moses

  23. MdecidesL: If Maccepts all wLandMrejectsallwL. That is: • For everywL M accept w. • For everywL M reject w. M is aDeciderTM: If M Halts on all inputs. (never loop) Computation & Complexity/Y. Moses

  24. The Language of TM M L(M) = the collections of strings that Maccepts. Computation & Complexity/Y. Moses

  25. Example The following TM M decides the language M=“on input string w 1. From left to right: cross off every other 0. 2. If in stage 1 a single 0 left: accept. an odd number of 0’s” reject. An even number: go to 1.” Computation & Complexity/Y. Moses

  26. Example: B={w#w|w{0,1}*} M1=“On input string w: • Scan and check that the input contains a single #. If not reject. • Zig-zag to check whether corresponding positions on either sides of # contain the same symbol. If not, reject. Cross off the checked symbols. • When all symbols to the left of # are crossed, check for remaining symbols to the right of #. If any symbol, reject. Otherwise, accept. Computation & Complexity/Y. Moses

  27. B={w#w|w{0,1}*} How are 0’s and 1’s decoded? Where are the reject states? Computation & Complexity/Y. Moses

  28. TM for Deciding the Language C={aibjck|i xj=kandi,j,k>0} M3on input w: 1. Scan to the right to check whether w{a* b* c*} if not, reject. 2. Return head to the left hand side. 3. Cross: one aand the same num. ofb and c. 4. Restore the crossed b and return to 3. accept if all a’s and c’s are crossed. Computation & Complexity/Y. Moses

  29. The Element Distinctness Problem E={#x1#x2#…#xn| xi{0,1}*andxixj ij} M4is a TM that accept E: it compares each pair of xiand xj. • At each “round” it marks a pair of the symbols # in an order that covers all possible pairs. • It compares the two strings that follow the marked symbols #. Computation & Complexity/Y. Moses

  30. Alphabet Duplication • How can we mark cells on the tape without changing their values? • Duplicate the alphabet of  such that for each  there is another symbol ’ . . Computation & Complexity/Y. Moses

  31. B1={w1#w2|wi{0,1}* & w1 w2} What do we have to change? B={w#w|w{0,1}*} Computation & Complexity/Y. Moses

  32. Turing-decidable Languages: • B={w#w|w{0,1}*} • C={aibjck|i xj=k and i,j,k>0} • E={#x1#x2#…#xn| xi{0,1}*andxixi ij} Computation & Complexity/Y. Moses

  33. Using a TM to Compute a Function. M is a TM that computes a (partial) function fM:*  *if there exist , *and qacceptQ s.t. q0w  *  qaccept. In this case fM(w)=. Computation & Complexity/Y. Moses

  34. A Function With a Number of Arguments • Use a special symbol on the tape to separate between the arguments. • w1&w2&…wnwhere &. • Examples of functions: • add(w1,w2) • mult(w1,w2) • max(w1,w2) Computation & Complexity/Y. Moses

  35. Can we distinguish a machine that is looping from one that is merely taking a long time? Computation & Complexity/Y. Moses

  36. MrecognizeL: If Maccepts all wL That is: • For everywL M acceptw. • For everywL M rejectw or M does not halt. Computation & Complexity/Y. Moses

  37. Turing-Recognizable Language A language L is Turing recognizableif there exists a TM M that recognizes it. That is L(M) for some TM M. Alsonamed recursively-enumerable Computation & Complexity/Y. Moses

  38. Turing-Recognizable Languages: • B={w#w|w{0,1}*} • C={aibjck|i xj=k and i,j,k>0} • E={#x1#x2#…#xn| xi{0,1}*andxixi ij} Computation & Complexity/Y. Moses

  39. Turing-recognizable Turing-decidable  Turing-decidable Turing-recognizable Computation & Complexity/Y. Moses

  40. Up to Here • Definition of a TM. • Configurations: initial, final, general, transitions . • Coding S (stay) transition. • Remember symbols by states. • Mark symbols. • Computing a function: input & output values. • Recognizing/deciding a Language. Computation & Complexity/Y. Moses

More Related