Automata, Computability and Formal Languages Luc Longpré faculty.utep.edu/longpre 1 - Pg 1
Slides : version 3.1 version 1 A. Tapp version 2 P. McKenzie, L. Longpré version 2.1 D. Gehl version 2.2 M. Csűrös, A. Tapp version 3 P. McKenzie, L. Longpré version 3.1 L. Longpré 1 - Pg 2
1. Introduction and preliminaries : (mostly) Textbook, chapter 0. 2. Regular Languages : (Textbook chapter 1) 3. Context-free Languages : (Textbook chapter 2) 4. Turing machines : Textbook, chapter 3. (Fundamental compute power) 5. Undecidability (Ultimate limit to computing) and reductions : Textbook chapter 4 and 5. 6. Time complexity : P and NP (Textbook chapter 7) 1 - Pg 3
1.1 Review : proof techniques 1 - Pg 4
Technique : by contradiction If the negation of a statement implies a contradiction, then the statement is true. Theorem (Sipser 0.14) : 2 is irrational. Proof : 1 - Pg 5
Leading to a contradiction, suppose that a, b N such that 2 = a where GCD(a, b) = 1. b Clearly a 2 = 2 = a2 2b 2 = a 2 b b 2 so a = 2k (i.e. a 2 even implies a even). Also, 2b 2 = (2k) 2 2b 2 = 4k 2 b 2 = 2k 2 so b = 2l (i.e. b 2 even implies b even). But we now have that 2 divides a and b. Contradiction! (GCD(a, b) = 1) We conclude that 2 a, for all a, b N. b Q.E.D. 1 - Pg 6
Let P be a predicate, i.e. P is a function N {0} {true, false}. NB : the following are equivalent for us : P (197) = true P (197) is true or just P (197). 1 - Pg 7
Technique : mathematical induction If then P (n 0 ), P (n 0 + 1),..., P (n 0 + x) are all true and separately for each n > n 0 + x, [P (n 0 ),..., P (n 2), P (n 1)] imply P (n) true P (i) is true for all i n 0. 1 - Pg 8
Technique : If A B and B A then A = B. Proposition : A B = A B. Proof : 1 - Pg 9
A B A B : If x A B then x A B then x A and x B then x A and x B hence x A B. A B A B : If x A B then x A and x B and x A and x B so x A B hence x A B. Q.E.D. 1 - Pg 10
Technique : Pigeonhole Principle If we place n + 1 objects in n boxes, there will be at least one box with more than one object. 1 - Pg 11
Problem : Can we position 13 players on a field of size 12m 12m such that players are at a distance of more than 5m from each other? 1 - Pg 12
Leading to a contradiction, suppose 13 players are positioned. 12 12 = 144 squares 13 π2.5 2 = 255.26 occupied by 13 players 144 < 255.26... contradiction?! Yes but... (12 + 2.5 + 2.5)(12 + 2.5 + 2.5) = 289 289 > 255.26 We need to find something else! 1 - Pg 13
Divide the field in rectangles of 3m 4m. There are 12 such rectangles. Two players must be in the same rectangle (pigeonhole principle!). The diagonal of a rectangle is : 32 + 4 2 = 5 meters. So there must be two players at a distance of 5m or less! Q.E.D. 1 - Pg 14
Technique : diagonalisation intro Paradox, hairy version : A woman cuts the hair of precisely all women in her village that don t cut their own hair. Who cuts the hair of this woman? Paradox, internet version : Consider the set W of all web pages having a link toward themselves. Can we build a web page with a link to all web pages of W and at no other web pages? 1 - Pg 15
Diagonalisation Let R be a binary relation on A. Example : A = {a, b, c, d} R a b c d a x x b x x c x d x x 1 - Pg 16
a A, define Example : R a = {b b A and (a, b) R} R a b c d a x x b x x c x d x x R a = {b, d} R b = {b, c} R c = {c} R d = {a, b} Then ( a A) R a D = {b b A and (b, b) / R} The D in this example is {a, d}. 1 - Pg 17
Haircut theorem. There is no village where one of the woman from this village cuts the hair of exactly all women of this village that don t cut their own hair. Proof. Leading to a contradiction, suppose such a village exists. Let F be the set of women from this village. 1 - Pg 18
Let R F F be the relation (a, b) R iff a cuts the hair of b. Let f be the woman that cuts the hair of all women in the village that don t cut their own hair. So we have that R f (=by definition the set of women that get their hair cut by f) is {b b F and (b, b) / R}. This is a contradiction since R f would be the diagonal set D for this relation R. So such a village cannot exist. Q.E.D. 1 - Pg 19
1.2 Langages (Textbook, pages 13-14) 1 - Pg 20
Définition : An alphabet is a finite set of symbols. Ex : Σ 1 = {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z} Σ 2 = {a, b} Σ 3 = {0, 1} Σ 4 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Σ 5 = {,,, } Σ 6 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +,,, /, (, )} Σ 7 = ASCII = {Adenine, Cytosine, Guanine, Thymine} Σ ADN 1 - Pg 21
Definition : A string over an alphabet is a finite sequence of symbols from the alphabet. Definition : ε denotes the empty string. Definition : Σ is the set of all strings that over an alphabet Σ. Definition : Σ ε = Σ {ε}. Note : ε Σ. 1 - Pg 22
Examples : Σ 2 = {a, b} Σ 2 = {ε, a, b, aa, ab, ba, bb, aaa, aab, } Σ 3 = {0, 1} Σ 3 = {ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, } Σ 6 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +,,, /, (, )} Σ 6 (25 + 50) 56 Σ 6 (()25 + + + 6 1 - Pg 23
Definition : Let w = w 1 w 2... w k Σ then Ex : hello = 5 w = k. Definition : Let w = w 1 w 2... w k Σ and a Σ then w a = #{w i w i = a}. Ex : yabadabadoo a = 4 yabadabadoo b = 2 1 - Pg 24
Definition : Let x = x 1 x 2... x k Σ and y = y 1 y 2... y l Σ then is the concatenation of x and y. Note : w ε = w. Ex : x y = x 1 x 2... x k y 1 y 2... y l hel lo = hello hi ε = hi 1 - Pg 25
Definition : Let < Σ be a total order on alphabet Σ, The lexicographic order of strings over Σ is defined as follows : w < w w < Σ w w = w w = x a y w = x b z w < Σ w a < Σ b Ex : Σ = {0, 1} Σ = {ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111, 0000, 0001,...} 1 - Pg 26
Definition : Let L Σ, we say that L is a language on alphabet Σ. Definition : We write {} or for the empty language, i.e. the language that has no string in it. Note : ε. 1 - Pg 27
Ex : Various languages (Σ = {a, b}) L 1 = {a, abba, abbb, b} L 2 = {w w = 2k, k N} = {ε, aa, ab, ba, bb, aaaa, aaab, aaba, aabb,...} L 3 = {w w = aw, w Σ } = {a, aa, ab, aaa, aab, aba, abb, aaaa,...} L 4 = {w w a = w b } = {ε, ab, ba, aabb, abab, abba, baab, baba,...} L 5 = {w w a w b P rime} = {aaab,..., aabbabaaaaa,...} 1 - Pg 28
Ex : Various languages (Σ = ASCII) L 6 = {w PROG(w) returns true where PROG(w) is a java program with w for code} L 7 = {w w compiles without errors in C } L 8 = {w w is a C++ program that writes Hello world! } 1 - Pg 29
Definition : Union A B = {w w A or w B} Ex : Let Σ = {a, b} and L 1 = {ε, a, aa} and L 2 = {a, bb}. L 1 L2 = {ε, a, aa, bb} Definition : Intersection A B = {w w A and w B} Ex : L 1 L2 = {a} Ex : L 1 = 1 - Pg 30
Definition : Complement A = {w w A}. More precisely, let U be the universal set, then A = {w w U et w A}. Ex : Let Σ = {a, b} and L 1 = {ε, a, aa} L 1 = {b, ab, ba, bb, aaa, aab, aba, baa, bba,...} 1 - Pg 31
Definition : Cartesian Product A B = {(x, y) x A and y B} Ex : Let Σ = {a, b} and L 1 = {ε, a, aa} and L 2 = {a, bb}. L 1 L 2 = {(ε, a), (ε, bb), (a, a), (a, bb), (aa, a), (aa, bb)} Note : A B = A B. Note : A =. 1 - Pg 32
Definition : Power set P(A) = 2 A = {B B A} Ex : P(L 1 ) = {, {ε}, {a}, {aa}, {ε, a}, {ε, aa}, {a, aa}, {ε, a, aa}} Note : P(A) = 2 A. 1 - Pg 33
Définition : Concatenation Let L 1 and L 2 be two languages over alphabet Σ. Then L 1 L 2 = {x y x L 1 et y L 2 } the concatenation of languages L 1 et L 2. Ex : Let Σ = {a, b} and L 1 = {ε, a, aa} and L 2 = {a, bb}. L 1 L 2 = {a, bb, aa, abb, aaa, aabb} Note : A B A B. Note : A =. 1 - Pg 34
Definition : Kleene star Let L be a language on alphabet Σ then L = {w = x 1 x 2 x k k 0 and x i L } is the Kleene star closure of L. Ex : L 2 = {ε, a, bb, aa, abb, bba, bbbb, aaa, aabb,...} Note : = {ε} = {ε} for every other language L, L = 1 - Pg 35