Big-Oh notation and P vs NP Hao Chung This presentation is mainly adapted from the lecture note of Prof. Mark Zhandry July 17, 2017 Hao Chung (NTU) crypto July 17, 2017 1 / 21
Overview 1 Big-Oh notation 2 Probabilistic Polynomial-Time (PPT) 3 P vs NP Hao Chung (NTU) crypto July 17, 2017 2 / 21
Outline 1 Big-Oh notation 2 Probabilistic Polynomial-Time (PPT) 3 P vs NP Hao Chung (NTU) crypto July 17, 2017 3 / 21
How to Compare Algorithms Say we want to compute a function f (n) Algorithm 1 runs in 100, 000n seconds Algorithm 2 runs in n 2 seconds Which algorithm is better? Algorithm 2 runs faster if n < 100, 000 Algorithm 1 runs faster if n > 100, 000 The ratio of run times goes to infinity Hao Chung (NTU) crypto July 17, 2017 4 / 21
How to Compare Algorithms Say we want to compute a function g(n) Algorithm 1 runs in 20n seconds Algorithm 2 runs in 10n + 30 seconds Which algorithm is better? Algorithm 2 is faster than Algorithm 1 when n > 3 However, it is only twice as fast Hao Chung (NTU) crypto July 17, 2017 5 / 21
Big-Oh Definition Let f (n) and g(n) be functions from positive reals to positive reals. Then, O(f (n)) = {g(n) : c, n 0 such that g(n) c f (n) for all n > n 0 } In human language: g(n) O(f (n)) if 1 there exists a constant c and a threshold n 0 such that 2 g(n) c f (n) for all n larger than n 0 Remark: Sometimes we abuse the notation and write g(n) = O(f (n)); however, you should aware that O(f (n)) is a set. Hao Chung (NTU) crypto July 17, 2017 6 / 21
Big-Oh Examples Example Let f (n) = 10n + 30, g(n) = 20n. Prove f (n) O(g(n)) and prove g(n) O(f (n)). Proof: Let c = 1, n 0 = 3. = If n n 0, then f (n) = 10n + 30 20n = cg(n). Let c = 2, n 0 = 1. = If n n 0, then g(n) = 20n 2x(10n + 30) = cf (n). Hao Chung (NTU) crypto July 17, 2017 7 / 21
Big-Oh Examples Example Let f (n) = 100, 000n, g(n) = n 2. Prove f (n) O(g(n)). Hao Chung (NTU) crypto July 17, 2017 8 / 21
Big-Oh Examples Example Let f (n) = n 4 + 3n + 500. Prove f (n) O(n 4 ). Hao Chung (NTU) crypto July 17, 2017 9 / 21
Big-Oh Properties Big Oh allows us to ignore constant factors: For any constant c, c f (n) O(f (n)). For example, addition costs 1 iteration on CPU and division costs 32 iteration on CPU. But whether count division as an elementary operation doesn t affect the time complexity. Hao Chung (NTU) crypto July 17, 2017 10 / 21
Big-Oh Properties Big Oh allows us to ignore lower order terms: If f (n) O(g(n)), then g(n) + f (n) O(g(n)). e.g. O(n 4 + 3n 2 + 1) = O(n 4 ). If there are many parts in an algorithm, the most expensive part will dominate. Hao Chung (NTU) crypto July 17, 2017 11 / 21
Big-Omega Definition Let f (n) and g(n) be functions from positive reals to positive reals. Then, Ω(f (n)) = {g(n) : c, n 0 such that g(n) c f (n) for all n > n 0 } In human language: g(n) Ω(f (n)) if 1 there exists a constant c and a threshold n 0 such that 2 g(n) c f (n) for all n larger than n 0 Hao Chung (NTU) crypto July 17, 2017 12 / 21
Big-Theta Definition Let f (n) and g(n) be functions from positive reals to positive reals. Then, Θ(f (n)) = {g(n) : c 1 > 0, c 2, n 0 such that c 1 f (n) g(n) c 2 f (n) for all n > n 0 } In human language: g(n) Θ(f (n)) if 1 there exists two constants c 1, c 2 and a threshold n 0 such that 2 c 1 f (n) g(n) c 2 f (n) for all n larger than n 0 Hao Chung (NTU) crypto July 17, 2017 13 / 21
Big-Oh Examples Example Let f (n) = n 4 + 3n + 500. Prove f (n) Ω(n 3 log n). Prove f (n) = Θ(n 4 ). Example Prove log n O(n k ), k > 0. Example Prove n k O(n log n ), k > 0. Example Let f (n) = n log n and n1 δ, where δ (0, 1). Prove f (n) O(g(n)) or g(n) O(f (n)). Hao Chung (NTU) crypto July 17, 2017 14 / 21
Outline 1 Big-Oh notation 2 Probabilistic Polynomial-Time (PPT) 3 P vs NP Hao Chung (NTU) crypto July 17, 2017 15 / 21
Probabilistic Polynomial-Time (PPT) In cryptography, we usually define the power of adversary as a probabilistic polynomial-time (PPT) algorithm. An algorithm is polynomial-time if its running time is O(n k ) for some k. An algorithm is probabilistic (or randomized) if we allow the algorithm to toss a coin at each step. Example (Primality-Test) 1 randomly choose a {2,, N 1} 2 if a N 1 1, output N is composite 3 run step 1 and step 2 many times 4 if none of a N 1 1 in previous steps, output N is likely a prime Hao Chung (NTU) crypto July 17, 2017 16 / 21
Outline 1 Big-Oh notation 2 Probabilistic Polynomial-Time (PPT) 3 P vs NP Hao Chung (NTU) crypto July 17, 2017 17 / 21
P vs NP Definition P is a set of problems that can be solved in polynomial time. Definition NP is a set of problems that can be checked in polynomial time given a solution. Hao Chung (NTU) crypto July 17, 2017 18 / 21
Polynomial-Time Reduction Problem A is polynomial-time reducible to problem B if 1 given an oracle for B 2 A can be solved in polynomial-time We write A p B to denote that A is polynomial-time reducible to B. Hao Chung (NTU) crypto July 17, 2017 19 / 21
Factoring is Reducible to Order-Finding If we have then If r is even, we have a r 1 (mod N), N a r 1. N (a r/2 1)(a r/2 + 1). It cannot happen that N (a r/2 1), because this would mean that r was not the order of a. If N (a r/2 + 1), then gcd(n, a r/2 + 1) is a non-trivial factor for N. Theorem If a is chosen randomly from ZN, and r is the order of a, then Pr[r is even N (a r/2 + 1)] 1 2. Hao Chung (NTU) crypto July 17, 2017 20 / 21
Hao Chung (NTU) crypto July 17, 2017 21 / 21