# Chapter 2. Finite Automata. 2.1 The Basic Model

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Chapter 2 Finite Automata 2.1 The Basic Model Finite automata model very simple computational devices or processes. These devices have a constant amount of memory and process their input in an online manner. By that we mean that the input is read a character at a time, and for each character, as it is read, a constant amount of processing is performed. One might wonder whether such simple devices could be useful. In fact, they are widely used as controllers in mechanical devices such as elevators and automatic doors. Example. A controller for the doors on the exit hatchway of a spaceship. The rather simple spaceship in this example has an exit area with two doors: one leads out into space, the other leads into the spaceship interior, as shown in Figure 2.1. The critical rule is that at most one door may be open at any given time (for otherwise all the air in the spaceship could vent out into the vacuum of space). The state of the doors in managed by a space exit area spaceship interior controller, a simple device which we describe next. The controller can receive signals or requests to open or close a door. For simplicity, we suppose that only one request can be received at one Figure 2.1: Spaceship Exit Doors time. The diagram in Figure 2.2 specifies the operation of the controller. It is simply a directed graph with edge labels. The vertex names in this graph specify the door state to which the vertex corresponds. The edges exiting a vertex indicate the actions taken by the controller on receiving the request labeling the edge. So for example, if both doors are closed and a request to open the exit door is received, then the controller opens this door and the state changes accordingly. On the other hand, if currently the interior door is open and a request to open the exit door 23

2 24 CHAPTER 2. FINITE AUTOMATA open interior door open exit door exit door open close interior door close exit door Both doors closed close exit door open interior door open exit door open interior door close interior door close interior door interior door open close exit door open exit door Figure 2.2: Spaceship Door Controller is made, then nothing changes; i.e. the interior door remains open and the exit door remains closed. Note that there are many requests that result in no change. We can simplify the diagram so as to show only those requests that cause a change of state, as shown in Figure 2.3. Both doors closed open exit door close interior door close exit door open interior door exit door open interior door open Figure 2.3: Spaceship Door Controller, Sparse Diagram As requests are received the controller cycles through the appropriate states. To implement the device it suffices to have a 2-bit memory to record the current state (2 bits can distinguish 4 states) plus a little logic to decide what state change to make as requests are received. Comment. The same design of controller would be needed for the doors on a torpedo hatchway in a submarine. Many controllers need similarly modest amounts of memory and logic. They are more readily understood as simple devices, specified by means of a graph, rather than as general purpose computers.

3 2.1. THE BASIC MODEL 25 Similar devices are also very useful as a front end in many programs, where they are used to partition the input into meaningful tokens. For example, a compiler, which is a program that processes input programs so they can then be executed, needs to partition the input into keywords, variables, numbers, operators, comments, etc. For example, we could imagine recognizing the keywords if, then, else, end with the help of the following device or procedure, represented as a graph. The processing begins at the vertex start and follows the path labeled by the input characters as they are read. if there is no edge to follow, then the computation fails; it recognizes a keyword if it finishes at a vertex represented by a double circle. For example, on reading the input string if, the finite automata goes from the start vertex to the vertex labeled if. Note that it is conventional for the start vertex, which need not be named start, to be indicated in the graph by means of a double arrow. There are more details to handle in a compiler. In particular, the compiler has to be able start t e i h n l f e d if s n end e then else Figure 2.4: Keyword Recognizer to decide when it has reached the end of a keyword rather than being in the middle of a variable (e.g. ended) whose name begins with the keyword. But these essentially straightforward and tedious, albeit important, details are not the focus here. Variables are another collection of strings that compilers need to recognize. Let us suppose variables consist of all strings of (lower-case) letters other than keywords, and to simplify the illustration below let us suppose there is just one keyword: if. Then the following procedure, shown in Figure 2.5, will recognize variables. start a, b,, h, j,, z i variable named i f keyword if a, b,, e, g,, z a, b,, z all other variable names a, b,, z Figure 2.5: Variable Recognizer Notice that the graph has a self-loop; also, some of its edges have more than one label (alternatively, we could think of this as a collection of parallel edges, each with a distinct label). Again, to use the variable recognizer, the compiler follows the path spelled out by

4 26 CHAPTER 2. FINITE AUTOMATA the input. Any input other than the word if leads to a vertex represented as a double circle and hence represents a variable A Precise Specification We need to introduce a little notation and terminology. Recall that an alphabet is a set of characters. For example: ˆ Binary = {0,1} ˆ Boolean = {T,F} ˆ English = {a, b,, z} The usual way of writing an unspecified k-character alphabet is as Σ = {a 1, a 2,, a k }. By convention, a finite automaton is named M, or M 1, M 2, if there are several. As we shall see subsequently, other devices will also be named by M. A finite automaton is a directed graph plus a finite alphabet Σ in which: ˆ One vertex is designated as the start vertex. ˆ A subset of the vertices, conventionally called F, form the collection of Recognizing or Final vertices. ˆ Each edge is labeled by a character of Σ. ˆ Each vertex has Σ outgoing edges, one for each character in Σ. In the corresponding drawing of the automaton, the start vertex is indicated by a double arrow, and the vertices in F are indicated by drawing them with double circles. M processes an input string s as follows: it determines the end of the path, which begins at the start vertex and follows the labels spelled out by reading s. For example, in the Keyword Recognizer (see Figure 2.4), the input if specifies the path from the vertex start to the vertex named if. If the end of the path is a vertex in F then M recognizes or accepts s; otherwise M rejects s. Continuing the example, input if is recognized by the automaton as the vertex if is in F. Thus we can view M as partitioning the set of all possible strings into those it accepts and those it rejects. The set of strings accepted by M is often called the language accepted by M, and is sometimes written as L(M) or L for short. The topic we will study is what sorts of collections of strings finite automata can accept. Conventionally, the vertices of a finite automata are called its states and are written as Q = {q 1, q 2,, q r } rather than V = {v 1, v 2,, v r }. The index n tends to be reserved for the length of the input string. However, we will tend to use more descriptive names for the vertices in our examples.

5 2.1. THE BASIC MODEL 27 Replace a with a, b b Figure 2.6: Simplifying Figures of Finite Automata For simplicity in drawing we replace multiple parallel edges by a single edge with multiple labels as shown in Figure 2.6. Also, it is often convenient to omit a sink state (a non-final state which cannot be left); see Figure 2.7. Use: λ y y e ye s yes Instead of: λ y e s y ye yes a, b,, x, z a,, d, f,, z a, b,, r t,, z a, b,, z a, b,, z any other string Figure 2.7: Omitting the Sink State Note the descriptive names being used for the vertices. These names help explain for which strings the automata reaches which vertices. Finally, it s helpful to have a notation for representing labeled edges. We write δ(p, a) = q to mean that there is an edge labeled a from vertex p to vertex q; a more active interpretation is that starting at vertex (state) p, on reading a the automata goes to vertex (state) q. In other words the destination on reading a when at vertex p is vertex q. Conventionally δ is called the transition function. It is also useful to extend the destination (or transition) function to the reading of strings; this is denoted by δ. δ (p, s) = r means that vertex r is the destination on reading string s starting at vertex p. For example, in the Variable Recognizer (see Figure 2.5), δ (start, it) = all other variables. 1 Observe that δ (p, λ) = p: reading the empty string, i.e. reading no characters, leaves the state unchanged. 1 When a name or string includes spaces we will often put quote marks around it to avoid ambiguity.

6 28 CHAPTER 2. FINITE AUTOMATA Some Particular Languages ˆ L(M) = φ This is the empty language, the language with no strings in it. So the finite automata M accepts nothing. ˆ L(M) = {λ} This is the language comprising the single string λ. Note that φ {λ}; these two languages are distinct Examples of Automata M 1, shown in Figure 2.8, accepts the following strings: those strings with at least one a and an even number of b s following the last a. Figure 2.8: Example Automata M 1 M 2, shown in Figure 2.9, recognizes the set L(M 2 ) = {x x {a, b} and x ends with an a}. Figure 2.9: Example Automata M 2 M 3, shown in Figure 2.10, recognizes the complement of the language recognized by M 2.

8 30 CHAPTER 2. FINITE AUTOMATA Figure 2.11: Example Automata M 4 : L(M 4 ) = {x x 1 x 2 x x }. Note that λ L(M 4 ). x i=1 x i = 0 mod 3, where x = Figure 2.12: Example Automata M 5 : The Transition Function

9 2.1. THE BASIC MODEL 31 Figure 2.13: Automata recognizing strings with an odd number of b s Figure 2.14: Automata recognizing strings with at least one a Figure 2.15: Automata recognizing strings with at least two b s

10 32 CHAPTER 2. FINITE AUTOMATA Recognizing More Complex Sets We consider sets (languages) built up by means of the following three operations: union, concatenation, and star (defined below). These are called the Regular Operations. ˆ Union: A B = {w w A or w B}. ˆ Concatenation: A B = {uv u A and v B}. This is the set of strings comprising a string from A followed by a string from B. ˆ Star: A = {x 1 x 2 x k k 0 and x i A, for i = 1, 2,, k}. Note that setting k = 0 shows λ A. This is the set of strings consisting of the concatenation of zero or more strings from A. As we will see, if the sets A and B can be recognized by finite automata, then so can their union, concatenation, and the star of each set. Recognizing A B The approach is natural: we use a device M that comprises two finite automata: one, M A, that accepts A, and one, M B, that accepts B. The device M runs M A and M B in parallel (simultaneously) on its input and accepts the input exactly if at least one of M A and M B reaches a final state on this input. The only challenge is to show how to have M be a finite automata. To describe this we need some more notation. Let M A = (Q A, Σ, δ A, start A, F A ), M B = (Q B, Σ, δ B, start B, F B ), and M = (Q, Σ, δ, start, F ). The states of M are pairs, where each pair consists of a state of M A and a state of M B ; we call these pair-states for clarity. The purpose of the M A state in the pair-state is to simulate the computation of M A, and similarly that of the M B state is to simulate M B s computation. Formally, we define Q = Q A Q B : each pair-state of M is a 2-tuple, consisting of a state of M A and a state of M B (in that order). The idea is that: Assertion M will be in state q = (q A, q B ) on reading input w exactly if M A is in state q A and M B is in state q B after reading input w. The definitions of start, δ, and F are now immediate. ˆ The start pair-state of M is the pair consisting of the start states of M A and M B : start = (start A, start B ). ˆ An edge of M, labeled a say, connects pair state p = (p A, p B ) to pair-state q = (q A, q B ), exactly if p A is connected to q A by an a-labeled edge in M A and p B is connected to q B by an a-labeled edge in M B ; in other words, δ(p, a) = δ((p A, p B ), a) = (δ A (p A, a), δ B (p B, a)) = (q A, q B ) = q. ˆ The final pair-states of M are those pairs that include either a final state of M A or a final state of M B (or both): F = (F A Q B ) (Q A F B ). Lemma M recognizes the language A B, L(M) = A B for short.

11 2.1. THE BASIC MODEL 33 Proof. We need to do two things: 1. Show that if w is recognized by M, w L(M), then w A B, and 2. show that if w A B, then w L(M). The first substep is to verify Assertion But this is easy to see: consider the computation of M on input w, but only pay attention to what is happening to the first component of its pair-state: this is identical to the computation of M A on input w. Likewise, if we pay attention only to the second component of the pair state, we see that the computation is identical to that of M B on input w. In particular, M reaches pair-state q = (q A, q B ) on reading input w exactly if M A is in state q A and M B is in state q B after reading input w, which is what Assertion states. Next, we show (1). So suppose that M recognizes w, that is, on input w, M reaches a final pair-state, q = (q A, q B ) say. By Assertion 2.1.1, M reaches pair-state q = (q A, q B ) on input w exactly if M A reaches state q A on input w and M B reaches state q B. Now, by definition, q is a final pair-state of M exactly if q (F A Q B ) (Q A F B ). Consider the case that q = (q A, q B ) F A Q B ; then q A F A, that is M A reaches a final state on input w. Similarly, in the case that q = (q A, q B ) Q A F B, q B F B, that is M B reaches a final state on input w. This shows that if M recognizes input w, then either w A or w B (or possibly both); this means that w A B, which is the statement in (1) above. Finally, we show (2). If w A B, then either w A or w B (or possibly both). Consider the case that w A. Then w is recognized by M A. That is, on input w, M A reaches a final vertex (state), q A say, with q A F A. At the same time, M B, on input w, reaches some vertex q B Q B. By Assertion 2.1.1, M, on input w reaches the pair-state (q A, q B ) F A Q B. So M recognizes w since (q A, q B ) F = (F A Q B ) (Q A F B ). An essentially identical argument shows that if w B then M again recognizes w. In sum, if w A B, then M recognizes w, that is w L(M). Corollary Let A and B be languages recognized by finite automata. Then there is another finite automata recognizing the language A B. Recognizing A B Again, we suppose we have finite automata M A recognizing A and M B recognizing B. We then build a device M to recognize A B, or AB for short. w AB exactly if we can divide w into two parts, u and v, with u A and v B. This immediately suggests how M will try to use M A and M B. First it runs M A on substring u and then it runs M B on substring v. The requirements are that M A recognize u and M B recognize v; that is, on input u, M A goes from its start state to a final state, and on input v, M B also goes from its start state to a final state. The difficulty is for M to know when u ends, for there may be multiple possibilities. For example, consider the languages A = {strings of one or more a s} and B = {strings of one or more b s}. On the string aabb it would not be correct to swich from simulating M A to simulating M B after reading a single a, while it would be correct on the string abb. The solution is to keep track of all possibilities. We do not explore this further at

12 34 CHAPTER 2. FINITE AUTOMATA this point, as this is more readily understood using the technique of nondeterminism, which is the topic of the next subsection. Likewise, we defer the description of how to recognize A to the next subsection. 2.2 Nondeterministic Finite Automata Non-deterministic Finite Automata, NFAs for short, are a generalization of the machines we have already defined, which are often called Deterministic Finite Automata by contrast, or DFAs for short. The reason for the name will become clear later. As with a DFA, an NFA is simply a graph with edges labeled by single letters from the input alphabet Σ. There is one structural change. For each vertex v and each character a Σ, the number of edges exiting v labeled with a is unconstrained; it could be 0, 1, 2 or more edges. This obliges us to redefine what an automaton M is doing, given an input x. Quite simply, M on input x determines all the vertices that can be reached by paths starting at the start vertex, start, and labeled x. If any of these reachable vertices is in the set of Accepting or Final vertices then M is defined to accept x. Another way of looking at this is that M recognizes x exactly if there is some path (and possibly more than one) labeled x, going from start to a vertex (state) q F ; such a path is called a recognizing or accepting path. Example Let A = {w the third to last character in w is a b }. The machine M with L(M) = A is shown in Figure Note that on input abbb all four vertices can be reached, whereas on input abab the second from rightmost vertex cannot be reached. Figure 2.16: NFA recognizing {w the third to last character in w is a b}. As we will see later, the collection of languages recognized by NFAs is exactly the collection of languages recognized by DFAs. That is, for each NFA N there is a DFA M with L(M) = L(N). Thus NFAs do not provide additional computational power. However, they can be more compact and easier to understand, and as a result they are quite useful.

14 36 CHAPTER 2. FINITE AUTOMATA vertex start, on reading w, at least one destination vertex (state) is an accepting or final vertex (state). δ is often defined formally as follows: δ : 2 Q Σ 2 Q. In this context, 2 Q means the collection of all possible subsets of Q, the set of states of the NFA, and so δ does exactly what it should. Its inputs are (i) a set of vertices (states), that is one of the elements of the collection 2 Q, and (ii) a character in Σ; its output is also a set of vertices (states). Next, we add one more option to NFAs: edges labeled with the empty string, as shown in Figure We call these edges λ-edges for short. Figure 2.18: λ label on an edge. The meaning is that if vertex (state) p is reached, then vertex (state) q can also be reached without reading any more input. Again, the same languages as before are recognized by NFAs with λ-edges and by DFAs; however, the λ-edges are very convenient in creating understandable machines. The meanings of the destination functions δ and δ are unchanged. Example Let A and B be languages over the alphabet Σ that are recognized by NFAs M A and M B, respectively. Then the NFA shown in Figure 2.19 recognizes the language A B. Its first step, prior to reading any input, is to go to the start vertices for machines M A and M B. Then the computation in these two machines is performed simultaneously. The set of final vertices for M is the union of the final vertices for M A and M B ; thus M reaches a final vertex on input w exactly if at least one of M A or M B reaches a final vertex on input w. In other words L(M) = L(M A ) L(M B ). Deterministic vs. Nondeterministic Another way of viewing the computation of an NFA M on input x is that the task is to find a path labeled x from the start vertex to a final vertex if there is one, and this is done correctly by (inspired) guessing. This process of correct guessing is called Non-deterministic computation. Correspondingly, if there is no choice or uncertainty in the computation, it is said to be Deterministic. This is not an implementable view; it is just a convenient way to think about what nondeterminism achieves Closure Properties Definition A language is said to be regular if it can be recognized by an NFA. The regular languages obey three closure properties: if A and B are regular, then so are A B, A B and A. We have already seen a demonstration of the first of these. We now give a simpler demonstration of the first property and then show the other two. First, the following technical lemma is helpful.

15 2.2. NONDETERMINISTIC FINITE AUTOMATA 37 Figure 2.19: An NFA recognizing language A B Lemma Let M be an NFA. Then there is another NFA, N, which has just one final vertex, and which recognizes the same language as M: L(N) = L(M). Proof. The idea is very simple: N is a copy of M with one new vertex, new final, added; new final is N s only final vertex. λ-edges are added from the vertices that were final vertices in M to new final, as illustrated in Figure Recall that a recognizing path in an NFA goes from its start vertex to a final vertex. It is now easy to see that M and N recognize the same language. The argument has two parts. First, any recognizing path in M, for string w say, can be extended by a single λ-edge to reach N s final vertex, and thereby becomes a recognizing path in N; in addition, the edge addition leaves the path label unchanged (as wλ = w). It follows that if M recognizes string w then so does N. In other words, L(M) L(N). Second, removing the last edge from a recognizing path in N yields a recognizing path in M having the same path label (for the removed edge has label λ). It follows that if N recognizes string w then so does M. In other words, L(N) L(M). Together, these two parts yield that L(M) = L(N), as claimed. We are now ready to demonstrate the closure properties. If A and B are regular then so is A B We show this using the NFA M A B in Figure M A B is built using M A and M B, NFAs with single final vertices recognizing A and

16 38 CHAPTER 2. FINITE AUTOMATA Figure 2.20: NFA N with a single final vertex Figure 2.21: NFA M A B recognizing A B

17 2.2. NONDETERMINISTIC FINITE AUTOMATA 39 B, respectively. It has an additional start vertex start, connected to M A and M B s start vertices by λ-edges, and an additional final vertex final, to which M A and M B s final vertices are connected by λ-edges. As in the earlier construction, each recognizing path in M A B corresponds to a recognizing path in one of M A and M B, and vice-versa, and thus w L(M A B ) if and only if w A B. We now show this more formally. Lemma M A B recognizes A B. Proof. We show that A B = L(M A B ) by showing that L(M A B ) A B and that A B L(M A B ). To show that L(M A B ) A B, it is enough to show that if w L(M A B ) then w A B also. So let w L(M A B ) and let P be a recognizing path for w in M A B. Removing the first and last edges of P, which both have label λ, yields a recognizing path in one of M A or M B, also having label w. This shows that if w L(M A B ), then either w L(M A ) = A or w L(M B ) = B (of course, it might be in both, but this argument does not reveal this); in other words, if w L(M A B ) then w A B. To show that A B L(M A B ), it is enough to show that if w A B then w L(M A B ) also. Now, if w A B, then either w A or w B (or possibly both). Consider the case that w A. Then there is a recognizing path P A for w in M A. Preceding P A with the appropriate λ-edge from start and following it with the λ-edge to final, yields a recognizing path in M A B, also having label w. This shows that if w L(M A ) = A then w L(M A B ) also. Similarly, if w B then w L(M A B ) too. Together, this gives that if w A B then w L(M A B ). If A and B are regular then so is A B We show this using the NFA M AB displayed in Figure M AB is built using M A and M B, NFAs with single final vertices, recognizing Figure 2.22: NFA M AB recognizing A B A and B, respectively. M AB comprises a copy of M A plus a copy M B, plus one additional edge. M A s start vertex is also M AB s start vertex, and M B s final vertex is M AB s only final vertex. Finally, the new edge, e, joins M A s final vertex to M B s start vertex.

18 40 CHAPTER 2. FINITE AUTOMATA The idea of the construction is that a recognizing path in M AB corresponds to recognizing paths in M A and M B joined by edge e. It then follows that w L(M AB ) if and only if w is the concatenation of strings u and v, w = uv, with u A and v B. We now show this more formally. Lemma M AB recognizes A B. Proof. We show that L(M AB ) = A B by showing that L(M AB ) A B and that A B L(M AB ). To show that L(M AB ) A B, it is enough to show that if w L(M AB ) then w A B also. So let w L(M AB ) and let P be a recognizing path for w in M AB. Removing edge e from P creates two paths P A and P B, with P A being a recognizing path in M A and P B a recognizing path in M B. Let u and v be the path labels for P A and P B, respectively. So u A and v B. As e is a λ-edge, w = uλv = uv. This shows that w A B. To show that A B L(M AB ), it is enough to show that if u A and v B then uv L(M AB ). So let u A, v B, let P A be a recognizing path for u in M A, and let P B be a recognizing path for v in M B. Then form the path P = P A, e, P B in M AB ; clearly, this is a recognizing path. Further, it has label uλv = uv. So uv L(M AB ). If A is regular then so is A We show this using the NFA M A in Figure M A is Figure 2.23: NFA M A recognizing A built using M A, an NFA with a single final vertex recognizing A. M A comprises a copy of M A plus a new start vertex, plus two additional λ-edges, e and f. e joins M A s start vertex to M A s start vertex, and f joints M A s final vertex to M A s start vertex. M A s start vertex is also its final vertex. The construction is based on the observation that removing all copies of e and f from a recognizing path in M A yields subpaths, k of them say, each of which is a recognizing path in M A. It then follows that a string w is recognized by M A if and only if it is the concatenation of k strings recognized by M A, for some k 0. Now we show this more formally.

19 2.2. NONDETERMINISTIC FINITE AUTOMATA 41 Lemma M A recognizes A. Proof. We show that L(M A ) = A by showing that L(M A ) A and that A L(M A ). To show that L(M A ) A, it is enough to show that if w L(M A ) then w A also. So let w L(M A ) and let P be a recognizing path for w in M A. Removing all instances of edges e and f from P creates k subpaths, for some k 0, where each subpath is a recognizing path in M A. Let the path labels on these k subpaths be u 1,, u k, respectively. So u i A, for 1 i k. As e and f are λ-edges, w = λu 1 λλu 2 λλ λλu k λ = u 1 u 2 u k. Thus w A. To show that A L(M A ), it is enough to show that if w A then w L(M A ). If w A then w = u 1 u 2 u k, with u 1, u 2,, u k A, for some k 0. As u i A, there is an accepting path P i in M A for u i. Let P be the following path in M A : e, P 1, f, e, P 2, f,, e, P k, f (for k = 0 we intend the path of zero edges). P is a recognizing path in M A, and it has label u 1 u 2 u k = w, as e and f are λ-edges. Thus w L(M A ) Every regular language is recognized by a DFA Let N be an NFA. We show how to construct a DFA M with L(M) = L(N). Recall that to implement an NFA we keep track of the set of currently reachable vertices. This is what M will do with its vertices or states, which we call superstates henceforth. Each of M s superstates is a subset of the set Q of vertices or states in N. So M s collection (set) of superstates is the power set of Q, 2 Q. The relation between superstates of M and sets of vertices in N is specified by the following assertion. Assertion On input w, M reaches superstate R if and only if N can reach the set of states R. To achieve Assertion 2.2.8, we define the transition function δ for M to be identical to the transition function δ for N. Note that this specifies where M s edges go. To make sure the assertion is correct initially, that is for w = λ, we set M s start superstate to be the set of N s vertices that N can reach on input λ. Finally, we set the final superstates of M to be those superstates that include one or more of the final vertices of N: so if F is the set of N s final vertices, then R is a final superstate for M exactly if R F φ. Lemma L(M) = L(N). Proof. We begin by arguing by induction on the length of the input string read so far that Assertion is true. The base case is for the empty string: the claim is true by construction. For the inductive step, if the claim is true for strings of length k, then we argue that it is also true for strings of length k + 1. By the inductive hypothesis, on an input w of length k, R is the superstate reached by M if and only if R is the set of vertices

20 42 CHAPTER 2. FINITE AUTOMATA reachable by N. But then, on input wa, M reaches superstate δ(r, a), and N can reach the set of vertices δ(r, a), so the claim is true for strings of length k + 1 also. It remains to consider which strings the two machines recognize. M recognizes input w if and only if on input w it reaches superstate R where R F φ; and N recognizes input w if and only if it can reach a set of vertices S where S F φ. But we have shown that S = R. So the two machines recognize the same collection of strings, that is L(M) = L(N). Implementation Remark The advantage of an NFA is that it may have far fewer vertices (states) than a DFA recognizing the same language, and thus use much less memory to store them. On the other hand, when running the machines, the NFA may be less efficient, as the set of reachable vertices had to be computed as the input is read, whereas in the DFA one just needs to follow a single edge. Which choice is better depends on the particulars of the language and the implementation environment. 2.3 Non Regular Languages We turn now to a method for demonstrating that some languages are not regular. For example, as we shall see, L = {a n b n n 1} is not a regular language. Intuition suggests that to recognize L we would need to count the number of a s in the input string; in turn, this suggests that any automata recognizing L would need an unbounded number of vertices. But how do we turn this into a convincing argument? We use a proof by contradiction. So suppose for a contradiction that L were regular. Then there must be a DFA M that accepts L. M has some number k of vertices. Let s consider feeding M the input a k b k. Look at the sequence of k + 1 vertices M goes through on reading a k : r 0 = start, r 1, r 2,, r k, where some of the r i s may be a repeated instance of the same vertex. This is illustrated in Figure Figure 2.24: The vertices traversed on input a k. As there are only k distinct vertices, there is at least one vertex that is visited twice in this sequence, r i = r j, say, for some pair i,j, 0 i < j k. This is shown in Figure In fact we see that r j+1 = r h+1 if j + 1 k, r j+2 = r h+2 if j + 2 k, and so forth. But all we will need for our result is the presence of one loop in the path, so we will stick with the representation in the figure above. It is helpful to partition the input into four pieces: a i, a j i, a k j, b k. The first a i takes M from vertex r 0 to r i (to the start of the loop), the next a j i takes M from r i to r j (once

21 2.3. NON REGULAR LANGUAGES 43 Figure 2.25: The path traversed on input a k. around the loop), the final a k j takes M from r j to r k, and b k takes M from r k to a final vertex, as shown in figure What happens on input a i a j i a j i a k j b k = a k+j i b k? The Figure 2.26: The path traversed on input a k. initial a i takes M from r 0 to r i, the first a j i takes M from r i to r j = r i (once around the loop), the second a j i takes M from r i to r j (around the loop again), the a k j takes M from r j to r k, and the b k takes M from r k to a final vertex. So M accepts a k+j i b k, which is not in L as j i > 0. This is a contradiction, and thus the initial assumption, that L was regular, must be incorrect. We now formalize the above approach in the following lemma. Lemma (Pumping Lemma) Let L be a regular language. Then there is a number p = p L, the pumping length for L, with the property that for each string s in L of length at least p, s can be written as the concatenation of 3 substrings x, y, and z, that is s = xyz, and these substrings satisfy the following conditions. 1. y > 0, 2. xy p, 3. For each integer i 0, xy i z L.

22 44 CHAPTER 2. FINITE AUTOMATA Definition We say s can be pumped if s L can be written as the concatenation of substrings x, y and z, and conditions 1 3 of the Pumping Lemma hold. Proof. Again, we use a proof by contradiction. So suppose that L were regular and let M be a DFA accepting L. Now suppose that M has p states. p, the number of states in M, will be the pumping length for L. Let s be a string in L of length n p. Write s as s = s 1 s 2 s n, where each s i is a character in Σ, the alphabet for L. Consider the substring s = s 1 s 2 s p. We look at the path M follows on input s. It must go through p + 1 vertices, and as M has only p vertices, at least one vertex must be repeated. Let start = r 0, r 1,, r p be this sequence of vertices and suppose that r i = r j, where 0 i < j p, is a repeated vertex, as shown in Figure Let x denote s 1 s i, y denote s i+1 s j, and z denote s j+1 s p s p+1 s n. The path Figure 2.27: The path traversed on i nput s = s 1 s 2 s p. traversed on input s = xyz is illustrated in Figure As j > i, y = j i > 0. Also Figure 2.28: The path traversed on input s = xyz. xy = s 1 s j = j p. So (1) and (2) are true. Clearly, xz is recognized by M, for x takes M from r 0 to r i = r j and z takes M from r j to a final vertex. Similarly xy i z is recognized by M for any i 1, for x takes M from r 0 to r i, each repetition of y takes M from r i (back) to r j = r i, and then the z takes M from r j to a final vertex. Thus (3) is also true, proving the result.

24 46 CHAPTER 2. FINITE AUTOMATA In Example both pumping down (i = 0) and pumping up (i = 2) will yield a contradiction. This is not the case in every example. Sometimes only one direction works, and then only for the right choice of s. A common mistake. Not infrequently, an attempted solution may try to specify how s is partitioned into x, y, and z. In Example 2.3.3, this might take the form of stating that x = λ, y = a p, and z = b p, and then obtaining a contradiction for this partition. This is an incomplete argument, however. All that the Pumping Lemma states is that there is a partition; it does not tell you what the partition is. The argument showing a contradiction must work for every possible partition. Example Let K = {ww R w {a, b} }. For example, λ, abba, abaaba L, ab, a, aba / L. We show that K is not regular. Step 1. Suppose, so as to obtain a contradiction, that L were regular. Then L must have a pumping length p 1 such that for any string s L with s p, s can be pumped. Step 2. Choose s. We choose the string s = a p bba p. Step 3. By pumping s, obtain a contradiction. As s can be pumped (for s = 2p + 2 p), we can write s = xyz, with y > 0, xy p, and xy i z L for all integer i 0. As the first p characters of s are all a s, the substring xy must also be a string of all a s. By condition (3), with i = 0, we have that xz L; but the string xz has removed y a s from s, that is xz = a p y bba p, and this string is not in L since it is not in the form ww R for any w. (To see this, note that if it were in the form ww R, as xz contains two b s, one of them would be in the w and the other in the w R ; this forces w = a p y b and w R = ba p, and this is not possible as p y = p. This is a very detailed explanation, which we will not spell out to this extent in future. Noting that p y = p will suffice.) This is a contradiction for we have shown that xz L and xz / L. Step 4. Consequently the initial assumption is incorrect; that is, L cannot be recognized by a DFA, so L is not regular. Another common mistake. I have seen attempted solutions for the above example that set s = w p (w R ) p. This is not a legitimate definition of s. For w is an arbitrary string, so such a definition does not fully specify the string s, that is it does not spell out the characters forming s. To effectively apply the Pumping Lemma you are going to need to choose an s, in which only p is left unspecified. So if you are told, for example, that p = 3, then you must be able to write down s as a specific string of characters (in Example 2.3.4, with p = 3, s = aaabbaaa). For the assumption in the application of the Pumping Lemma is that the language L under consideration is recognized by a DFA. What is not known is the assumed size of the DFA. What the argument leading to a contradiction shows is that regardless of its size, the supposed DFA cannot recognize L, but this requires the argument to work for any value of p.

25 2.4. REGULAR EXPRESSIONS 47 Example J = {w w has equal numbers of a s and b s}. We show that J is not regular. To do this we introduce a new technique. Note that if A and B are regular then so is A B = (A B) (for the union and complement of regular languages are themselves regular; alternatively, see Problem 2 in Problem Collection 2 ). Now note that R = {a i b j i, j 0} is regular. Thus if J is regular, then so is J R = {a i b i i 0}. But we have already shown that J R was not regular in Example Thus J cannot be regular either. (Strictly, this is a proof by contradiction.) We could also proceed as in Example 2.3.3, applying the Pumping Lemma to string s = a p b p. The exact same argument will work. Question Does the proof of the Pumping Lemma work if we consider a p-state NFA that accepts L, rather than a p-state DFA? Justify your answer. 2.4 Regular expressions Regular expressions provide another, elegant and simple way of describing regular languages. We denote regular expressions by small letters such as r, s, r 1, etc. As with regular languages, they are defined with respect to a specified alphabet Σ. They are defined by the following six rules, comprising three base cases and three combining rules. We begin with the base cases. 1. φ is a regular expression; it represents φ, the empty set. 2. λ is a regular expression; it represents the language {λ}, the language containing the empty string alone. 3. a is a regular expression; it represents the language {a}. For the combining rules, let regular expressions r and s represent languages R and S. The rules follow. 4. r s is a regular expression; it represents language R S. 5. r s is a regular expression; it represents language R S. We write rs for short. 6. r is a regular expression; it represents language R. Parentheses are used to indicate the scope of an operator. It is also convenient to introduce the notation r + ; while not a standard regular expression, it is shorthand for rr, which represents the language RR. Also Σ is used as a shorthand for a 1 a 2 a k, where Σ = {a 1, a 2,, a k }. Finally, L(r) denotes the language represented by regular expression r. Examples.

26 48 CHAPTER 2. FINITE AUTOMATA 1. a ba = {w w contains exactly one b}. 2. Σ babσ = {w w contains bab as a substring}. 3. (ΣΣ) = {w w has even length}. 4. aσ a bσ b a b = {w w has the same first and last character}. 5. (a λ)b = ab b. 6. a φ = φ. Next we show that regular expressions represent exactly the regular languages. Lemma Let r be a regular expression. There is an NFA N r that recognizes the language represented by r: L(N r ) = L(r). Proof. The proof is by induction on the number of operators (union, concatenation, and star) in regular expression r. The base case is for zero operators, which are also the base cases for specifying regular expressions. It is easy to give DFAs that recognize the languages specified in each of these base cases and this is left as an exercise for the reader. For the inductive step, suppose that r is given by one of the recursive definitions, r 1 r 2, r 1 r 2, or r 1. Since r 1, and r 2 if it occurs, contain fewer operators than r, we can assume by the inductive hypothesis that there are NFAs recognizing the languages represented by regular expressions r 1 and r 2. Then Lemmas provide the NFAs recognizing the languages r. We can conclude that there is an NFA recognizing L(r). To prove the converse, that every regular language can be represented by a regular expression takes more effort. To this end, we introduce yet another variant of NFAs, called GNFAs (for Generalized NFAs). In a GNFA each edge is labeled by a regular expression r rather than by one of λ or a character a Σ. We can think of an edge labeled by regular expression r being traversable on reading string x exactly if x is in the language represented by r. String w is recognized by a GNFA M if there is a path P in M from its start vertex to a final vertex such that P s label, the concatenation of the labels on P s edges, forms a regular expression that includes w among the set of strings it represents. In more detail, suppose P consists of edges e 1, e 2,, e k, with labels r 1, r 2,, r k, respectively; then P is a w-recognizing path if w can be written as w = w 1 w 2 w k and each w i is in the language represented by r i, for 1 i k. Clearly, every NFA is a GNFA, so it will be enough to show that any language recognized by a GNFA can also be represented by a regular expression. We begin with two simple technical lemmas.

27 2.4. REGULAR EXPRESSIONS 49 Lemma Suppose that GNFA M has two vertices p and q with h edges from p to q, edges e 1, e 2,, e h. Suppose further that these edges are labeled by regular expressions r 1, r 2,, r h, respectively. Then replacing these h edges by a new edge e labeled r 1 r 2 r h, or r for short, yields a GNFA N recognizing the same language as M. Figure 2.29: Edge replacement in Lemma Proof. The edge replacement is illustrated in Figure First we show that L(M) L(N). Suppose that M recognizes string w. Let P be a w-recognizing path in M. Replacing each instance of edge e i, for 1 i h, by edge e yields a new path P in N, with P being w-recognizing (for a substring w i read on traversing edge e i, and hence represented by r i, is also represented by r and so can be read on traversing edge e also. This shows w L(N). Next we show that L(N) L(M). Suppose that N recognizes string w. let P be a w- recognizing path in N. Suppose that edge e is traversed j times in P, and let w 1, w 2,, w j be the substrings of w read on these j traversals. Each substring w g, 1 g j, is represented by regular expression r, and as r = r 1 r h, each w g is represented by one of r 1, r 2,, r h ; so let w g be represented by r ig, where 1 i g h. Replacing the corresponding instance of e in P by e ig yields a path P in M which is also w-recognizing. This shows that w L(M). Lemma suppose GNFA M has three vertices u, v, q, connected by edges labeled as shown in Figure 2.30 and further suppose that they are the only edges incident on q. Then Figure 2.30: Edge replacement in Lemma removing vertex q and creating edge (u, v) with label r 1 r 2r 3 yields a GNFA N recognizing the same language as M.

### Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

### Reading 13 : Finite State Automata and Regular Expressions

CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

### 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

### C H A P T E R Regular Expressions regular expression

7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

### Automata and Computability. Solutions to Exercises

Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

### Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

### CHAPTER 3 Numbers and Numeral Systems

CHAPTER 3 Numbers and Numeral Systems Numbers play an important role in almost all areas of mathematics, not least in calculus. Virtually all calculus books contain a thorough description of the natural,

### Regular Expressions. Languages. Recall. A language is a set of strings made up of symbols from a given alphabet. Computer Science Theory 2

Regular Expressions Languages Recall. A language is a set of strings made up of symbols from a given alphabet. Computer Science Theory 2 1 String Recognition Machine Given a string and a definition of

### CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

CMPSCI 250: Introduction to Computation Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 Regular Expressions and Their Languages Alphabets, Strings and Languages

### Regular Languages and Finite State Machines

Regular Languages and Finite State Machines Plan for the Day: Mathematical preliminaries - some review One application formal definition of finite automata Examples 1 Sets A set is an unordered collection

### Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Pushdown Automata In the last section we found that restricting the computational power of computing devices produced solvable decision problems for the class of sets accepted by finite automata. But along

### Theory of Computation

Theory of Computation For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Theory of Computation Regular Expressions and Finite Automata, Context-Free Grammar s

### Automata on Infinite Words and Trees

Automata on Infinite Words and Trees Course notes for the course Automata on Infinite Words and Trees given by Dr. Meghyn Bienvenu at Universität Bremen in the 2009-2010 winter semester Last modified:

### Finite Automata and Regular Languages

CHAPTER 3 Finite Automata and Regular Languages 3. Introduction 3.. States and Automata A finite-state machine or finite automaton (the noun comes from the Greek; the singular is automaton, the Greek-derived

### Automata and Formal Languages

Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

### Regular Languages and Finite Automata

Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

### Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras

Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding

### Scanner. tokens scanner parser IR. source code. errors

Scanner source code tokens scanner parser IR errors maps characters into tokens the basic unit of syntax x = x + y; becomes = + ; character string value for a token is a lexeme

### Induction. Margaret M. Fleck. 10 October These notes cover mathematical induction and recursive definition

Induction Margaret M. Fleck 10 October 011 These notes cover mathematical induction and recursive definition 1 Introduction to induction At the start of the term, we saw the following formula for computing

### Motivation. Automata = abstract computing devices. Turing studied Turing Machines (= computers) before there were any real computers

Motivation Automata = abstract computing devices Turing studied Turing Machines (= computers) before there were any real computers We will also look at simpler devices than Turing machines (Finite State

### Finite Automata. Reading: Chapter 2

Finite Automata Reading: Chapter 2 1 Finite Automaton (FA) Informally, a state diagram that comprehensively captures all possible states and transitions that a machine can take while responding to a stream

### Mathematical Induction

Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

### CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

CSC45 AUTOMATA 2. Finite Automata: Examples and Definitions Finite Automata: Examples and Definitions A finite automaton is a simple type of computer. Itsoutputislimitedto yes to or no. It has very primitive

### Applications of Methods of Proof

CHAPTER 4 Applications of Methods of Proof 1. Set Operations 1.1. Set Operations. The set-theoretic operations, intersection, union, and complementation, defined in Chapter 1.1 Introduction to Sets are

### CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions Theory of Formal Languages In the English language, we distinguish between three different identities: letter, word, sentence.

CS5236 Advanced Automata Theory Frank Stephan Semester I, Academic Year 2012-2013 Advanced Automata Theory is a lecture which will first review the basics of formal languages and automata theory and then

### The Halting Problem is Undecidable

185 Corollary G = { M, w w L(M) } is not Turing-recognizable. Proof. = ERR, where ERR is the easy to decide language: ERR = { x { 0, 1 }* x does not have a prefix that is a valid code for a Turing machine

### CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

### Class One: Degree Sequences

Class One: Degree Sequences For our purposes a graph is a just a bunch of points, called vertices, together with lines or curves, called edges, joining certain pairs of vertices. Three small examples of

### Finite Automata and Formal Languages

Finite Automata and Formal Languages TMV026/DIT321 LP4 2011 Lecture 14 May 19th 2011 Overview of today s lecture: Turing Machines Push-down Automata Overview of the Course Undecidable and Intractable Problems

### (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

3130CIT: Theory of Computation Turing machines and undecidability (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. An undecidable problem

### 3515ICT Theory of Computation Turing Machines

Griffith University 3515ICT Theory of Computation Turing Machines (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 9-0 Overview Turing machines: a general model of computation

### 2. Methods of Proof Types of Proofs. Suppose we wish to prove an implication p q. Here are some strategies we have available to try.

2. METHODS OF PROOF 69 2. Methods of Proof 2.1. Types of Proofs. Suppose we wish to prove an implication p q. Here are some strategies we have available to try. Trivial Proof: If we know q is true then

### INCIDENCE-BETWEENNESS GEOMETRY

INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full

### Compiler Construction

Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation

### ECS 120 Lesson 17 Church s Thesis, The Universal Turing Machine

ECS 120 Lesson 17 Church s Thesis, The Universal Turing Machine Oliver Kreylos Monday, May 7th, 2001 In the last lecture, we looked at the computation of Turing Machines, and also at some variants of Turing

### Vector Spaces II: Finite Dimensional Linear Algebra 1

John Nachbar September 2, 2014 Vector Spaces II: Finite Dimensional Linear Algebra 1 1 Definitions and Basic Theorems. For basic properties and notation for R N, see the notes Vector Spaces I. Definition

### 1 Introduction to Counting

1 Introduction to Counting 1.1 Introduction In this chapter you will learn the fundamentals of enumerative combinatorics, the branch of mathematics concerned with counting. While enumeration problems can

### Fundamentele Informatica II

Fundamentele Informatica II Answer to selected exercises 1 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 Let L be a language. It is clear

### . 0 1 10 2 100 11 1000 3 20 1 2 3 4 5 6 7 8 9

Introduction The purpose of this note is to find and study a method for determining and counting all the positive integer divisors of a positive integer Let N be a given positive integer We say d is a

### INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Name : FORMAL LANGUAGES AND AUTOMATA THEORY Code : A40509 Class : II B. Tech II

### 1 Definition of a Turing machine

Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,

### Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

### 136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

136 TER 4. INDUCTION, GRHS ND TREES 4.3 Graphs In this chapter we introduce a fundamental structural idea of discrete mathematics, that of a graph. Many situations in the applications of discrete mathematics

### Deterministic Push-Down Store Automata

Deterministic Push-Down tore Automata 1 Context-Free Languages A B C D... A w 0 w 1 D...E The languagea n b n : a b ab 2 Finite-tate Automata 3 Pushdown Automata Pushdown automata (pda s) is an fsa with

### Turing Machines: An Introduction

CIT 596 Theory of Computation 1 We have seen several abstract models of computing devices: Deterministic Finite Automata, Nondeterministic Finite Automata, Nondeterministic Finite Automata with ɛ-transitions,

### 6.080/6.089 GITCS Feb 12, 2008. Lecture 3

6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my

### CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

CS54 Turing Machines Turing Machine q 0 AI N P U T IN TAPE read write move read write move Language = {0} q This Turing machine recognizes the language {0} Turing Machines versus DFAs TM can both write

### Computing Functions with Turing Machines

CS 30 - Lecture 20 Combining Turing Machines and Turing s Thesis Fall 2008 Review Languages and Grammars Alphabets, strings, languages Regular Languages Deterministic Finite and Nondeterministic Automata

### Inf1A: Deterministic Finite State Machines

Lecture 2 InfA: Deterministic Finite State Machines 2. Introduction In this lecture we will focus a little more on deterministic Finite State Machines. Also, we will be mostly concerned with Finite State

### Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 Proofs Intuitively, the concept of proof should already be familiar We all like to assert things, and few of us

### The Graphical Method: An Example

The Graphical Method: An Example Consider the following linear program: Maximize 4x 1 +3x 2 Subject to: 2x 1 +3x 2 6 (1) 3x 1 +2x 2 3 (2) 2x 2 5 (3) 2x 1 +x 2 4 (4) x 1, x 2 0, where, for ease of reference,

### SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89 by Joseph Collison Copyright 2000 by Joseph Collison All rights reserved Reproduction or translation of any part of this work beyond that permitted by Sections

### 6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10

Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base- system. When you

### Software Analysis (POPA Sec , )

Software Analysis (POPA Sec. 2.2.2, 2.5-2.5.2) Klaus Ostermann Based on slides by Jurriaan Hage Overview Correctness proof Live Variables Analysis The While language with procedures Live Variables Analysis

### CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing

### Just the Factors, Ma am

1 Introduction Just the Factors, Ma am The purpose of this note is to find and study a method for determining and counting all the positive integer divisors of a positive integer Let N be a given positive

### ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

ω-automata ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear: in verification, as encodings of non-terminating executions of a program. in arithmetic,

### Elementary Number Theory We begin with a bit of elementary number theory, which is concerned

CONSTRUCTION OF THE FINITE FIELDS Z p S. R. DOTY Elementary Number Theory We begin with a bit of elementary number theory, which is concerned solely with questions about the set of integers Z = {0, ±1,

### Regular Languages and Finite Automata

Regular Languages and Finite Automata A C Norman, Lent Term 1996 Part IA 1 Introduction This course is short, but it is present in Part 1A because of the way it introduces links between many different

### 3. Equivalence Relations. Discussion

3. EQUIVALENCE RELATIONS 33 3. Equivalence Relations 3.1. Definition of an Equivalence Relations. Definition 3.1.1. A relation R on a set A is an equivalence relation if and only if R is reflexive, symmetric,

### Week 5: Binary Relations

1 Binary Relations Week 5: Binary Relations The concept of relation is common in daily life and seems intuitively clear. For instance, let X be the set of all living human females and Y the set of all

### Testing LTL Formula Translation into Büchi Automata

Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland

### Mathematical Induction. Mary Barnes Sue Gordon

Mathematics Learning Centre Mathematical Induction Mary Barnes Sue Gordon c 1987 University of Sydney Contents 1 Mathematical Induction 1 1.1 Why do we need proof by induction?.... 1 1. What is proof by

### Quotient Rings and Field Extensions

Chapter 5 Quotient Rings and Field Extensions In this chapter we describe a method for producing field extension of a given field. If F is a field, then a field extension is a field K that contains F.

### 2.3 Scheduling jobs on identical parallel machines

2.3 Scheduling jobs on identical parallel machines There are jobs to be processed, and there are identical machines (running in parallel) to which each job may be assigned Each job = 1,,, must be processed

### Computational Models Lecture 8, Spring 2009

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown Univ. p. 1 Computational Models Lecture 8, Spring 2009 Encoding of TMs Universal Turing Machines The Halting/Acceptance

### Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Automata Theory Automata theory is the study of abstract computing devices. A. M. Turing studied an abstract machine that had all the capabilities of today s computers. Turing s goal was to describe the

### COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about

### Lecture 2: Regular Languages [Fa 14]

Caveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to jeffe@illinois.edu. But the Lord came down to see the city and the tower the people were building.

### Lecture 17 : Equivalence and Order Relations DRAFT

CS/Math 240: Introduction to Discrete Mathematics 3/31/2011 Lecture 17 : Equivalence and Order Relations Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last lecture we introduced the notion

### Finite Automata. Reading: Chapter 2

Finite Automata Reading: Chapter 2 1 Finite Automata Informally, a state machine that comprehensively captures all possible states and transitions that a machine can take while responding to a stream (or

### (Refer Slide Time: 2:03)

Control Engineering Prof. Madan Gopal Department of Electrical Engineering Indian Institute of Technology, Delhi Lecture - 11 Models of Industrial Control Devices and Systems (Contd.) Last time we were

### Midterm Practice Problems

6.042/8.062J Mathematics for Computer Science October 2, 200 Tom Leighton, Marten van Dijk, and Brooke Cowan Midterm Practice Problems Problem. [0 points] In problem set you showed that the nand operator

### Mathematical Induction. Lecture 10-11

Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

### Math212a1010 Lebesgue measure.

Math212a1010 Lebesgue measure. October 19, 2010 Today s lecture will be devoted to Lebesgue measure, a creation of Henri Lebesgue, in his thesis, one of the most famous theses in the history of mathematics.

### Why? A central concept in Computer Science. Algorithms are ubiquitous.

Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

### 8 Divisibility and prime numbers

8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

### COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH. 1. Introduction

COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH ZACHARY ABEL 1. Introduction In this survey we discuss properties of the Higman-Sims graph, which has 100 vertices, 1100 edges, and is 22 regular. In fact

### 1 if 1 x 0 1 if 0 x 1

Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

### I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

I GROUPS: BASIC DEFINITIONS AND EXAMPLES Definition 1: An operation on a set G is a function : G G G Definition 2: A group is a set G which is equipped with an operation and a special element e G, called

### 3. Mathematical Induction

3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

### CONTENTS 1. Peter Kahn. Spring 2007

CONTENTS 1 MATH 304: CONSTRUCTING THE REAL NUMBERS Peter Kahn Spring 2007 Contents 2 The Integers 1 2.1 The basic construction.......................... 1 2.2 Adding integers..............................

### ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605

ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605 (1) (a) (0 + 1) 010 (finite automata below). (b) First observe that the following regular expression generates the binary strings with an even

### 6.3 Conditional Probability and Independence

222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted

### Deterministic Finite Automata

1 Deterministic Finite Automata Definition: A deterministic finite automaton (DFA) consists of 1. a finite set of states (often denoted Q) 2. a finite set Σ of symbols (alphabet) 3. a transition function

### Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

### Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

### Euclidean Geometry. We start with the idea of an axiomatic system. An axiomatic system has four parts:

Euclidean Geometry Students are often so challenged by the details of Euclidean geometry that they miss the rich structure of the subject. We give an overview of a piece of this structure below. We start

### HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

Math 7 Fall 205 HOMEWORK 5 SOLUTIONS Problem. 2008 B2 Let F 0 x = ln x. For n 0 and x > 0, let F n+ x = 0 F ntdt. Evaluate n!f n lim n ln n. By directly computing F n x for small n s, we obtain the following

### LEARNING OBJECTIVES FOR THIS CHAPTER

CHAPTER 2 American mathematician Paul Halmos (1916 2006), who in 1942 published the first modern linear algebra book. The title of Halmos s book was the same as the title of this chapter. Finite-Dimensional

### Basic Proof Techniques

Basic Proof Techniques David Ferry dsf43@truman.edu September 13, 010 1 Four Fundamental Proof Techniques When one wishes to prove the statement P Q there are four fundamental approaches. This document

### 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of

### CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

### Pythagorean Triples. Chapter 2. a 2 + b 2 = c 2

Chapter Pythagorean Triples The Pythagorean Theorem, that beloved formula of all high school geometry students, says that the sum of the squares of the sides of a right triangle equals the square of the

### MODULAR ARITHMETIC. a smallest member. It is equivalent to the Principle of Mathematical Induction.

MODULAR ARITHMETIC 1 Working With Integers The usual arithmetic operations of addition, subtraction and multiplication can be performed on integers, and the result is always another integer Division, on

### Click on the links below to jump directly to the relevant section

Click on the links below to jump directly to the relevant section What is algebra? Operations with algebraic terms Mathematical properties of real numbers Order of operations What is Algebra? Algebra is

### Lecture I FINITE AUTOMATA

1. Regular Sets and DFA Lecture I Page 1 Lecture I FINITE AUTOMATA Lecture 1: Honors Theory, Spring 02, Yap We introduce finite automata (deterministic and nondeterministic) and regular languages. Some