Tests : 4/18, 6/13 Discrete Mathematics Feb. 2001 Wang, J. S. Department of Computer Science National Tsing Hua University Outline Graphs 1. Graphs and Planar Graphs 2. Tree and Cut-Sets 3. Analysis of Algorithms Functions and Counting 1. Binary Relations and Functions 2. Permutations, Combinations, and Discrete Probability 3. Discrete Numeric Functions and Generating Functions 4. Recurrence Relations and Algorithms Machines and Computation 1. Computability and Formal Languages 2. Finite State Machine Modern Algebra 1. Groups and Rings 2. Boolean Algebra 3. Group Codes Text Book: C. L. Liu, Elements of Discrete Mathematics, 2nd edition, McGraw-Hill, 1985. Related Courses Data Structures The Design and Analysis of Algorithms Graph Theory Automata Theory Formal Languages Probability Theory Information Theory VLSI Computer Added Design Discrete Math. VS. Related Courses Data Structures The Design of Algorithms Graph Theory Discovering the properties of problems Getting it done right Getting it done cheaply Getting it done methodically The Thread of Discrete Mathematics Numbers n Sets V Relations R Graphs G(V,E) Functions f: AB Algebraic Structures (A, ) 數學不僅是一種方法、一門藝術或一種語言, 還是一門有者豐富內容的知識體系。 其內容對自然科學家、社會科學家、哲學家、 邏輯學家和藝術家十分有用; 同時影響著政治家和神學家的學說:滿足人類探索宇宙 的好奇心和對美妙音樂的冥想;… 數學風格以簡潔和型式的完美為其目標, 但有時由於過份地拘泥於形式上的完美、簡潔和精確, 已至喪失了竭盡全力要達到的清晰。 「數學是一門知識體系,但是他卻不包含任何真理。」 與上述論點相反的觀點確認為: 數學是無可辯駁真理的匯集。 數學就像是信仰。 M. Kline, Mathematics in Western Culture, 1953. 埃及人、巴比倫人: 計數系統(數系)、代數學、簡單幾何學 商業、天文、曆法、航海、建築、氣象、… 類比、歸納法:經驗法則 阿梅斯 (Ahmes) 草書、托勒密(C. Ptolemy)、 丟番圖(Diophantus) 希臘人: 算數、三角、平面幾何學、立體幾何、天文學 無理數 抽象思維、數學抽象化 演譯法 歐基里得、畢達哥拉斯、柏拉圖、阿基里得 圓錐曲線 羅馬人、日耳曼人 文藝復興: Leonardo da Vinci, Copernicus, Galileo, Kepler, Pascal, Fermat, Euler, Newton, …….. 印度人、阿拉伯人: 零的概念、負數、… Numbers Natural numbers, fractions, zero, negative numbers, irrational numbers, imaginary numbers, random numbers Real numbers 5, 1/2, 0, -5, 2, , e, , , ~4.669 (Feigenbaus number), -1, … “Not notations but notions”, Gauss Algebraic numbers, transcendental numbers an xn + an-1 xn-1 + … + a1 x1 + a0 x0 = 0 an, an-1, …, a1, a0 are all integers. Transcendental numbers: e, , lim (1 n 1 1 ... log n) 2 n Principia Mathematica, Russell and Whitehead Countably infinite and uncountably infinite, Cantor 0 and C(1) Prove by contradiction If 2 " 2 Q" a , a, b b a2 = 2b2, then a is even, that is, a = 2c for some c. 4c2 = 2b2, b2 = 2c2, b is even, violates the assumption that a/b is of the reduced form. Fabonacci sequence, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …. Fabonacci recurrence, can be solved by generating function F0 = 0, F1 = 1, Fn =Fn-1 + Fn-2, Fn n > 1. 1 1 5 ( n ˆ n ), . 2 5 Chaos function, Xnext = X(1 – X), = 3. Fractal geometry, Mandelbrot Sets How do we specify the elements of a set? {Calculus, Discrete Math., Probability, …} {x|x is an even positive integer not larger than 10} , , , , R(P1P2…Pk)=(RP1) (RP2)… (RPk) Power set: ({a,b}) = {{}, {a}, {b}, {a,b}} Finite and infinite sets Uncountably infinite sets Diagonal argument Cantor’s Theorem: For any set S, S and (S) are not equivalent. Mathematical induction Principle of inclusion and exclusion Propositions Russell’s Paradox Russell, 1911 S = {x| x x} Whether S S? SSSS SSSS Self-contradiction Russell’s paradox : It is not always the case that we can precisely specify the elements of a set by specifying the properties of the elements in the set. x = 所有不是蘋果的東西所組成的集合 x 不是蘋果 所以成為自己集合的一個元素, x x. The barber paradox There is a barber in a small village. He will shave everybody who does not shave himself. If the barber shaves himself, then he should not shave himself (because he only shaves those who not shave themselves). If the barber does not shave himself, then he should shave himself (because he shaves all of those who do not shave themselves.) No such barber can exist. 鱷魚和小孩 鱷魚: 『我會吃掉妳的小孩嗎? 如果妳答對了,我就把寶寶 毫髮無傷的還給妳。』 母親: 『天啊! 你會把我的寶寶吃掉。』 鱷魚困境: 同時吃掉小孩,又把寶寶還給母親。 母親: 『你將把我的寶寶還給我。』 還回去,或是吃掉均可。 Don Quixote Paradox 奇怪的法律: 警衛會詢問每位旅客: 『你為什麼來此地參觀? 』 如果旅客說的是謊話,他就會被吊死。 一位聰明的旅客回答: 『我來這裡是為了被吊死! 』 不吊死那位旅客 不是真話 該被吊死 吊死那位旅客 真話 不該被吊死 Proof of Cantor’s Theorem Assume there is a mapping m : A (A). Example: (A) A a b c d e f g {b,c} {d} {a,b,c,d} {} A {a,c,f,g, …} {b,i,j, …} Define B, B = {x| x m(x)} e.g. B = {a, b, d, g, …} B (A) y yB Case 1: y B y m(y) = B contradiction Case 2: y B y m(y) = B contradiction Q. E. D. (0, 1) Is Not Countable Assume there is a mapping (0, 1) : . Example: 1 2 3 4 5 . n . (0, 1) x1 = .371652 x2 = .500000 x3 = .142678 x4 = .000819 x5 = .987676 … xn = .a1a2a3 … an … … Construct a number b, 0 < b < 1 b = .b1b2b3 … bn … e.g. x1(1) = 3 x2(2) = 0 x3(3) = 2 x4(4) = 8 b1 = 4 b2 = 1 b3 = 3 b4 = 7 diagonal argument b (0, 1) but b x1, x2, x3, … xn, … contradiction Q. E. D. Noncomputable: there are tasks no computer can perform. When we say a certain task is beyond the capability of all computers, how do we know that it is not due to our ineptness as a user of the computer? How do we know for sure that it is not due to the fact that our computer is not “powerful” enough for the task? The possibility of writing a program that will examine any student’s program together with the data it works on and report whether the program, working on the given data, will ever stop. 1. Program Q accepts program P as input. 2. If program P, when using program P as input data, will eventually stop, then program Q will enter an infinite loop. 3. If program P, when using program P as input data, will enter an infinite loop then program Q will stop. We can let program Q be the input to program Q 1. If program Q, when using program Q as input data, will eventually stop, then program Q will enter an infinite loop. (self-contradictory) 2. If program Q, when using program Q as input data, will enter an infinite loop, then program Q will stop. (self-contradictory) Halting problem: It is not possible to write a program that examines any given data set and determines whether the program will eventually stop. Incompleteness, Undecidability and Intractability Hilbert (1900) 23 problems for 20th Century The second problem We hear within us the perpetual call: There is the problem. Seek its solution. You can find it by pure reason, for in mathematics, there is no ignorabimus. Gödel (1931) Incompleteness Theorem If any system as “powerful” as arithmetic is consistent, then it cannot be complete – meaning that some true statements are unprovable in the system. Today we do not know whether arithmetic is consistent; all we can say is that if it is, then there are true things we cannot prove in it. Halting problem Heisenberg (1927) Uncertainty principle in Quantum mechanics We can find the exact position of a subatomic particle, or we can find its exact velocity, but we cannot do both together. Turing (1936) Turing machine Study the class of languages it defines; the class of integer functions it computes. Partial recursive functions countable number of functions Kleene (1936) Church (1936) Post (1936) 王浩 Cook (1971) Cook-Levin Theorem Satisfiability problem is NP-complete NP P? Computation Methods and Analysis Formal system: Getting it done methodically Proof: Getting it done right Analysis: Getting it done cheaply Inefficiency and Intractability You can not always get it done cheaply. Noncomputability and Undecidability Sometimes you can not get it done at all! Parallelism and Concurrency Getting it done by cooperating. Probabilistic algorithms Getting it done by tossing coins. Algorithms and Intelligence Are they better at it than us? Languages Ordered sets ordered pair, (a, b): the first object is a and the second object is b. ordered triple, ((a, b), c) or (a, b, c) : the first object is a and the second object is b, and the third one is c. Let A be a finite set which is the alphabet of the language. A language is a subset of the set A, where A is the set of all sequences of letters from set A. L1 = {a, aa, ab, ac, abc, cba} L2 = { } L1 = {aicbi| i > 0} Phrase structure grammars 1. A set of terminals T. 2. A set of nonterminals N. 3. A set of productions P. 4. Among all nonterminals in N, there is a special nonterminal that is referred to as the starting symbol. L = {aib2i| i > 0}: T = {a, b} and N = {S} S aSbb S abb Types of grammars and languages (Chomsky Hierarchy) Type 3(Regular): all productions in the grammar are of the forms Aa A aB, (right linear automata) or equivalently, of the form Aa A Ba Type 2(Context-free): every productions in the grammar is of the forms A or equivalently, as the Chomsky Normal form A BC Aa Example: T = {a, b} and N = {S, A, B} S aB S bA Aa A aS A bAA Bb B bS B aBB The sentences in the language are all strings of a’s and b’s in which the number of a’s equals the number of b’s. Type 1(Context-sensitive): for every production The length of is larger than or equal to the length of . A ab A aA aAb aBCb Type 0(Turing machine): no restriction Are there languages that are not type-0 languages? How about all the programming? Is each class of type-i languages nonempty?