Top Banner

Click here to load reader

Theory of Computation CS3102 Spring njb2b/theory/Theory_lecture23_web.pdf Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic

Jan 05, 2020

ReportDownload

Documents

others

  • Nathan Brunelle

    Department of

    Computer Science

    University of Virginia

    www.cs.virginia.edu/~njb2b/theory

    Theory of Computation CS3102 – Spring 2014

    A tale of computers, math, problem solving, life, love and tragic death

  • Complexity Classes

    Def: DTIME(t(n))={L | L is decidable within

    time O(t(n)) by some deterministic TM}

    Def: NTIME(t(n))={L | L is decidable within

    time O(t(n)) by some non-deterministic TM}

    Def: DSPACE(s(n))={L | L decidable within

    space O(s(n)) by some deterministic TM}

    Def: NSPACE(s(n))={L | L decidable within

    space O(s(n)) by some non-deterministic TM}

  • Non-Robustness of TM Complexity • Computability: all variations on TMs have the same

    computing power – If there is a multi-tape TM that can decide L, there is a

    regular TM that can decide L. – If there is a nondeterministic TM that can decide L, there is a

    deterministic TM that can decide L.

    • Complexity: variations on TM can solve problems in different times – Is a multi-tape TM faster than a regular TM? – Is a nondeterministic TM faster than a regular TM?

  • Complexity Class P

    P = U k

    DTIME(nk)

    P is the class of languages that can be decided in Polynomial Time on a deterministic, single- tape Turing machine.

  • Classes in P

    a) TIME(n2)

    b) TIME(O(n7))

    c) TIME(O(2n))

    d) Class of languages that can be decided in Polynomial Time by a 2-tape TM

    e) Class of languages that can be decided in Polynomial Time by a nondeterministic TM

    Unknown! This is the P = NP question. Focus of this class…

    Yes! We can simulate each step of a 2- tape TM by making 2 passes over the whole tape ~ 2(n+t(n)) (See Theorem 7.8)

  • P Examples

    • What are some examples of problems in P?

    – Arithmetic

    – Matrix Multiplication

    – Matrix Inversion

    – Sorting

  • Non-deterministic polynomial time

    • Deterministic Polynomial Time: TM takes at most O(nc) steps to accept a string of length n

    • Non-deterministic Polynomial Time: The TM takes at most O(nc) steps on some path to accept a string of length n

  • Complexity Class NP

    NP = U k

    NTIME(nk)

    P is the class of languages that can be decided in Polynomial Time on a non-deterministic Turing Machine.

  • Alternative Definition • A language is in NP if some execution path answers in

    polynomial time

    • What if we had a “list of directions”?

    • Some information that told us which path accepted quickly

    • L is in NP if there is a “verifier” which given a string x in L and a polynomial length “witness” it can verify x is a member of L in polynomial time

    • NP = “easy to verify” problems

  • Neil Immerman

    Alternate Definition of NP Using Descriptive complexity

  • Argue why these are in NP • Sets of integers which sum to 0

    – Add them together, check if sum is 0

    • Sets of integers which have a subset with sum 0 – Given a “witness” w (a particular subset which sums to 0) we can:

    • Verify w is indeed a subset of the input • Verify that w sums to 0

    • Sets of integers which have a subset of size 3 which sums to 0 – Try all subsets of size 3, check if any sum to 0 – Called “3-Sum”

    • Primality testing: Given an integer, is it prime? – Given a “witness” (a pair of numbers) we can:

    • Verify the product of these numbers gives the input (just 1 multiplication) • Surprisingly, this can be solved in Polynomial time (AKS, 2002)

  • The Class P and the Class NP

    • P = { L | L is accepted by a deterministic Turing Machine in polynomial time }

    • NP = { L | L is accepted by a non-deterministic Turing Machine in polynomial time }

    • They are sets of languages

  • Most important CS Problem

    • Does P = NP?

    • Are all “easily verifiable problems” also “easily computable”?

    • How much more efficient are non- deterministic Turing Machines?

  • Progress • P = NP if every NP problem has a deterministic

    polynomial time algorithm • We could find an algorithm for every NP problem • Seems… hard…

    • Study an “archetypical” example

    – An NP problem which is in P iff P=NP – Called Complete

    • We need: At least one such problem

  • NP

    NP Hardness & Completeness Def: A problem L’ is NP-hard if:

    (1) Every L in NP reduces to L’ in polynomial time.

    Def: A problem L’ is NP-complete if:

    (1) L is NP-hard; and

    (2) L is in NP.

    If one NPC problem is in P P=NP

    P

    NP-Hard

  • NP Completeness Benefits 1. Saves time & effort of trying to solve intractable problems

    efficiently;

    2. Saves money by not separately working to efficiently solve different problems;

    3. Helps systematically build on & leverage the work (or lack of progress) of others;

    4. Transformations can be used to solve new problems by reducing them to known ones;

    5. Illuminates the structure & complexity of seemingly unrelated problems;

  • NP Completeness Benefits 6. Informs as to when we should use approximate solutions vs.

    exact ones;

    7. Helps understand the ubiquitous concept of parallelism (via non- determinism);

    8. Enabled vast, deep, and general studies of other “completeness” theories;

    9. Helps explain why verifying proofs seems to be easier than constructing them;

    10. Illuminates the fundamental nature of algorithms and computation;

  • NP Completeness Benefits 11. Gave rise to new and novel mathematical approaches, proofs,

    and analyses;

    12. Robustly decouples / abstracts complexity from underlying computational models;

    13. Gives disciplined techniques for identifying “hardest” problems / languages;

    14. Forged new unifications between computer science, mathematics, and logic;

    15. NP-Completeness is interesting and fun!

  • Our “Favorite” NP Complete Problem Satisfiability (SAT): Given a Boolean expression in conjuctive

    normal form, is there some assignment of T/F to its variables such that the expression resolves to “True”?

    Note: we may restrict each disjunction to have 3 variables (3-SAT)

    Examples:

    ¬𝑎 ∨ 𝑏 ∨ ¬𝑐 ∧ 𝑎 ∨ 𝑑 ∨ 𝑐 ∧ (𝑑 ∨ 𝑏 ∨ ¬𝑒)

    Satisfied if: 𝑎 = 𝐹, 𝑏 = 𝐹, 𝑐 = 𝑇, 𝑑 = 𝑇 𝑎 ∨ 𝑏 ∧ ¬𝑎 ∨ ¬𝑏 ∧ (¬𝑎 ∨ 𝑏) ∧ (𝑎 ∨ ¬𝑏) Can’t be Satisfied!

  • Stephen Cook

    Leonid Levin

    The Cook/Levin Theorem Theorem [Cook/Levin, 1971]: SAT is NP-complete. Proof idea: given a non-deterministic polynomial time TM M and input w, construct a CNF formula that is satisfiable iff M accepts w.

    Create boolean variables:

    q[i,k]  at step i, M is in state k

    h[i,k]  at step i, M’s RW head scans tape cell k

    s[i,j,k]  at step i, M’s tape cell j contains symbol Sk

    M halts in polynomial time p(n)

     total # of variables is polynomial in p(n)

    Qk

  • Stephen Cook

    Leonid Levin

    Add clauses to the formula to enforce necessary restrictions on how M operates / runs:

    • At each time i:

    M is in exactly 1 state

    r/w head scans exactly 1 cell

    All cells contain exactly 1 symbol

    • At time 0  M is in its initial state

    • At time P(n)  M is in a final state

    • Transitions from step i to i+1 all obey M's transition function

    Resulting formula is satisfiable iff M accepts w!

    Qk

    The Cook/Levin Theorem

  • “Guess and Verify” Approach Note: SAT  NP.

    Idea: Nondeterministically “guess” each Boolean variable value, and then verify the guessed solution.

     polynomial-time nondeterministic algorithm  NP

    This “guess & verify” approach is general.

    Idea: “Guessing” is usually trivially fast ( NP)

     NP can be characterized by the “verify” property:

    NP  set of problems for which proposed solutions can be quickly verified

    set of languages for which string membership can be quickly tested.

  • Historical Note The Cook/Levin theorem was independently proved by Stephen Cook

    and Leonid Levin

    • Denied tenure at Berkeley (1970) • Invented NP completeness (1971) • Won Turing Award (1982)

    • Student of Andrei Kolmogorov • Seminal paper obscured by Russian, style, and Cold War

  • An NP-Complete Encyclopedia Classic book: Garey & Johnson, 1979

    • Definitive guide to NP-completeness

    • Lists hundreds of NP-complete problems

    • Gives reduction types and refs

    Michael Garey David Johnson

  • NP-Completeness Proof Method

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.