# INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

## Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."— Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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. Definition: TIME(t(n)) = { L | L is a language decided by a O(t(n)) time Turing Machine }

P = TIME(n c )  c  N IMPORTANT COMPLEXITY CLASSES NP = NTIME(n c )  c  N 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.

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) HARDEST PROBLEMS IN NP 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. Theorem: A language B is NP-complete if:

SPACE COMPLEXITY

WHEN A COMPUTER IS USEFUL…

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

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

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.

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

3SAT  SPACE(n) (x  y  x) xy (x  y  x) # 00 xy (x  y  x) # 01

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)

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

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

Idea: Given two configurations c 1 and c 2 together with a number t, test whether N can get from c 1 to c 2 in t steps and space f(n) def can_yield(N,c 1, c 2, t, f): if t = 1: else: for c m ∈ { f-cell configurations }: if can_yield(c 1,c m,t/2,f) and can_yield(c m,c 2,t/2,f): return True else: return False if (c 1 = c 2 ) or (c 2 ∈ next_conf(N,c 1 )): return True else: return False

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,q 0 w,c accept, 2 df(n), f(n))

PSPACE = SPACE(n k )  k  N NPSPACE = NSPACE(n k )  k  N PSPACE = NPSPACE

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

PSPACE is frequently called the class of games because many popular games belong to PSPACE.

P  PSPACE? YES

NP  PSPACE? YES

PNPPSPACE

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) = 2 O(f(n)) EXPTIME = TIME(2 )  k  ℕ nknk PSPACE  EXPTIME

P  NP  PSPACE  EXPTIME P ≠ EXPTIME