1 / 7

Definition and Importance of P in Theory of Computation

P is the class of languages that are decidable in polynomial time on a deterministic TM. It is a mathematically robust class that is invariant across different models of computation. P corresponds to problems that are realistically solvable on a computer. This section also covers the RELPRIME problem and the time complexity of context-free languages.

idecker
Download Presentation

Definition and Importance of P in Theory of Computation

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. CSC 4170 Theory of Computation The class P Section 7.2

  2. 7.2.a The definition and importance of P Definition 7.12P is the class of languages that are decidable in polynomial time on a deterministic (single-tape) TM. In other words, P = TIME(n1)  TIME(n2)  TIME(n3)  TIME(n4) … Importance 1. P is invariant for all models of computation that are polynomially equivalent to the deterministic single-tape TM. Here polynomial equivalence means equivalence with only a polynomial difference in running time. Thus, P is a mathematically robust class, not affected by the particulars of the model of computation that we are using. 2. P roughly corresponds to the class of problems that are realistically solvable on a computer. Thus, P is relevant from a practical standpoint.

  3. 7.2.b 1. When we only care about polynomiality, algorithms can be described at high level without reference to features of a particular implementation model. Doing so avoids tedious details of tapes and head motions. 2. We describe algorithms with numbered stages. The notion of a stage is analogous to a step of a TM, though of course, implementing one stage will usually require many TM steps. Asymptotic analysis allows us to ignore this difference. 3. To show that an algorithm runs in polynomial time, it is sufficient to show that: a) There is a polynomial upper bound (usually in big-O notation) on the number of stages that the algorithm uses when it runs on an input of length n, and that b) Each stage takes a polynomial number of (actual TM) steps on a reasonable deterministic model. 4. The underlying (and usually non-specified) encoding of objects should be reasonable, and polynomially equivalent to other reasonable encodings. E.g., encoding 12 as 111111111111 is unreasonable as it is exponentially bigger than the binary (or decimal) encoding. 5. Among the reasonable encodings for graphs are encodings of their adjacency matrices. Since the size of such a matrix only polynomially differs from the number of nodes, it is OK if we show the polynomiality of an algorithm in the number of its nodes rather than in the size of its adjacency matrix. Analyzing polynomial-time algorithms

  4. 7.2.c The PATHproblem PATH = {<G,s,t> | G is a directed graph that has a directed path from s to t} M= “On input <G,s,t> where G is a directed graph and s,tare nodes of G: 1. Marks. 2. Repeat until no additional nodes are marked: 3. Scan all the edges of G. If an edge (a,b) is found going from a marked nodea to an unmarked node b, mark node b. 4. If t is marked, accept. Otherwise reject.” 2 3 1 4 5 8 s 7 6 t 9 12 10 11 14 15 13 16

  5. 7.2.d The RELPRIME problem Two numbers are said to be relatively prime iff 1 is the largest integer that evenly divides both of them. Are the following numbers relatively prime? 15 and 27 8 and 9 11 and 19 No, - both divisible by 3 Yes Yes: two different prime numbers are always relatively prime RELPRIME = {<x,y> | x and y are relatively prime} Is RELPRIME decidable? What is the time complexity of the brute force decision algorithm (TM)? But there is a smarter algorithm that runs in polynomial time. It is based on the Euclidean algorithm for finding the greatest common divisor.

  6. 7.2.e The Euclidean algorithm: E = “On input <x,y>, where x and y are natural numbers, x>y: 1. Repeat until y=0. 2. Assign x  x mod y. 3. Exchange x and y. 4. Output x.” A polynomial-time algorithm for the RELPRIME problem Testing on <33,15>: x = 3 y = 0 Output: 3 What is the time complexity of this algorithm? --- It can be shown to be polynomial because on every iteration of Step 1, the value of x is at most half of the previous value. Now, the following algorithm R solves RELPRIMEin polynomial time: R = “On input <x,y>, where x and y are natural numbers: 1. Swap x and y if necessary so that x>y. 2. Run E on <x,y>. 3. If the result is 1, accept. Otherwise reject.

  7. 7.2.f The time complexity of context-free languages Theorem 7.16 Every context-free language is a member of P. Specifically, is of complexity O(n3). Proof omitted (and will not be asked).

More Related