1 / 30

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

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

phuong
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. 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 }

  3.  P = TIME(nc) NP = NTIME(nc) c  N c  N IMPORTANTCOMPLEXITY CLASSES Problems where it is easy to find the answer. Problems where it’s easy to check the answer. If P = NP then generation is as easy as recognition.

  4. HARDEST PROBLEMS IN NP Theorem: A language B is NP-complete if: 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) 2. A is NP-complete and A ·P B If B is NP-Complete and P  NP, then There is no fast algorithm for B.

  5. c e e b b b b a a a a d d d d c c 3-COLORING

  6. 3SAT P 3COLOR We transform a 3-cnf formula  into a graph G so   3SAT  G  3COLOR The transformation can be done in time polynomial in the length of 

  7. x1 x1 ? T F x2 x2 (x1⋁ x2⋁x2)

  8. ? T F (x1⋁ x2⋁x2) x1 x1 x2 x2 c13 c11 c12 c16 c14 c15

  9. ? T F (x1⋁x2⋁ x2) ∧(x2 ⋁ ¬x1 ⋁ ¬x1) x1 x1 x2 x2 c13 c13 c11 c12 c11 c12 c16 c14 c16 c15 c14 c15

  10. ? T F (x1⋁x2⋁ x2) ∧(x2 ⋁ ¬x1 ⋁ ¬x1) x1 x1 x2 x2 c13 c13 c11 c12 c11 c12 c16 c14 c16 c15 c14 c15

  11. SPACE COMPLEXITY

  12. WHEN A COMPUTER IS USEFUL…

  13. ENCODING CHESS A 8£8 chess board has 64 squares and 32 pieces: Each square can have one of 13 values: 4 bits +1 bit encodes turn information. CHESS = { 〈B〉 | B is a chess board and white canforce a win. }

  14. HOW MUCH DISK DOES HARRY NEED? ≤376 How many moves at any level? W ≤9Q + 1K + 2B + 2R + 2N = 376 ≤1051 How many levels? D ≤(64)32⨉2 = 2193 ≈ 1051 1052 So, at most, WD≤ 10 positions By remembering whether each board B ∈CHESS, we can explore “only” D ≈1051 positions. HOW MUCH SPACE?

  15. Definition: Let M be a deterministic TM that halts on all inputs. The space complexity of M is the function ƒ: N  N, where ƒ(n) is the rightmost tape position that M reaches on any input of length n. Definition: Let M be a non-deterministic TM that halts on all inputs. The space complexity of M is the function ƒ: N  N, where ƒ(n) is the rightmost tape position that M reaches on any branch of its computation on any input of length n.

  16. { L | L is a language decided by a O(t(n)) space deterministic Turing Machine } Definition: SPACE(t(n)) = { L | L is a language decided by a O(t(n)) space non-deterministic Turing Machine } Definition: NSPACE(t(n)) =

  17. ( x   y  x ) ( ( ( x x x       y y y    x x x ) ) ) x x y y # # 3SAT  SPACE(n) x y # 0 0 0 1

  18. ¬ALLNFA∈NSPACE(n) ALLNFA = { 〈N〉 | N is an NFA and L(N) = Σ* } can_reject_a_string(N): (Q,Σ,δ,Q0,F) = remove_epsilons(N) S = Q0 for i∈{1, … , 2n}: if S⋂F = Ø: return True nextBit= guess() S = s∈Sδ(s,nextBit) if S⋂F = Ø: return True else: return False ¬ALLNFAis NP-Hard, but probably not in NP!

  19. Assume a branch of a non-looping non-deterministic computation uses space k How many time steps can this branch have? k⨉|Q|⨉|Γ|k = 2O(k)

  20. SAVITCH’S THEOREM Theorem: For any function f where f(n)  n, NSPACE(f(n))  SPACE(f(n)2) Proof: Let N be a non-deterministic TM with space complexity f(n) Construct a deterministic machine M that simply tries each branch of N Since each branch of N uses space at most f(n), then M uses space at most f(n)

  21. We need to simulate a non-deterministic computation while saving as much space as possible

  22. Idea: Given two configurations c1 and c2 together with a number t, test whether N can get from c1 to c2 in t steps and space f(n) defcan_yield(N,c1, c2, t, f): if t = 1: if (c1 = c2) or (c2∈ next_conf(N,c1)): return True else: return False else: for cm∈ { f-cellconfigurations }: if can_yield(c1,cm,t/2,f) and can_yield(cm,c2,t/2,f): return True else: return False

  23. SAVITCH’S THEOREM Theorem: For any function f where f(n)  n NSPACE(f(n))  SPACE(f(n)2) Proof: Let N be a non-deterministic TM with space complexity f(n) We modify N so that when it accepts, it clears its tape and moves the head to the leftmost cell Construct a deterministic machine M that on input w, simply returns can_yield(N,q0w,caccept, 2df(n), f(n))

  24.  PSPACE = SPACE(nk) NPSPACE = NSPACE(nk) k  N k  N PSPACE = NPSPACE

  25. EXAMPLE Let OTHELLO = { 〈B〉 | B is an othello position with a winning move for the current player. } Prove that OTHELLO∈ PSPACE.

  26. P  PSPACE? YES

  27. NP  PSPACE? YES

  28. P NP PSPACE

  29. nk EXPTIME = TIME(2 ) k  ℕ Assume a deterministic Turing machine that halts on all inputs runs in space f(n) Question: At most how many time steps can this machine run for? f(n)⨉|Q|⨉|Γ|f(n) = 2O(f(n)) PSPACE  EXPTIME

  30. P  NP  PSPACE  EXPTIME P ≠ EXPTIME

More Related