FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 Read sections 7.1 – 7.3 of the book for next time.

Slides:



Advertisements
Similar presentations
Measuring Time Complexity
Advertisements

1 Nondeterministic Space is Closed Under Complement Presented by Jing Zhang and Yingbo Wang Theory of Computation II Professor: Geoffrey Smith.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
The class NP Section 7.3 Giorgi Japaridze Theory of Computability.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Umans Complexity Theory Lectures Lecture 2a: Reductions & Completeness.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
The diagonalization method The halting problem is undecidable Decidability.
Complexity 25-1 Complexity Andrei Bulatov #P-Completeness.
Measuring Time Complexity Sipser 7.1 (pages )
P and NP Sipser (pages ). CS 311 Fall Polynomial time P = ∪ k TIME(n k ) … P = ∪ k TIME(n k ) … TIME(n 3 ) TIME(n 2 ) TIME(n)
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Mount Holyoke College 2 The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Fall The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
Complexity ©D.Moshkovitz 1 Turing Machines. Complexity ©D.Moshkovitz 2 Motivation Our main goal in this course is to analyze problems and categorize them.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
NP-Completeness CS 51 Summer 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AA A A AAA.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 8+9 Time complexity 1 Jan Maluszynski, IDA, 2007
CS 310 – Fall 2006 Pacific University CS310 P vs NP the steel cage death match Section 7.2 November 29, 2006.
Time Complexity.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Fall 2004COMP 3351 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation.
February 20, 2015CS21 Lecture 191 CS21 Decidability and Tractability Lecture 19 February 20, 2015.
CS 310 – Fall 2006 Pacific University CS310 Complexity Section 7.1 November 27, 2006.
1 The Cook-Levin Theorem Zeph Grunschlag. 2 Announcements Last HW due Thursday Please give feedback about course at oracle.seas.columbia.edu/wces oracle.seas.columbia.edu/wces.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CS 461 – Nov. 21 Sections 7.1 – 7.2 Measuring complexity Dividing decidable languages into complexity classes. Algorithm complexity depends on what kind.
Definition: Let M be a deterministic Turing Machine that halts on all inputs. Space Complexity of M is the function f:N  N, where f(n) is the maximum.
חישוביות וסיבוכיות Computability and Complexity Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
CSCI 2670 Introduction to Theory of Computing December 1, 2004.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
Complexity 25-1 Complexity Andrei Bulatov Counting Problems.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
Measuring complexity Section 7.1 Giorgi Japaridze Theory of Computability.
P Vs NP Turing Machine. Definitions - Turing Machine Turing Machine M has a tape of squares Each Square is capable of storing a symbol from set Γ (including.
NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability.
NP-completeness Class of hard problems. Jaruloj ChongstitvatanaNP-complete Problems2 Outline  Introduction  Problems and Languages Turing machines and.
CSE 6311 – Spring 2009 ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS Lecture Notes – Feb. 3, 2009 Instructor: Dr. Gautam Das notes by Walter Wilson.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation.
NP-complete Languages
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
Theory of Computational Complexity Yuji Ishikawa Avis lab. M1.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
 2005 SDU Lecture15 P,NP,NP-complete.  2005 SDU 2 The PATH problem PATH = { | G is a directed graph that has a directed path from s to t} s t
Theory of Computational Complexity TA : Junichi Teruyama Iwama lab. D3
NP-Completeness A problem is NP-complete if: It is in NP
CSE 105 theory of computation
Time complexity Here we will consider elements of computational complexity theory – an investigation of the time (or other resources) required for solving.
CS154, Lecture 13: P vs NP.
Computational Complexity
Time Complexity We use a multitape Turing machine
CS154, Lecture 13: P vs NP.
CS154, Lecture 12: Time Complexity
CSC 4170 Theory of Computation Time complexity Section 7.1.
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Instructor: Aaron Roth
CSE 105 theory of computation
CSC 4170 Theory of Computation Time complexity Section 7.1.
Theory of Computability
Presentation transcript:

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time

TIME COMPLEXITY OF ALGORITHMS (Chapter 7 in the textbook)

COMPLEXITY THEORY Studies what can and can’t be computed under limited resources such as time, space, etc. Today: Time complexity

MEASURING TIME COMPLEXITY We measure time complexity by counting the elementary steps required for a machine to halt Consider the language A = { 0 k 1 k | k  0 } 1. Scan across the tape and reject if the string is not of the form 0 m 1 n 2. Repeat the following if both 0s and 1s remain on the tape: Scan across the tape, crossing off a single 0 and a single 1 3. If 0s remain after all 1s have been crossed off, or vice-versa, reject. Otherwise accept. 2k 2k 2 2k

The number of steps that an algorithm uses on a particular input may depend on several parameters. For instance, if the input is a graph, then the number of steps may depend on the number of nodes, the number of edges, et cetera. For simplicity, we compute the running time purely as a function of the length of the input string and don’t consider any other parameters.

Let M be a TM that halts on all inputs. Assume we compute the running time purely as a function of the length of the input string. Definition: The running time or time-complexity function of M is the function f : N  N such that f(n) is the maximum number of steps that M uses on any input of length n.

ASYMPTOTIC ANALYSIS 5n 3 + 2n n + 6= O(n 3 ) Big-O notation has been discussed in previous classes. We will briefly review it.

Let f and g be two functions f, g : N  R +. We say that f(n) = O(g(n)) if positive integers c and n 0 exist so that for every integer n  n 0 f(n)  c g(n) When f(n) = O(g(n)), we say that g(n) is an asymptotic upper bound for f(n) BIG- O 5n 3 + 2n n + 6= O(n 3 ) If c = 6 and n 0 = 10, then 5n 3 + 2n n + 6  cn 3

3 n log 2 n + 5 n log 2 log 2 n 2 n n n log 10 n 78 = O(n 4.1 ) = O(n log 2 n) = O(n log 10 n) log 10 n = log 2 n / log 2 10 O(n log 2 n) = O(n log 10 n) = O(n log n)

Definition: TIME(t(n)) is the set of languages decidable in O(t(n)) time by a Turing Machine. { 0 k 1 k | k  0 }  TIME(n 2 )

A = { 0 k 1 k | k  0 }  TIME(n log n) Cross off every other 0 and every other 1. If the # of 0s and 1s left on the tape is odd, reject x0x0x0x0x0x0xx1x1x1x1x1x1x xxx0xxx0xxx0xxxx1xxx1xxx1x xxxxxxx0xxxxxxxxxxxx1xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx

We can prove that a (single-tape) TM can’t decide A faster than O(n log n). A = { 0 k 1 k | k  0 }

Can A = { 0 k 1 k | k  0 } be decided in time O(n) with a two-tape TM? Scan all 0s and copy them to the second tape. Scan all 1s, crossing off a 0 from the second tape for each 1.

Different models of computation yield different running times for the same language!

Theorem. Let t(n) be a function such that t(n)  n. Then every t(n)-time multi-tape TM has an equivalent O(t(n) 2 ) single-tape TM.

P = TIME(n k )  k  N Polynomial Time

NON-DETERMINISTIC TURING MACHINES AND NP

0 → 0, R readwritemove  → , R q accept q reject 0 → 0, R  → , R 0 → 0, R DETERMINISTIC TMs NON-

NON-DETERMINISTIC TMs …are just like standard TMs, except: 1. The machine may proceed according to several possibilities. 2. The machine accepts a string if there exists a path from start configuration to an accepting configuration.

0 → , R  → , R q accept q reject 0 → x, R x → x, R  → , R x → x, R 0 → 0, L x → x, L x → x, R  → , L  → , R 0 → x, R 0 → 0, R  → , R x → x, R q0q0 q1q1 q2q2 q3q3 q4q4  → , R

Deterministic Computation Non-Deterministic Computation accept or rejectaccept reject

Definition: A Non-Deterministic TM is a 7-tuple T = (Q, Σ, Γ, , q 0, q accept, q reject ), where: Q is a finite set of states Γ is the tape alphabet, where   Γ and Σ  Γ q 0  Q is the start state Σ is the input alphabet, where   Σ  : Q  Γ → Pow(Q  Γ  {L,R}) q accept  Q is the accept state q reject  Q is the reject state, and q reject  q accept

Deterministic Computation Non-Deterministic Computation accept or rejectaccept reject

the set of languages decided by a O(t(n))-time non-deterministic Turing machine. Definition: NTIME(t(n)) is TIME(t(n))  NTIME(t(n))

BOOLEAN FORMULAS (  x  y)  z  = logical operations variables parentheses A satisfying assignment is a setting of the variables that makes the formula true. x = 1, y = 1, z = 1 is a satisfying assignment for 

BOOLEAN FORMULAS x = 0, y = 0, z = 1 is a satisfying assignment for:  (x  y)  (z   x)

Definition: SAT is the language consisting of all satisfiable boolean formulas. SAT = {  |  is a satisfiable boolean formula } A boolean formula is satisfiable if there exists a satisfying assignment for it.  (x  y)  x a  b  c   d YES NO

A literal is a variable or the negation of a var. Example: The variable x is a literal, and its negation,  x, is a literal. A clause is a disjunction (an OR) of literals. Example: (x  y   z) is a clause. Conjunctive Normal Form (CNF) A formula is in Conjunctive Normal Form (CNF) if it is a conjunction (an AND) of clauses. Example: (x   z)  (y  z) is in CNF. A CNF formula is a conjunction of disjunctions of literals.

Definition: A CNF formula is a 3CNF-formula iff each clause has exactly 3 literals. (x 1   x 2  x 3 )  (x 4  x 2  x 5 ) ...  (x 3   x 2   x 1 ) clauses A literal is a variable or the negation of a var. A clause is a disjunction (an OR) of literals. A formula is in Conjunctive Normal Form (CNF) if it is a conjunction (an AND) of clauses. A CNF formula is a conjunction of disjunctions of literals.

Definition: A CNF formula is a 3CNF-formula iff each clause has exactly 3 literals. (x 1   x 2  x 3 )  (x 4  x 2  x 5 ) ...  (x 3   x 2   x 1 ) clauses (x 1   x 2  x 1 ) (x 3  x 1 )  (x 3   x 2   x 1 ) (x 1  x 2  x 3 )  (  x 4  x 2  x 1 )  (x 3  x 1   x 1 ) (x 1   x 2  x 3 )  (x 3   x 2   x 1 ) YES NO 3SAT = {  |  is a satisfiable 3cnf-formula }

Theorem: 3SAT  NTIME(n 2 ) 3SAT = {  |  is a satisfiable 3cnf-formula } 1. Check if the formula is in 3cnf. On input  : 2. For each variable, non-deterministically substitute it with 0 or Test if the assignment satisfies . (x  y  x) (  y  )00 (  y  ) 11 (  )000(  )010

NP = NTIME(n k )  k  N Non-deterministic Polynomial Time

Theorem: L  NP if and only if there exists a poly-time Turing machine V with L = { x |  y. |y| = poly(|x|) and V(x,y) accepts }. Proof: (1) If L = { x |  y. |y| = poly(|x|) and V(x,y) accepts } then L  NP. Because we can guess y and then run V. (2) If L  NP then L = { x |  y. |y| = poly(|x|) and V(x,y) accepts } Let N be a non-deterministic poly-time TM that decides L. Define V(x,y) to accept if y is an accepting computation history of N on x.

3SAT = {  |  y such that y is a satisfying assignment to  and  is in 3cnf } SAT = {  |  y such that y is a satisfying assignment to  }

A language is in NP if and only if there exist polynomial-length certificates for membership to the language. SAT is in NP because a satisfying assignment is a polynomial-length certificate that a formula is satisfiable.

NP = The set of all the problems for which you can verify an alleged solution in polynomial time.

P = NP?

POLY-TIME REDUCIBILITY f : Σ*  Σ* is a polynomial-time computable function Language A is polynomial time reducible to language B, written A  P B, if there is a poly- time computable function f : Σ*  Σ* such that: w  A  f(w)  B f is called a polynomial-time reduction of A to B. if some poly-time Turing machine M, on every input w, halts with just f(w) on its tape.

AB f f

Theorem: If A  P B and B  P, then A  P. Proof: Let M B be a poly-time (deterministic) TM that decides B and let f be a poly-time reduction from A to B. We build a machine M A that decides A as follows: On input w: 1. Compute f(w) 2. Run M B on f(w)

Definition: A language B is NP-complete iff: 1. B  NP 2. Every language in NP is reducible to B in polynomial time.

P NP B If B is NP-Complete and B  P then NP = P. Why?

A 3cnf-formula is of the form: (x 1   x 2  x 3 )  (x 4  x 2  x 5 )  (x 3   x 2   x 1 ) clauses SAT = {  |  is a satisfiable boolean formula } 3-SAT = {  |  is a satisfiable 3cnf-formula }

SAT, 3-SAT  NP SAT = {  |  is a satisfiable boolean formula } 3-SAT = {  |  is a satisfiable 3cnf-formula }

Theorem (Cook-Levin): SAT is NP-complete. Proof Outline: (1) SAT  NP (2) Every language A in NP is polynomial time reducible to SAT We build a poly-time reduction from A to SAT Let N be a non-deterministic TM that decides A in time n k How do we know N exists? The reduction turns a string w into a 3-cnf formula  such that w  A iff   3-SAT.  will simulate the NP machine N for A on w.

So proof will also show: 3-SAT is NP-Complete P NP 3-SAT

f turns a string w into a 3-cnf formula  such that w  A    3-SAT.  will simulate an NP machine N on w, where A = L(N)