컴파일러입문 제 3 장 정규언어

Size: px
Start display at page:

Download "컴파일러입문 제 3 장 정규언어"

Transcription

1 컴파일러입문 제 3 장 정규언어

2 목차 3.1 정규문법과정규언어 3.2 정규표현 3.3 유한오토마타 3.4 정규언어의속성 Regular Language Page 2

3 정규문법과정규언어 A study of the theory of regular languages is often justified by the fact that they model the lexical analysis stage of a compiler. Type 3 Grammar(N. Chomsky) RLG : A tb, A t LLG : A Bt, A t where, A,B V N and t V T *. It is important to note that grammars in which left-linear productions are intermixed with right-linear productions are not regular. For example, G : S ar S c R Sb L(G) = {a n cb n n 0} is a cfl. Regular Language Page 3

4 Definition (1) A grammar is regular if each rule is i) A ab, A a, where a V T, A, B V N. ii) if S ε P, then S doesn't appear in RHS. 우선형문법 A tb, A t 의형태에서 t 가하나의 terminal 로 이루어진경우로정규문법에관한속성을체계적으로전개하기위하 여바람직한형태이다. (2) A language is said to be a regular language(rl) if it can be generated by a regular grammar. ex) L = { a n b m n, m 1 } is rl. S as aa A ba b Regular Language Page 4

5 [Theorem] The production forms of regular grammar can be derived from those of RLG.(RLG => RG) (Text p.69) (proof) A tb, where t V T *. Let t = a 1 a 2... a n, a i V T. A a 1 A 1 A 1 a 2 A 2. A n-1 a n B. If t = ε, then A B (single production) or A ε (epsilon production). These forms of productions can be easily removed. (Text pp ) ex) S abca S as 1, S 1 bs 2 S 2 ca A bca A ba 1, A 1 ca A cd A ca 1 ', A 1 ' d Right-linear grammar : A tb or A t, where A, B V N and t V T *. Regular Language Page 5

6 Equivalence 1. 언어 L 은우선형문법에의해생성된다. 2. 언어 L 은좌선형문법에의해생성된다. 3. 언어 L 은정규문법에의해생성된다. 정규언어 [ 예 ] L = {a n b m n,m 1} : rl S as aa A ba b Text p. 70 Regular Language Page 6

7 토큰의구조를정의하는데정규언어를사용하는이유 (1) 토큰의구조는간단하기때문에정규문법으로표현할수있다. (2) context-free 문법보다는정규문법으로부터효율적인인식기를구현할수있다. (3) 컴파일러의전반부를모듈러하게나누어구성할수있다. (Scanner + Parser) 문법의형태가정규문법이면그문법이나타내는언어의형태를체계적으로구하여정규표현으로나타낼수있다. G derivation L if G = rg, L: re. Regular Language Page 7

8 정규표현 A notation that allows us to describe the structures of sentences in regular language. The methods for specifying the regular languages (1) regular grammar(rg) (2) regular expression(re) (3) finite automata(fa) rg fa re Regular Language Page 8

9 Definition : Text p. 71 A regular expression over the alphabet T and the language denoted by that expression are defined recursively as follows : I. Basis : φ, ε, a T. (1) φ is a regular expression denoting the empty set. (2) ε is a regular expression denoting {ε}. (3) a where a T is a regular expression denoting {a}. II. Recurse : +,, * If P and Q are regular expressions denoting L p and L q respectively, then (1) (P + Q) is a regular expression denoting L p U L q. (union) (2) (P Q) is a regular expression denoting L p L q. (concatenation) (3) (P*) is a regular expression denoting (closure) {e} U L p U L p 2 U... U L p n... Note : precedence : + < < * II. Nothing else is a regular expression. Regular Language Page 9

10 ex) (0+1)* denotes {0,1}*. (0+1)*011 denotes the set of all strings of 0 s and 1 s ending in 011. Definition : if α is α regular expression, L(α) denotes the language associated with α. (Text p.72) Let a and b be regular expressions. Then, (1) L(α+ β) = L(α) L(β) (2) L(α β) = L(α) L(β) (3) L(α * ) = L(α) * examples : (1) L(a * ) = {ε, a, aa, aaa, } = {a n n 0} (2) L((aa) * (bb) * b) = {a 2n b 2m+1 n,m 0} (3) L((a+b) * b(a+ab) * ) --- 연습문제 3.2 (3) - text p.115 = { b, ba, bab, ab, bb, aab, bbb, } Regular Language Page 10

11 Definition : Two regular expressions are equal if and only if they denote the same language. α= β if L(α) = L(β). Axioms : Some algebraic properties of regular expressions. Let a, b and g be regular expressions. Then, (Text p.73) A1. α+β = β+α A2. (α+β) +γ = α+ (β+γ) A3. (αβ) γ = α (βγ) A4. α(β+γ) = αβ +αγ A5. (β + γ) α = βα + γα A6. α+α=α A7. α + φ = α A8. αφ = φ = φα A9. ε α = α = α ε A10. α * = ε +α α * A11. α * = (ε + α) * A12. (α * ) * = α * A13. α * + α = α * A14. α * + α + = α * A15. (α + β) * = (α * β * ) * Regular Language Page 11

12 All of these identities(=axioms) are easily proved by the definition of regular expression. A8. αφ = φ = φ α (proof) αφ = { xy x L α and y Lφ } Since y Lφ is false, (x L α and y Lφ) is false. Thus αφ = φ. Definitions : regular expression equations. ::= the set of equations whose coefficient are regular expressions. ex) α,β 가정규표현이면, X = αx+β 가정규표현식이다. 이때, X 의의미는 nonterminal 심볼이며우측의식이그 nonterminal 이생성하는언어의형태이다. Regular Language Page 12

13 The solution of the regular expression equation X = αx + β When we substitute X = α*β in both side of the equation, each side of the equation represents the same language. X = αx + β = α(α*β) + β = αα*β + β = (αα* + ε)β = α*β. fixed point iteration X = αx + β = α(αx + β) + β = α 2 X + αβ + β = α 2 X + (ε + α)β. = α k+1 X + (ε + α + α α k )β = (ε + α + α α k +...)β = α*β. Regular Language Page 13

14 Not all regular expression equations have unique solution. X = αx + β (a) If ε is not in α, then X = α * β is the unique solution. (b) If ε is in α, then X = α * (β + L) for some language L. So it has an infinity of solutions. Smallest solution : X = α * β. ex) X = X + a : not unique solution X = a + b or X = b * a or X = (a + b) * etc. X = X + a X = X + a = a + b + a = b * a + a = a + a + b = (b * + ε) a = a + b. = b * a Regular Language Page 14

15 Finding a regular expression denoting L(G) for a given rg G. G derivation L if G = rg, L: re. L(A) where A V N denotes the language generated by A. By definition, if S is a start symbol, then L(G)= L(S). Two steps : 1. Construct a set of simultaneous equations from G. A ab, A a L(A) = {a} L(B) U {a} A = ab + a In general, X α β γ X = α + β + γ. 2. Solve these equations. X = αx + β X = α * β. Regular Language Page 15

16 ex1) S as S br S ε R as L(S) = {a}l(s) U {b}l(r) U{ε} L(R) = {a}l(s) ree: S = as + br + ε R = as S = as + bas + ε = (a + ba)s + ε = (a + ba) * ε = (a + ba) * ex2) S aa bb b A ba ε B bs ree: S = aa + bb + b A = ba + ε A = b * ε = b * B = bs S = ab * + bbs + b = bbs + ab * + b = (bb) * (ab * +b) Regular Language Page 16

17 ex3) A 0B 1A B 1A 0C C 0C 1C ε ex4) S aa bs A as bb B ab bb ε ex5) S 0A 1B 0 ex6) X 1 = 0X 2 + 1X 1 + ε A 0A 0S 1B X 2 = 0X 3 + 1X 2 B 1B 1 0 X 3 = 0X 1 + 1X 3 Text p (5) ex7) A 1 = (01* + 1) A 1 + A 2 A 2 = A A 3 A 3 = A 1 + A 2 + ε ex8) A ab ba B ab bc C bd ab D ba ab ε 풀이 ex9) X α 1 X + α 2 Y + α 3 ex10) PR b DL SL e Y β 1 X + β 2 Y + β 3 DL d ; DL ε SL SL ; s s Regular Language Page 17

18 인식기 (Recognizer) A recognizer for a language L is a program that takes as input string x and answers yes if x is a sentence of L and no otherwise. Turing Machine Linear Bounded Automata Pushdown Automata Finite Automata Regular Language Page 18

19 유한오토마타 Definition : fa Text p. 78 A finite automaton M over an alphabet is a system (Q,, δ, q 0, F) where, Q : finite, non-empty set of states. : finite input alphabet. δ : mapping function. q 0 Q : start(or initial) state. F Q : set of final states. mapping δ : Q x 2 Q. i,e. δ(q,a) = {p 1, p 2,..., p n } G = (V N, V T, P, S) re : φ, ε, a, +,, * M = (Q,, δ, q 0, F) DFA, NFA. Regular Language Page 19

20 목차 - FA 1. DFA 2. NFA 3. Converting NFA into DFA 4. Minimization of FA 5. Closure Properties of FA Regular Language Page 20

21 1. Deterministic Finite Automata(DFA) deterministic if δ(q,a) consists of one state. We shall write "δ(q,a) = p " instead of δ(q,a) = {p} if deterministic. If δ(q,a) always has exactly one number, We say that M is completely specified. extension of δ : Q x Q x * δ(q, ε ) = q δ(q,xa) = δ(δ(q,x),a), where x * and a. A sentence x is said to be accepted by M if δ(q 0, x) = p, for some p F. The language accepted by M : L(M) = { x δ(q 0,x) F } Regular Language Page 21

22 ex) M = ( {p, q, r}, {0, 1}, δ, p, {r} ) δ : δ(p,0) = q δ(q,0) = r δ(r,0) = r 1001 L(M)? δ(p,1) = p δ(q,1) = p δ(r,1) = r δ(p,1001) = δ(p,001) = δ(q,01) = δ(r,1) = r F L(M) L(M)? δ(p,1010) = δ(p,010) = δ(q,10) = δ(p,0) = q F L(M). δ : matrix 형태로 transition table. ex) δ Input symbols 0 1 p q p q r p r r r Regular Language Page 22

23 Definition : State (or Transition) diagram for automaton. The state diagram consists of a node for every state and a directed arc from state q to state p with label a if δ(q,a) = p. Final states are indicated by a double circle and the initial state is marked by an arrow labeled start. start 1 p 0 1 q 0 r 0, 1 (1+01) * 00(0+1) * Identifier : letter, digit start S letter A Regular Language Page 23

24 Algorithm : w? L(M). assume M = (Q,, δ, q 0, F); begin currentstate := q 0 ; (* start state *) get(nextsymbol); while not eof do begin currentstate := δ(currentstate, nextsymbol); get(nextsymbol) end; if currentstate in F then write( Valid String ) else write( Invalid String ); end. Text p. 82 Regular Language Page 24

25 2. Nondeterministic Finite Automata(NFA) nondeterministic if δ(q,a) = {p 1, p 2,..., p n } In state q, scanning input data a, moves input head one symbol right and chooses any one of p 1, p 2,..., p n as the next state. ex) NFA (Nondeterministic Finite Automata) M = ( {q 0,q 1,q 2,q 3,q f }, {0,1}, δ, q 0, {q f } ) δ 0 1 q 0 {q 1, q 2 } {q 1, q 3 } q 1 {q 1, q 2 } {q 1, q 3 } q 2 {q f } φ q 3 φ {q f } q f {q f } {q f } if δ(q,a) = φ, then δ(q,a) is undefined. Regular Language Page 25

26 To define the language recognized by NFA, we must extend δ. (i) δ : Q x * 2 Q δ( q, ε ) = { q } δ( q, xa ) = U δ(p,a), where a V T and x V T *. p δ( q, x ) (ii) δ : 2 Q x * 2 Q δ({p 1, p 2,..., p k }, x) = k i=1 δ (p i,x) Definition : A sentence x is accepted by M if there is a state p in both F and δ(q 0, x). ex) 1011 L(M)? δ(q 0, 1011) = δ({q 1,q 3 }, 011) = δ({q 1,q 2 },11) = δ({q 1,q 3 },1) = {q 1,q 3,q f } 1011 L(M) ( {q 1,q 3,q f } {q f } Φ) ex) 0100 L(M)? Regular Language Page 26

27 Nondeterministic behavior q 0 q 1 q 3 q 1 q 2 φ q 1 q 3 φ q 1 q 3 q f If the number of states Q = m and input length x = n, then there are m n nodes. In general, NFA can not be easily simulated by a simple program, but DFA can be simulated easily. And so we shall see DFA is constructible from the NFA. Regular Language Page 27

28 3. Converting NFA into DFA Text p. 86 NFA : easily describe the real world. DFA : easily simulated by a simple program. ===> Fortunately, for each NFA we can find a DFA accepting the same language. Accepting Sequence(NFA) δ(q 0, a 1 a 2... a n ) = δ({q 1,q 2,,q i }, a 2 a 3... a n ) = δ({p 1,p 2,,p j }, a i... a n ) = {r 1,r 2,...,r k } Since the states of the DFA represent subsets of the set of all states of the NFA, this algorithm is often called the subset construction. Regular Language Page 28

29 [Theorem] Let L be a language accepted by NFA. Then there exists DFA which accepts L. Text p.86 (proof) Let M = (Q,, δ, q 0, F) be a NFA accepting L. Define DFA M' = (Q',, δ', q 0 ', F') such that (1) Q' = 2 Q, {q 1, q 2,..., q i } Q', where q i Q. denote a set of Q' as [q 1, q 2,..., q i ]. (2) q 0 ' = {q 0 } = [q 0 ] (3) F' = {[r 1, r 2,..., r k ] r i F} (4) δ' : δ' ([q 1, q 2,...,q i ], a) = [p 1, p 2,..., p j ] if δ({q 1, q 2,..., q j }, a) = {p 1, p 2,..., p j }. Now we must prove that L(M) = L(M ) i.e, δ' (q 0 ',x) F' δ(q 0, x) F φ. we can easily show that by inductive hypothesis on the length of the input string x. Regular Language Page 29

30 ex1) M = ({q 0,q 1 }, {0,1}, δ, q 0, {q 1 }), δ 0 1 q 0 {q 0, q 1 } {q 0 } q 1 φ {q 0, q 1 } dfa M' = (Q',, δ', q 0 ', F'), where Q' = 2 Q = {[q 0 ], [q 1 ], [q 0,q 1 ]} q 0 ' = [q 0 ] F' = {[q 1 ], [q 0,q 1 ]} δ' :δ'([q 0 ],0) = δ({q 0 },0) = {q 0,q 1 } = [q 0,q 1 ] δ'([q 0 ],1) = {q 0 } = [q 0 ] δ' ([q 1 ],0) = δ(q 1,0) = φ δ' ([q 1 ],1) = δ(q 1,1) = {q 0,q 1 } = [q 0,q 1 ] δ' ([q 0,q 1 ],0) = δ({q 0,q 1 },0) = {q 0,q 1 } = [q 0,q 1 ] δ' ([q 0,q 1 ],1) = δ({q 0,q 1 },1) = {q 0,q 1 } = [q 0,q 1 ] Regular Language Page 30

31 State renaming : [q 0 ] = A, [q 1 ] = B, [q 0,q 1 ] = C. δ 0 1 A C A B φ C C C C 1 B 1 0, 1 start A 0 C Since B is an inaccessible state, it can be removed. 1 0, 1 start A 0 C Regular Language Page 31

32 Definition : we call a state p accessible if there is w such * that (q 0, w) (p, ε), where q 0 is the initial state. ex2) NFA DFA NFA : δ 0 1 q 0 {q 1,q 2 } {q 1,q 3 } q 1 {q 1,q 2 } {q 1,q 3 } q 2 {q f } φ q 3 φ {q f } q f {q f } {q f } DFA : δ 0 1 q 0 q 1 q 2 q 1 q 3 q 1 q 2 q 1 q 2 q f q 1 q 3 q 1 q 3 q 1 q 2 q 1 q 3 q f q 1 q 2 q f q 1 q 2 q f q 1 q 3 q f q 1 q 3 q f q 1 q 2 q f q 1 q 3 q f Regular Language Page 32

33 Definition : ε - NFA M = (Q,, δ, q 0, F) δ : Q ( {ε} ) 2 Q ε - CLOSURE : ε 을보고갈수있는상태들의집합 s 가하나의상태 ε-closure(s) = {s} {q (p, ε)=q, p ε-closure(s)} T 가하나이상의상태집합인경우 ε-closure(t) = ex) ε - NFA 에서 CLOSURE 를구하기 start a A ε B ε-closure(q) q T a b C ε D a ε CLOSURE (A) = {A, B, D} CLOSURE({A,C}) = CLOSURE(A) CLOSURE(C) = {A, B, C, D} Regular Language Page 33

34 Ex) ε - NFA DFA a 2 b start A a B b D start 1 ε c 3 ε 4 c c C δ CLOSURE(1) = {1,3,4} CLOSURE(2) = {2} [1,3,4] [2] a b φ c CLOSURE(3) = {3,4} [3,4] [2] φ CLOSURE(4) = {4} [4] φ [3,4] φ φ CLOSURE(3) = {3,4} [3,4] [4] φ φ φ A = [1,3,4], B = [2], C = [3,4], D = [4] Regular Language Page 34

35 4. Minimization of FA Text p. 95 State minimization => state merge Definition : ω * distinguishes q 1 from q 2 if δ(q 1,ω) = q 3, δ(q 2,ω) = q 4 and exactly one of q 3, q 4 is in F. Algorithm : equivalence relation( ) partition. (1) : final state 인가아닌가로 partition. (2) : input symbol 에따라다른 equivalence class 로가는가? 그 symbol 로 distinguish 된다고함. : (3) : 더이상 partition 이일어나지않을때까지. The states that can not be distinguished are merged into a single state. Regular Language Page 35

36 Ex) a b A a a F b a Text p D b b C b B a a E b : {A,F}, {B, C, D, E} : 처음에 final, nonfinal로분할한다. : {A,F}, {B,E}, {C,D} : {B, C, D, E} 가 input symbol b에의해 partition 됨 : {A,F}, {B,E}, {C,D}. δ [AF] [BE] [CD] a [AF] [BE] [CD] b [BE] [CD] [AF] Regular Language Page 36

37 How to minimize the number of states in a fa. <step 1> Delete all inaccessible states; <step 2> Construct the equivalence relations; <step 3> Construct fa M = (Q,, δ, q 0, F ), (a) Q : set of equivalence classes under Let [p] be the equivalence class of state p under. (b) δ ([p],a) = [q] if δ(p,a) = q. (c) q 0 is [q 0 ]. (d) F' = {[q] q F}. Definition : M is said to be reduced. if (1) no state in Q is inaccessible and (2) no two distinct states of Q are indistinguishable Regular Language Page 37

38 ex) Find the minimum state finite automaton for the language specified by the finite automaton M = ({A,B,C,D,E,F}, {0,1}, δ, A, {E,F}), where δ is given by δ A B C D E F 0 1 B E A F D D C F A E F E Text p (2) : {A, B, C, D}, {E, F} : {A}, {C}, {B, D}, {E, F} δ 0 1 [A]=p [C]=q r p q p [B,D]=r s s [E, F]=s r s Regular Language Page 38

39 Programming < 연습문제 3.20> --- 교과서 121 쪽 NFA NFA to DFA DFA Minimization of DFA Reduced DFA Input Design Data Structure Regular Language Page 39

40 5. Closure properties of FA [Theorem] If L 1 and L 2 are finite automaton languages (FAL), then so are (i) L 1 U L 2 (ii) L 1 L 2 (iii) L 1 *. (proof) M 1 = (Q 1,, δ1, q 1, F 1 ) M 2 = (Q 2,, δ2, q 2, F 2 ), Q 1 Q 2 = φ ( renaming) (i) M = (Q 1 U Q 2 U {q 0 },, δ, q 0, F) where, (1) q 0 is a new state. (2) F = F 1 U F 2 if ε L 1 U L 2. F 1 U F 2 U {q 0 } if ε L 1 U L 2. (3) (a) δ(q 0,a) = δ(q 1,a) U δ(q 2,a) for all a. (b) δ(q,a) = δ1(q,a) for all q Q 1, a. (c) δ(q,a) = δ2(q,a) for all q Q 2, a. 새로운시작상태를만들어각각의 fa 에마치각 fa 의시작상태에서온것처럼연결한다. 그리고 ε 를인식하면새로만든시작상태도종결상태로만든다. ex) p.98 [ 예 28] Regular Language Page 40

41 (ii) M = (Q 1 U Q 2,, δ, q 0, F) (1) F = F 2 if q 2 F 2 F 1 U F 2 if q 2 F 2 (2) (a) δ(q,a) = δ1(q,a) for all q Q 1 - F 1. (b) δ(q,a) = δ1(q,a) U δ2(q 2,a) for all q F 1. (c) δ(q,a) = δ2(q,a) for all q Q 2. M 1 의종결상태에서 M 2 의시작상태에서온것처럼연결한다. 그리고 M 1 의시작상태가접속한오토마타의시작상태가된다. 1 0 M 1 : start A B => 01 * 1 0 M 2 : start X Y => 01 * A B Y M 1 M 2 : start => 01 * 01 * 1 Regular Language Page 41

42 정규언어의속성 Regular grammar (rg) Finite automata (fa) Regular expression (re) re ===> fa : scanner generator Regular Language Page 42

43 목차 1. RG & FA 2. FA & RE 3. Closure Properties of Regular Language 4. The Pumping Lemma for Regular Language Regular Language Page 43

44 1. RG & FA Given rg, there exists a fa that accepts the same language generated by rg and vice versa. rg fa Given rg, G = (V N, V T, P, S), construct M = (Q,, δ, q 0, F). (1) Q = V N U {f}, where f is a new final state. (2) = V T. (3) q 0 = S. (4) F = {f} if ε L(G) = {S, f} otherwise. (5) δ : if A ab P then δ(a,a) B. if A a P then δ(a,a) f. Regular Language Page 44

45 (proof) If ω is accepted by fa then it is accepted in some sequence of moves through states, ending in f. But if δ(a,a) = B and B f, then A ab is a productions. Also if δ(a,a) = f then A a is a production. So we can use the same series of productions to generate ω in G * Thus S => ω. ex) p.101 [ 예 29] Regular Language Page 45

46 fa rg Given M = (Q,, δ, q 0, F), construct G = (V N, V T, P, S). (1) V N = Q (2) V T = ex) (3) S = q 0 (4) P : if δ(q,a) = r then q ar. start if p F then p ε. 1 p 0 1 q p 1p 0q q 1p 0r r 0r 1r ε 0 r 0, 1 L(P)=(1+01) * 00(0+1) * Regular Language Page 46

47 2. FA & RE fa rg re ex) p (1) b a start A a B b b a C a b D A = ba + ab B = ab + bc C = ab + bd D = ab + ba + ε = A + ε A = (a+b)*abb Regular Language Page 47

48 re fa ( scanner generator) For each component, we construct a fa inductively : 1. basis ε : i ε f a Σ : i a f 2. induction - combine the components. (1) N 1 + N 2 ε N 1 ε i f ε N 2 ε Regular Language Page 48

49 (2) N 1 N 2 ε i N 1 N 2 f (3) N * ε i ε N ε f ε Regular Language Page 49

50 Definition : The size of a regular expression is the number of operations and operands in the expression. ex) size(ab + c*) = 6 decomposition: R6 R3 + R5 R1. R2 R4 * a b c The number of state is at most twice the size of the expression. ( each operand introduces two states and each operator introduces at most two states.) The number of arcs is at most four times the size of the expression. Regular Language Page 50

51 Simplifications : p.106 ε -arc 로연결된두상태는소스상태에서나가는다른 arc 가 없으면같은상태로취급될수있다. A ε a ex) p.105 [ 예 31] B A re ε-nfa ( 간단화 ) DFA ex) p.109 [ 예 33] a The following statements are equivalent : 1. L is generated by some regular grammar. 2. L is recognized by some finite automata. 3. L is described by some regular expression. Regular Language Page 51

52 p (1) (b + a(aa* b)*b)* b X a b Y a b Z a (2) (b + aa + ac + aaa + aac)* b X a a, c Y a Z a, c (3) a(a+b)*b(a+b)*a(a+b)*b(a+b)* S a, b a, b a, b a, b a b a b W X Y Z Regular Language Page 52

53 3. Closure Properties of Regular Language [Theorem] If L 1 and L 2 are regular languages, then so are (i) L 1 U L 2, (ii) L 1 L 2, and (iii) L * 1. (proof) (ii) Since L 1 and L 2 are rl, rg G 1 = (V N1, V T1, P 1, S 1 ) and rg G 2 = (V N2,V T2, P 2, S 2 ), such that L(G 1 ) = L 1 and L(G 2 ) = L 2. Construct G=(V N1 U V N2,V T1 U V T2, P, S 1 ) in which P is defined as follows : (1) If A ab P 1, A ab P. (2) If A a P 1, A as 2 P. (3) All productions in P 2 are in P. We must prove that L(G) = L(G 1 ). L(G 2 ). Since G is rg, L(G) is rl. Therefore L(G 1 ). L(G 2 ) is rl. ex) P 1 : S as ba A aa a P 2 : X 0X 1Y Y 0Y 1 P : S as ba A aa ax X 0X 1Y Y 0Y 1 Regular Language Page 53

54 (iii) L : rl, rg G = (V N, V T, P, S) such that L(G) = L. Let G' = (V N U {S'}, V T, P', S') P' : (1) If A ab P, then A ab P'. (2) If A a P, then A a, A as' P'. (3) S' S ε P'. We must prove that L(G') = (L(G))*. * * * ω L(G), S => ω. S' => S => ws' => w * S' => w *. (L(G))* = L(G'). ex) P : S as, S b P' : S as, S b, S bs', S' S, S' ε. note P : S = as + b = a*b P' : S = as + b + bs' = a*(b+bs') = a*b + a*bs' S' = S + ε = a*bs' + a*b + ε = (a*b)*(a*b + ε ) = (a*b)*(a*b) + (a*b)* = (a*b)* Regular Language Page 54

55 4. The Pumping Lemma for Regular Language It is useful in proving certain languages not to be regular. [Theorem] Let L be a regular language. There exists a constant p such that if a string w is in L and ω p, then w can be written as xyz, where 0 < y p and xy i z L for all i 0. (proof) Let M = (Q,, δ, q 0, F) be a fa with n states such that L(M) = L. Let p = n. If ω L and ω n, then consider the sequence of configurations entered by M in accepting w. Since there are at least n+1 configurations in the sequence, there must be two with the same state among the first n+1 configurations. Thus we have a sequence of moves such that δ(q 0,xyz) = δ(q 1,yz) = δ δ(q 1,z) = q f F for some q 1. y q 0 x q 1 z q f But then, δ(q 0,xy i z) = δ(q 1,y i z) = δ(q 1,y i-1 z) =... = δ(q 1,z) = q f F. Since w = xyz L, xy i z L for all i 0. Regular Language Page 55

56 Consequently, we say that finite automata can not count, meaning they can not accept a language which requires that they count the number exactly. ex) L = {0 n 1 n n 1} is not type 3. (Proof) Suppose that L is regular. Then for a sufficiently large n, 0 n 1 n can be written as xyz such that y 0 and xy i z L for all i 0. If y 0 + or y 1 +, then xz = xy 0 z L. If y , then xyz L. We have a contradiction, so L can not be regular. a n cb n not rl a n cb m rl Regular Language Page 56

57 연습문제 3.5 풀이교과서 116 쪽 A = ab + ba (1) B = ab + bc (2) C = bd + ab (3) D = ba + ab + ε (4) 식 (4) 에서 ba + ab = ab + ba = A 이므로 D = A + ε (5) 식 (3) 에식 (5) 를대입 C = b(a + ε) + ab = ba + ab + b = A + b (6) 식 (2) 에식 (6) 을대입 B = ab + b(a + b) = ab + ba + bb = A + bb (7) 식 (1) 에식 (7) 을대입 A = ab + ba = a(a + bb) + ba = aa + abb + ba = (a + b)a + abb = (a+b)*abb L(G) = (a+b)*abb Regular Language Page 57

Page 1. Compiler Lecture Note, (Regular Language) 컴파일러입문 제 3 장 정규언어. Database Lab. KHU

Page 1. Compiler Lecture Note, (Regular Language) 컴파일러입문 제 3 장 정규언어. Database Lab. KHU Page 1 컴파일러입문 제 3 장 정규언어 Page 2 목차 I. 정규문법과정규언어 II. 정규표현 III. 유한오토마타 VI. 정규언어의속성 Page 3 정규문법과정규언어 A study of the theory of regular languages is often justified by the fact that they model the lexical analysis

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

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

Chapter 5. Finite Automata

Chapter 5. Finite Automata Chapter 5 Finite Automata 5.1 Finite State Automata Capable of recognizing numerous symbol patterns, the class of regular languages Suitable for pattern-recognition type applications, such as the lexical

More information

Theory of Computation - Module 3

Theory of Computation - Module 3 Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of

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

Foundations of Informatics: a Bridging Course

Foundations of Informatics: a Bridging Course Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages

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

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 14 SMALL REVIEW FOR FINAL SOME Y/N QUESTIONS Q1 Given Σ =, there is L over Σ Yes: = {e} and L = {e} Σ Q2 There are uncountably

More information

Theory of Computation Turing Machine and Pushdown Automata

Theory of Computation Turing Machine and Pushdown Automata Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type

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

Deterministic Finite Automaton (DFA)

Deterministic Finite Automaton (DFA) 1 Lecture Overview Deterministic Finite Automata (DFA) o accepting a string o defining a language Nondeterministic Finite Automata (NFA) o converting to DFA (subset construction) o constructed from a regular

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013 Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction

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

UNIT II REGULAR LANGUAGES

UNIT II REGULAR LANGUAGES 1 UNIT II REGULAR LANGUAGES Introduction: A regular expression is a way of describing a regular language. The various operations are closure, union and concatenation. We can also find the equivalent regular

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

Introduction to Theory of Computing

Introduction to Theory of Computing CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages

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

Java II Finite Automata I

Java II Finite Automata I Java II Finite Automata I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz November, 23 Processing Regular Expressions We already learned about Java s regular expression

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

Section 1 (closed-book) Total points 30

Section 1 (closed-book) Total points 30 CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes

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

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

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

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

Lecture 17: Language Recognition

Lecture 17: Language Recognition Lecture 17: Language Recognition Finite State Automata Deterministic and Non-Deterministic Finite Automata Regular Expressions Push-Down Automata Turing Machines Modeling Computation When attempting to

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

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

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a. VTU QUESTION BANK Unit 1 Introduction to Finite Automata 1. Obtain DFAs to accept strings of a s and b s having exactly one a.(5m )( Dec-2014) 2. Obtain a DFA to accept strings of a s and b s having even

More information

Theory of Computation

Theory of Computation Thomas Zeugmann Hokkaido University Laboratory for Algorithmics http://www-alg.ist.hokudai.ac.jp/ thomas/toc/ Lecture 3: Finite State Automata Motivation In the previous lecture we learned how to formalize

More information

More on Finite Automata and Regular Languages. (NTU EE) Regular Languages Fall / 41

More on Finite Automata and Regular Languages. (NTU EE) Regular Languages Fall / 41 More on Finite Automata and Regular Languages (NTU EE) Regular Languages Fall 2016 1 / 41 Pumping Lemma is not a Sufficient Condition Example 1 We know L = {b m c m m > 0} is not regular. Let us consider

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

Pushdown Automata. Reading: Chapter 6

Pushdown Automata. Reading: Chapter 6 Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?

More information

Introduction to Formal Languages, Automata and Computability p.1/42

Introduction to Formal Languages, Automata and Computability p.1/42 Introduction to Formal Languages, Automata and Computability Pushdown Automata K. Krithivasan and R. Rama Introduction to Formal Languages, Automata and Computability p.1/42 Introduction We have considered

More information

Author: Vivek Kulkarni ( )

Author: Vivek Kulkarni ( ) Author: Vivek Kulkarni ( vivek_kulkarni@yahoo.com ) Chapter-3: Regular Expressions Solutions for Review Questions @ Oxford University Press 2013. All rights reserved. 1 Q.1 Define the following and give

More information

Chapter 3. Regular grammars

Chapter 3. Regular grammars Chapter 3 Regular grammars 59 3.1 Introduction Other view of the concept of language: not the formalization of the notion of effective procedure, but set of words satisfying a given set of rules Origin

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

Context-free Languages and Pushdown Automata

Context-free Languages and Pushdown Automata Context-free Languages and Pushdown Automata Finite Automata vs CFLs E.g., {a n b n } CFLs Regular From earlier results: Languages every regular language is a CFL but there are CFLs that are not regular

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

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

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam ECS 120: Theory of Computation Handout MT UC Davis Phillip Rogaway February 16, 2012 Midterm Exam Instructions: The exam has six pages, including this cover page, printed out two-sided (no more wasted

More information

Regular expressions and Kleene s theorem

Regular expressions and Kleene s theorem and Kleene s theorem Informatics 2A: Lecture 5 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 29 September 2016 1 / 21 1 More closure properties of regular languages Operations

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

Regular expressions and Kleene s theorem

Regular expressions and Kleene s theorem and Informatics 2A: Lecture 5 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 25 September, 2014 1 / 26 1 More closure properties of regular languages Operations on languages

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

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Outline Nondeterminism Regular expressions Elementary reductions http://www.cs.caltech.edu/~cs20/a October 8, 2002 1 Determistic Finite Automata A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Q is a finite

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014 Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary

More information

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3}, Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All

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

Question Bank UNIT I

Question Bank UNIT I Siddhivinayak Technical Campus School of Engineering & Research Technology Department of computer science and Engineering Session 2016-2017 Subject Name- Theory of Computation Subject Code-4KS05 Sr No.

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 5 CHAPTER 2 FINITE AUTOMATA 1. Deterministic Finite Automata DFA 2. Nondeterministic Finite Automata NDFA 3. Finite Automata

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

CISC4090: Theory of Computation

CISC4090: Theory of Computation CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter

More information

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata

More information

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor 60-354, Theory of Computation Fall 2013 Asish Mukhopadhyay School of Computer Science University of Windsor Pushdown Automata (PDA) PDA = ε-nfa + stack Acceptance ε-nfa enters a final state or Stack is

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

UNIT-VI PUSHDOWN AUTOMATA

UNIT-VI PUSHDOWN AUTOMATA Syllabus R09 Regulation UNIT-VI PUSHDOWN AUTOMATA The context free languages have a type of automaton that defined them. This automaton, called a pushdown automaton, is an extension of the nondeterministic

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

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

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

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

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

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages Context Free Languages Automata Theory and Formal Grammars: Lecture 6 Context Free Languages Last Time Decision procedures for FAs Minimum-state DFAs Today The Myhill-Nerode Theorem The Pumping Lemma Context-free

More information

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Finite Automata. BİL405 - Automata Theory and Formal Languages 1 Finite Automata BİL405 - Automata Theory and Formal Languages 1 Deterministic Finite Automata (DFA) A Deterministic Finite Automata (DFA) is a quintuple A = (Q,,, q 0, F) 1. Q is a finite set of states

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES Contents i SYLLABUS UNIT - I CHAPTER - 1 : AUT UTOMA OMATA Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 2 : FINITE AUT UTOMA OMATA An Informal Picture of Finite Automata,

More information

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

October 6, Equivalence of Pushdown Automata with Context-Free Gramm Equivalence of Pushdown Automata with Context-Free Grammar October 6, 2013 Motivation Motivation CFG and PDA are equivalent in power: a CFG generates a context-free language and a PDA recognizes a context-free

More information

SFWR ENG 2FA3. Solution to the Assignment #4

SFWR ENG 2FA3. Solution to the Assignment #4 SFWR ENG 2FA3. Solution to the Assignment #4 Total = 131, 100%= 115 The solutions below are often very detailed on purpose. Such level of details is not required from students solutions. Some questions

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

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 9 : Myhill-Nerode Theorem and applications

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 9 : Myhill-Nerode Theorem and applications COMP-33 Theory of Computation Fall 217 -- Prof. Claude Crépeau Lec. 9 : Myhill-Nerode Theorem and applications COMP 33 Fall 212: Lectures Schedule 1-2. Introduction 1.5. Some basic mathematics 2-3. Deterministic

More information

THEORY OF COMPUTATION

THEORY OF COMPUTATION THEORY OF COMPUTATION There are four sorts of men: He who knows not and knows not he knows not: he is a fool - shun him; He who knows not and knows he knows not: he is simple teach him; He who knows and

More information

Introduction to Formal Languages, Automata and Computability p.1/51

Introduction to Formal Languages, Automata and Computability p.1/51 Introduction to Formal Languages, Automata and Computability Finite State Automata K. Krithivasan and R. Rama Introduction to Formal Languages, Automata and Computability p.1/51 Introduction As another

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

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-500 014 Subject: FORMAL LANGUAGES AND AUTOMATA THEORY Class : CSE II PART A (SHORT ANSWER QUESTIONS) UNIT- I 1 Explain transition diagram, transition

More information

Theory Of Computation UNIT-II

Theory Of Computation UNIT-II Regular Expressions and Context Free Grammars: Regular expression formalism- equivalence with finite automata-regular sets and closure properties- pumping lemma for regular languages- decision algorithms

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

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions? Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)

More information

COM364 Automata Theory Lecture Note 2 - Nondeterminism

COM364 Automata Theory Lecture Note 2 - Nondeterminism COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly

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

DD2371 Automata Theory

DD2371 Automata Theory KTH CSC VT 2008 DD2371 Automata Theory Dilian Gurov Lecture Outline 1. The lecturer 2. Introduction to automata theory 3. Course syllabus 4. Course objectives 5. Course organization 6. First definitions

More information

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

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10 Regular Languages Andreas Karwath & Malte Helmert 1 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages

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

V Honors Theory of Computation

V Honors Theory of Computation V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant

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

An automaton with a finite number of states is called a Finite Automaton (FA) or Finite State Machine (FSM).

An automaton with a finite number of states is called a Finite Automaton (FA) or Finite State Machine (FSM). Automata The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled computing device which follows a predetermined

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of

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

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

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

Formal Languages, Automata and Models of Computation

Formal Languages, Automata and Models of Computation CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2011 1 Content - More Properties of Regular Languages (RL)

More information

Pushdown Automata: Introduction (2)

Pushdown Automata: Introduction (2) Pushdown Automata: Introduction Pushdown automaton (PDA) M = (K, Σ, Γ,, s, A) where K is a set of states Σ is an input alphabet Γ is a set of stack symbols s K is the start state A K is a set of accepting

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

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

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX

More information