Theory 12

download Theory 12

of 46

Transcript of Theory 12

  • 7/27/2019 Theory 12

    1/46

    [next][tail][up]

    5.1 Time and Space

    Random Access Machines

    Time and Space on Turing TransducersComplexity of ProblemsComplexity ClassesTime and Space on Universal Turing Transducers

    The time and space requirements of a given program depend on the program itself and on theagent executing it.

    Each agent has its own sets of primitive data items and primitive operations. Each primitive dataitem of a given agent requires some fixed amount of memory space. Similarly, each primitiveoperation requires some fixed amount of execution time.

    Moreover, each pair of agents that execute the same program are relatively primitive. That is,each primitive data item of one agent can be represented by some fixed number of primitive dataitems of the other agent. Similarly, each primitive operation of one agent can be simulated bysome fixed number of primitive operations of the other agent.

    When executing a given program, an agent represents the elements the program processes withits own primitive data items. Similarly, the agent simulates with its own primitive operations theinstructions the program uses.

    As a result, each computation of a given program requires some c1s space and some c2t time,

    where s and t depend only on the program and c1 and c2 depend only on the agent. c1 representsthe packing power of the agent; c2 represents the speed of the agent and the simulation power ofits operations.

    Since different agents differ in their implied constants c1 and c2, and since the study ofcomputation aims at the development of a general theory, then one can, with no loss ofgenerality, restrict the study of time and space to behavioral analyses. That is, to analyses inwhich the required accuracy is only up to some linear factor from the time and memoryrequirements of the actual agents. Such analyses can be carried out by employing models ofcomputing machines, such as the random access machines and Turing transducers used here.

    Random Access Machines

    In general, programs are written for execution on computers. Consequently, abstractions ofcomputers are of central interest when considering the resources that programs require. Aconventional computer can be viewed as having an input tape, an output tape, a fixed program,and a memory (see Figure5.1.1).

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk.html#Q2-60001-2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk.html#Q2-60001-2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk.html#Q2-60001-2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.html
  • 7/27/2019 Theory 12

    2/46

    Figure 5.1.1The structure of a computer.

    The input and output tapes are one-way sequential tapes used for holding the input values and theoutput values, respectively. The memory consists of cells that can be accessed in any order. Eachcell can hold values from a domain that has a binary representation. The number of cells can beassumed to be unbounded, because of the availability of giant memories for computers.Similarly, because of the large variety of values that can be stored in each cell, the size of eachcell can be assumed to be unbounded. The fixed program can consist of any "standard" kind ofdeterministic instructions (e.g., read, write, add, subtract, goto).

    Such abstract computers are called random access machines, or simply RAM's. In what follows,RAM's will be identified with deterministic programs of similar characteristics. In particular, theprograms will be assumed to have domains of variables that are equal to the set of natural

    numbers, and variables that can be viewed as one-dimensional arrays. Each entry A(l) of an array

    A will be assumed to be accessed through an indexing operator whose parameters are A and l.

    Example 5.1.1 The RAM in Figure5.1.2

    readK

    for i := 1 up to K do readA(i)

    for i := 2 up to K do

    for j := i down to 2 do

    if A(j) < A(j - 1) then A(j)

    A(j - 1)

    for i := 1 up to K do write A(i)

    Figure 5.1.2A RAM that sorts any given set of numbers.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2
  • 7/27/2019 Theory 12

    3/46

    sorts any given set of natural numbers. It is represented by a deterministic program of free format

    and employs the variables i, j, K, and A.

    The RAM reads into K the cardinality N of the set to be sorted, and into A(1), . . . , A(N) the Nelements to be sorted. Then the RAM sorts the set incrementally, starting with the trivially sorted

    subset that consists only of the element in A(1). At each stage the element in the next entry A(l) ofA is added to the sorted subset and placed in its appropriate position.

    In the case of RAM's there are two common kinds of cost criteria for the space and time

    analyses: the logarithmic and the uniform cost criteria.

    Under the logarithmic cost criterion the following assumptions are made. The primitive dataitems are the bits in the binary representations of the natural numbers being used. The primitiveoperations are the bit operations needed for executing the instructions of the RAM's. Thememory needed in a computation of a given RAM is equal to that required by the entries of thevariables. The memory required by a given entry of a variable, in turn, is equal to the length ofthe binary representation of the largest value v being stored in it, that is, to

    log (v + 1)

    if v

  • 7/27/2019 Theory 12

    4/46

    0 and to 1 if v = 0. The time needed by thecomputation is equal to the number of bit operations needed for executing the instructions.

    The uniform cost criterion is a degeneration of the logarithmic cost criterion in which thefollowing assumptions are made. Each value is a primitive data item, the memory required by agiven variable is equal to the number of entries in the array that it represents, the memoryrequired by a RAM is equal to the total memory required by its variables, and the time requiredby a RAM is equal to the number of instructions being executed.

    Example 5.1.2 Consider the RAM of Example5.1.1(see Figure5.1.2). On input N, v1, . . . , vN

    the RAM requires 1 unit of space forK , one unit fori, one forj, and N units forA , under theuniform cost criterion. On the other hand, under the logarithmic cost criterion, the RAM requires

    log N

    units of space forK,

    log N

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1
  • 7/27/2019 Theory 12

    5/46

    units fori,

    log N

    forj, and Nmax(

    log v1

    , . . . ,

    log vN

  • 7/27/2019 Theory 12

    6/46

    ) units of space forA. (In this example

    log

    is

    assumed to equal log (

    + 1)

    if

  • 7/27/2019 Theory 12

    7/46

    0 and to equal 1 if

    = 0.)

    The readK instruction takes one unit of time under the uniform cost criterion, and

    log N

    units under the logarithmic cost criterion.

    Ifi holds the value l then the instruction readA(i) takes 2 units of time under the uniform cost

    criterion: one unit for accessing the value l ofi, and one unit for accessing the value ofA(l).Under the logarithmic cost criterion the instruction requires

    log l

  • 7/27/2019 Theory 12

    8/46

    +

    log vl units of time. Similarly, in such a case the

    instruction writeA(i) takes 2 units of time under the uniform cost criterion, and

    log l

    +

    log (the lth smallest value in {v1, . . . , vN }) unitsunder the logarithmic cost criterion.

    The code segments fori := 1 up toKdo readA(i) and fori := 1 up toKdo writeA(i) taketime that is linear in N under the uniform cost criterion, and that is linear in (1 + log v1) + (log 2

  • 7/27/2019 Theory 12

    9/46

    + log v2) +

    +

    (log N + log vN ) Nlog N + log (v1

    vN ) under the logarithmic cost criterion.

    The RAM requires space that is linear in N under the uniform cost criterion, and linear in Nlog m

    under the logarithmic cost criterion. m denotes the largest value in the input. The RAM requires

  • 7/27/2019 Theory 12

    10/46

    time that is linear in N2 under the uniform cost criterion, and linear in N2log m under the

    logarithmic cost criterion.

    In general, both the time and the space required for finding a solution to a problem at a giveninstance increase with the length of the representation of the instance. Consequently, the timeand space requirements of computing machines are specified by functions of the length of theinputs.

    In what follows, n will be used for denoting the length of the instances in question.

    Example 5.1.3 A natural number greater than 1 and divisible only by 1 and itself, is called aprime number. Theprimality problem asks for any given positive integer number m whether it isprime. The RAM in Figure5.1.3,

    readx

    if x < 2 then halt with answer no

    if x = 2 then halt with answer yes

    y :=

    do

    if x is divisible by y then halt with answer no

    y := y - 1

    until y = 1

    halt with answer yes

    Figure 5.1.3A RAM that solves the primality problem.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3
  • 7/27/2019 Theory 12

    11/46

    represented by a deterministic program in free format, solves the primality problem using abrute-force approach.

    An input m can be given to the RAM in a unary or binary representation, whereas the variables

    can hold their values only in binary. A unary representation for m has length n = m, and a binary

    representation for m has length n = log (m + 1)

    if m

    0 and length n = 1 if m = 0.

    With a unary representation for a given instance m of the problem, under the uniform costcriterion, the RAM requires a constant space, and time linear in n. On the other hand, under thelogarithmic cost criterion, the RAM requires space linear in log n and time linear in n(log n)kforsome k > 0. A linear time in n is required for reading the input m and storing it in binary (seeExercise5.1.2), and a polynomial time in log n is required for checking the divisibility of m by

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2
  • 7/27/2019 Theory 12

    12/46

    an integer i, where 2 i

    .

    With a binary representation for a given instance m of the problem, the RAM requires a constant

    space under the uniform cost criterion, and space linear in n under the logarithmic cost criterion.But the algorithm requires time polynomial in m, or in 2n, under both the uniform and

    logarithmic cost criteria.

    Time and Space on Turing Transducers

    In the case of Turing transducers we assume the following. The transition rules are the primitiveoperations, and the characters of the alphabets are the primitive data items. Each move takes oneunit of time, and the time a computation takes is equal to the number of moves made during thecomputation. The space that a computation requires is equal to the number of locations visited inthe auxiliary work tape, which has the maximal such number. (A possible alternative for thespace measurement could be the sum of the number of locations visited over all the auxiliarywork tapes. However, since the number of auxiliary work tapes is fixed for a given Turingtransducer, and since constant factors are ignored in the analyses performed here, we use thetraditional definition.)

    A Turing transducer M is said to be a T(n) time-bounded Turing transducer, or oftimecomplexity T(n), if all the possible computations of M on each input x of length n take no morethan T(n) time. M is said to bepolynomially time-bounded, or ofpolynomial time complexity, ifT(n) is a polynomial in n. The Turing transducer M is said to be an S(n) space-bounded Turingtransducer, or ofspace complexity S(n), if all the possible computations of M on each input x oflength n take no more than S(n) space. M is said to bepolynomially space-bounded, or ofpolynomial space complexity, if S(n) is a polynomial in n. M is said to be logspace-bounded, or

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-4
  • 7/27/2019 Theory 12

    13/46

    oflogspace complexity, if S(n) = c log n for some constant c. Similar definitions also hold forTuring machines, RAM's, and other classes of computing machines.

    The following statement adds a refinement to Church's thesis. As in the case of the originalthesis, the refinement cannot be proved to be correct. However, here too one can intuitively be

    convinced of the correctness of the statement, by showing the existence of translations betweenthe different classes of models of computation under which the result is invariant. Thetranslations between RAM's and deterministic Turing transducers can be similar to thoseexhibited in Section 4.2.

    The Sequential Computation Thesis A function is computable (or, respectively, partiallycomputable) by an algorithm A only if it is computable (or, respectively, partially computable)by a deterministic Turing transducer that satisfies the following conditions: A on a given inputhas a computation that takes T(n) time and S(n) space only if on such an input the Turingtransducer has a computation that takes p(T(n)) time and p(S(n)) space, where p() is some fixedpolynomial not dependent on the input.

    Complexity of Problems

    With no loss of generality, in what follows it is assumed that a time-bound T(n) is equal to

    max(n, T(n)

    ), that is, is equal to at least the time needed toread all the input. In addition, a space-bound S(n) is assumed to equal max(1,

    S(n)

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-5
  • 7/27/2019 Theory 12

    14/46

    ). log 0 is assumed to equal l. f(n) is assumed to

    equal f(n)

    for all the other functions f(n).

    The big O notation f(n) = O(g(n)) will be used for specifying that there exist a constant c > 0 and

    n0 such that f(n) cg(n) for all n

    n0. In such a case, f(n) will be said to be of order

    g(n).

    A problem will be said to be oftime complexity T(n) if it is solvable by a T(n) time-bounded,deterministic Turing transducer. The problem will be said to be ofnondeterministic timecomplexity T(n) if it is solvable by a T(n) time-bounded Turing transducer. The problem will besaid to be ofspace complexity S(n) if it is solvable by an S(n) space-bounded, deterministicTuring transducer. The problem will be said to be ofnondeterministic space complexity S(n) if itis solvable by an S(n) space-bounded Turing transducer.

  • 7/27/2019 Theory 12

    15/46

    Similarly, a language will be said to be oftime complexity T(n) if it is accepted by a T(n) time-bounded, deterministic Turing machine. The language will be said to be ofnondeterministic timecomplexity T(n) if it is accepted by a T(n) time-bounded, nondeterministic Turing machine. Thelanguage will be said to be ofspace complexity S(n) if it is accepted by an S(n) space-bounded,deterministic Turing machine. The language will be said to be ofnondeterministic space

    complexity S(n) if it is accepted by an S(n) space-bounded, nondeterministic Turing machine.

    Complexity Classes

    The following classes are important to our study of time and space.

    DTIME(T(n))--

    the class of languages that have time complexity O(T(n)).

    NTIME(T(n))--

    the class of languages that have nondeterministic time complexity O(T(n)).

    DSPACE (S(n))--

    the class of languages that have deterministic space complexity O(S(n)).

    NSPACE (S(n))

    --

    the class of languages that have nondeterministic space complexity O(S(n)).

    P-- the class of membership problems for the languages in

    (p(n) stands for a polynomial in n.)

    NP

    -- the class of membership problems for the languages in

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-6
  • 7/27/2019 Theory 12

    16/46

    EXPTIME

    -- the class of membership problems for the languages in

    PSPACE-- the class of membership problems for the languages in

    NLOG

    -- the class of membership problems for the languages inNSPACE(log n).

    DLOG-- the class of membership problems for the languages inDSPACE(log n).

    So that our analyses of the complexity of problems will be meaningful, only "natural"representations are assumed for their instances. The "naturalness" is considered with respect tothe resources being analyzed.

    Example 5.1.4 The primality problem can be solved by a deterministic Turing transducer inpolynomial time if the instances are given in unary representations, and in exponential time if theinstances are given in nonunary representations (see Example5.1.3). However, for a giveninstance m both approaches require time that is polynomial in m.

    When considering the complexity of the primality problem, a nonunary representation for theinstances is considered natural and a unary representation for the instances is consideredunnatural. The specific choice of the cardinality d of a nonunary representation is of noimportance, because the lengths of such different representations of a number m are equal up to aconstant factor. Specifically, a length logd1m and a length logd2m, for a pair of representations ofm, satisfy the relation logd1m = (logd1d2)logd2m when d1 and d2 are greater than 1.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3
  • 7/27/2019 Theory 12

    17/46

    Consequently, the RAM in Figure5.1.3and the sequential computation thesis imply that theprimality problem is of exponential time complexity.

    Time and Space on Universal Turing Transducers

    An analysis of the proof of Theorem4.4.1provides the following lemma.

    Lemma 5.1.1 The universal Turing transducer U of Theorem4.4.1on a given input (M, x), ofa deterministic Turing transducer M and an input x for M,

    a. Halts within cM t2 moves, if M halts within t moves on input x and t

    |x|.b. Visits at most cM s locations in each of the auxiliary work tapes, if M visits no more than

    s locations in each of its auxiliary work tapes and s

    log |x|.

    cM is assumed to be some polynomial in the length of the representation of M. (The polynomialdoes not depend on M.)

    Proof Assume the notations in the proof of Theorem4.4.1. The number of moves that U needsto check for proper input (M, x) is at most some constant times |x|, where the constant dependsonly on the length of the representation of M.

    Specifically, U needs |E(M)| + 3 moves for finding E(M). |E(M)| moves for scanning E(M), and 3moves for determining the 01 that follows the suffix 01 of E(M).

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3
  • 7/27/2019 Theory 12

    18/46

    Checking for a proper representation E(M) of a Turing transducer M takes a number of moves,which is linear in |E(M)|, that is,

    a. |E(M)| moves for determining the number m of auxiliary work tapes of M, and for

    verifying that each transition rule = (q, a,

    b1, . . . , bm, p, d0, c1, d1, . . . , cm, dm, ) ofM contains 3m + 5 entries. Each transition rule

    is represented in E(M) by a substring E(

    ) that is enclosed between two separators

    of the form 01. The substring E( ) mustcontain exactly 3m + 5 0's.

    b. |E(M)| moves for determining that the head movements di in the transition rules arerepresented by binary strings of the form E(-1) = 011, E(0) = 0111, and E(+1) = 01111.

  • 7/27/2019 Theory 12

    19/46

    c. |E(M)| moves for determining that the transition rules refer to the blank symbol B of Monly in the auxiliary work tapes, and to the left endmarker and the right endmarker $only in the input tape.

    d. |E(M)| moves for determining that none of the states of M is represented by the binarystring 0.

    Checking that M is deterministic takes a number of moves that is linear in |E(M)|2. The checkingcan be done by copying E(M) to an auxiliary work tape of U, and then comparing each transition

    rule in the auxiliary work tape of U against each

    of the transition rules that follows in the inputtape of U.

    Checking for a proper input x for the Turing transducer M requires time that is linear in|E(M)|(|E(M)| + |x|). Specifically, U in time that is linear in |E(M)|2 determines the input symbolsof M and stores them in an auxiliary work tape. Then U in |E(M)|

    |x| time checks that only symbols from theauxiliary work tape are in x.

  • 7/27/2019 Theory 12

    20/46

    U requires log |x| + |E(M)|(ms + 1) + 2m + 3

    s locations in the auxiliary work tapes for

    recording the strings #E(q)#|u|#E(u1)#E(v1)#

    #E(um)# E(vm)# which represent the configurations (uqv, u1qv1, . . . , umqvm, w) of M, where

    = 8|E(M)|m. U requires log |x| locations for |u|,|E(M)| locations for q, |E(M)| locations for each symbol in each u i, |E(M)| locations for each

    symbol in each vi, and 2m + 3 locations for the symbols #.

  • 7/27/2019 Theory 12

    21/46

    Given a string #E(q)#|u|#E(u1)#E(v1)#

    #E(um)#E(vm)#, the universal Turing transducer U can determine in at most

    (s + |x|)

    tmoves the first m + 2 elements q, a, b1, . . . , bm of the transition rule

    = (q, a, b1, . . . , bm, p, d0, c1, d1, . . . , cm, dm,

    ) to be used in the next simulated move of M,

  • 7/27/2019 Theory 12

    22/46

    where is some constant whose magnitude is linearin |E(M)| and bi denotes the first symbol in viB. The transducer takes at most

    s moves for extracting |u|, E(q), E(b1), . . . , E(bm)

    from #E(q)#|u|#E(u1)#E(v1)#

    #E(um)#E(vm)#. In particular, 6|u| moves are needed over the string representing |u| for countingdown from |u| to 0 (see Exercise5.1.2), and |E(M)| + |01| + |E(u)| moves are needed forextracting the symbol a from the input tape.

    Given the first m + 2 elements (q, a, b1, . . . , bm) in

    , the universal Turing transducer U can determine

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2
  • 7/27/2019 Theory 12

    23/46

    the tuple (p, d0, c1, d1, . . . , cm, dm, ) in a singlesweep over the input tape. Having such a tuple, U can also modify the recorded configuration ofM in a single sweep.

    Consequently, the total number of moves that U needs for simulating the moves of M is nogreater than ct2. c is some polynomial (independent of M) in the length of the standard binary

    representation of M.

    [next][front][up]

    [next][tail][up]

    5.1 Time and Space

    Random Access MachinesTime and Space on Turing TransducersComplexity of ProblemsComplexity ClassesTime and Space on Universal Turing Transducers

    The time and space requirements of a given program depend on the program itself and on theagent executing it.

    Each agent has its own sets of primitive data items and primitive operations. Each primitive dataitem of a given agent requires some fixed amount of memory space. Similarly, each primitiveoperation requires some fixed amount of execution time.

    Moreover, each pair of agents that execute the same program are relatively primitive. That is,each primitive data item of one agent can be represented by some fixed number of primitive dataitems of the other agent. Similarly, each primitive operation of one agent can be simulated bysome fixed number of primitive operations of the other agent.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk.html#Q2-60001-2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk.html#Q2-60001-2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q1-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk.html#Q2-60001-2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#tailtheory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.html
  • 7/27/2019 Theory 12

    24/46

    When executing a given program, an agent represents the elements the program processes withits own primitive data items. Similarly, the agent simulates with its own primitive operations theinstructions the program uses.

    As a result, each computation of a given program requires some c1s space and some c2t time,

    where s and t depend only on the program and c1 and c2 depend only on the agent. c1 representsthe packing power of the agent; c2 represents the speed of the agent and the simulation power ofits operations.

    Since different agents differ in their implied constants c1 and c2, and since the study ofcomputation aims at the development of a general theory, then one can, with no loss ofgenerality, restrict the study of time and space to behavioral analyses. That is, to analyses inwhich the required accuracy is only up to some linear factor from the time and memoryrequirements of the actual agents. Such analyses can be carried out by employing models ofcomputing machines, such as the random access machines and Turing transducers used here.

    Random Access Machines

    In general, programs are written for execution on computers. Consequently, abstractions ofcomputers are of central interest when considering the resources that programs require. Aconventional computer can be viewed as having an input tape, an output tape, a fixed program,and a memory (see Figure5.1.1).

    Figure 5.1.1The structure of a computer.

    The input and output tapes are one-way sequential tapes used for holding the input values and theoutput values, respectively. The memory consists of cells that can be accessed in any order. Eachcell can hold values from a domain that has a binary representation. The number of cells can beassumed to be unbounded, because of the availability of giant memories for computers.Similarly, because of the large variety of values that can be stored in each cell, the size of eachcell can be assumed to be unbounded. The fixed program can consist of any "standard" kind ofdeterministic instructions (e.g., read, write, add, subtract, goto).

    Such abstract computers are called random access machines, or simply RAM's. In what follows,RAM's will be identified with deterministic programs of similar characteristics. In particular, theprograms will be assumed to have domains of variables that are equal to the set of natural

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3002r5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-3
  • 7/27/2019 Theory 12

    25/46

  • 7/27/2019 Theory 12

    26/46

    the binary representation of the largest value v being stored in it, that is, to

    log (v + 1)

    if v

    0 and to 1 if v = 0. The time needed by thecomputation is equal to the number of bit operations needed for executing the instructions.

    The uniform cost criterion is a degeneration of the logarithmic cost criterion in which thefollowing assumptions are made. Each value is a primitive data item, the memory required by a

    given variable is equal to the number of entries in the array that it represents, the memoryrequired by a RAM is equal to the total memory required by its variables, and the time requiredby a RAM is equal to the number of instructions being executed.

    Example 5.1.2 Consider the RAM of Example5.1.1(see Figure5.1.2). On input N, v1, . . . , vNthe RAM requires 1 unit of space forK , one unit fori, one forj, and N units forA , under theuniform cost criterion. On the other hand, under the logarithmic cost criterion, the RAM requires

    log N

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3004r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3003t5.1.1
  • 7/27/2019 Theory 12

    27/46

    units of space forK,

    log N

    units fori,

    log N

    forj, and Nmax(

    log v1

  • 7/27/2019 Theory 12

    28/46

    , . . . ,

    log vN

    ) units of space forA. (In this example

    log

    is

    assumed to equal log (

  • 7/27/2019 Theory 12

    29/46

    + 1)

    if

    0 and to equal 1 if

    = 0.)

    The readK instruction takes one unit of time under the uniform cost criterion, and

    log N

    units under the logarithmic cost criterion.

  • 7/27/2019 Theory 12

    30/46

    Ifi holds the value l then the instruction readA(i) takes 2 units of time under the uniform cost

    criterion: one unit for accessing the value l ofi, and one unit for accessing the value ofA(l).Under the logarithmic cost criterion the instruction requires

    log l

    +

    log vl units of time. Similarly, in such a case the

    instruction writeA(i) takes 2 units of time under the uniform cost criterion, and

    log l

    +

  • 7/27/2019 Theory 12

    31/46

  • 7/27/2019 Theory 12

    32/46

    vN ) under the logarithmic cost criterion.

    The RAM requires space that is linear in N under the uniform cost criterion, and linear in Nlog m

    under the logarithmic cost criterion. m denotes the largest value in the input. The RAM requirestime that is linear in N2 under the uniform cost criterion, and linear in N2log m under the

    logarithmic cost criterion.

    In general, both the time and the space required for finding a solution to a problem at a giveninstance increase with the length of the representation of the instance. Consequently, the timeand space requirements of computing machines are specified by functions of the length of theinputs.

    In what follows, n will be used for denoting the length of the instances in question.

    Example 5.1.3 A natural number greater than 1 and divisible only by 1 and itself, is called aprime number. Theprimality problem asks for any given positive integer number m whether it isprime. The RAM in Figure5.1.3,

    readx

    if x < 2 then halt with answer no

    if x = 2 then halt with answer yes

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3
  • 7/27/2019 Theory 12

    33/46

    y :=

    do

    if x is divisible by y then halt with answer no

    y := y - 1until y = 1

    halt with answer yes

    Figure 5.1.3A RAM that solves the primality problem.

    represented by a deterministic program in free format, solves the primality problem using abrute-force approach.

    An input m can be given to the RAM in a unary or binary representation, whereas the variablescan hold their values only in binary. A unary representation for m has length n = m, and a binary

    representation for m has length n = log (m + 1)

  • 7/27/2019 Theory 12

    34/46

    if m

    0 and length n = 1 if m = 0.

    With a unary representation for a given instance m of the problem, under the uniform cost

    criterion, the RAM requires a constant space, and time linear in n. On the other hand, under thelogarithmic cost criterion, the RAM requires space linear in log n and time linear in n(log n)kforsome k > 0. A linear time in n is required for reading the input m and storing it in binary (seeExercise5.1.2), and a polynomial time in log n is required for checking the divisibility of m by

    an integer i, where 2 i

    .

    With a binary representation for a given instance m of the problem, the RAM requires a constantspace under the uniform cost criterion, and space linear in n under the logarithmic cost criterion.

    But the algorithm requires time polynomial in m, or in 2n

    , under both the uniform and

    logarithmic cost criteria.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2
  • 7/27/2019 Theory 12

    35/46

    Time and Space on Turing Transducers

    In the case of Turing transducers we assume the following. The transition rules are the primitiveoperations, and the characters of the alphabets are the primitive data items. Each move takes oneunit of time, and the time a computation takes is equal to the number of moves made during the

    computation. The space that a computation requires is equal to the number of locations visited inthe auxiliary work tape, which has the maximal such number. (A possible alternative for thespace measurement could be the sum of the number of locations visited over all the auxiliarywork tapes. However, since the number of auxiliary work tapes is fixed for a given Turingtransducer, and since constant factors are ignored in the analyses performed here, we use thetraditional definition.)

    A Turing transducer M is said to be a T(n) time-bounded Turing transducer, or oftimecomplexity T(n), if all the possible computations of M on each input x of length n take no morethan T(n) time. M is said to bepolynomially time-bounded, or ofpolynomial time complexity, ifT(n) is a polynomial in n. The Turing transducer M is said to be an S(n) space-bounded Turing

    transducer, or ofspace complexity S(n), if all the possible computations of M on each input x oflength n take no more than S(n) space. M is said to bepolynomially space-bounded, or ofpolynomial space complexity, if S(n) is a polynomial in n. M is said to be logspace-bounded, oroflogspace complexity, if S(n) = c log n for some constant c. Similar definitions also hold forTuring machines, RAM's, and other classes of computing machines.

    The following statement adds a refinement to Church's thesis. As in the case of the originalthesis, the refinement cannot be proved to be correct. However, here too one can intuitively beconvinced of the correctness of the statement, by showing the existence of translations betweenthe different classes of models of computation under which the result is invariant. Thetranslations between RAM's and deterministic Turing transducers can be similar to those

    exhibited in Section 4.2.

    The Sequential Computation Thesis A function is computable (or, respectively, partiallycomputable) by an algorithm A only if it is computable (or, respectively, partially computable)by a deterministic Turing transducer that satisfies the following conditions: A on a given inputhas a computation that takes T(n) time and S(n) space only if on such an input the Turingtransducer has a computation that takes p(T(n)) time and p(S(n)) space, where p() is some fixedpolynomial not dependent on the input.

    Complexity of Problems

    With no loss of generality, in what follows it is assumed that a time-bound T(n) is equal to

    max(n, T(n)

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-4http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-5http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-4
  • 7/27/2019 Theory 12

    36/46

    ), that is, is equal to at least the time needed toread all the input. In addition, a space-bound S(n) is assumed to equal max(1,

    S(n)

    ). log 0 is assumed to equal l. f(n) is assumed to

    equal f(n)

    for all the other functions f(n).

  • 7/27/2019 Theory 12

    37/46

    The big O notation f(n) = O(g(n)) will be used for specifying that there exist a constant c > 0 and

    n0 such that f(n) cg(n) for all n

    n0. In such a case, f(n) will be said to be of orderg(n).

    A problem will be said to be oftime complexity T(n) if it is solvable by a T(n) time-bounded,deterministic Turing transducer. The problem will be said to be ofnondeterministic timecomplexity T(n) if it is solvable by a T(n) time-bounded Turing transducer. The problem will besaid to be ofspace complexity S(n) if it is solvable by an S(n) space-bounded, deterministicTuring transducer. The problem will be said to be ofnondeterministic space complexity S(n) if itis solvable by an S(n) space-bounded Turing transducer.

    Similarly, a language will be said to be oftime complexity T(n) if it is accepted by a T(n) time-bounded, deterministic Turing machine. The language will be said to be ofnondeterministic timecomplexity T(n) if it is accepted by a T(n) time-bounded, nondeterministic Turing machine. The

    language will be said to be ofspace complexity S(n) if it is accepted by an S(n) space-bounded,deterministic Turing machine. The language will be said to be ofnondeterministic spacecomplexity S(n) if it is accepted by an S(n) space-bounded, nondeterministic Turing machine.

    Complexity Classes

    The following classes are important to our study of time and space.

    DTIME(T(n))--

    the class of languages that have time complexity O(T(n)).

    NTIME(T(n))--

    the class of languages that have nondeterministic time complexity O(T(n)).

    DSPACE (S(n))

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-6http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-6
  • 7/27/2019 Theory 12

    38/46

    --

    the class of languages that have deterministic space complexity O(S(n)).

    NSPACE (S(n))

    --

    the class of languages that have nondeterministic space complexity O(S(n)).

    P

    -- the class of membership problems for the languages in

    (p(n) stands for a polynomial in n.)

    NP-- the class of membership problems for the languages in

    EXPTIME

    -- the class of membership problems for the languages in

    PSPACE

    -- the class of membership problems for the languages in

  • 7/27/2019 Theory 12

    39/46

    NLOG

    -- the class of membership problems for the languages inNSPACE(log n).DLOG

    -- the class of membership problems for the languages inDSPACE(log n).So that our analyses of the complexity of problems will be meaningful, only "natural"representations are assumed for their instances. The "naturalness" is considered with respect tothe resources being analyzed.

    Example 5.1.4 The primality problem can be solved by a deterministic Turing transducer in

    polynomial time if the instances are given in unary representations, and in exponential time if theinstances are given in nonunary representations (see Example5.1.3). However, for a giveninstance m both approaches require time that is polynomial in m.

    When considering the complexity of the primality problem, a nonunary representation for theinstances is considered natural and a unary representation for the instances is consideredunnatural. The specific choice of the cardinality d of a nonunary representation is of noimportance, because the lengths of such different representations of a number m are equal up to aconstant factor. Specifically, a length logd1m and a length logd2m, for a pair of representations ofm, satisfy the relation logd1m = (logd1d2)logd2m when d1 and d2 are greater than 1.

    Consequently, the RAM in Figure5.1.3and the sequential computation thesis imply that theprimality problem is of exponential time complexity.

    Time and Space on Universal Turing Transducers

    An analysis of the proof of Theorem4.4.1provides the following lemma.

    Lemma 5.1.1 The universal Turing transducer U of Theorem4.4.1on a given input (M, x), ofa deterministic Turing transducer M and an input x for M,

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#Q2-60001-7http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3014r5.1.3http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.html#60001-3011t5.1.3
  • 7/27/2019 Theory 12

    40/46

    a. Halts within cM t2 moves, if M halts within t moves on input x and t

    |x|.b. Visits at most cM s locations in each of the auxiliary work tapes, if M visits no more than

    s locations in each of its auxiliary work tapes and s

    log |x|.

    cM is assumed to be some polynomial in the length of the representation of M. (The polynomialdoes not depend on M.)

    Proof Assume the notations in the proof of Theorem4.4.1. The number of moves that U needsto check for proper input (M, x) is at most some constant times |x|, where the constant dependsonly on the length of the representation of M.

    Specifically, U needs |E(M)| + 3 moves for finding E(M). |E(M)| moves for scanning E(M), and 3moves for determining the 01 that follows the suffix 01 of E(M).

    Checking for a proper representation E(M) of a Turing transducer M takes a number of moves,which is linear in |E(M)|, that is,

    a. |E(M)| moves for determining the number m of auxiliary work tapes of M, and for

    verifying that each transition rule = (q, a,

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fourse4.html#50004-17001t4.4.1
  • 7/27/2019 Theory 12

    41/46

    b1, . . . , bm, p, d0, c1, d1, . . . , cm, dm, ) ofM contains 3m + 5 entries. Each transition rule

    is represented in E(M) by a substring E(

    ) that is enclosed between two separators

    of the form 01. The substring E( ) mustcontain exactly 3m + 5 0's.

    b. |E(M)| moves for determining that the head movements di in the transition rules arerepresented by binary strings of the form E(-1) = 011, E(0) = 0111, and E(+1) = 01111.

    c. |E(M)| moves for determining that the transition rules refer to the blank symbol B of Monly in the auxiliary work tapes, and to the left endmarker and the right endmarker $only in the input tape.

    d. |E(M)| moves for determining that none of the states of M is represented by the binarystring 0.

    Checking that M is deterministic takes a number of moves that is linear in |E(M)|2. The checkingcan be done by copying E(M) to an auxiliary work tape of U, and then comparing each transition

  • 7/27/2019 Theory 12

    42/46

    rule in the auxiliary work tape of U against each

    of the transition rules that follows in the inputtape of U.

    Checking for a proper input x for the Turing transducer M requires time that is linear in|E(M)|(|E(M)| + |x|). Specifically, U in time that is linear in |E(M)|2 determines the input symbolsof M and stores them in an auxiliary work tape. Then U in |E(M)|

    |x| time checks that only symbols from the

    auxiliary work tape are in x.

    U requires log |x| + |E(M)|(ms + 1) + 2m + 3

    s locations in the auxiliary work tapes for

  • 7/27/2019 Theory 12

    43/46

    recording the strings #E(q)#|u|#E(u1)#E(v1)#

    #E(um)# E(vm)# which represent the configurations (uqv, u1qv1, . . . , umqvm, w) of M, where

    = 8|E(M)|m. U requires log |x| locations for |u|,|E(M)| locations for q, |E(M)| locations for each symbol in each u i, |E(M)| locations for eachsymbol in each vi, and 2m + 3 locations for the symbols #.

    Given a string #E(q)#|u|#E(u1)#E(v1)#

    #E(um)#E(vm)#, the universal Turing transducer U can determine in at most

  • 7/27/2019 Theory 12

    44/46

    (s + |x|)

    tmoves the first m + 2 elements q, a, b1, . . . , bm of the transition rule

    = (q, a, b1, . . . , bm, p, d0, c1, d1, . . . , cm, dm,

    ) to be used in the next simulated move of M,

    where is some constant whose magnitude is linearin |E(M)| and bi denotes the first symbol in viB. The transducer takes at most

    s moves for extracting |u|, E(q), E(b1), . . . , E(bm)

  • 7/27/2019 Theory 12

    45/46

    from #E(q)#|u|#E(u1)#E(v1)#

    #E(um)#E(vm)#. In particular, 6|u| moves are needed over the string representing |u| for countingdown from |u| to 0 (see Exercise5.1.2), and |E(M)| + |01| + |E(u)| moves are needed for

    extracting the symbol a from the input tape.

    Given the first m + 2 elements (q, a, b1, . . . , bm) in

    , the universal Turing transducer U can determine

    the tuple (p, d0, c1, d1, . . . , cm, dm, ) in a singlesweep over the input tape. Having such a tuple, U can also modify the recorded configuration ofM in a single sweep.

    Consequently, the total number of moves that U needs for simulating the moves of M is no

    greater than ct

    2

    . c is some polynomial (independent of M) in the length of the standard binary

    representation of M.

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fiveli1.html#60007-34006r5.1.2
  • 7/27/2019 Theory 12

    46/46

    [next][front][up]

    http://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-five.html#theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese1.htmlhttp://www.cse.ohio-state.edu/~gurari/theory-bk/theory-bk-fivese2.html