Page 1. Compiler Lecture Note, (Regular Language) 컴파일러입문 제 3 장 정규언어. Database Lab. KHU
|
|
- Patrick May
- 5 years ago
- Views:
Transcription
1 Page 1 컴파일러입문 제 3 장 정규언어
2 Page 2 목차 I. 정규문법과정규언어 II. 정규표현 III. 유한오토마타 VI. 정규언어의속성
3 Page 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 : LLG : A tb, A t 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.
4 Page 4 Definition (1) A grammar is regular if each rule is i) A ab, A a, where a VT, A, B VN. ii) if S e 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
5 Page 5 [Theorem] The production forms of regular grammar can be derived from those of RLG.(RLG => RG) (proof) A -> tb, where t V T*. Let t = a1 a2... an, ai V T. A -> a 1 A 1 A 1 -> a 2 A 2. A n-1 -> a n B. Right-linear grammar : A -> tb or A -> t, where A,B V N and t V T *. If t = e, then A -> B (single production) or A -> e (epsilon production). Þ These forms of productions can be easily removed. (Text pp ) ex) S -> abca A -> bca A -> cd Þ S -> as1, S1 -> bs2 S2 -> ca Þ A -> ba1, A1 -> ca Þ A -> ca1', A1' -> d
6 Page 6 Equivalence 1. 언어 L 은우선형문법에의해생성된다. 2. 언어 L 은좌선형문법에의해생성된다. 3. 언어 L 은정규문법에의해생성된다. 정규언어 [ 예 ] L = {a n b m n,m >= 0 } : rl S -> as aa A -> ba b
7 Page 7 토큰의구조를정의하는데정규언어를사용하는이유 (1) 토큰의구조는간단하기때문에정규문법으로표현할수있다. (2) context-free 문법보다는정규문법으로부터효율적인인식기를구현할수있다. (3) 컴파일러의전반부를모듈러하게나누어구성할수있다. (Scanner + Parser) 문법의형태가정규문법이면그문법이나타내는언어의형태를체계적으로구하여정규표현으로나타낼수있다. G derivation L if G = rg, L: re.
8 Page 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
9 Page 9 Definition : A regular expression over the alphabet T and the language denoted by that expression are defined recursively as follows : I. Basis : f, e, a T. (1) f is a regular expression denoting the empty set. (2) e is a regular expression denoting {e}. (3) a where a T is a regular expression denoting {a}. II. Recurse : +,, * If P and Q are regular expressions denoting Lp and Lq respectively, then (1) (P + Q) is a regular expression denoting Lp U Lq. (union) (2) (P Q) is a regular expression denoting Lp Lq. (concatenation) (3) (P*) is a regular expression denoting (closure) {e} U Lp U Lp 2 U... U Lp n... Note : precedence : + < < * III. Nothing else is a regular expression.
10 Page 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 a is a regular expression, L(a) denotes the language associated with a. (Text p.74) Let a and b be regular expressions. Then, (1) L(a + b) = L(a) + L(b) (2) L(a b) = L(a) L(b) (3) L(a * ) = L(a) * examples : (1) L(a * ) = {e, 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.122 = { b, ba, bab, ab, bb, aab, bbb, }
11 Page 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 α, β and γ be regular expressions. Then, (Text p.75) Α1. α + β = β + α Α2. (α + β) + γ = α + (β + γ) Α3. (α β) γ = α (β γ) Α4. α (β + γ) = α β + α γ Α5. (β + γ) α = β α + γ α Α6. α + α = α Α7. α + φ = α Α8. α φ = φ = φ α Α9. ε α = α = α ε Α10. α = ε + α α Α11. α = (ε + α) Α12. (α ) = α Α13. α + α = α Α14. α + α + = α Α15. (α + β) = (α β )
12 Page 12 All of these identities(=axioms) are easily proved by the definition of regular expression. A8. a f = f = f a (proof) a f = { xy x L a and y L f } Since y L f is false, (x L a and y L f ) is false. Thus a f = f. Definitions : regular expression equations. ::= the set of equations whose coefficient are regular expressions. ex) a, b 가정규표현이면, X = ax+b 가정규표현식이다. 이때, X 의의미는 nonterminal 심볼이며우측의식이그 nonterminal 이생성하는언어의형태이다.
13 Page 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 +...)β = α*β.
14 Page 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
15 Page 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 = α * β.
16 Page 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)
17 Page 17 Homework 1 ex3) A 0B 1A ex4) S aa bs B 1A 0C A as bb C 0C 1C ε 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 ex7) A 1 = (01* + 1) A 1 + A 2 A 2 = A A 3 A 3 = A 1 + A 2 + ε ex9) X α 1 X + α 2 Y + α 3 Y β 1 X + β 2 Y + β 3 ex8) A ab ba B ab bc C bd ab D ba ab ε ex10) PR b DL SL e DL d ; DL ε SL SL ; s s
18 Page 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. a 0 a 1 a 2... a i a i+1 a i+2... a n input Input head Finite State Control Auxiliary Storage Turing Machine Linear Bounded A PushDown Automata Finite Automata
19 Page 19 Definition : fa 유한오토마타 A finite automaton M over an alphabet is a system (Q,, δ,q0,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. G = (V N, V T, P, S) mapping δ : Q x 2 Q. i,e. δ(q,a) = {p 1, p 2,..., p n } re : φ, ε, a, +,, * M = (Q,, δ, q 0, F) DFA, NFA.
20 Page 20 차례 - FA 1. DFA 2. NFA 3. Converting NFA into DFA 4. Minimization of FA 5. Closure properties of FA
21 Page 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 }
22 Page 22 ex) M = ( {p, q, r}, {0, 1}, δ, p, {r} ) δ : δ(p,0) = q δ(p,1) = p δ(q,0) = r δ(q,1) = p δ(r,0) = r δ(r,1) = r 1001 L(M)? δ(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
23 Page 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. 0, start p q 0 r 1 (1+01)*00(0+1)* Identifier : letter, digit start S letter A
24 Page 24 Algorithm : ω 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.85
25 Page 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 4 {q f } {q f } if δ(q,a) = φ, then δ(q,a) is undefined.
26 Page 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) = Definition : A sentence x is accepted by M ex) 1011 L(M)? if there is a state p in both F and δ(q 0, x). δ({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)? k i= 1 δ ( p i, x)
27 Page 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 constructable from the NFA.
28 Page Converting NFA into DFA Text p.89 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.
29 Page 29 [Theorem] Let L be a language accepted by NFA. Then there exists DFA which accepts L. Text p.89 (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.
30 Page 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 ]
31 Page 31 State renaming : [q 0 ] = A, [q 1 ] = B, [q 0,q 1 ] = C. δ 0 1 A C A B φ C C C C B start A C 0,1 Since B is an inaccessible state, it can be removed. start A 1 0 C 0,1
32 Page 32 Definition : we call a state p accessible if there is ω such that (q 0, ω) * (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
33 Page 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) = ε CLOSURE( q) q T ex) ε - NFA 에서 CLOSURE 를구하기 start a A ε a b B C ε D a ε CLOSURE (A) = {A, B, D} CLOSURE({A,C}) = CLOSURE(A) CLOSURE(C) = {A, B, C, D}
34 Page 34 Ex) ε - NFA DFA CLOSURE(3) = {3,4} [3,4] a 2 b start A a B b D start 1 ε c 3 ε 4 c c C CLOSURE(1) = {1,3,4} [1,3,4] CLOSURE(2) = {2} [2] CLOSURE(3) = {3,4} [3,4] CLOSURE(4) = {4} [4] a b c δ A = [1,3,4], B = [2], C = [3,4], D = [4] [2] φ φ φ φ [3,4] [4] φ φ φ [3,4] φ
35 Page Minimization of FA Text p.98 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.
36 Page 36 Ex) a a A F b b a D b b C b B a a E b a : {A,F}, {B, C, D, E} : 처음에 final, non-final 로분할한다. : {A,F}, {B,E}, {C,D} : {B, C, D, E} 가 input symbol 에의해 partition 됨 : {A,F}, {B,E}, {C,D}. δ a b [AF] [AF] [BE] [BE] [BE] [CD] [CD] [CD] [AF]
37 Page 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.
38 Page 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 δ 0 1 A B C B E F C A A D F E E D F F D E Text p (2) : {A, B, C, D}, {E, F} : {A, C}, {B, D}, {E, F} δ 0 1 [A,C] = p q p [B,D] = q r r [E,F] = r q r
39 Page 39 Programming < 연습문제 3.20> --- 교과서 127 쪽 NFA NFA_to_DFA DFA Minimization_of_DFA Reduced DFA Input Design Data Structure
40 Page 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.103 [ 예 28]
41 Page 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 M 1 : start A 0 B => 01* M 2 : start X 0 Y 1 1 => 01* M 1 M 2 : start 0 A B Y 0 => 01*01* 1
42 Page 42 (iii) L : FAL => L * : FAL. Construct M' = (Q U {q 0 '},, δ ', q 0 ', FU{q 0 '}), δ ' : (1) δ '(q,a) = δ(q,a) if q Q - F and a. (2) δ '(q,a) = δ(q,a) U δ(q 0,a) if q F, a. (3) δ '(q 0 ',a) = δ(q 0,a) for all a. 새로운시작상태를만들어마치기존의시작상태에서온것처럼연결한다. 또한, 종결상태들에대해서도시작상태처럼 arc 를추가한다. M : 0 A 1 B 0, 1 δ '(B,0) = δ(b,0) U δ(a,0) = {B,A} δ '(B,1) = δ(b,1) U δ(a,1) = {B} M ' : q 0 ' 0 0 A δ '(q 0 ',0) = δ(a,0) = {A} δ '(q 0 ',1) = δ(a,1) = {B}. 1 0 B 0, 1 1
43 Page 43 [Theorem] L : FAL => L R : FAL (proof) M = (Q,, δ, q 0, F) Construct M' = (Q U {q 0 '},, δ ', q 0 ', F'), where F = {q 0 } if ε L. {q 0,q 0 '} if ε L. δ : (1) δ '(q 0 ',a) contains q if δ(q,a) F. (2) For all q' Q' and a, δ '(q',a) contains q if δ(q,a) = q'. It is easy to show that δ(q 0, ω) F iff δ '(q 0 ', ω R ) F' = φ. 새로운시작상태를만들어마치종결상태들에서간것처럼연결한다. 그리고나머지는모두역방향으로만든다. ex) 0 M : A 1 B 0, 1 0*1(0+1)* M ' : 0 1 q 0 ' A 0 B 0, 1 (0+1)* 10* 0, 1
44 Page 44 정규언어의속성 regular grammar (rg) finite automata (fa) regular expression (re) re ===> fa : scanner generator 1. RG & FA 2. FA & RE
45 Page 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) F = {S, f} otherwise. (5) δ : if A ab P then δ(a,a) B. if A a P then δ(a,a) f.
46 Page 46 (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.105 [ 예 29]
47 Page 47 fa rg Given M = (Q,, δ, q 0, F), construct G = (V N, V T, P, S). (1) V N = Q (2) V T = (3) S = q 0 (4) P : if δ(q,a) = r then q ar. if p F then p ε. ex) start p q p 1p 0q q 1p 0r r 0r 1r ε 0 0, 1 r L(P) = (1+01)*00(1+0)*
48 Page FA & RE fa rg re ex) p (1) b a start A B C a b a a b D b A = ba + ab B = ab + bc C = ab + bd D = ab + ba + ε = A + ε A = (a+b)*abb
49 Page 49 re fa ( scanner generator) For each component, we construct a fa inductively : 1. basis ε : i f a Σ : i f ε a 2. induction - combine the components. (1) N 1 + N 2 ε N 1 ε i ε ε f N 2
50 Page 50 (2) N 1 N 2 i ε N 1 N 2 f (3) N* ε i ε N ε f ε ex) p.110 [ 예 31]
51 Page 51 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.
52 Page 52 Simplifications : p.111 ε -arc 로연결된두상태는소스상태에서나가는다른 arc 가없으면같은상태로취급될수있다. A ε a B A a ex) p.96 [ 예 31] re ε-nfa ( 간단화 ) DFA ex) p.114 [ 예 33] 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.
53 Page 53 p (1) (b + a(aa*b)*b)* b a X Y Z b a b 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)* a a, b a, b a, b a, b b S W X Y Z a b
54 Page 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
55 Page 55 (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 =>* ωs' =>* ω * S' => ω *. (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)*
56 Page 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 ω is in L and ω p, then ω 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. x q 0 q 1 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. y z
57 Page 57 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 ω and xy i z L for all i 0. If y 0 + or y 1 +, then xz = xy 0 z L. If y , then xyyz L. We have a contradiction, so L can not be regular. a n cb n not rl a n cb m rl
58 Page 58 HW #2 연습문제 3.5 풀이교과서 122 쪽 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
컴파일러입문 제 3 장 정규언어
컴파일러입문 제 3 장 정규언어 목차 3.1 정규문법과정규언어 3.2 정규표현 3.3 유한오토마타 3.4 정규언어의속성 Regular Language Page 2 정규문법과정규언어 A study of the theory of regular languages is often justified by the fact that they model the lexical
More informationFORMAL 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 informationTheory 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 informationClosure 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 informationUses 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 informationFORMAL 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 informationTheory 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 informationFoundations 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 informationChapter 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 informationTHEORY 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 informationCS 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 informationTheory 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 informationNondeterministic 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 informationFinite 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 informationcse303 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 informationAC68 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 informationHarvard 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 informationIncorrect 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 informationTheory 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 informationIntroduction 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 informationSri 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 informationLecture 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 informationSection 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 informationUNIT 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 informationChapter 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 informationWhat 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 informationGEETANJALI 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 informationJava 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 informationacs-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 informationTheory 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 informationPushdown 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 informationTAFL 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 informationMore 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 informationCS 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 informationComputational 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 informationCS 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 informationCS 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 informationTheory 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 informationFinite 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 informationVTU 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 informationCISC4090: 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 informationLecture 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 informationThis lecture covers Chapter 7 of HMU: Properties of CFLs
This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal
More informationUNIT-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 informationProperties 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 informationAuthor: 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 informationChapter 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 informationUNIT-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 informationRecap 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 informationDeterministic 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 informationAutomata: 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 informationChapter 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 informationCMSC 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 informationFinite 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 informationQuestion 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 informationCS 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 informationSFWR 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 information60-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 information3515ICT: 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 informationPushdown 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 informationBefore 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 informationHomomorphisms and Efficient State Minimization
Homomorphisms and Efficient State Minimization Mridul Aanjaneya Stanford University July 10, 2012 Mridul Aanjaneya Automata Theory 1/ 23 Homomorphisms A homomorphism on an alphabet is a function that gives
More informationPS2 - 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 informationIntroduction 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 informationContext 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 informationOctober 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 informationCOMP-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 informationAC68 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},
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 informationUNIT-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 informationLecture 11 Context-Free Languages
Lecture 11 Context-Free Languages COT 4420 Theory of Computation Chapter 5 Context-Free Languages n { a b : n n { ww } 0} R Regular Languages a *b* ( a + b) * Example 1 G = ({S}, {a, b}, S, P) Derivations:
More informationComputational 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 informationcse303 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 informationCS375: 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 informationLecture 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 informationSeptember 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 informationAn 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 informationECS 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 informationdownload instant at Assume that (w R ) R = w for all strings w Σ of length n or less.
Chapter 2 Languages 3. We prove, by induction on the length of the string, that w = (w R ) R for every string w Σ. Basis: The basis consists of the null string. In this case, (λ R ) R = (λ) R = λ as desired.
More informationCISC 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 informationCSE 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 informationDD2371 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 informationOutline. 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 informationName: 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 informationTHEORY 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 informationAutomata 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 informationFinite 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 informationMA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online
More informationContext-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 informationIntroduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.
Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.
More informationTheory 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 informationCS A Term 2009: Foundations of Computer Science. Homework 2. By Li Feng, Shweta Srivastava, and Carolina Ruiz.
CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 2 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 4 Problem 1: (10 Points) Exercise 4.3 Solution 1: S is
More informationCS154. Non-Regular Languages, Minimizing DFAs
CS54 Non-Regular Languages, Minimizing FAs CS54 Homework is due! Homework 2 will appear this afternoon 2 The Pumping Lemma: Structure in Regular Languages Let L be a regular language Then there is a positive
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form:
More informationProperties of Regular Languages (2015/10/15)
Chapter 4 Properties of Regular Languages (25//5) Pasbag, Turkey Outline 4. Proving Languages Not to e Regular 4.2 Closure Properties of Regular Languages 4.3 Decision Properties of Regular Languages 4.4
More informationIntroduction 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 informationTasks 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 informationPart 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 informationLanguages, 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 informationUNIT-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