CS601 DTIME and DSPACE Lecture 5 Time and Space Functions: T, S

CS601 DTIME and DSPACE Lecture 5 Time and Space Functions: T, S

CS601 DTIME and DSPACE Lecture 5 Time and Space functions: t, s : N → N+ Definition 5.1 A set A ⊆ U is in DTIME[t(n)] iff there exists a deterministic, multi-tape TM, M, and a constant c, such that, 1. A = L(M) ≡ w ∈ U M(w)=1 , and 2. ∀w ∈ U, M(w) halts within c · t(|w|) steps. Definition 5.2 A set A ⊆ U is in DSPACE[s(n)] iff there exists a deterministic, multi-tape TM, M, and a constant c, such that, 1. A = L(M), and 2. ∀w ∈ U, M(w) uses at most c · s(|w|) work-tape cells. (Input tape is “read-only” and not counted as space used.) Example: PALINDROMES ∈ DTIME[n], DSPACE[n]. In fact, PALINDROMES ∈ DSPACE[log n]. [Exercise] 1 CS601 F(DTIME) and F(DSPACE) Lecture 5 Definition 5.3 f : U → U is in F (DTIME[t(n)]) iff there exists a deterministic, multi-tape TM, M, and a constant c, such that, 1. f = M(·); 2. ∀w ∈ U, M(w) halts within c · t(|w|) steps; 3. |f(w)|≤|w|O(1), i.e., f is polynomially bounded. Definition 5.4 f : U → U is in F (DSPACE[s(n)]) iff there exists a deterministic, multi-tape TM, M, and a constant c, such that, 1. f = M(·); 2. ∀w ∈ U, M(w) uses at most c · s(|w|) work-tape cells; 3. |f(w)|≤|w|O(1), i.e., f is polynomially bounded. (Input tape is “read-only”; Output tape is “write-only”. Neither is counted as space used.) Example: Plus ∈ F (DTIME[n]), Mult ∈ F (DTIME[n2]) 2 CS601 L, P, and PSPACE Lecture 5 L ≡ DSPACE[log n] ∞ O i P ≡ DTIME[n (1)] ≡ [ DTIME[n ] i=1 ∞ O i PSPACE ≡ DSPACE[n (1)] ≡ [ DSPACE[n ] i=1 These classes will become your good friends soon. 3 Theorem 5.5 For any functions t(n) ≥ n, s(n) ≥ log n, we have DTIME[t(n)] ⊆ DSPACE[t(n)] DSPACE[s(n)] ⊆ DTIME[2O(s(n))] ⋆ Proof: Let M be a DSPACE[s(n)] TM, let w ∈ Σ0, let n = |w| M(w) has k tapes and uses at most cs(n) work-tape cells. ′ M(w) has at most 2k s(n) possible configurations: ′ |Q| · (n + cs(n)+2)k · |Σ|cs(n) < 2k s(n) # of states · # of head positions · # of tape contents ′ Thus, after 2k s(n) steps, M(w) must be in an infinite loop. Corollary 5.6 L ⊆ P ⊆ PSPACE 4 CS601 PALINDROMES ∈ L Lecture 5 ⊲ A B L E L B A ⊔ ⊲ ⊔ . ⊲ A B L E L B A ⊔ ⊲ 0 0 1 ⊔ 1 1 1 . ⊲ A B L E L B A ⊔ ⊲ 0 1 0 ⊔ 1 1 0 . ⊲ A B L E L B A ⊔ ⊲ 0 1 1 ⊔ 1 0 1 . ⊲ A B L E L B A ⊔ ⊲ 1 0 0 ⊔ 1 0 0 . ⊲ A B L E L B A ⊔ ⊲ 1 ⊔ Using O(log n) workspace, we can keep track of and manipulate two pointers into the input. 5 CS601 DTIME versus RAMTIME Lecture 5 RAM = Random Access Machine Memory: κ r0 r1 r2 r3 r4 ··· ri ··· κ = program counter; r0 = accumulator Instruction Operand Semantics READ j | ↑ j | = j r0 := (rj | rrj | j) STORE j | ↑ j (rj | rrj ) := r0 ADD j | ↑ j | = j r0 := r0 +(rj | rrj | j) SUB j | ↑ j | = j r0 := r0 − (rj | rrj | j) HALF r0 := ⌊r0/2⌋ JUMP j κ := j JPOS j if (r0 > 0) then κ := j JZERO j if (r0 = 0) then κ := j HALT κ := 0 6 Theorem 5.7 DTIME[t(n)] ⊆ RAM-TIME[t(n)] ⊆ DTIME[(t(n))3] Proof: Memorize program in finite control. Store all registers on one tape: ⊲ 1 1 , 0 : 1 0 1 , 1 0 1 : 0 , 1 0 1 1 : 1 0 ⊔ κ r0 r5 r11 Store workspace for calculations on second tape: ⊲ 1 0 0 , 1 0 1 1 ⊔ κ′ A Use the third tape for copying and pasting sections of the first tape. ⊲ 0 : 1 0 1 , 1 0 1 : 0 , 1 0 1 1 : 1 0 ⊔ r0 r5 r11 Each register contains at most n + t(n) bits. [O(log n) would be more realistic.] The total number of tape cells used is at most 2t(n)(n + t(n)) = O((t(n))2). Each step takes at most O((t(n))2) steps to simulate. 7 CS601 Nondeterministic TM Lecture 5 Nondeterministic Turing Machines choose one of two possible moves each step. guess.tm s g q 0 1 ⊔ g, ⊔, −| q, ⊔, − s, 0, → | s, 1, → ⊲ s, ⊲, → comment g or q guess 0 or 1 the rest Nondeterministic Guess Machine is a typical example: • Write down an arbitrary string, g ∈{0, 1}⋆: the guess. • Proceed with the rest of the computation, using g if desired. • Accept iff there exists some guess that leads to acceptance. 8 s ⊲ ⊔ s ⊲ ⊔ g ⊲ ⊔ s ⊲ 0 ⊔ g ⊲ 0 ⊔ s ⊲ 0 1 ⊔ g ⊲ 0 1 ⊔ s ⊲ 0 1 1 ⊔ g ⊲ 0 1 1 ⊔ . s ⊲ 0 1 1 0 ··· 1 ⊔ q ⊲ 0 1 1 0 ··· 1 ⊔ guess.tm s g q 0 1 ⊔ g, ⊔, −| q, ⊔, − s, 0, → | s, 1, → ⊲ s, ⊲, → comment g or q guess 0 or 1 the rest 9 Definition 5.8 The set accepted by a NTM, N: L(N) ≡ w ∈ U some run of N(w) halts with output “1” The time taken by N on w ∈L(N) is the number of steps in the shortest computation of N(w) that accepts. Unfortunately, this is a mathematical fiction. As far as we know, you can’t really build a nondeterministic Turing Machine. 10 0 0 0 0 0 0 0 0 0 1 0 t(n) s 0 2 0 0 0 0 0 0 0 0 0 0 t(n) 0 b1 b2 b3 ··· bt(n) 11 CS601 NTIME and NP Lecture 5 NTIME[t(n)] ≡ problems accepted by NTMs in time O(t(n)) ∞ O i NP ≡ NTIME[n (1)] ≡ [ NTIME[n ] i=1 Theorem 5.9 For any function t(n), DTIME[t(n)] ⊆ NTIME[t(n)] ⊆ DSPACE[t(n)] ⊆ DTIME[2O(t(n))] Corollary 5.10 L ⊆ P ⊆ NP ⊆ PSPACE Corollary 5.11 The definition of Recursive and r.e. are unchanged if we use nondeterministic instead of deterministic Turing machines. 12 NSPACE[s(n)] is the set of problems accepted by NTMs using at most O(s(n)) space on each branch. [Can run in time t(n) ≤ 2O(s(n)).] 0 0 0 0 0 0 0 0 0 1 0 t(n) s 0 2 0 0 0 0 0 0 0 0 0 0 t(n) 0 b1 b2 b3 b4 ··· bt(n) 13 ⋆ Definition 5.12 REACH = G s → t 3 8 2 11 7 s t 1 4 9 6 5 10 Prop: REACH ∈ NL = NSPACE[log n] 1. b := s 2. for c := 1 to n = |V | do { a 2 3. if b = t then accept 4. a := b 5. choose new b b 4 6. if (¬E(a, b)) then reject } accept! 7. reject 14 Def: Problem T is complete for complexity class C iff 1. T ∈ C, and 2. ∀A ∈ C (A ≤ T ) Reductions now must be in F (L). 15 co-r.e. complete Arithmetic Hierarchy FO(N) r.e. complete K K co-r.e. FO∀(N) r.e. FO∃(N) Recursive Primitive Recursive O EXPTIME SO(LFP) SO[2n (1) ] QSAT PSPACE complete O PSPACE FO[2n (1) ] FO(PFP) SO(TC) SO[nO(1)] co-NP complete PTIME Hierarchy SO NP complete SAT SAT co-NP SO∀ NP SO∃ NP ∩ co-NP FO[nO(1)] P complete Horn- P FO(LFP) SO(Horn) SAT FO[(log n)O(1)] “truly NC FO[log n] feasible” AC1 FO(CFL) sAC1 FO(TC) SO(Krom) 2SAT NL comp. NL FO(DTC) 2COLOR L comp. L FO(REGULAR) NC1 FO(COUNT) ThC0 FO LOGTIME Hierarchy AC0 16.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    16 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us