COT5310: Formal Languages and Automata Theory

COT5310: Formal Languages and Automata Theory

COT5310: Formal Languages and Automata Theory Lecture Notes #3: Complexity Dr. Ferucio Laurent¸iu T¸iplea Visiting Professor School of Computer Science University of Central Florida Orlando, FL 32816 E-mail: [email protected] http://www.cs.ucf.edu/~tiplea Complexity 1. Time and space bounded computations 2. Central complexity classes 3. Reductions and completeness 4. Hierarchies of complexity classes UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 1 1. Time and space bounded computations 1.1. Orders of magnitude 1.2. Running time and work space of Turing machines UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 2 1.1. Orders of magnitude Let g : N R be a function. Define the following sets: → + (g) = f : N R+ ( c R )( n0 N)( n n0)(f(n) cg(n)) O { → | ∃ ∈ +∗ ∃ ∈ ∀ ≥ ≤ } Ω(g) = f : N R+ ( c R )( n0 N)( n n0)(cg(n) f(n)) { → | ∃ ∈ +∗ ∃ ∈ ∀ ≥ ≤ } Θ(g) = f : N R+ ( c1, c2 R )( n0 N)( n n0) { → | ∃ ∈ +∗ ∃ ∈ ∀ ≥ (c1g(n) f(n) c2g(n)) ≤ ≤ } o(g) = f : N R+ ( c R )( n0 N)( n n0)(f(n) cg(n)) { → | ∀ ∈ +∗ ∃ ∈ ∀ ≥ ≤ } Let f, g : N R and X , Ω, Θ,o . f is said to be X of → + ∈ {O } g, denoted f(n) = X(g(n)), if f X(g). ∈ (“big O”), Ω (“big Ω”), Θ (“big Θ”), and o (“little o”) O are order of magnitude symbols. UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 3 1.1. Orders of magnitude cg(n)2 cg(n) f(n) f(n) f(n) cg(n) cg(n)1 n n0 n0 0 O (g(n)) W(g(n)) q(g(n)) f(n) = (g(n)) • O – g(n) is an asymptotic upper bound for f(n) – f(n) is no more than g(n) – used to state the complexity of a worst case analysis; f(n) = Ω(g(n)) – similar interpretation; • f(n) = o(g(n)) – f(n) is less than g(n) (the difference • between and o is analogous to the difference between O and <). ≤ UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 4 1.1. Orders of magnitude Proposition 1 Let f,g,h,k : N R . Then: → + (1) f(n) = (f(n)); O (2) if f(n) = (g(n)) and g(n) = (h(n)), then f(n) = O O (h(n)); O (3) f(n) = (g(n)) iff g(n) = Ω(f(n)); O (4) f(n) = Θ(g(n)) iff f(n) = (g(n)) and f(n) = Ω(g(n)); O (5) if f(n) = (h(n)) and g(n) = (k(n)), then (f g)(n) = O O · (h(n)k(n)) and (f + g)(n) = (max h(n), k(n) ); O O { } (6) if there exists n0 N such that g(n) = 0 for any n n0, ∈ f(n) 6 ≥ then f(n) = o(g(n)) iff limn = 0. →∞ g(n) UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 5 1.1. Orders of magnitude Some useful inequalities: (Stirling’s formula) • n n 1 n n 1 √2πn e12n+1 n! √2πn e12n, e ≤ ≤ e for any n 1; ≥ for any real constants ǫ and c such that 0 < ǫ < 1 < c, • n 1 <lnlnn<lnn<e√(ln n)(lnlnn) <nǫ <nc <nlnn < cn <nn < cc (each inequality holds for all n n , where n is suitable ≥ 0 0 chosen). UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 6 1.1. Orders of magnitude Example 1 1. if f(x) = a + a x + + a xk is a polynomial of degree 0 1 · · · k k with real coefficients and f(x) 0 for any x N, then ≥ ∈ f(n) = Θ(nk); 2. logc n = Θ(log n), for any real constant c > 1; 3. log n = (nǫ), for any real number ǫ such that 0 < ǫ < 1; O 4. logk n = (n), for any natural number k 1; O ≥ 5. n! = Ω(2n) and n! = o(nn); 6. log(n!) = Θ(nlog n). UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 7 1.1. Orders of magnitude Example 2 If f : N R satisfies f(n) 1 for any n n → + ≥ ≥ 0 and some n N, then: 0 ∈ 1. 12 log2 f(n) f(n) 2 log2 f(n) , for any n n ; 2 ⌈ ⌉ ≤ ≤ ⌈ ⌉ ≥ 0 log f(n) 2. f(n) = Θ(2⌈ 2 ⌉). Remark 1 4n = (2n). 6 O UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 8 1.1. Orders of magnitude Let and be sets of functions as those defined above (e.g., A B (g) etc.), and let f : N R . Then, we denote O → + 1. f + = f + g g ; A { | ∈ A} 2. + = f + g f , g ; A B { | ∈A ∈ B} 3. f = f g g . If f is the constant c function, then A { · | ∈ A} we will write c instead of f ; A A 4. = fg f , g ; AB { | ∈A ∈ B} 5. ( ) = f (f). O A S ∈A O UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 9 1.1. Orders of magnitude Convention: = stands for . A B A⊆B Proposition 2 Let f, g : R R and c R . Then: + + ∈ + (1) (f(n)) + (g(n)) = (f(n) + g(n)); O O O (2) c (f(n)) = (f(n)); O O (3) ( (f(n))) = (f(n)); O O O (4) (f(n)) (g(n)) = (f(n)g(n)); O O O (5) (f(n)g(n)) = f(n) (g(n)). O O UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 10 1.2. Running time and workspace of TMs Notsemi-decidable Undecidable Semi-decidable butnotdecidable } Decidable Classifythemintocomplexityclasses } Decidable problems are classified into complexity classes ac- cording to the amount of work (time, space etc.) needed to solve them. UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 11 1.2. Running time and work space of TMs Let M be a deterministic TM (DTM) that halts on all inputs, and let w be an input. 1. The computation time of M on w is the number of steps required by M to halt on w (regardless of whether M accepts or not w); 2. The running time or time complexity of M is the function timeM given by: time (n) is the maximum computation time of M on • M inputs of length n, for any n 0. ≥ Assumption: time (n) n, for any n (M needs at least n M ≥ steps to read the entire input). UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 12 1.2. Running time and work space of TMs Let M be a non-deterministic TM (NTM) wherein all com- putations halt on all words, and let w be an input. 1. The computation time of M on w is the maximum number of steps required by M to halt on w (regardless of whether or not M accepts w); 2. The running time ot time complexity of M is the function timeM given by: time (n) is the maximum computation time of M on • M inputs of length n, for any n 0. ≥ Assumption: time (n) n, for any n. M ≥ UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 13 1.2. Running time and work space of TMs Allwordsoflengthn Allwordsoflengthn Discretetime 1 Discretetime 1 accept reject reject 2 2 reject reject 3 reject 3 accept reject accept ... ... f(n) reject f(n) accept DTM:computationthreads NTM:computationtrees Measuring deterministic and non-deterministic running time. UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 14 1.2. Running time and work space of TMs Let f : N N. We say that a language L is accepted by a → DTM (NTM) M within time f(n) if M accepts L and the running time of M is at most f(n) for every n. Remark 2 The above concepts can be generalized to multiple- tape TM (mTM) as well. UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 15 1.2. Running time and work space of TMs Theorem 1 (Reduction in the number of tapes) If L is accepted by an mDTN within time f(n) and f(n) n ≥ for any n, then L is accepted by a DTM within time (f 2(n)). O Proof Given an mDTN M, construct a DTM M′ as follows. M′ stores the contents of M’s tapes on its single tape and uses a new symbol # to separate them. In addition, M′ keeps track of the locations of M’s heads by marking the corresponding cells on its tape. To simulate a single move of M, M′ scans its tape from left to right, records the marked symbols, and then makes a pass from right to left in order to update the tapes according to M’s transition relation. UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 16 1.2. Running time and work space of TMs The total time to simulate one step of M is (f(n)). The O initial stage (where M′ puts its tape into the proper format) requires (n) steps. Afterward, M simulates each of the O ′ steps of M using (f(n))) steps. Therefore, the entire sim- O ulation uses (n) + (f 2(n)) steps. As f(n) n + 1, we O O ≥ conclude that M ’s running time is (f 2(n)). 2 ′ O UCF-SCS/COT5310/Fall 2005/F.L. Tiplea 17 1.2. Running time and work space of TMs Theorem 2 If L is accepted by an NTN within time f(n) and f(n) n for any n, then L is accepted by a DTM within (f≥(n)) time 2O . Proof Given an NTM M, construct a 3-tape DTM M′ which tries all possible branches of M’s non-deterministic compu- tation.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    103 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