lecmulti version timestamp ordering protocolture 05

31
Theory of Computation Lecture #5 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 25

Upload: sun-java

Post on 07-Nov-2015

248 views

Category:

Documents


3 download

DESCRIPTION

Multi Version Timestamp Ordering Protocol

TRANSCRIPT

  • Theory of ComputationLecture #5

    Sarmad Abbasi

    Virtual University

    Sarmad Abbasi (Virtual University) Theory of Computation 1 / 25

  • Lecture 5: Overview

    Variants of Turing Machines.k -tape TMs.Show that k -tape TMs have the same power as 1-tape TMs.Study enumerators.Prove equivalence of enumerators and TMs.Dovetailing.

    Sarmad Abbasi (Virtual University) Theory of Computation 2 / 25

  • Variants of TMs

    We will show that multi-tape TMs are not more powerful than singletape TMs.

    Sarmad Abbasi (Virtual University) Theory of Computation 3 / 25

  • Variants of TMs

    Sarmad Abbasi (Virtual University) Theory of Computation 4 / 25

  • The Acceptance Problem for DFAs

    TheoremEvery multi-tape TM has an equivalent single tape TM.

    A single tape TM can actually simulate a multi-tape TM.

    Sarmad Abbasi (Virtual University) Theory of Computation 5 / 25

  • Variants of TMs

    Let us look at a 3-tape TM.

    How can we describe its configuration?

    Sarmad Abbasi (Virtual University) Theory of Computation 6 / 25

  • Variants of TMs

    The congfiguration of this TM is described as follows:

    q3#aaaab#baaab#aaaab

    The main point is that this configuration can be written on a single tape.

    Sarmad Abbasi (Virtual University) Theory of Computation 7 / 25

  • Multi-tape TMs

    The method for writing a configuration on a single tape is:1 write the state first followed by #.2 write the contents of the first tape followed by a #.3 write the contents of the second tape followed by a #.4 write the contents of the third tape followed by a #.5 place dots on all symbols that are currently been scanned by the

    TM.

    Sarmad Abbasi (Virtual University) Theory of Computation 8 / 25

  • Multi-tape TMs

    Suppose that I have only a single tape. I want to know what amulti-tape TM will do on input w . I can write

    q0#w ##

    Which denotes the initial configuration of M on w .

    Sarmad Abbasi (Virtual University) Theory of Computation 9 / 25

  • Multi-tape TMs

    Here w is the same string as w except the first character has a dotplaced on top of it.Now, I can keep scanning the entire tape to find out which symbols arebeing read by M. In the second pass I can make all the modificationsthat M would have done in one step.

    Sarmad Abbasi (Virtual University) Theory of Computation 10 / 25

  • Multi-tape TMs

    Given a k tape TM M we descibe a single tape TM S. S is going tosimulate M by using only one tape.

    Sarmad Abbasi (Virtual University) Theory of Computation 11 / 25

  • Simulating multi-tape TMs

    Description of S:On input w = w1 wn

    1 Put the tape in the format that represents the initial configurationof M; that is,

    #q0w1w2 wn## ##2 To simulate a single move of M, S scans it tape from left to right.

    In order to determine the symbols that are placed under itsvirtual heads. Then it makes a second pass to update thecontents of the tapes according to the transition function of M.

    3 If at any point S has to move a head to the right on to # that is ifM is moving to a previously unread black. Then S inserts byshifting symbols to the right.

    4 If S reaches an accepting configuration then it accepts and if itreaches a rejecting configuration then it rejects.

    Sarmad Abbasi (Virtual University) Theory of Computation 12 / 25

  • Simulating multi-tape TMs

    Suppose we have a three tape Turing machine and we give it the inputaabb. The machine is in the following configuration:

    Sarmad Abbasi (Virtual University) Theory of Computation 13 / 25

  • Simulating multi-tape TMsThis configuration will be written on a single tape of S as:

    #q0aabb###and suppose (q0,a,,) = (q2,b, c,a,R,R,R). That means the nextconfiguration will be written as:

    #q2babb#c#a#This represents the machine in the following configuration:

    Sarmad Abbasi (Virtual University) Theory of Computation 14 / 25

  • Simulating multi-tape TMs

    Now, if (q2,a,,) = (q3, c,b,b,R,L,R) then

    #q3bcbb#cb#ab#

    represents the next configuration.

    Sarmad Abbasi (Virtual University) Theory of Computation 15 / 25

  • Simulating multi-tape TMs

    In order for S to simulate a single step of M it has to make two passes.1 In the first pass it finds out the current symbols being scanned by

    M s heads.2 In the second pass it makes the required changes to the tape

    contents.

    TheoremM accepts w if and only if S accepts w.

    Sarmad Abbasi (Virtual University) Theory of Computation 16 / 25

  • Simulating multi-tape TMs

    Thus we have proved the our theorem:

    TheoremEvery multi-tape TM has an equivalent single tape TM.

    A few words about this theorem:

    Sarmad Abbasi (Virtual University) Theory of Computation 17 / 25

  • Simulating multi-tape TMs

    1 We have only given a high level description of S. You shouldconvince yourself that given any k -tape TM you can come up witha exact and formal definition of S. Which essentially means youcan fill all the details in the above proof.

    2 Work alphabet of S will be much larger than that of M.

    Sarmad Abbasi (Virtual University) Theory of Computation 18 / 25

  • Simulating multi-tape TMs

    Another important point to note in this proof:It seems like S is not very efficient. To perform one step of M it makestwo passes over the entire tape. However, efficiency is not our concernin computability theory (it will be when we study complexity theory).

    Sarmad Abbasi (Virtual University) Theory of Computation 19 / 25

  • Simulating multi-tape TMs

    It is your homework to prove the following theorem:

    TheoremEvery k-head TM has an equivalent single tape TM.

    The proof of this theorem is almost a ditto copy of the previoustheorem. However, there are some subtle differences. You must writethe proof in detail to understand these differences.

    Sarmad Abbasi (Virtual University) Theory of Computation 20 / 25

  • Multi-tape TMs

    Can we use this theorem to make our lives simpler? Yes.Suppose someone asks you if the language

    L = {w#w : w {0,1}}is decidable. It is much simpler to design a two tape TM for thislanguage.

    Sarmad Abbasi (Virtual University) Theory of Computation 21 / 25

  • Multi-tape TMs

    Description of a 2-tape TM that accepts L.

    1 In the first pass make sure the input is of the form w1#w2.2 Cope the contents after # to the second tape.3 Bring both tape heads all the way to the left.4 Match symbols of w1 and w2 one by one to make sure they are

    equal.

    Note that this is a much more natural solution than matching symbolsby shuffling over the input.

    Sarmad Abbasi (Virtual University) Theory of Computation 22 / 25

  • Multi-tape TMs

    From now on we will mostly describe multi-tape TMs. By this theoremwe can always find a one-tape TM that is equivalent to our multi-tapeTM. This theorem is going to be extremely useful.

    Sarmad Abbasi (Virtual University) Theory of Computation 23 / 25

  • Enumerators

    Let us now look at another model of computation called enumerators.Enumerators are devices that do not take any input and only produceoutput. Here is a picture of an enumerator:

    Sarmad Abbasi (Virtual University) Theory of Computation 24 / 25

  • Enumerators

    Enumerators are another model of computation. They do not take anyinput and only produce output. Let us define them formally: Anenumerator E = (Q,, ,q0, ).

    1 Q is the set of states.2 is the output alphabet and #, 6 .3 is the work alphabet and .4 q0 is the start state.5 is the transition function.

    Well what is the domain and range of .

    : Q 7 Q {L,R} ( {,#})

    Sarmad Abbasi (Virtual University) Theory of Computation 25 / 25

  • Enumerators

    L(E) the language enumerated by E is the set of all strings that itoutputs.

    Sarmad Abbasi (Virtual University) Theory of Computation 26 / 25

  • Enumerators

    Given an enumerator E Can we make a TM M such that

    L(E) = L(M);

    that is, the language accepted by M is the same as the oneenumerated by E .

    Sarmad Abbasi (Virtual University) Theory of Computation 27 / 25

  • Enumerators

    This is easy M simply has E encoded in it. On input x it runs E andwaits for x to appear. If it appears it accepts.

    Sarmad Abbasi (Virtual University) Theory of Computation 28 / 25

  • Enumerators

    The answer is yes. Consider a TM M and suppose:

    1 is accepted by M.2 0 is rejected by M.3 1 is accepted by M.4 On 00 M loops forever.5 01 is accepted by M.

    We want to make an enumerator that outputs

    ,1,01, . . . .

    Sarmad Abbasi (Virtual University) Theory of Computation 29 / 25

  • Enumerators

    We can try to make an enumerator as follows:

    1 For each string x = ,0,1,00,01,10,11, 2 run M on x; if M accepts output x

    This does not work. Since, M loops for ever on 00 thus it will neveroutput 01!

    Sarmad Abbasi (Virtual University) Theory of Computation 30 / 25

  • Dovetailing

    We can use dovetailing to get over this problem. The idea is to usetime sharing so that one bad string does not take up all the time.

    Sarmad Abbasi (Virtual University) Theory of Computation 31 / 25