computational complexity 1
play

Computational Complexity 1 Nabil Mustafa Graduate Algorithms Nabil - PowerPoint PPT Presentation

Computational Complexity 1 Nabil Mustafa Graduate Algorithms Nabil Mustafa Computational Complexity 1 An Example Problem Definition A formula f ( x 1 , . . . , x n ) is in conjunctive normal form (CNF) iff f = C 1 C 2 . . . C m


  1. Example: Satisfiability (Cont.) Construct: f ( a 1 , . . . , a 2 k − 1 ) = 1 iff � i a i ≥ k , a i ∈ { 0 , 1 } � � a i i ∈ I I ⊂ 2 A , | I | = k Key point : If more than half a i ’s are 1s then all subsets of size ( n / 2 ) + 1 will have at least one 1. Nabil Mustafa Computational Complexity 1

  2. Example: Satisfiability (Cont.) Construct: f ( a 1 , . . . , a 2 k − 1 ) = 1 iff � i a i ≥ k , a i ∈ { 0 , 1 } � � a i i ∈ I I ⊂ 2 A , | I | = k Key point : If more than half a i ’s are 1s then all subsets of size ( n / 2 ) + 1 will have at least one 1. Construct: p = ⇒ q Nabil Mustafa Computational Complexity 1

  3. Example: Satisfiability (Cont.) Construct: f ( a 1 , . . . , a 2 k − 1 ) = 1 iff � i a i ≥ k , a i ∈ { 0 , 1 } � � a i i ∈ I I ⊂ 2 A , | I | = k Key point : If more than half a i ’s are 1s then all subsets of size ( n / 2 ) + 1 will have at least one 1. Construct: p = ⇒ q ( p ∨ q ) Nabil Mustafa Computational Complexity 1

  4. Satisfiability Satisfiability Given a CNF formula f , is f satisfiable? Nabil Mustafa Computational Complexity 1

  5. Satisfiability Satisfiability Given a CNF formula f , is f satisfiable? 2-Satisfiability Given a CNF formula f , where each clause has exactly 2 literals, is f satisfiable? Nabil Mustafa Computational Complexity 1

  6. Satisfiability Satisfiability Given a CNF formula f , is f satisfiable? 2-Satisfiability Given a CNF formula f , where each clause has exactly 2 literals, is f satisfiable? 3-Satisfiability Given a CNF formula f , where each clause has exactly 3 literals, is f satisfiable? Nabil Mustafa Computational Complexity 1

  7. Satisfiability Satisfiability Given a CNF formula f , is f satisfiable? 2-Satisfiability Given a CNF formula f , where each clause has exactly 2 literals, is f satisfiable? 3-Satisfiability Given a CNF formula f , where each clause has exactly 3 literals, is f satisfiable? f is in k -CNF form if each clause C i has at most k literals. Nabil Mustafa Computational Complexity 1

  8. Satisfiability Satisfiability Given a CNF formula f , is f satisfiable? 2-Satisfiability Given a CNF formula f , where each clause has exactly 2 literals, is f satisfiable? 3-Satisfiability Given a CNF formula f , where each clause has exactly 3 literals, is f satisfiable? f is in k -CNF form if each clause C i has at most k literals. k -Satisfiability Given a k -CNF formula f , is f satisfiable? Nabil Mustafa Computational Complexity 1

  9. Complexity class Different problems have different levels of hardness Nabil Mustafa Computational Complexity 1

  10. Complexity class Different problems have different levels of hardness Each problem can be viewed as computing a function Nabil Mustafa Computational Complexity 1

  11. Complexity class Different problems have different levels of hardness Each problem can be viewed as computing a function Definition A complexity class is a set of functions that can be computed within a given resource. Nabil Mustafa Computational Complexity 1

  12. Complexity class Different problems have different levels of hardness Each problem can be viewed as computing a function Definition A complexity class is a set of functions that can be computed within a given resource. A Turing Machine is a primitive computational device, a basic computer Nabil Mustafa Computational Complexity 1

  13. DTIME Definition DTIME ( T ( n )) : set of all functions computable in at most c · T ( n ) time for some constant c > 0, where n is input size. Nabil Mustafa Computational Complexity 1

  14. DTIME Definition DTIME ( T ( n )) : set of all functions computable in at most c · T ( n ) time for some constant c > 0, where n is input size. For example, DTIME ( n 2 ) is the set of all functions computable in at most O ( n 2 ) time. Nabil Mustafa Computational Complexity 1

  15. DTIME Definition DTIME ( T ( n )) : set of all functions computable in at most c · T ( n ) time for some constant c > 0, where n is input size. For example, DTIME ( n 2 ) is the set of all functions computable in at most O ( n 2 ) time. T 1 ( n ) = O ( T 2 ( n )) Nabil Mustafa Computational Complexity 1

  16. DTIME Definition DTIME ( T ( n )) : set of all functions computable in at most c · T ( n ) time for some constant c > 0, where n is input size. For example, DTIME ( n 2 ) is the set of all functions computable in at most O ( n 2 ) time. T 1 ( n ) = O ( T 2 ( n )) = ⇒ DTIME ( T 1 ( n )) ⊆ DTIME ( T 2 ( n )) Nabil Mustafa Computational Complexity 1

  17. DTIME Definition DTIME ( T ( n )) : set of all functions computable in at most c · T ( n ) time for some constant c > 0, where n is input size. For example, DTIME ( n 2 ) is the set of all functions computable in at most O ( n 2 ) time. T 1 ( n ) = O ( T 2 ( n )) = ⇒ DTIME ( T 1 ( n )) ⊆ DTIME ( T 2 ( n )) Definition � DTIME ( n c ) P = c ≥ 1 Nabil Mustafa Computational Complexity 1

  18. DTIME Definition DTIME ( T ( n )) : set of all functions computable in at most c · T ( n ) time for some constant c > 0, where n is input size. For example, DTIME ( n 2 ) is the set of all functions computable in at most O ( n 2 ) time. T 1 ( n ) = O ( T 2 ( n )) = ⇒ DTIME ( T 1 ( n )) ⊆ DTIME ( T 2 ( n )) Definition � DTIME ( n c ) P = c ≥ 1 The class P contains all classes DTIME ( T ( n )) where T ( n ) is a polynomial of finite degree. Nabil Mustafa Computational Complexity 1

  19. The class P The class P is considered the set of “efficiently” solvable problems Nabil Mustafa Computational Complexity 1

  20. The class P The class P is considered the set of “efficiently” solvable problems Sort: Given a set S of n integers, sort S . Nabil Mustafa Computational Complexity 1

  21. The class P The class P is considered the set of “efficiently” solvable problems Sort: Given a set S of n integers, sort S . Sorting n integers requires time Θ( n log n ) . Nabil Mustafa Computational Complexity 1

  22. The class P The class P is considered the set of “efficiently” solvable problems Sort: Given a set S of n integers, sort S . Sorting n integers requires time Θ( n log n ) . 1 , 000 , 000 numbers on modern hardware in less than 10 secs. Nabil Mustafa Computational Complexity 1

  23. The class P The class P is considered the set of “efficiently” solvable problems Sort: Given a set S of n integers, sort S . Sorting n integers requires time Θ( n log n ) . 1 , 000 , 000 numbers on modern hardware in less than 10 secs. P also includes functions computable in time High degree polynomials: O ( n 1000 ) . Nabil Mustafa Computational Complexity 1

  24. The class P The class P is considered the set of “efficiently” solvable problems Sort: Given a set S of n integers, sort S . Sorting n integers requires time Θ( n log n ) . 1 , 000 , 000 numbers on modern hardware in less than 10 secs. P also includes functions computable in time High degree polynomials: O ( n 1000 ) . High constants for small polynomials: 1 , 000 , 000 , 000 , 000 · n Nabil Mustafa Computational Complexity 1

  25. The class P The class P is considered the set of “efficiently” solvable problems Sort: Given a set S of n integers, sort S . Sorting n integers requires time Θ( n log n ) . 1 , 000 , 000 numbers on modern hardware in less than 10 secs. P also includes functions computable in time High degree polynomials: O ( n 1000 ) . High constants for small polynomials: 1 , 000 , 000 , 000 , 000 · n Being in P doesn’t guarantee it’ll work in practice. Nabil Mustafa Computational Complexity 1

  26. The class P The class P is considered the set of “efficiently” solvable problems Sort: Given a set S of n integers, sort S . Sorting n integers requires time Θ( n log n ) . 1 , 000 , 000 numbers on modern hardware in less than 10 secs. P also includes functions computable in time High degree polynomials: O ( n 1000 ) . High constants for small polynomials: 1 , 000 , 000 , 000 , 000 · n Being in P doesn’t guarantee it’ll work in practice. However, if a problem is not in P , forget about solving it. Nabil Mustafa Computational Complexity 1

  27. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Nabil Mustafa Computational Complexity 1

  28. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Function f can be computed in poly-time. Nabil Mustafa Computational Complexity 1

  29. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Function f can be computed in poly-time. What if don’t know how to compute f in poly-time? Nabil Mustafa Computational Complexity 1

  30. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Function f can be computed in poly-time. What if don’t know how to compute f in poly-time? 3-CNF satisfiability. Not known how to find an assignment. Nabil Mustafa Computational Complexity 1

  31. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Function f can be computed in poly-time. What if don’t know how to compute f in poly-time? 3-CNF satisfiability. Not known how to find an assignment. Instead, settle for languages with efficiently verifiable solutions. Nabil Mustafa Computational Complexity 1

  32. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Function f can be computed in poly-time. What if don’t know how to compute f in poly-time? 3-CNF satisfiability. Not known how to find an assignment. Instead, settle for languages with efficiently verifiable solutions. Define a new class NP : A function f is in NP if Nabil Mustafa Computational Complexity 1

  33. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Function f can be computed in poly-time. What if don’t know how to compute f in poly-time? 3-CNF satisfiability. Not known how to find an assignment. Instead, settle for languages with efficiently verifiable solutions. Define a new class NP : A function f is in NP if There exists a poly-sized solution of f – say u Nabil Mustafa Computational Complexity 1

  34. Checking solutions efficiently The class P : set of languages L f decidable in time O ( n c ) . Function f can be computed in poly-time. What if don’t know how to compute f in poly-time? 3-CNF satisfiability. Not known how to find an assignment. Instead, settle for languages with efficiently verifiable solutions. Define a new class NP : A function f is in NP if There exists a poly-sized solution of f – say u Verify in polynomial time that u is a correct solution for f Nabil Mustafa Computational Complexity 1

  35. Examples of problems in NP INDSET : Given a graph G and a integer k , decide if G has an independent set (I.S.) of size k . Nabil Mustafa Computational Complexity 1

  36. Examples of problems in NP INDSET : Given a graph G and a integer k , decide if G has an independent set (I.S.) of size k . Language L : set of all graphs with independent set of size k Nabil Mustafa Computational Complexity 1

  37. Examples of problems in NP INDSET : Given a graph G and a integer k , decide if G has an independent set (I.S.) of size k . Language L : set of all graphs with independent set of size k Input x : graph G and integer k Nabil Mustafa Computational Complexity 1

  38. Examples of problems in NP INDSET : Given a graph G and a integer k , decide if G has an independent set (I.S.) of size k . Language L : set of all graphs with independent set of size k Input x : graph G and integer k Certificate u : V ′ ⊆ V , | V ′ | = k , and V ′ is an I.S. Nabil Mustafa Computational Complexity 1

  39. Examples of problems in NP INDSET : Given a graph G and a integer k , decide if G has an independent set (I.S.) of size k . Language L : set of all graphs with independent set of size k Input x : graph G and integer k Certificate u : V ′ ⊆ V , | V ′ | = k , and V ′ is an I.S. p ( | x | ) : binary labels of k vertices, of total size k log n . Nabil Mustafa Computational Complexity 1

  40. Examples of problems in NP INDSET : Given a graph G and a integer k , decide if G has an independent set (I.S.) of size k . Language L : set of all graphs with independent set of size k Input x : graph G and integer k Certificate u : V ′ ⊆ V , | V ′ | = k , and V ′ is an I.S. p ( | x | ) : binary labels of k vertices, of total size k log n . M ( x , u ) : TM M which verifies in polynomial time if u = ⌊ V ′ ⌋ is an independent set of size k Nabil Mustafa Computational Complexity 1

  41. Some examples Claim: 3-CNF satisfiability is in NP Nabil Mustafa Computational Complexity 1

  42. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u Nabil Mustafa Computational Complexity 1

  43. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Nabil Mustafa Computational Complexity 1

  44. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Given f and u , can verify in O ( nm ) that u satisfies f Nabil Mustafa Computational Complexity 1

  45. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Given f and u , can verify in O ( nm ) that u satisfies f Claim: k -coloring is in NP Nabil Mustafa Computational Complexity 1

  46. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Given f and u , can verify in O ( nm ) that u satisfies f Claim: k -coloring is in NP If G is k -colorable ⇐ ⇒ ∃ a correct coloring c Nabil Mustafa Computational Complexity 1

  47. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Given f and u , can verify in O ( nm ) that u satisfies f Claim: k -coloring is in NP If G is k -colorable ⇐ ⇒ ∃ a correct coloring c The correct coloring c has polynomial size Nabil Mustafa Computational Complexity 1

  48. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Given f and u , can verify in O ( nm ) that u satisfies f Claim: k -coloring is in NP If G is k -colorable ⇐ ⇒ ∃ a correct coloring c The correct coloring c has polynomial size Given G and c , verify in O ( m ) time that c correctly colors G Nabil Mustafa Computational Complexity 1

  49. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Given f and u , can verify in O ( nm ) that u satisfies f Claim: k -coloring is in NP If G is k -colorable ⇐ ⇒ ∃ a correct coloring c The correct coloring c has polynomial size Given G and c , verify in O ( m ) time that c correctly colors G Subset sum: Given n integers A 1 , . . . , A n and integer T , does there exist a subset of numbers that sum up to T Nabil Mustafa Computational Complexity 1

  50. Some examples Claim: 3-CNF satisfiability is in NP If f is satisfiable ⇐ ⇒ ∃ a satisfying assignment u The satisfying assignment u has polynomial size. Given f and u , can verify in O ( nm ) that u satisfies f Claim: k -coloring is in NP If G is k -colorable ⇐ ⇒ ∃ a correct coloring c The correct coloring c has polynomial size Given G and c , verify in O ( m ) time that c correctly colors G Subset sum: Given n integers A 1 , . . . , A n and integer T , does there exist a subset of numbers that sum up to T Claim: Subset sum is in NP Nabil Mustafa Computational Complexity 1

  51. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. Nabil Mustafa Computational Complexity 1

  52. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. It would imply that if a small solution exists, then are always efficient algorithms to find it Nabil Mustafa Computational Complexity 1

  53. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. It would imply that if a small solution exists, then are always efficient algorithms to find it Everyone believes that P � = NP Nabil Mustafa Computational Complexity 1

  54. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. It would imply that if a small solution exists, then are always efficient algorithms to find it Everyone believes that P � = NP P = NP = ⇒ no cryptography Nabil Mustafa Computational Complexity 1

  55. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. It would imply that if a small solution exists, then are always efficient algorithms to find it Everyone believes that P � = NP P = NP = ⇒ no cryptography P = NP = ⇒ computers can do math proofs and so on Nabil Mustafa Computational Complexity 1

  56. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. It would imply that if a small solution exists, then are always efficient algorithms to find it Everyone believes that P � = NP P = NP = ⇒ no cryptography P = NP = ⇒ computers can do math proofs and so on P = NP = ⇒ computers can make the most beautiful music Nabil Mustafa Computational Complexity 1

  57. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. It would imply that if a small solution exists, then are always efficient algorithms to find it Everyone believes that P � = NP P = NP = ⇒ no cryptography P = NP = ⇒ computers can do math proofs and so on P = NP = ⇒ computers can make the most beautiful music After 40 years of continuous work, no result even close. Nabil Mustafa Computational Complexity 1

  58. P = NP ? Ultimate question The question of whether P = NP is the biggest open problem in computer science. It would imply that if a small solution exists, then are always efficient algorithms to find it Everyone believes that P � = NP P = NP = ⇒ no cryptography P = NP = ⇒ computers can do math proofs and so on P = NP = ⇒ computers can make the most beautiful music After 40 years of continuous work, no result even close. Resolving the question wins a prize of 1 million dollars. Nabil Mustafa Computational Complexity 1

  59. Reducibility Several different languages are in the class NP . Nabil Mustafa Computational Complexity 1

  60. Reducibility Several different languages are in the class NP . Question: Is there a fundamental language L that captures the essence of all the problems in NP ? Nabil Mustafa Computational Complexity 1

  61. Reducibility Several different languages are in the class NP . Question: Is there a fundamental language L that captures the essence of all the problems in NP ? If one could decide L , then one could solve any problem in NP Nabil Mustafa Computational Complexity 1

  62. Reducibility Several different languages are in the class NP . Question: Is there a fundamental language L that captures the essence of all the problems in NP ? If one could decide L , then one could solve any problem in NP Reductions Language A is polynomial-time reducible to language B if there exists a poly-time function f such that x ∈ A ⇐ ⇒ f ( x ) ∈ B We say A ≤ p B . Nabil Mustafa Computational Complexity 1

  63. Reducibility Several different languages are in the class NP . Question: Is there a fundamental language L that captures the essence of all the problems in NP ? If one could decide L , then one could solve any problem in NP Reductions Language A is polynomial-time reducible to language B if there exists a poly-time function f such that x ∈ A ⇐ ⇒ f ( x ) ∈ B We say A ≤ p B . A language B is NP-hard if A ≤ p B for every A ∈ NP Nabil Mustafa Computational Complexity 1

  64. Reducibility Several different languages are in the class NP . Question: Is there a fundamental language L that captures the essence of all the problems in NP ? If one could decide L , then one could solve any problem in NP Reductions Language A is polynomial-time reducible to language B if there exists a poly-time function f such that x ∈ A ⇐ ⇒ f ( x ) ∈ B We say A ≤ p B . A language B is NP-hard if A ≤ p B for every A ∈ NP A language B is NP-complete if B is NP-hard and B ∈ NP Nabil Mustafa Computational Complexity 1

  65. Properties of Reductions A ≤ p B Computing A can be reduced to computing B Nabil Mustafa Computational Complexity 1

  66. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Nabil Mustafa Computational Complexity 1

  67. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A Nabil Mustafa Computational Complexity 1

  68. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A To show C is ‘hard’ to compute efficiently: Nabil Mustafa Computational Complexity 1

  69. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A To show C is ‘hard’ to compute efficiently: If possible, reduce computing B to computing C Nabil Mustafa Computational Complexity 1

  70. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A To show C is ‘hard’ to compute efficiently: If possible, reduce computing B to computing C Then if computing C was easy, computing B would be easy Nabil Mustafa Computational Complexity 1

  71. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A To show C is ‘hard’ to compute efficiently: If possible, reduce computing B to computing C Then if computing C was easy, computing B would be easy But we know that computing B is hard. Nabil Mustafa Computational Complexity 1

  72. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A To show C is ‘hard’ to compute efficiently: If possible, reduce computing B to computing C Then if computing C was easy, computing B would be easy But we know that computing B is hard. Some properties of reductions: If A ≤ p B and B ≤ p C , then A ≤ p C Nabil Mustafa Computational Complexity 1

  73. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A To show C is ‘hard’ to compute efficiently: If possible, reduce computing B to computing C Then if computing C was easy, computing B would be easy But we know that computing B is hard. Some properties of reductions: If A ≤ p B and B ≤ p C , then A ≤ p C If A is NP-hard and A ∈ P then P = NP Nabil Mustafa Computational Complexity 1

  74. Properties of Reductions A ≤ p B Computing A can be reduced to computing B If we can compute B , we can compute A Therefore, B must be at least as hard as A To show C is ‘hard’ to compute efficiently: If possible, reduce computing B to computing C Then if computing C was easy, computing B would be easy But we know that computing B is hard. Some properties of reductions: If A ≤ p B and B ≤ p C , then A ≤ p C If A is NP-hard and A ∈ P then P = NP If A is NP-complete then A ∈ P if and only if P = NP Nabil Mustafa Computational Complexity 1

  75. Reduction Scheme A B Reduced in NP- Member of NP Poly-time to NP Hard If member If of NP member of P NP- P=NP Complete Nabil Mustafa Computational Complexity 1

  76. Finding hard problems To show L is NP-hard, required to show that every language in NP can be reduced to this language Nabil Mustafa Computational Complexity 1

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend