Introduction to Automata Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr 1 / 20
Automata Theory? Automata theory = the study of abstract computing machines (or models of computation) Computation is a sequence of steps that can be performed by a computer. 1930 s: Turing machines 1940 s and 50 s: Finite automata, formal grammars (Chomsky) 1960 s and 70 s: Extension of Turing s (Cook), decidability (what could and what could not computed) and intractability (P, NP-complete, NP-hard) 2 / 20
Finite Automata Finite automata are used as a model for Software for designing and checking the behavior of digital circuits Lexical analyzer of a compiler Searching for keywords in a file or on the web Software for verifying finite state systems, such as communication protocols. 3 / 20
Examples of Finite Automata psuh start off on push (a) start t h e n t th the (b) then Figure: (a) a finite automaton modeling an on/off switch; (b) a finite automaton modeling recognition of then. 4 / 20
Sets Definition A set is a collection of elements without any structure other than membership. Subset: A B, proper subset: A B. S = {0, 1, 2}, S = {i i > 0, i is even}. S 1 S 2 (union), S 1 S 2 (intersection), S 1 S 2 (difference), S (complementation). Disjoint: S 1 S 2 = φ (where φ denotes empty set). Power set of S, denoted by 2 S, is the set of all subsets of a set S. For example, given S = {a, b}, the power set is 2 S = {φ, {a}, {b}, {a, b}}. Note that 2 S = 2 S. Cartesian product: S = S 1 S 2 = {(x, y) x S 1, y S 2 }. 5 / 20
Functions Definition Let A and B be sets. A function, f from A to B is an assignment of exactly one element of B to each element of A. f : A B (f maps A to B), where A is domain of f, B is codomain of f, and the range of f is the set of all images of elements of A. A function f is said to be one-to-one (injective) iff f (x) = f (y) implies x = y for all x and y in the domain of f. A function f is said to be onto (surjective) iff for b B, there exists a A with f (a) = b. That is, the range of f is equal to B. A function f is a one-to-one correspondence (bijection) if it is both one-to-one and onto. 6 / 20
Graphs and Trees A graph, G(V, E) consists of two finite sets, V (a set of vertices) and E (a set of edges). Walk, trail, path, closed, cycle Tree: connected acyclic graph Probabilistic graphical model: Happy marriage between graph theory and probability theory 7 / 20
Walk, Trail, Path Walk: A sequence of edges (v 0, v j ), (v j, v k ),..., (v m, v n ) is said to be a walk from v 0 to v n. Trail: A walk in which all the edges are distinct. Path: A walk in which all the edges are distinct and the vertices are distinct (except v 0 = v n ). Closed: A path is closed if v 0 = v n. Cycle: A closed path containing at least one edge is a cycle. 8 / 20
Example A walk: v w x y z z y w A trail: v w x y z z x A path: v w x y z 9 / 20
Proof Techniques Deductive proof: Consists of a sequence of statements whose truth leads us from the hypothesis to a conclusion statement. Proof by induction Basis: Prove that P(1) is true. Induction step: For each i 1, assume that P(i) is true and use this assumption to show that P(i + 1) is true. Proof by contradiction: Assume that the theorem is false and then show that this assumption leads to an obviously false consequence (contradiction) 10 / 20
Example: Proof by Induction Theorem A binary tree is a tree in which no parent can have more than two children. Prove that a binary tree of height n has at most 2 n leaves. Proof. 11 / 20
Proof Denote by l(n) the maximum number of leaves of a binary tree of height n. Then we want to show that l(n) 2 n. Basis: One can easily see that l(0) = 1 = 2 0. IH: l(i) 2 i for i = 0, 1,..., n. To get a binary tree of height n + 1 from the one of height n, we can create at most two leaves in place of each previous one. Therefore l(n + 1) 2 l(n) = 2 n+1. 12 / 20
Example: Proof by Contradiction Theorem Show that 2 is irrational. Proof. 13 / 20
Proof Assume that 2 is a rational number, leading to 2 = n m, where n and m are integers without a common factor. Square both sides of this equation yields 2m 2 = n 2. n 2 must be even, so n = 2k. Then 2m 2 = 4k 2, i.e., m 2 = 2k 2, leading to m is even. But this contradicts our assumption that n and m have no common factors. Thus n and m can not exist and 2 is not a rational number. 14 / 20
Central Concepts of Automata Theory Alphabet: A finite nonempty set Σ of symbols. Σ = {0, 1}, the binary alphabet. Σ = {a, b,..., z}, the set of all lower-case letters. String: A finite sequence of symbols chosen from some alphabet Given Σ = {0, 1}, 0011 is a string from the binary alphabet and 101 is another string from this alphabet. Empty string: the string with zero occurrences of symbols, denoted by ɛ. Note that ɛ is a string that may be chosen from any alphabet whatsoever. Length of string: the number of positions for symbols in the string. For example, for w = 001, w = 3 (cardinality). Note that ɛ = 0. 15 / 20
Powers of an alphabet: Σ k = the set of strings of length k, each of whose symbols is in Σ. For example, given Σ = {0, 1}, Σ 1 = {0, 1}. Σ 2 = {00, 01, 10, 11}. Σ 0 = {ɛ}. How many string are there in Σ 3? Σ : the set of all strings over Σ. Σ + = Σ 1 Σ 2 Σ 3 Σ = Σ + {ɛ} = Σ 0 Σ 1 Σ 2 Concatenation: Let w = a 1 a 2 a n and v = b 1 b 2 b m, then wv = a 1 a 2 a n b 1 b 2 b m. Note that ɛw = wɛ = w. w n = } ww {{ w } and w 0 = ɛ. n 16 / 20
Languages Given an alphabet Σ, a language L is a set of strings all of which are chosen from Σ. In other words, L Σ, then L is a language over Σ. Examples of languages include: The set of legal English words. The set of legal C programs. The set of strings consisting of n 0 s followed by n 1 s for some n 0, i.e., {ɛ, 01, 0011, 000111,...}. The set of strings of 0 s and 1 s with an equal number of each: {ɛ, 01, 10, 0011, 0101,...}. 17 / 20
More Examples The set of binary numbers whose value is a prime: {10, 11, 101, 111, 1011,...}. Σ is a language for any alphabet Σ. The empty language φ is a language over any alphabet. {ɛ}, the language consisting of only the empty string, is also a language over any alphabet. Note that φ {ɛ}; the former has no strings and the latter has one string. 18 / 20
Problems If Σ is an alphabet and L is a language over Σ, then the problem is: Given a string w in Σ, decide whether or not w is in L. Let L p = {w w is a binary number that is prime}. Is 11101 L p? What computational resources are needed to answer the question? Usually we think of problems not as yes/no decision, but as something that transforms an input into an output. For instance, the task of the parser in a C compiler does more than decide. Nevertheless, the definition of problems as languages has stood the test of time as the appropriate way to deal with the important questions of complexity theory. 19 / 20
Structural Representations These are alternatively ways of specifying a machine. Grammars Regular expressions 20 / 20