acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

Size: px
Start display at page:

Download "acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10"

Transcription

1 Regular Languages Andreas Karwath & Malte Helmert 1

2 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages The pumping lemma 2

3 Finite Automata An intuitive example : supermarket door controller front pad rear pad rear both neither closed front open front rear both door Top view of an automatic door neither State diagram for the automatic door controler Probabilistic counterparts exist Markov chains, Bayesian nets, etc. Not in this course Transition table for the automatic door controler: neither front rear both closed closed open closed closed open closed open open open 3

4 A finite automaton Figure 1.4 Formally States : q, q, q Startstate : q 1 q 1 q Acceptstate : q q 3 0,1 Transitions Output : accept or 2 reject A finite automaton is a 5-tuple ( Q, Σ, δ, q, F) 1. Qis a finite set of states 2. Σ is a finite set, the alphabet 3. δ : Q Σ Qis the transition function 4. q Q is the start state o 5. F Qis the set of accept states 0 4

5 q 1 q 2 q Ais the language of machine M we write LM ( ) = A A= { w wcontains at least one 1 and an even number of 0s follows the last 1 } Describe Q= { q, q, q } Σ= {0,1} δ defined by 0 1 q F start state = { q } 2 M q q q q q q q q q 5

6 0 1 1 q 1 q 2 State diagram of the two-state finite automaton M q 1 q 2 State diagram of the two-state finite automaton M 3 0 6

7 Other examples 7,8,9 7

8 Another example A generalisation : A i is the language of all strings where the sum of the numbers is a multiple of iexcept that the sum is reset to 0 whenever the symbol reset appears Automaton B = 1. Q = { q,..., i 0 qi 1 } 2. Σ ={0,1,2, reset } 3. δ ( q,0) = q j i δ ( q,1) = q where k = ( j+ 1) modi j δ ( q,2) = q where k = ( j+ 2) mod i j δ ( q, reset ) = q j k j k 4. q Q is start and accept state o 0 8

9 Formal definition of computation Let M be a finite automaton ( Q, Σ, δ, q, F) Let w= w... w be a string over Σ 1 n 0 M accepts wif a sequence of states r,..., r exists in Q such that δ i i+ 1 i ( r, w ) = r for all i = 0,..., n 1 3. r r n = q F 0 n M recognizes language Aif A= { w M accepts w} A language is regular if some finite automaton recognizes it. 9

10 Designing finite automata Design automaton for language consisting of binary strings with an odd number of 1s Design first states 0 1 Then transitions q even Start state and accept states 1 0 q odd 10

11 Another example Design an automaton to recognize the language of binary strings containing the string 001 as substring We have four possibilities: 1. we haven t seen any symbol of the pattern yet, or 2. we have seen a 0, or 3. we have seen a 00, or 4. we have seen the pattern

12 Another example Design an automaton to recognize the language of binary strings containing the string 001 as substring We have four possibilities: 1. we haven t seen any symbol of the pattern yet, or 2. we have seen a 0, or 3. we have seen a 00, or 4. we have seen the pattern , q q 0 q 00 q

13 The Regular Operations Let A and B be languages We define : Union : A B= { x x A or x B} Concatenation : Ao B= { xy x A and y B} Star * : A = { x1x2... xn n 0 and each xi A} note: always A * Example A = { good, bad} B = { boy, girl} A B= { good, bad, boy, girl} Ao B = { goodboy, goodgirl, badboy, badgirl} * A = {, good, bad, goodgood, goodbad, badgood, badbad, goodgoodgood, goodgoodbad,...} 13

14 Regular languages are closed under A set S is closed under an operation oif applying oon elements of S yields elements of S. Example: multiplication on natural numbers Counterexample :division of natural numbers Theorem 1.12 The class of the regular languages is closed under the union operation. In other words, if A and A are regular languages, so is A A

15 Proof 1.12 (by construction) Let M recognize A, where M = (Q, Σ, δ,q,f ), and M recognize A, where M = (Q, Σδ,,q,F ) Construct M to recognize A A, where M = (Q, Σ,δ, q,f ) { } 1. Q = (r,r ) r Q and r Q This set is the Cartesian product of sets Q and Q (written Q Q ) It is the set of all pairs of states, the first from Q and the second from Q Σ, the alphabet, is the same as in M and M. The theorem remains true if they have different alphabets, Σ and Σ. We would then modify the proof to let Σ = Σ Σ

16 3. δ, the transition function, is defined as follows. For each (r,r ) Q and each a Σ, let δ(( r,r ),a ) = ( δ ( r,a ), δ ( r,a )) Hence δ gets a state of M (which actually is a pair of states from M and M ), together with an input symbol, and returns M's next state. 4. q is the pair (q,q ) F M1 M2 5. is the set of pairs in which either member is an accept state of and. We can write it as F = {(r,r ) r F or r F } This expression is the same as F = (F Q ) (Q F ) Note that it is not the same as F = F F. What would that give us?

17 Example M 1 with L(M 1 ) = {w w contains a 1} 0 0,1 1 q 1 q 2 M = ( Q, Σ, δ, q, F) constructed from M = ( Q, Σ, δ, q, F) and M = ( Q, Σ, δ, q, F ) Define 1. Q= {( r, r ) r Q and r Q } 2. Σ=Σ Σ δ(( r, r ), a) = ( δ ( r, a), δ ( r, a)) q = ( q, q ) F = {( r, r ) r F or r F } M 2 with L(M 2 ) = {w w contains at least two 0s} 1 1 0,1 0 0 p 1 p 2 p 3 17

18 Theorem 1.13 The class of the regular languages is closed under the concatenation operation. In other words, if A and A are regular languages, so is A o A

19 Non deterministic finite automata Deterministic One successor state transitions not allowed Non deterministic Several successor states possible transitions possible 0,1 0,1 1 0, 1 q 1 q 2 q 3 q 4 19

20 Deterministic versus non deterministic computation Figure 15 20

21 0,1 0,1 q 1 1 0, q 2 q 3 1 q 4 0 q 1 q 1 1 Input: w = q 1 q 2 q 3 1 q 1 q 3 1 q 1 q 2 q 3 q 4 0 q 1 q 2 q 3 q 4 q 4 q 1 q 3 q 4 q 4 21

22 Another NFA 22

23 Nondeterministic finite automaton A nondeterministic finite automaton is a 5-tuple ( Q, Σ, δ, q, F) 1. Qis a finite set of states 2. Σ is a finite set, the alphabet 3. δ : Q Σ P( Q) is the transition function 4. q Q is the start state o 5. F Qis the set of accept states 0 Σ includes P( Q) the powerset of Q 23

24 Example 0,1 1 0, 0,1 q 1 q 2 q 3 q Q= { q, q, q, q } Σ = {0,1} 3. δ is given as: 0 1 q { q} { q, q } {} q { q } {} { q } q {} { q } {} q { q } { q } {} 4. q is the start state 5. F = { q } 4 24

25 Formal definition of computation Let M be a nondeterministic finite automaton ( Q, Σ, δ, q, F) Let w= w... w be a string over Σ 1 n 0 M accepts wif a sequence of states r,..., r exists in Q such that 1. r = q r δ ( r, w ) for all i = 0,..., n 1 i+ 1 i i r n F 0 n 25

26 Every NFA has an equivalent DFA 26

27 Equivalence NFA and DFA Two machines are equivalent if they recognize the same language Theorem 1.19 Every nondeterministic finite automaton has an equivalent finite automaton Corollary 1.20 A language is regular if and onl yi f automaton recognizes it. some nondeterministic finite 27

28 Proof: Theorem 1.19 Let N = (Q, Σ, δ,q,f ) be the NFA recognizing some language A. 0 0 Construct a DFA M recognizing A. First we consider the easier case wherein N has no arrows. The arrows are taken into account later. 28

29 Proof: Theorem 1.19 (cont.) ' ' Construct M = (Q', Σ, δ 0,q 0,F'). 1. Q' = P(Q ). Every state of M is a set of states of N. (Recall that P(Q) is the power set of Q). 2. For R Q' and a Σ let δ '(R,a) = {q Q q δ(r,a) for some r R}. If R is a state of M, it is also a set of states of N. When M reads a symbol a in state R, it shows where a takes each state in R. Because each state leads to to a set of states, we take the union of all these sets. Alternativly we write: 3. q = {q }. ' 0 0 U δ '( R,a ) = δ( r,a ). r R M starts in the state corresponding to the collection containing just the start state of N. 4. F' = {R Q' R contains an accept state of N }. The machine M accepts if one of the possible states that N could be in at this point is an accept state. 29

30 Proof: Theorem 1.19 (cont.) Now for the arrows one needs to set up an extra bit of notation. For any state R of M we define E(R) to be the collection of states that can be reached from R by going only along arrows, including the members of R themselves. Formally, for R Q let E( R ) = { q q can be reached from R by traveling along 0 or more arrows }. The transition function of M is then modified to take int o account all states that can be reached by going along arrows after every step. Replacing δ(r,a) by E( δ(r, a)) achieves this. Thus δ '( R,a ) = { q Q q E( δ( r,a )) for some r R }. Additionally the start state of M has to be modified to cater for all possible states that can be reached from the start state of N along the arrows. Changing q to be E({q }) achieves this effect. ' 0 0 We have now completed the construction of the DFA M that simulates the NFA N. 30

31 An example 31

32 An example The resulting DFA The resulting DFA after removing redundant states 32

33 Closure under the regular operations Theorem 1.12/1.22 The class of the regular languages is closed under the union operation. In other words, if A and A are regular languages, so is A A Theorem 1.23 The class of the regular languages is closed under the concatenation operation. Theorem 1.24 The class of the regular languages is closed under the star operation. 33

34 Proof idea Theorem 1.12/1.22 The class of the regular languages is closed under the union operation. In other words, if A and A are regular languages, so is A A

35 Proof 1.12/1.22 Let N = (Q, Σ, δ,q,f ) recognize A, and N = (Q, Σ, δ,q,f ) recognize A Construct N = (Q, Σ, δ,q,f ) to recognize A A Q = {q } Q Q The states of N are all the states of N and N, with the addition of a new start state q. 2. The state q is the start state of N The accept states F = F F The accept states of N are all the accept states of N and N. That way N accepts if either N accepts or N accepts. 4. Define δ so that for any q Q and any a Σ, δ1(q,a) q Q1 δ2(q,a) q Q2 δ (q,a) = {q 1,q 2} q= q0 and a= q = q0 and a

36 Proof idea Theorem 1.23 The class of the regular languages is closed under the concatenation operation. 36

37 Proof 1.23 Let N = (Q, Σ, δ,q,f ) recognize A, and N = (Q, Σ, δ,q,f ) recognize A Construct N = (Q, Σ, δ,q,f ) to recognize A o A Q = Q1 Q 2. The states of N are all the states of N1 and N The state q is the same as the start state of N The accept states F are the same as the accept states of N Define δ so that for any q Q and any a Σ, δ (q,a) q Q and q F δ (q,a) q F and a δ (q,a) = δ 1(q,a) {q 2} q = F1 and a = δ (q,a) q Q

38 Proof idea Theorem 1.24 The class of the regular languages is closed under the star operation. 38

39 Proof 1.24 Let N = (Q, Σ, δ,q,f ) recognize A Construct N = (Q, Σ, δ,q,f ) recognize A. * Q = {q } Q. 0 1 The states of N are the states of N plus a new start state. 2. The state q is the new start state F = {q } F 0 1 The accept states are the old accept states plus the new start state. 4. Define δ so that for any q Q and any a Σ, 1 δ1(q,a) q Q and q F δ 1(q,a) q F1 and a δ (q,a) = δ 1(q,a) {q 1} q F1 and a = {q 1} q= q0 and a= q = q0 and a

40 Regular expressions Definition Say that R is a regular expression if R is 1. a for some a in the alphabet Σ, 2., 3., 4. (R R ), where R and R are regular expressions, (R o R ), where R and R are regular expressions, or R, where Ris a regular expression. *

41 RE Examples In the following examples we assume that the alphabet Σ is {0,1}. * * = {w whas exactly a single 1}. 2. Σ 1 Σ = {w w has at least one 1}. 3. Σ 001 Σ = { w w contains the string 001 as a substring }. 4. ( ΣΣ) = {w w is a string of even length }. * 5. ( ΣΣΣ ) = {w the length of w is a multiple of three } = {01,10 }. 7. 0Σ 0 1Σ = { w w starts and ends with the same symbol }. 41

42 RE Examples (cont.) * * * (0 )(1 ) = The expression 0 describes the language {0, }, so the concatenation * operation adds either 0 or before every string in 1. (0 )(1 ) = {,0,1,01}. * =. Concatenating the empty set to any set yields the empty set. * 11. = { }. The star operation puts together any number of strings from the language to get a string in the result. If the language is empty, the star operation can put together 0 string, giving only the empty string. R R R R = R o = R o R R 42

43 Applications Design of compilers * * * * { +,, }( DD DD. D D. DD ) where D = {0,...,9} awk, grep, vi in unix (search for strings) Perl, Python, or Java programming languages Bioinformatics So called motifs (patterns occurring in sequences, e.g. proteins) 43

44 Equivalence RE and NFA Theorem 1.28 A language is regular if and only if some regular expression describes it Proof through : Lemma 1.29 If a language is described by some regular expression, then it is regular Lemma 1.32 If a language is regular, then it is described by some regular expression 44

45 Proof for Lemma 1.29 Convert R into an NFA N. Consider the six cases in the formal definition of regular expressions. 1. R= a for some a in Σ. Then L( R ) = { a }, and the following NFA recognizes L( R ). a Note that this machine fits the definition of an NFA but not that of a DFA, as not all input symbols possess exiting arrows. Formally, N = ({ q,q }, Σ, δ,q,{ q }), where we describe δ by saying that δ (q,a) = { q }, δ (r,b) = for r q or b a

46 Proof for Lemma 1.29 (cont.) 2. R =. Then L(R) = { }, and the following NFA recognizes L(R). Formally, N = ({q }, Σ, δ,q,{q }), where δ (r,b) = for any r and b. 46

47 Proof for Lemma 1.29 (cont.) 3. R =. Then L(R) =, and the following NFA recognizes L(R). Formally, N = ({q}, Σ, δ,q, ), where δ (r,b) = for any r and b. 47

48 Proof for Lemma 1.29 (cont.) R= R R. 1 2 R= R o R. R = R. 1 2 * 1 For the last three cases we use the constructions given in the proofs that the class of regular languages is closed under the regular operations. In other words, we construct the NFA for R from the NFAs for R and R (or just R in case 6) and the appropriate closure construction

49 Example 1.30 * We convert the regular expression (ab a) to an NFA in a sequence of stages. We build up from the smallest subexpressions to larger subexpressions until we have an NFA for the original expression, as shown in the following diagram. Note that this procedure generally doesn't give the NFA with the fewest states! 49

50 Example: NFA for: (ab a)* a: a b: b ab: a b ab a a b a (ab a)* a a b 50

51 Exercise: NFA for: (a b)*aba a: b: a b a b a b (a b)* a b 51

52 acs-04: Regular Languages 52 a b a b Example: NFA for: (a b)*aba (cont.) aba: (a b)*aba: a b a a b a a b a

53 Lemma 1.32 If a language is regular, then it is described by some regular expression Two steps DFA into GNFA (generalized nondeterministic finite automaton) Convert GNFA into regular expression 53

54 GNFAs Labels are regular expressions Two states q and r are connected in both directions (fully connected) Exception : One direction only Start state (exiting transition arrows) Accept state (only one!) (only incoming transition arrows) b q start Ø ab ab * a * (aa) * b * q accept aa ab ba 54

55 Formally A generalized nondeterministic finite automaton is a 5-tuple ( Q, Σ, δ, q, q ) 1. Qis a finite set of states 2. Σ is a finite set, the alphabet 3. δ : ( Q { q }) ( Q { q }) R is the transition function accept 4. q Q is the start state start start 55 start accept 5. qaccept Q the accept state * A GNFA accepts w= w1... wk where each wi Σ if a sequence of states r,..., r exists in Q such that 1. r 0 2. r k = = q q start accept 3. for all i = 0,..., n 1, we ha ve that w L( R) where R = δ ( r, r) i i 1 i 0 n i i

56 Convert DFA into GNFA Add new start state, with arrow to old start state Add new accept state, with arrows from old accept states If any arrows have multiple labels a and b, replace by a b Add arrows with label between states where necessary (*:between states that had no arrows before) * 56

57 Convert GNFA into regular expression 3 state DFA 5 state GNFA 4 state GNFA Regular Expression 2 state GNFA 3 state GNFA 57

58 Ripping of states Replace one state by the corresponding RE R 4 q 1 q 2 (R 1 )(R 2 )* ) (R 3 ) R 4 q 1 q 2 R 1 q rip R 3 R 2 58

59 Convert(G) Convert( G ) : 1. Let k be the number of states of G. 2. If k = 2, then G must consist of a start state, an accept state, and a single arrow connectiong them and labeled with a regular expression R. Return the expression R. 3. If k > 2, we select any state q Q different from q and q and let G' be the GNFA (Q', Σδ, ',q,q ), where start rip start accept accept Q' = Q {q }, and for any q Q' {q } and any q Q' {q } let rip i accept j start δ '(q,q ) = (R )(R ) (R ) (R ), * i j for R =δ (q,q ),R =δ (q,q ),R =δ (q,q ), and R =δ(q,q ). 1 i rip 2 rip rip 3 rip j 4 i j 4. Compute Convert( G') and return this value. 59

60 Example R 4 q 1 q 2 q 1 (R 1 )(R 2 )* (R 3 ) R 4 q 2 R 1 q rip R 3 R 2 Rip 2: Rip 1: 60

61 Another Example DFA: a 1 2 b a b 3 a b GNFA: s a 1 2 b a b 3 a b a Rip 1: Rip 2: 2 a s b ab 3 aa b b aba a a bb (ba a) (aa b)*ab bb s a(aa b)*ab b a(aa b)* 3 a (ba a) (aa b)* Rip 3: s (a(aa b)*ab b)((ba a) (aa b)*ab bb)*((ba a) (aa b)* ) a(aa b)* a 61

62 Induction Proof Claim For any GNFA G, Convert( G ) is equivalent to G. R 4 q 1 q 2 q 1 (R 1 )(R 2 )* (R 3 ) R 4 q 2 We prove this claim by induction on k, the number of states of the GNFA. R 1 q rip R 2 Basis: Prove the claim true for k = 2 states. If G has only two R 2 states, it can have only a single arrow, which goes from the start state to the accept state. The regular expression label on this arrow describes all the strings that allow G to get to the accept state. Hence this expression is equivalent to G. Induction step: Assume that the claim is true for k 1states and use this assumption to prove that the claim is true for k states. First we show that G and G' recognize the same language. Suppose that G accepts an input w. Then in an accepting branch of the computation G enters a sequence of states q,q,q,q,...,q. start accept If none of them is the removed state q, clearly G' also accepts w. The reason is that each of the new regular expressions labeling the arrows of G' contains the old regular expression as part of a union. rip 62

63 Induction Proof (cont.) q 1 R 4 q 2 q 1 (R 1 )(R 2 )* (R 3 ) R 4 q 2 If q does appear, removing each run of consecutive q states rip forms an accepting computation for G'. The states q and q bracketing a run have a new regular expression on the arrow between them that i rip j R 1 q rip R 2 describes all strings taking q to q via q on G. So G' accepts w. i j rip For the other direction, suppose that G' accepts an input w. As each R 2 arrow between any two states q and q in G' describes the collection i j of strings taking q to q in G, either directly or via q,g must also i j rip accept wthus G and G' are equivalent. The induction hypothesis states that when the alorithm calls itself recursively on input G', the result is a regular expression that is equivalent to G' because G' has k 1 states. Hence the regular expression also is equivalent to G, and the algorithm is proved correct. This concludes the proof of Claim 1.34, Lemma 1.32, and theorem

64 Nonregular Languages Finite Automata have a finite memory Are the following languages regular? n n B= {0 1 n 0} C = { w whas an equal number of 0s and 1s} D= { w whas an equal number of occurences of 01 and 10} Mathematical proof necessary 64

65 The pumping lemma If A is regular language, then there is a number p (the pumping length), where, if s is any string in A of length at least p then s may be divided into three pieces s = xyz such that i 1. for each i 0, xy z A 2. y > 0 3. xy p Note from 2: y 65

66 Proof Idea Let M be a DFA recognizing A. Assign p to be the number of states in M. Show that string s, with length at least p, canbebrokenintoxyz. Pigeonhole principle Now prove that all three conditions are met 66

67 Proof: Pumping Lemma Let M = (Q, Σ, δ, q 1, F) be a DFA recognizing A and Q = p. Let s = s 1 s 2...s n be a string in A, with s = n, and n p Let r =r 1,...,r n+1 be the sequence of states that M enters for s, so r i+1 = δ(r i,s i ) with 1 i n. r 1,...,r n+1 = n+1, n+1 p+1. Amoung the first p+1 elements in r, there must be a r j and a r l being the same state q m, with j l. As r l occurs in the first p+1 states: l p+1. Let x = s 1...s j-1, y = s j...s l-1 and z = s l...s n : as x takes M from r 1 to r j, y from r j to r l, and z from r l to r n+1, being an accept state, M must accept xy i z for i 0 with j l, y > 0 with l p+1, xy p 67

68 Pumping Lemma (cont.) Use pumping lemma to prove that a language A is not regular: 1. Assume that A is regular (Proof by contradiction) 2. use the lemma to guarantee the existence of p, such that strings of length p or greater can be pumped 3. find string s of A, with s p that cannot be pumped 4. demonstrate that s cannot be pumped using all different ways of dividing s into x,y, and z (using condition 3. is here very useful ) 5. the existence of s contradicts the assumption, therefore A is not a regular language 68

69 Nonregular languages examples B n n = {0 1 n 0} p Choose s = 0 1 p for s p: i 1. for each i 0, xy z A 2. y > 0 3. xy p If we would now only consider condition2, then we would have that: 1. string y consists only of 0s 2. string y consists only of 1s 3. string y consists of both 0s and 1s 69

70 C = { w whas an equal number of 0s and 1s} p Choose s = 0 1 p Would seem possible without condition 3! However, condition 3 of lemma states xy Thus y consists of 0s only Then xyyz C p for s p: i 1. for each i 0, xy z A 2. y > 0 3. xy p Choc i e of s crucial. Consider s = (01) p Alternative proof : B is nonregular If C were C = B * * regular, then 0 1 regular Regular languages closed under intersection 70

71 Example language B again B n n = {0 1 n 0} for s p: i 1. for each i 0, xy z A 2. y > 0 3. xy p p Choose s = 0 1 p condition 3 of lemma states xy Thus y consists of 0s only Then xyyz B p 71

72 F = * { ww w {0,1}} p p Choose s = 0101 Condition 3 of lemma states xy Thus y consists of 0s only Then xyyz F p for s p: i 1. for each i 0, xy z A 2. y > 0 3. xy p p p 0 0 would not work, as it can be pumped! 72

73 i j E = { w 01 where i > j} p+ p Choose s = 0 1 Condition 3 of lemma states xy Thus y consists of 0s only Then 0 xy z F p for s p: i 1. for each i 0, xy z A 2. y > 0 3. xy p 73

74 Example Exam Question for s p: i 1. for each i 0, xy z A 2. y > 0 3. xy p Q: Use the pumping lemma to prove that L = {0 k 1 j : k,j 0 and k 2j} is not regular. A: Assume that L = {0 k 1 j : k,j 0 and k 2j} is regular. Let p be the pumping length of L. The pumping lemma states that for any string s L of at least length p, there exist string x,y, and z such that s = xyz, xy p, y > 0, and for all i 0: xy i z L. Choose s = 0 2p 1 p. Because s L and s =3p p, we obtain from the pumping lemma the strings x,y, and z with the above properties. As s = xyz, xy p, and s begins with 2p zeros, one can see that xy can only consist of zeros. If we pump s down, i.e. select i = 0, the string xy 0 z = xz = 0 2p- y 1 p. As xz has p ones, and y > 0, xz has fewer than 2p zeros. Hence xz L CONTRADICTION. Therfore L is not regular! 74

75 Example Exam Question for s p: i 1. for each i 0, xy z A 2. y > 0 3. xy p Q: Use the pumping lemma to prove that L = {0 k 1 j : k,j 0 and k 2j} is not regular. A: Assume that L = {0 k 1 j : k,j 0 and k 2j} is regular. Let p be the pumping length of L. The pumping lemma states that for any string s L of at least length p, there exist string x,y, and z such that s = xyz, xy p, y > 0, and for all i 0: xy i z L. Choose s = 0 2p 1 p. Because s L and s =3p p, we obtain from the pumping lemma the strings x,y, and z with the above properties. As s = xyz, xy p, and s begins with 2p zeros, one can see that xy can only consist of zeros. If we pump s down, i.e. select i = 0, the string xy 0 z = xz = 0 2p- y 1 p. As xz has p ones, and y > 0, xz has fewer than 2p zeros. Hence xz L CONTRADICTION. Therfore L is not regular! 75

76 Summary Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages The pumping lemma 76

Applied Computer Science II Chapter 1 : Regular Languages

Applied Computer Science II Chapter 1 : Regular Languages Applied Computer Science II Chapter 1 : Regular Languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany Overview Deterministic finite automata Regular languages

More information

UNIT-III REGULAR LANGUAGES

UNIT-III REGULAR LANGUAGES Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

Introduction to Languages and Computation

Introduction to Languages and Computation Introduction to Languages and Computation George Voutsadakis 1 1 Mathematics and Computer Science Lake Superior State University LSSU Math 400 George Voutsadakis (LSSU) Languages and Computation July 2014

More information

Theory of Languages and Automata

Theory of Languages and Automata Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology Finite State Automaton We begin with the simplest model of Computation, called finite

More information

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

More information

CPS 220 Theory of Computation REGULAR LANGUAGES

CPS 220 Theory of Computation REGULAR LANGUAGES CPS 22 Theory of Computation REGULAR LANGUAGES Introduction Model (def) a miniature representation of a thing; sometimes a facsimile Iraq village mockup for the Marines Scientific modelling - the process

More information

Critical CS Questions

Critical CS Questions Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Critical CS Questions What is a computer? And What is a Computation? real computers too complex for any

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automata (FA or DFA) CHAPTER Regular Languages Contents definitions, examples, designing, regular operations Non-deterministic Finite Automata (NFA) definitions, euivalence of NFAs and DFAs, closure

More information

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is Abstraction of Problems Data: abstracted as a word in a given alphabet. Σ: alphabet, a finite, non-empty set of symbols. Σ : all the words of finite length built up using Σ: Conditions: abstracted as a

More information

Theory of Computation (II) Yijia Chen Fudan University

Theory of Computation (II) Yijia Chen Fudan University Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest

More information

Computational Models #1

Computational Models #1 Computational Models #1 Handout Mode Nachum Dershowitz & Yishay Mansour March 13-15, 2017 Nachum Dershowitz & Yishay Mansour Computational Models #1 March 13-15, 2017 1 / 41 Lecture Outline I Motivation

More information

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}

More information

Computational Models - Lecture 1 1

Computational Models - Lecture 1 1 Computational Models - Lecture 1 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. February 29/ March 02, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames

More information

Computational Models: Class 1

Computational Models: Class 1 Computational Models: Class 1 Benny Chor School of Computer Science Tel Aviv University October 19, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES and REGULAR EXPRESSIONS TUESDAY Jan 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w has equal number

More information

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy: Incorrect reasoning about RL Since L 1 = {w w=a n, n N}, L 2 = {w w = b n, n N} are regular, therefore L 1 L 2 = {w w=a n b n, n N} is regular If L 1 is a regular language, then L 2 = {w R w L 1 } is regular,

More information

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

Theory of Computation (I) Yijia Chen Fudan University

Theory of Computation (I) Yijia Chen Fudan University Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

Non-Deterministic Finite Automata

Non-Deterministic Finite Automata Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 8 Non-Deterministic Finite Automata 0,1 0,1 0 0,ε q q 1 q 2 3 1 q 4 an NFA

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

Time Magazine (1984)

Time Magazine (1984) Time Magazine (1984) Put the right kind of software into a computer, and it will do whatever you want it to. There may be limits on what you can do with the machines themselves, but there are no limits

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r Syllabus R9 Regulation UNIT-II NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: In the automata theory, a nondeterministic finite automaton (NFA) or nondeterministic finite state machine is a finite

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,

More information

Lecture 4: More on Regexps, Non-Regular Languages

Lecture 4: More on Regexps, Non-Regular Languages 6.045 Lecture 4: More on Regexps, Non-Regular Languages 6.045 Announcements: - Pset 1 is on piazza (as of last night) - If you don t have piazza access but are registered for 6.045, send email to TAs with

More information

TDDD65 Introduction to the Theory of Computation

TDDD65 Introduction to the Theory of Computation TDDD65 Introduction to the Theory of Computation Lecture 2 Gustav Nordh, IDA gustav.nordh@liu.se 2012-08-31 Outline - Lecture 2 Closure properties of regular languages Regular expressions Equivalence of

More information

CS 455/555: Finite automata

CS 455/555: Finite automata CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

front pad rear pad door

front pad rear pad door front pad rear pad door REAR BOTH NEITHER closed FRONT open FRONT REAR BOTH NEITHER Think of this as a simple program that outputs one of two values (states) when provided with the current state and an

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. UNIT 2 Structure NON-DETERMINISTIC FINITE AUTOMATA

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation 1/26/2016 LECTURE 5 Last time: Closure properties. Equivalence of NFAs, DFAs and regular expressions Today: Conversion from NFAs to regular expressions Proving that a language

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

UNIT-I. Strings, Alphabets, Language and Operations

UNIT-I. Strings, Alphabets, Language and Operations UNIT-I Strings, Alphabets, Language and Operations Strings of characters are fundamental building blocks in computer science. Alphabet is defined as a non empty finite set or nonempty set of symbols. The

More information

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

1.3 Regular Expressions

1.3 Regular Expressions 51 1.3 Regular Expressions These have an important role in descriing patterns in searching for strings in many applications (e.g. awk, grep, Perl,...) All regular expressions of alphaet are 1.Øand are

More information

Uses of finite automata

Uses of finite automata Chapter 2 :Finite Automata 2.1 Finite Automata Automata are computational devices to solve language recognition problems. Language recognition problem is to determine whether a word belongs to a language.

More information

September 7, Formal Definition of a Nondeterministic Finite Automaton

September 7, Formal Definition of a Nondeterministic Finite Automaton Formal Definition of a Nondeterministic Finite Automaton September 7, 2014 A comment first The formal definition of an NFA is similar to that of a DFA. Both have states, an alphabet, transition function,

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata. CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications

More information

Chapter Five: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more

More information

Lecture 4 Nondeterministic Finite Accepters

Lecture 4 Nondeterministic Finite Accepters Lecture 4 Nondeterministic Finite Accepters COT 4420 Theory of Computation Section 2.2, 2.3 Nondeterminism A nondeterministic finite automaton can go to several states at once. Transitions from one state

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions

More information

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata : Organization of Programming Languages Theory of Regular Expressions Finite Automata Previous Course Review {s s defined} means the set of string s such that s is chosen or defined as given s A means

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

Lecture 3: Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where

More information

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

Regular Languages. Problem Characterize those Languages recognized by Finite Automata. Regular Expressions Regular Languages Fundamental Question -- Cardinality Alphabet = Σ is finite Strings = Σ is countable Languages = P(Σ ) is uncountable # Finite Automata is countable -- Q Σ +1 transition

More information

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

COMP4141 Theory of Computation

COMP4141 Theory of Computation COMP4141 Theory of Computation Lecture 4 Regular Languages cont. Ron van der Meyden CSE, UNSW Revision: 2013/03/14 (Credits: David Dill, Thomas Wilke, Kai Engelhardt, Peter Höfner, Rob van Glabbeek) Regular

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Theory of Regular Expressions DFAs and NFAs Reminders Project 1 due Sep. 24 Homework 1 posted Exam 1 on Sep. 25 Exam topics list posted Practice homework

More information

Chapter 6. Properties of Regular Languages

Chapter 6. Properties of Regular Languages Chapter 6 Properties of Regular Languages Regular Sets and Languages Claim(1). The family of languages accepted by FSAs consists of precisely the regular sets over a given alphabet. Every regular set is

More information

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three

More information

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2 5-25 Great Theoretical Ideas in Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 January 26th, 27 Formal definition: DFA A deterministic finite automaton (DFA) M =(Q,,,q,F) M is

More information

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Before we show how languages can be proven not regular, first, how would we show a language is regular? CS35 Proving Languages not to be Regular Before we show how languages can be proven not regular, first, how would we show a language is regular? Although regular languages and automata are quite powerful

More information

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007. Proofs, Strings, and Finite Automata CS154 Chris Pollett Feb 5, 2007. Outline Proofs and Proof Strategies Strings Finding proofs Example: For every graph G, the sum of the degrees of all the nodes in G

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Design an automaton that recognizes a given language. Specify each of

More information

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression) CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression) Objectives Prove the Pumping Lemma, and use it to show that there are non-regular languages

More information

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 2 January 5, 2018 January 5, 2018 CS21 Lecture 2 1 Outline Finite Automata Nondeterministic Finite Automata Closure under regular operations NFA, FA equivalence

More information

Automata and Computability. Solutions to Exercises

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

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 28 2017 Part 2 out of 5 Last week was all about Deterministic Finite Automaton

More information

Chapter 2 The Pumping Lemma

Chapter 2 The Pumping Lemma Chapter 2 The Pumping Lemma Fourth Academic Year/ Elective Course-General Electrical Engineering Department College of Engineering University of Salahaddin April 2015 Nonregular Languages Consider the

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

Formal Definition of a Finite Automaton. August 26, 2013

Formal Definition of a Finite Automaton. August 26, 2013 August 26, 2013 Why a formal definition? A formal definition is precise: - It resolves any uncertainties about what is allowed in a finite automaton such as the number of accept states and number of transitions

More information

Proving languages to be nonregular

Proving languages to be nonregular Proving languages to be nonregular We already know that there exist languages A Σ that are nonregular, for any choice of an alphabet Σ. This is because there are uncountably many languages in total and

More information

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions TAFL 1 (ECS-403) Unit- II 2.1 Regular Expression: 2.1.1 The Operators of Regular Expressions: 2.1.2 Building Regular Expressions 2.1.3 Precedence of Regular-Expression Operators 2.1.4 Algebraic laws for

More information

Automata and Computability. Solutions to Exercises

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

More information

Theory of Computation

Theory of Computation Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 3 January 9, 2017 January 9, 2017 CS21 Lecture 3 1 Outline NFA, FA equivalence Regular Expressions FA and Regular Expressions January 9, 2017 CS21 Lecture 3 2

More information

CS 121, Section 2. Week of September 16, 2013

CS 121, Section 2. Week of September 16, 2013 CS 121, Section 2 Week of September 16, 2013 1 Concept Review 1.1 Overview In the past weeks, we have examined the finite automaton, a simple computational model with limited memory. We proved that DFAs,

More information

Finite Automata and Regular Languages

Finite Automata and Regular Languages Finite Automata and Regular Languages Topics to be covered in Chapters 1-4 include: deterministic vs. nondeterministic FA, regular expressions, one-way vs. two-way FA, minimization, pumping lemma for regular

More information

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 Theory of Computation  Professor Jeanne Ferrante CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Today s agenda NFA Review and Design NFA s Equivalence to DFA s Another Closure Property proof for Regular Languages

More information

Tasks of lexer. CISC 5920: Compiler Construction Chapter 2 Lexical Analysis. Tokens and lexemes. Buffering

Tasks of lexer. CISC 5920: Compiler Construction Chapter 2 Lexical Analysis. Tokens and lexemes. Buffering Tasks of lexer CISC 5920: Compiler Construction Chapter 2 Lexical Analysis Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Copyright Arthur G. Werschulz, 2017. All

More information

Nondeterminism and Epsilon Transitions

Nondeterminism and Epsilon Transitions Nondeterminism and Epsilon Transitions Mridul Aanjaneya Stanford University June 28, 22 Mridul Aanjaneya Automata Theory / 3 Challenge Problem Question Prove that any square with side length a power of

More information

Name: Student ID: Instructions:

Name: Student ID: Instructions: Instructions: Name: CSE 322 Autumn 2001: Midterm Exam (closed book, closed notes except for 1-page summary) Total: 100 points, 5 questions, 20 points each. Time: 50 minutes 1. Write your name and student

More information

Lecture 1: Finite State Automaton

Lecture 1: Finite State Automaton Lecture 1: Finite State Automaton Instructor: Ketan Mulmuley Scriber: Yuan Li January 6, 2015 1 Deterministic Finite Automaton Informally, a deterministic finite automaton (DFA) has finite number of s-

More information

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1 Properties of Regular Languages BBM 401 - Automata Theory and Formal Languages 1 Properties of Regular Languages Pumping Lemma: Every regular language satisfies the pumping lemma. A non-regular language

More information

Lecture 2: Regular Expression

Lecture 2: Regular Expression Lecture 2: Regular Expression Instructor: Ketan Mulmuley Scriber: Yuan Li January 8, 2015 In the last lecture, we proved that DFA, NFA, and NFA with ϵ-moves are equivalent. Recall that a language L Σ is

More information

Automata and Languages

Automata and Languages Automata and Languages Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Nondeterministic Finite Automata with empty moves (-NFA) Definition A nondeterministic finite automaton

More information

3515ICT: Theory of Computation. Regular languages

3515ICT: Theory of Computation. Regular languages 3515ICT: Theory of Computation Regular languages Notation and concepts concerning alphabets, strings and languages, and identification of languages with problems (H, 1.5). Regular expressions (H, 3.1,

More information

Nondeterminism. September 7, Nondeterminism

Nondeterminism. September 7, Nondeterminism September 7, 204 Introduction is a useful concept that has a great impact on the theory of computation Introduction is a useful concept that has a great impact on the theory of computation So far in our

More information

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010 University of Virginia - cs3102: Theory of Computation Spring 2010 PS2 - Comments Average: 77.4 (full credit for each question is 100 points) Distribution (of 54 submissions): 90, 12; 80 89, 11; 70-79,

More information

Inf2A: Converting from NFAs to DFAs and Closure Properties

Inf2A: Converting from NFAs to DFAs and Closure Properties 1/43 Inf2A: Converting from NFAs to DFAs and Stuart Anderson School of Informatics University of Edinburgh October 13, 2009 Starter Questions 2/43 1 Can you devise a way of testing for any FSM M whether

More information

Equivalence of DFAs and NFAs

Equivalence of DFAs and NFAs CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs

More information

Finite Automata. Seungjin Choi

Finite Automata. Seungjin Choi Finite 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 / 28 Outline

More information

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission. CSE 5 Homework Due: Monday October 9, 7 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments in this

More information

Finite State Automata

Finite State Automata Trento 2005 p. 1/4 Finite State Automata Automata: Theory and Practice Paritosh K. Pandya (TIFR, Mumbai, India) Unversity of Trento 10-24 May 2005 Trento 2005 p. 2/4 Finite Word Langauges Alphabet Σ is

More information

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is, Recall A deterministic finite automaton is a five-tuple where S is a finite set of states, M = (S, Σ, T, s 0, F ) Σ is an alphabet the input alphabet, T : S Σ S is the transition function, s 0 S is the

More information

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1 Unit 6 Non Regular Languages The Pumping Lemma Reading: Sipser, chapter 1 1 Are all languages regular? No! Most of the languages are not regular! Why? A finite automaton has limited memory. How can we

More information