Download presentation

Presentation is loading. Please wait.

Published byJerome French Modified over 5 years ago

1
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2
WHEN A COMPUTER IS USEFUL…

3
ENCODING CHESS A 88 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.

4
CHESS IS DECIDABLE can_white_force_win(board, b_list): if board ∈ b_list: return NO # black can force stalemate if checkmate(black, board): return YES if checkmate(white, board): return NO if turn(board) == white: win = NO else: win = YES for m ∈ legal_moves(board): win_move = can_white_force_win(move(board,m), b_list+[board]) if turn(board) == white: win = win or win_move else: win = win and win_move return win

5
HOW LONG TO SAVE THE DAY? 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. Can we do better?

6
DIVIDING BUGS A circuit is a collection of boolean gates and inputs connected by wires: ∧ ⋁ ¬ ⋁ x0x0 x1x1 x2x2 It is satisfiable if some setting of inputs makes it output 1. It can be encoded by listing for the inputs and operation of each gate. CIRCUIT-SAT = { 〈 C 〉 | C is a satisfiable circuit }

7
CIRCUIT-SAT IS DECIDABLE is_satisfiable(C): for each input value x ∈ {0 n, 0 n-1 1, … 1 n }: if circuit_value(C,x)==1: return True else: return False How long to check the Pentium division circuit? 2 64-bit inputs: at most 2 128 calls to circuit_value Around 10 42 steps. Can we do better?

8
STABLE MARRIAGES A High School has N boys and N girls. Each has a ranked list of dates for the 1951 Senior Prom. Albert BobCharlie Alice Betty Carol B,C,A A,C,B A,B,C B,A,CC,A,BC,B,A An unstable couple prefer each other to their current dates. STABLE = { 〈 B,G 〉 | There is a pairing with no unstable couple}

9
COMPLEXITY THEORY Studies what can and can’t be computed under limited resources such as time, space, etc Today: Time complexity

10
DECISION VS SEARCH Decision ProblemsSearch Problems Is there a winning move for white? Find a winning move for white Is there an input to satisfy the circuit? Find a satisfying input. Is there a stable pairing?Find a stable pairing.

11
MEASURING TIME COMPLEXITY We measure time complexity by counting the elementary steps required for a machine to halt Consider the language A = { 0 k 1 k | k 0 } 1. Scan across the tape and reject if the string is not of the form 0 m 1 n 2. Repeat the following if both 0s and 1s remain on the tape: Scan across the tape, crossing off a single 0 and a single 1 3. If 0s remain after all 1s have been crossed off, or vice-versa, reject. Otherwise accept. 2k 2k 2 2k

12
Definition: Let M be a TM that halts on all inputs. The running time or time-complexity of M is the function ƒ : ℕ ℕ, where ƒ(n) is the maximum number of steps that M uses on any input of length n.

13
ASYMPTOTIC ANALYSIS 5n 3 + 2n 2 + 22n + 6= O(n 3 )

14
Let f and g be two functions f, g : ℕ → ℝ +. We say that f(n) = O(g(n)) if positive integers c and n 0 exist so that for every integer n n 0 f(n) cg(n) When f(n) = O(g(n)), we say that g(n) is an asymptotic upper bound for f(n) BIG- O 5n 3 + 2n 2 + 22n + 6= O(n 3 ) If c = 6 and n 0 = 10, then 5n 3 + 2n 2 + 22n + 6 cn 3

15
3n log 2 n + 5n log 2 log 2 n 2n 4.1 + 200283n 4 + 2 n log 10 n 78 = O(n 4.1 ) = O(n log 2 n) = O(n log 10 n) log 10 n = log 2 n / log 2 10 O(n log 2 n) = O(n log 10 n) = O(n log n)

16
EXAMPLES Is f(n) = O(g(n)) or g(n) = O(f(n))? f(n)g(n) 4n 2 2n2n n log n n! n log log n (log n) log n

17
WHY USE BIG-O? Suppose there is a k-state TM for L that runs in time f(n). Then there is a O(k2 c )-state TM for L that runs in time f(n)/c: 1010110110101110 10 110110 1110

18
Definition: TIME(t(n)) = { L | L is a language decided by a O(t(n)) time Turing Machine } A = { 0 k 1 k | k 0 } TIME(n 2 ) CIRCUIT-SAT TIME(2 n )

19
A = { 0 k 1 k | k 0 } TIME(n log n) Cross off every other 0 and every other 1. If the # of 0s and 1s left on the tape is odd, reject 00000000000001111111111111 x0x0x0x0x0x0xx1x1x1x1x1x1x xxx0xxx0xxx0xxxx1xxx1xxx1x xxxxxxx0xxxxxxxxxxxx1xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx

20
We can prove that a TM cannot decide A in less time than O(n log n)

21
Can A = { 0 k 1 k | k 0 } be decided in time O(n) with a two-tape TM? Scan all 0s and copy them to the second tape. Scan all 1s, crossing off a 0 from the second tape for each 1.

22
Different models of computation yield different running times for the same language!

23
Theorem: Let t(n) be a function such that t(n) n. Then every t(n)-time multi-tape TM has an equivalent O(t(n) 2 ) single tape TM

24
SIMULATING MULTIPLE TAPES 1. “Format” tape. If a tape head goes off right end, insert blank. If tape head goes off left end, move back right. Scan left-to-right, finding current symbols Scan left-to-right, writing new symbols Scan left-to-right, moving each tape head: 2. For each move of the k-tape TM: L#100#□#□#R qiqi q i1 q i1□ q i1□□ q j101RSS L#100#0#□#R L#100#0#1#R ● q jRSS 100 ● ● ● qjqj

25
COUNTING STEPS 1. “Format” tape. If a head goes off right end, insert blank. If a head goes off left end, move back right. Scan left-to-right, finding current symbols Scan left-to-right, writing new symbols Scan left-to-right, moving each tape head: 2. For each move of the k-tape TM: O(n+k) steps Do t(n) times: 2t(n) steps 2kt(n) steps Total = t(n)((6+2k) t(n)) + O(n+k) = O(t 2 (n))

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google