1 / 26

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. QUIZ 5. The language L ∈ TIME( t(n) ) if:. L can be decided by a TM in time O(t(n)). The language L ∈ NP if:. L can be decided by a NTM in time O( n c ). L has a polynomial time verifier. 3SAT is the language:.

zoltan
Download Presentation

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

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. CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS

  2. QUIZ 5 The language L ∈ TIME(t(n)) if: L can be decided by a TM in time O(t(n)) The language L ∈ NP if: L can be decided by a NTM in time O(nc) L has a polynomial time verifier 3SAT is the language: { ϕ | ϕ is a satisfiable 3cnf formula}

  3. QUIZ 5 Give a satisfying assignment to x1 = 0, x2 = 0 Asymptotic upper bounds for: = O(n2.1) (a) 4n2.1 + 2n log3 n = O(n3/2) (b) 4(log₂n)/3 + 8n(n/2)1/2

  4. TIMECOMPLEXITY Definition: Let M be a TM that halts on all inputs. The running time or time-complexity of M is the function f : N  N, where f(n) is the maximum number of steps that M uses on any input of length n. Definition: TIME(t(n)) = { L | L is a language decided by a O(t(n)) time Turing Machine }

  5.  P = TIME(nc) NP = NTIME(nc) c  N c  N IMPORTANTCOMPLEXITY CLASSES L ∈P iff there is an nc-time TM that decides L. L ∈NP iff there is an nc-time NTM that decides L iff there is an nc-time “verifier” for L Problems in P can be efficiently solved. Problems in NP can be efficiently verified.

  6. HARDEST PROBLEMS IN NP Definition: A language B is NP-complete if: 1. B  NP 2. Every A in NP is poly-time reducible to B (i.e. B is NP-hard) Theorem: if B is NP-Complete and B ∈ P, then NP=P. Corollary: if B is NP-Complete and P  NP, then there is no fast algorithm for B. Theorem: if A is NP-Hard and A ≤PB, then B is NP-Hard.

  7. HARDEST PROBLEMS IN NP NP P C B

  8. Theorem (Cook-Levin): 3SAT is NP-complete Proof: (1) 3SAT  NP (2) Every language A in NP is polynomial time reducible to 3SAT Our proof of (2) has three steps. • CIRCUIT-SAT is NP-Hard • CIRCUIT-SAT ≤P CNF-SAT • CNF-SAT ≤P 3SAT Corollary: 3SAT  P if and only if P = NP

  9. ∧ ∧ A CIRCUIT x1 … is a collection of (boolean) gatesand inputs connected by wires. x2 x0 ¬ … is satisfiable if some setting of inputs makes it output 1. ∧ … has arbitrary fan-in and fan-out CIRCUIT-SAT = { 〈C〉 |C is a satisfiable circuit }

  10. Given TM M and time bound t, we create a circuit that takes n input bits and runs up to t steps of M. The circuit will have t “rows”, where the ith row represents the configuration of M after i steps: a “tableau” t t

  11. q0 q0 qa q1 q0 qa q0 qa q1 q0 q1 qa q1     1 0 0 0 1 1 0 1 ∧ ∧ ⋁ Rows are made up of cells. Each cell has a “light” for every state and every tape symbol. Each light has a circuit that turns it on or off based on the previous row.

  12. q0 qa qa q1 q0 qa q1 qa q1 q0 q0 q1 qa q0 q1      0 1 0 0 1 0 1 1 0 1 ∧ ∧ ⋁ ∧ ⋁ ∧ ∧ ⋁ ∧ ∧ ∧ ⋁ ⋁ ∧ ∧ ⋁ ⋁ ∧ ∧ ⋁ ∧ ⋁ ∙ ∙ ∙ EXAMPLE 1→□, R 1→1, R 0→0, R q1 qa q0 □→□, L 0→□, R

  13. xn-1 … xn x1 x2 x3 qa qa qa qa qa qa q0 qa qa   ⋁ The lights in the first row are connected to the circuit inputs and the tape head is hardwired in: The circuit should output 1 iff M ends in qaccept.

  14. x2 x1 ∧ ⋁ ∧ ⋁ ⋁ CNF-SAT = {  |  is a satisfiable CNF formula } Theorem. CIRCUIT-SAT ≤PCNF-SAT. Proof. Given a circuit C, we will output a CNF formula  that is satisfiableiff C is. (x1∧x2) (x1⋁ x2) ((x1∧x2) ∧(x1⋁ x2)) ((x1∧x2) ⋁(x1⋁ x2)) ((x1 ∧ x2) ⋁(x1⋁ x2)) ⋁ ((x1∧ x2) ∧(x1 ⋁ x2))

  15. x2 x1 ∧ ⋁ ∧ ⋁ ⋁ For every gate in the circuit C, we introduce a new variable gi and force gi to satisfy the gate. g1→ (x1 ∧ x2) g1 = (x1 ∧ x2) (x1 ∧ x2) → g1 g2 → (x1 ⋁ x2) g2 = (x1 ⋁ x2) (x1 ⋁ x2) → g2 g3 → (g1 ∧ g2) g3 = (g1 ∧ g2) (g1 ∧ g2) →g3 g4 → (g1 ⋁ g2) g4 = (g1 ⋁ g2) (g1 ⋁ g2) →g4 g5 → (g3 ⋁ g4) g5 = (g3 ⋁ g4) (g3 ⋁ g4) →g5 g5

  16. g → (ℓ1 ⋁ ℓ2 …⋁ ℓn) ≡ (ℓ1 ∧ ℓ2 …∧ ℓn) → g ≡ g → (ℓ1 ∧ ℓ2 … ∧ ℓn) ≡ (ℓ1 ⋁ ℓ2 …⋁ ℓn) → g ≡ We can convert to CNF using the fact that (p → q) is equivalent to (¬p ⋁ q) so: (¬g ⋁ℓ1 ⋁ ℓ2 …⋁ ℓn) (¬ℓ1 ⋁ ¬ℓ2 …⋁ ¬ℓn ⋁ g) (¬g⋁ℓ1)∧(¬g⋁ ℓ2)… ∧(¬g⋁ ℓn) (¬ℓ1⋁ g)∧(¬ℓ2⋁g)… ∧(¬ℓn⋁g) The final output  is the CNF with all the clauses produced from gates in this way, plus the clause (gi), where gi corresponds to C’s output gate.

  17. If C has k inputs, m gates, n wires, how long is ? O(m+n+k) How long to compute ? O(m+n+k) Suppose an assignment to x1…xk and g1…gm satisfies . Then C outputs 1 on input x1…xk. Suppose C(x1…xk)=1. Then setting each gi to the value of the corresponding gate satisfies.

  18. Theorem. CNF-SAT ≤P3SAT. Proof. We show how to create an equivalent 3cnf for any cnf formula. cnf formula  is not in 3cnf iff there is a clause C with less than 3 literals or more than 3 literals. if C = (ℓi), replace C with (ℓi _ ℓi _ ℓi) if C = (ℓi _ ℓj), replace C with (ℓi _ ℓi _ ℓj)

  19. We can reduce the number of literals in any clause by one if we introduce a new variable and clause: (ℓ1 ⋁ ℓ2 …⋁ ℓn) ≡ (z ⋁ ℓ3 …⋁ ℓn) ∧ (z → (ℓ1⋁ ℓ2)) ≡ (z ⋁ ℓ3 …⋁ ℓn) ∧ (¬z ⋁ℓ1⋁ ℓ2)) if we satisfy the first clause by setting z=1, then to satisfy the second, we must set (ℓ1⋁ ℓ2)=1. Repeat until every clause has three literals.

  20. MORE SATISFIABILITY PROBLEMS Let NAESAT = {  |  is a 3cnf and ∃x. (x)=1 and each clause has ≥ 1 false literal} Theorem. NAESAT is NP-Complete. Let DSAT = {  |  is a cnf with ≥ 2 satisfying assignments} Theorem. DSAT is NP-Complete. Let 2-in-4-SAT = {  |  is a 4cnf and ∃x: each clause has exactly two true literals.} Theorem. 2-in-4-SAT is NP-Complete.

  21. SATISFYING CONSTRAINTS A 2csp is a list of constraints on pairs of variables Each constraint C(x,y) is a list of values for (x,y). An assignment satisfies a constraint if (x,y)∈C(x,y). An assignment satisfies a 2csp if it satisfies all constraints. e.g. Scheduling a project; seating at a wedding… 2CSP = { C | C is a satisfiable 2csp } Theorem. 2CSP is NP-Complete.

  22. Theorem. 2CSP is NP-Complete. Proof. 1. 2CSP ∈ NP. Given an assignment to the variables we can check that all constraints are satisfied in linear time. 2. 3SAT ≤P 2CSP. Idea: the main difference is that a 2csp constraint should have only two variables. Add variables to the 2csp that represent pairs of variables in the 3cnf, and constraints to enforce consistency with the 3cnf variables.

  23. Map 3cnf ϕ with n variables and m clauses to a 2csp Cϕ with 2n+m variables and 3m+n constraints: for each variable x ∈ϕ: add (vx,v¬x) ∈ {(0,1),(1,0)} for each clause (x∨y∨z) ∈ϕ: add vxy∈ {00,01,10,11} add (vxy,vz) ≠ (00,0) add (vxy,vx) ∈ {(00,0), (01,0), (10,1), (11,1)} add (vxy,vy) ∈ {(00,0), (01,1), (10,0), (11,1)} Claim. Cϕ∈ 2CSP ⇔ϕ∈ 3SAT: Proof. A satisfying assignment to ϕ can be mapped to a satisfying assignment to Cϕby assigning each vx = x and each vxy = 2vx+vy because… An assignment to Cϕ maps to an assignment to ϕ by setting each x = vx, because…

  24. 2SAT 2SAT = {  |  is in 2cnf and  is satisfiable} Theorem. 2SAT ∈ P! Idea: a 2SAT clause (x ∨ y) is equivalent to (¬x → y) and (¬y → x). If there is a chain (x → z1)∧(z1 → z2)∧…∧(zk → ¬x) and (¬x→y1)∧(y1→y2)∧…∧(yk→x) then: x ↔ ¬x e.g. (x∨x) ∧ (¬x∨y) ∧ (¬y∨¬x) If not, the formula is consistent, so satisfiable.

  25. (x₁∨x₂)∧(x₂∨x̅₃)∧(x̅₁∨x₃) x₁ x₂ x₃ ͞x₁ ͞x₂ ͞͞x₃ def is_satisfiable_2cnf(F): V = Ø, E = Ø, G = (V,E) for l ∈ literals(F): V = V∪{l, ¬l} for (x∨y) ∈ clauses(F): E = E∪{(¬x,y), (¬y,x)} for x ∈vars(F): if has_path(G,x,¬x) and has_path(G,¬x,x): return False return True

  26. We will use 3SAT to prove other problems are NP-Complete or NP-Hard. Examples include 3SAT ≤PDSAT, NAESAT, 2CSP… 3SAT ≤PCLIQUE 3SAT ≤P0/1-ILP 3SAT ≤PHAMPATH 3SAT ≤P3COLOR 3SAT≤PGRADUATION 3SAT ≤PVERTEX-COVER

More Related