THEOTY OF COMPUTATION

Size: px
Start display at page:

Download "THEOTY OF COMPUTATION"

Transcription

1 Pushdown utomt nd Prsing lgorithms: Pushdown utomt nd context-free lnguges; Deterministic PDNondeterministic PD- Equivlence of PD nd CFG-closure properties of CFL. PUSHDOWN UTOMT ppliction: Regulr lnguges re those which re ccepted by finite utomt but lnguge such s l=( n b n /n>=1) cnnot be ccepted by regulr lnguge becuse it hs to precisely remember the number of s nd b s which would require infinite number of sttes. Hence push down utomt hs been designed to ccept context free lnguges. This is done by dding uxiliry memory in the form of stck. Definitions: The pushdown utomt formlly consist of 7 tuples given by M=(Q,,δ,,q 0,z 0,F) Where, Q: finite non empty set of sttes : finite non empty set of input symbols δ: the trnsition function from q ( U{^}) to the set of finite subsets Q * : finite non empty set of push down symbols q 0 : specil stte clled initil stte z 0 : specil push down symbols clled the initil symbols on the pushdown store denoted by z 0. In other words indictes the top of the stck F: the pushdown symbol denoting the finl stte. COMPONENTS OF PUSH DOWN UTOMT: The following digrm denotes the bsic model of pushdown utomt.. string detection removing direction finite stte control push down store J. Veerendeswri /IT/ RGCET Pge 1

2 It hs red only input tpe, input lphbet, finite stte control, set of finl sttes nd n initil stte s in the cse of finite utomt. ut in ddition to this it hs stck clled the pushdown store, it is red write pushdown store s we dd elements to the PDS or remove elements from PDS. finite utomt is in sme stte nd on reding n input symbol the top most symbol in PDS moves to new stte nd writes string of symbols in the PDS. DESIGN FOR PUSH DOWN UTOMT: Consider the context free lnguges n b n, n>=1, from this exmple it cn be concluded tht the lnguge consist of equl number of s s equl number of b s. Let us consider the cse where n=2, then we get the string bb, the following figure shows the structure of PD for the bove string. b b $ z 0 pushdown store finite stte control There re three sttes to be considered in this cse they re: q 0 : it is the stte tht recognizes the beginning lphbets(i.e)the symbol q 1: q 2 : it recognizes the second hlf of the strings (i.e)the symbol b it is the stte tht ccepts ll the lphbets now we strt the design of the pushdown utomt. Step1: δ (q 0,,z 0 ) b b $ finite stte control z 0 pushdown store J. Veerendeswri /IT/ RGCET Pge 2

3 in this cse of the beginning lphbet is pushed to the stck nd hed pointer is incremented. Step 2: δ (q 0,,z 0 ) b b $ finite stte control z 0 pushdown store the next lphbet is recognized by q0 nd pushed into the stck. Step 3: δ (q 1,b,z 0 ) b b $ finite stte control z 0 pushdown store in this cse we find tht we encounter new lphbet b upon this the lphbet is poped from the stck. Step 4: δ(q 1,b,zo) b b $ z 0 Finite stte control push down store Here gin we encountered b,so nother is poped from the stck. J. Veerendeswri /IT/ RGCET Pge 3

4 Step 5: δ(q 2,,zo) b b $ z 0 Finite stte control Push down store This is the finl stte in which we gin end up hving the stck empty becuse fter ll the s in the given string re dded to the stck. When the symbol b is encounter in the input string n is removed from stck bses. this confirms the sttement equl number of s nd equl number of b s in the string. PP P0 P1 P0P0 P1P1 context free grmmr for plindromes CONTEXT FREE GRMMERS: There re four importnt components in grmmticl description of lnguge: 1. There is finite set of symbols tht form the strings of the lnguge being defined. This set ws {0, 1} in the plindrome exmple we just sw. We cll this lphbet the terminls, or terminl symbols. 2. There is finite set of vribles, lso clled sometimes nonterminls or syntctic ctegories. Ech vribles represents lnguge; i.e., set of strings. In our exmples bove, there ws only one vrible, P, which we used to represent the clss of plindromes over lphbet {0, 1}. 3. One of the vribles represents the lnguge being defined; it is clled the strt symbol. Other vribles represent uxiliry clsses of strings tht re used to help define the lnguge of the strt symbol. In our exmples, P, the only vrible, is the strt symbol. 4. There is finite set of productions or rules tht represents the recursive definition of lnguge. Ech production consists of: ) vrible tht is being (prtilly) defined by the production. This vrible is often clled the hed of the production. b) The production symbol c) string of zero or more terminls nd vribles.this string, clled the body of the production, represents one wy to form strings in the lnguge of the production, represents one wy to form strings in the lnguge of the vrible of the hed. In so doing, we leve terminls unchnged nd J. Veerendeswri /IT/ RGCET Pge 4

5 substitute for ech vrible of the body ny string tht is known to be in the lnguge of tht vrible. The four components just described form context free grmmr, or just grmmr, or CFG. We shll represent CFG G by its four components, tht is, G= (V, T, P, S), where V is the set of vribles the terminls the set of productions, nd S the strt symbol. PPLICTION OF PUMPING LEM PPLICTION: 1. 1.check whether the given lnguge is context free lnguge or not to check whether the string is finite or infinite. 3. Pumping level for cfl s sttes tht ther re lwys two short substrings close together tht cn be repeted, both the sme number of time s often we like. THEOREM Sttement: Let L be ny CFL (context free lnguge).then there is constnt n depending only on L, such tht z is in l nd z n,then we my write z=uvwxy such tht, ) ) vx 1 b) b) vwx n nd c) for ll i>0,uv i wx i y is in L. To Prove: To check whether uv i wx i y is in context free lnguge L or not Proof: Let G be Chomsky norml form grmmr generting L(G).observe tht if Z is in L(G) nd Z is long, then ny prse tree for x must contin long pth. more precisely we cn show by induction on i tht if the prse tree of word generted by Chomsky norml form grmmr hs no pth of length greter thn i, then the word is of length no greter thn 2 i-1. sis: For the pth i=1, the derivtion tree is of the form, s here n 2 i-1 where n=1,i=1 l 2 i-1 l 1 hence bsis is proved. Induction Prt: J. Veerendeswri /IT/ RGCET Pge 5

6 For this consider i>1.let the roots re s T1 T2 If there re no pth greter thn i,the words is of length no greter thn 2 i-1.if there re no greter thn 2 i-1.if there re no pths greter thn 2 i-1,the word is of length no greter thn 2 i-2 or fewer symbols. For proof ws the Chomsky norml form grmmr, G=({,,C},{,b},->C,C->,->,->b},) Where, V={,,C} T={,b} P={->C,->,C->,->b} S={} Consider string Z=bbbb in this grmmer.the derivtion nd derivtion tree is s follows. C C (replce ->) b C (replce ->b) b CC (replce ->C) bb CC (replce ->b) bbc (replce C->) bbbc (replce ->b) bbbc (replce ->C) bbb (replce C->) bbbb (replce ->b) bbbb (replce ->) Derivtion tree: C b C sub tree with prent vertex()v1: J. Veerendeswri /IT/ RGCET Pge 6

7 C b b sub tree with prent vertex()v2: In the prse tree, let p be pth tht is long or longer thn ny pth in the tree.then there must be two vertices v1 nd v2 on the pth stisfying the following conditions, 1. the vertices v1 nd v2 both hve sme lbel wy. 2. vertex v1 is closer to the root thn vertex v2. 3. the position of the pth v1 to the lef is of length lmost k+1. To use tht V1 nd V2 cn be lwys found,just proceed up pth p from the lef, keeping trck of the lbels encountered of the first k+2 vertices only the lef hs terminl lbel. Consider substring bb from the string bbbb contining the pth length i=3 C b b pth i=3 thus, =>bb=w Since pth length i=3 w 2 i-1 w = Which holds the condition w 2 i-1 for pumping lemm for CFL J. Veerendeswri /IT/ RGCET Pge 7

8 CLOSURE PROPERTIES OF CFL The closure properties of CFL re 1. CFL s re closed under union, conctention nd Kleene closure. 2. CFL s re closed under homomorphism 3. CFL s re closed under substitutions 4. If L is CFL nd R is regulr lnguge then, L/\R is CFL. 5. CFL s re not closed under intersection 6. CFL s re closed under complementtion. Theorem Context-free lnguges re closed under union, conctention nd kleene losure. Proof : let L1 nd L2 be CFL s generted by the CFG s G1={V1,T1,P1,S1) nd G2={V2,T2,P2,S2} Respectively. Since we my renme vribles t will without chnging the lnguge generted, we ssume tht V1 nd V2 re disjoint. ssume lso tht S2,S4 nd S5 re not in V1 or V2. For L1U L2 construct grmmr G3=(V1 U V2 U {S3},T1 U T2,P3,S3), where P3 is P1 U P2 plus the production S3 S1 S2. If w is in L1, then the derivtion S3=> S1=>w is derivtion in G3,s every production of G1 is production of G3. similrly, every word in L2 hs derivtion in G3 beginning with S3=>S2. Thus L1UL2 L(G3). For the converse, let w be in L(G3). Then the derivtion S3=>w begins with either S3=>S1=>w or S3=>S2=>w. In the former cse, s V1 nd V2 re disjoint, only symbols of G1 my pper in the derivtions S1=>w. s the only productions of P3 tht involve only symbols of G1 re those from P1, we conclude tht only productions of P1 re used in the derivtions S1=>w. Thus S1=>w, nd w is in L1. nlogously, if the derivtion strts S3=>S2, we my conclude w is in L2. Hence L(G2) L1UL2, so L(G3)= l1ul2 s desired. For conctention, let G4=(V1UV2U{S4},T1,P4,S4), where P4 is P1UP2 plus the production S4 S1 S2. proof tht L(G4)=L(G1)L(G2) is similr to the proof for union nd is omitted. For closure, let G2=(V1UV2U{S4}, T1,P2,S3), where P3 is P1 plus the productions S3 S1 S5 Є.We gin leve the proof tht L(G5)=L(G1)* to the reder. Theorem: The context-free lnguges re closed under substitution. Proof : Let L be CFL, L *, nd for ech in let L be CFL. Let L be L(G) nd for ech in let L be L(G). Without loss of generlity ssume tht the vribles of G nd the G S re disjoint. Construct grmmr G s follows the vribles of G re ll the vribles of G nd the G s, the terminls of G re the terminls of the G s. the strt symbol of G is the strt symbol of G. The productions of G re ll the productions of the G s together with those productions formed by tking production α of G nd substituting S, the strt symbol of Gn, for ech instnce of n in Σ ppering in α. Exmple : Let L be the set of words with n equl number of s nd b s L={0 1 n 1} nd L={ww r w is in (0+2)*}. For G we my choose S sbs bss є For G tke S 0S1 01 For Gb tke Sb 0Sb0 2Sb2 є If f is the substitution f()=l nd f(b)=lb, then f(l) is generted by the grmmr S S SSbS Sb SS S є J. Veerendeswri /IT/ RGCET Pge 8

9 S 0S1 01 Sb 0Sb0 2Sb2 є One should observe tht since {,b},{b}, nd CFL s the closure pf CFL s under substitute implies closure under union, conctention, nd *. The union of L nd Lb is simply the substitute of L nd Lb into {,b} nd similrly L Lb nd L* re tge substitute into{b} nd *, respectively. Thus theorem6.1 could be presented s corollry of theorem6.2. Since homomorphism is specil type of substitution we stte the following corollry. Corollry The CFL s re closed under homomorphism. Theorem : The context-free lnguge re closed under inverse homomorphism. Proof : s with regulr sets, mchine-bsed proof for closure under inverse homomorphism is esiest to understnd. Let h: be homomorphism nd L be CFL. Let L=L(M), where M is the PD (Q,,,δ,qo,Zo,F). In nlogy with the finite-utomton construction of theorem, we construct PD M ccepting h-1 (L) s follows. On input m M genertes the string h() nd simultes M on h(). if M were finite utomton, ll it could do on string h() would be to chnge stte, so M could simulte such composite move in one of its moves. However, in the PD cse, M could pop mny symbols on sting, or, since it is nondeterministic, mke moves tht push n rbitrry simulte M s moves on h() with one (or ny finite number of) moves of its own. Wht we do is give M buffer, in which it my store h(). then M my simulte ny є-moves of M it likes nd consume the symbols of h() one t time, s if they were M s input. s the buffer is prt of M s finite control, it cnnot be llowed to grow rbitrrily long. We ensure tht it does not, by permitting M to red n input symbol only when the buffer is empty. Thus the buffer holds suffix of h() for some t ll times. M ccepts its input w if the buffer is empty nd M is in finl stte. Tht is, M hs ccepted h(w). thus l(m )={w h(w)is in L}, tht is Input to M uffer Control of M Control Of M J. Veerendeswri /IT/ RGCET Pge 9

10 Stck Of M nd M' Construction of PD ccepting h 1(L) L(M )=h 1(L(M)).The rrngement is depicted in fig ;the forml construction follows. Let M =(Q,,Γ,δ,[q0, ],Zo,F { }),where Q consists of pir [q,x] such tht q is in Q nd x is (not necessrily proper)suffix of some h()for in.δ is defined s follows: 1. δ ([q,x],,y) contins ll ([p,x],γ) such tht δ(q,,y) contins(p,γ).simulte -moves of M independent of the buffer contents. 2. δ ([q,x],,y) contins ll([p,x],γ) such tht δ(q,,y) contins(p,γ). Simulte moves of M on input in, removing from the front of the buffer. 3. δ ([q, ],,Y) contins(q,h()],y) for ll in nd Y in Γ. Lod the buffer with h (), reding from M s input ; the stte of M remin unchnged. To show tht L(M )=h 1 (L(M))first observe tht by one ppliction of rule (3), followed by ppliction of rules(1)nd(2),if(q,h(),α)*/m(p,,β). Theorem:The CFL S re not closed under intersection. Proof: we showed the lnguge L1={ i b i c i i 1 } ws not CFL. We clim tht L2= { i b i c i i 1 nd L3={ i b i c i i 1 nd j 1} re both CFL s. For emple PD to recognize L2 stores the s pm its stck nd cncels them ginst b s, then ccepts its input fter seeing one or mors c s. lterntively L2 is generted by the grmmr S-> ->b b ->c c Where genertes ^ib^i nd genertes c^i. similr grmmr S->CD C->C D->bDc bc Genertes L3. However, L2^L3 =L1. If the CFL s were closed under intersection. L1 would thus be CFL. Corollry : The CFL s re not closed under complementtion. Proof: we know the CFL s re closed under union. If they were closed under complementtion, they would, by DeMorgn s lw, L1^L2=L1UL2, be closed under intersection. Theorem : If L is CFL nd R is regulr set, then L R is CFL. Proof: Let L be L(M) for PD M=(Qm,,,ᵟ,[p0,qo],z0,f fm), nd let R be L()for DF =( q,,ᵟ,p0,f ). We construct PD M for L R by running M nd in prllel, M simultes moves of M on input without chnging the stte of. when M mkes move on input symbol, M simultes tht move nd lso simultes s chnge of stte on input. M ccepts if nd only if both nd M ccept. Formlly, let M'=(Q Qm,,,ᵟ,[p0,q0],z0,F Fm) J. Veerendeswri /IT/ RGCET Pge 10

11 Input to,mndm' Control of M uffer Control Of M Stck of M nd M DECISION LGORITHM FOR CFL Sttement: Decision lgorithm for CFL is minly used to check whether the given lnguge is finite, empty or non finite(infinite). To Prove: To check whether the lnguge is finite, infinite or empty. ssumptions: 1. the grmmr should be in Chomsky norml form(cnf) without ᶓ production. 2. if s is the strt symbol nd r is the rnk of the symbol, then the string length will be greter then or equl to 2 r. If is the reverse vertex ssocited with s is the root node,then the string length will not be greter thn 2 r-1. If is the reverse vertex ssocited with s is the root node, then the string length will not be greter thn 2 r-2. sis : (r=0) Consider production,it is directed cyclic grph denoted by.y the ssumption non terminl with rnk r cnnot generte string of length greter thn 2 r. Here, the rnk of is 0.i.e(r=0) y the condition l 2 r, substitute r vlue, We get l 2 0 L 1 Hence it is proved by considering the form ->,we my derive only string of length 1,which is finite. Induction : J. Veerendeswri /IT/ RGCET Pge 11

12 If we use production of the form,we my derive only string of length 1.if we begin with C, then s nd C re of rnk r-1 or less, by the inductive hypothesis, they derive only strings of length 2 r-1 or less. Thus C cnnot derive string of length greter thn 2r. Since s is of finite rnk r0,nd in fct, is of rnk no greter thn the number of vribles derives strings of length no greter thn the number of vribles derives strings of length no greter thn 2 r0.thus the lnguge is finite. Consider n exmple, S C CC C S r (s)=3 r()=2 r()=1 r(c)=0 C Rnk of strting symbol s (r(s)=3). Rnk,r() depends on root node s, it should be less thn s nd rnk of b,r() depends on both S nd,it should be less thn both S nd. From, the figure check the condition l 2 r r (s)=3, l 2 3 l 8 r()=2, l 2 2 l 4 r() =1, l 2 1 l 2 r(c) =0, l 2 0 l 1 hence the finite length for ech string is derived..hence it proved. Now, consider the directed cyclic grph, s C For the figure, the rnk cnnot be specified. Hence for the cyclic grph the lnguge is infinite. For cyclic grph the lnguge is finite. Hence the sttement is proved. J. Veerendeswri /IT/ RGCET Pge 12

1.4 Nonregular Languages

1.4 Nonregular Languages 74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll

More information

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

More information

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1 Non-Deterministic Finite Automt Fll 2018 Costs Busch - RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch - RPI 2 Nondeterministic Finite Automton (NFA) Alphbet

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson)

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed

More information

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38 Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton 25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

More information

Theory of Computation Regular Languages

Theory of Computation Regular Languages Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

More information

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata CSC4510 AUTOMATA 5.1 Definitions nd Exmples 5.2 Deterministic Pushdown Automt Definitions nd Exmples A lnguge cn be generted by CFG if nd only if it cn be ccepted by pushdown utomton. A pushdown utomton

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

More information

Automata and Languages

Automata and Languages Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering Lb. The University of Aizu Jpn Grmmr Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Regulr Lnguges Context Free Lnguges Context Sensitive

More information

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51 Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)

More information

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

This lecture covers Chapter 8 of HMU: Properties of CFLs

This lecture covers Chapter 8 of HMU: Properties of CFLs This lecture covers Chpter 8 of HMU: Properties of CFLs Turing Mchine Extensions of Turing Mchines Restrictions of Turing Mchines Additionl Reding: Chpter 8 of HMU. Turing Mchine: Informl Definition B

More information

CSC 473 Automata, Grammars & Languages 11/9/10

CSC 473 Automata, Grammars & Languages 11/9/10 CSC 473 utomt, Grmmrs & Lnguges 11/9/10 utomt, Grmmrs nd Lnguges Discourse 06 Decidbility nd Undecidbility Decidble Problems for Regulr Lnguges Theorem 4.1: (embership/cceptnce Prob. for DFs) = {, w is

More information

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir CSCI 2400 Models of Computtion, Section 3 Solutions to Homework 4 Problem 1. ll the solutions below refer to the Pumping Lemm of Theorem 4.8, pge 119. () L = f n b l k : k n + lg Let's ssume for contrdiction

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun: CMPU 240 Lnguge Theory nd Computtion Spring 2019 NFAs nd Regulr Expressions Lst clss: Introduced nondeterministic finite utomt with -trnsitions Tody: Prove n NFA- is no more powerful thn n NFA Introduce

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Lecture 6 Regular Grammars

Lecture 6 Regular Grammars Lecture 6 Regulr Grmmrs COT 4420 Theory of Computtion Section 3.3 Grmmr A grmmr G is defined s qudruple G = (V, T, S, P) V is finite set of vribles T is finite set of terminl symbols S V is specil vrible

More information

Normal Forms for Context-free Grammars

Normal Forms for Context-free Grammars Norml Forms for Context-free Grmmrs 1 Linz 6th, Section 6.2 wo Importnt Norml Forms, pges 171--178 2 Chomsky Norml Form All productions hve form: A BC nd A vrile vrile terminl 3 Exmples: S AS S AS S S

More information

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tble of Contents: Week 1: Preliminries (set lgebr, reltions, functions) (red Chpters 1-4) Weeks

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

Context-Free Grammars and Languages

Context-Free Grammars and Languages Context-Free Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;

More information

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!) CMSC 330: Orgniztion of Progrmming Lnguges DFAs, nd NFAs, nd Regexps (Oh my!) CMSC330 Spring 2018 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

Chapter 2 Finite Automata

Chapter 2 Finite Automata Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent

More information

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1 Non Deterministic Automt Forml Lnguges nd Automt - Yonsei CS 1 Nondeterministic Finite Accepter (NFA) We llow set of possible moves insted of A unique move. Alphbet = {} Two choices q 1 q2 Forml Lnguges

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q

More information

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages 5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

More information

1 Structural induction, finite automata, regular expressions

1 Structural induction, finite automata, regular expressions Discrete Structures Prelim 2 smple uestions s CS2800 Questions selected for spring 2017 1 Structurl induction, finite utomt, regulr expressions 1. We define set S of functions from Z to Z inductively s

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA RIGHT LINEAR LANGUAGES. Right Liner Grmmr: Rules of the form: A α B, A α A,B V N, α V T + Left Liner Grmmr: Rules of the form: A Bα, A α A,B V N, α V T

More information

TREE AUTOMATA AND TREE GRAMMARS

TREE AUTOMATA AND TREE GRAMMARS TREE AUTOMATA AND TREE GRAMMARS rxiv:1510.02036v1 [cs.fl] 7 Oct 2015 by Joost Engelfriet DAIMI FN-10 April 1975 Institute of Mthemtics, University of Arhus DEPARTMENT OF COMPUTER SCIENCE Ny Munkegde, 8000

More information

Non-Deterministic Finite Automata

Non-Deterministic Finite Automata Non-Deterministic Finite Automt http://users.comlb.ox.c.uk/luke. ong/teching/moc/nf2up.pdf 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q1 q2 2 Alphbet ={} Two choices q1 q2 3 Alphbet ={} Two choices

More information

Tutorial Automata and formal Languages

Tutorial Automata and formal Languages Tutoril Automt nd forml Lnguges Notes for to the tutoril in the summer term 2017 Sestin Küpper, Christine Mik 8. August 2017 1 Introduction: Nottions nd sic Definitions At the eginning of the tutoril we

More information

Deterministic Finite Automata

Deterministic Finite Automata Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

More information

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

More information

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

Fundamentals of Computer Science

Fundamentals of Computer Science Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,

More information

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa CS:4330 Theory of Computtion Spring 208 Regulr Lnguges Equivlences between Finite utomt nd REs Hniel Brbos Redings for this lecture Chpter of [Sipser 996], 3rd edition. Section.3. Finite utomt nd regulr

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch. Overview H9 Vertlerouw H 9: Prsing: op-down & LL(1) do 3 mei 2001 56 heo Ruys h. 8 - Prsing 8.1 ontext-free Grmmrs 8.2 op-down Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

1 From NFA to regular expression

1 From NFA to regular expression Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work

More information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

CSCI FOUNDATIONS OF COMPUTER SCIENCE

CSCI FOUNDATIONS OF COMPUTER SCIENCE 1 CSCI- 2200 FOUNDATIONS OF COMPUTER SCIENCE Spring 2015 My 7, 2015 2 Announcements Homework 9 is due now. Some finl exm review problems will be posted on the web site tody. These re prcqce problems not

More information

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA Nondeterminism Nondeterministic Finite Automt Nondeterminism Subset Construction A nondeterministic finite utomton hs the bility to be in severl sttes t once. Trnsitions from stte on n input symbol cn

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model? CS125 Lecture 11 Fll 2016 11.1 Finite Automt Motivtion: TMs without tpe: mybe we cn t lest fully understnd such simple model? Algorithms (e.g. string mtching) Computing with very limited memory Forml verifiction

More information

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

Formal Languages Simplifications of CFGs

Formal Languages Simplifications of CFGs Forml Lnguges implifictions of CFGs ubstitution Rule Equivlent grmmr b bc ubstitute b bc bbc b 2 ubstitution Rule b bc bbc ubstitute b bc bbc bc Equivlent grmmr 3 In generl: xz y 1 ubstitute y 1 xz xy1z

More information

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

More information

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines CI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 16: Non-Context-Free Lnguges Chpter 16: Non-Context-Free Lnguges I. Theory of utomt II. Theory of Forml Lnguges III. Theory of Turing Mchines

More information

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-* Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion

More information

Lecture 3 ( ) (translated and slightly adapted from lecture notes by Martin Klazar)

Lecture 3 ( ) (translated and slightly adapted from lecture notes by Martin Klazar) Lecture 3 (5.3.2018) (trnslted nd slightly dpted from lecture notes by Mrtin Klzr) Riemnn integrl Now we define precisely the concept of the re, in prticulr, the re of figure U(, b, f) under the grph of

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

More information

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines CI 3104 /Winter 2011: Introduction to Forml Lnguges Chter 13: Grmmticl Formt Chter 13: Grmmticl Formt I. Theory of Automt II. Theory of Forml Lnguges III. Theory of Turing Mchines Dr. Neji Zgui CI3104-W11

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information

1 Structural induction

1 Structural induction Discrete Structures Prelim 2 smple questions Solutions CS2800 Questions selected for Spring 2018 1 Structurl induction 1. We define set S of functions from Z to Z inductively s follows: Rule 1. For ny

More information

a b b a pop push read unread

a b b a pop push read unread A Finite Automton A Pushdown Automton 0000 000 red unred b b pop red unred push 2 An Exmple A Pushdown Automton Recll tht 0 n n not regulr. cn push symbols onto the stck cn pop them (red them bck) lter

More information

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3 2 The Prllel Circuit Electric Circuits: Figure 2- elow show ttery nd multiple resistors rrnged in prllel. Ech resistor receives portion of the current from the ttery sed on its resistnce. The split is

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, section 003, George Mson University, Fll 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 7 1. Prove (p q) (p q), () (5pts) using truth tles. p q

More information

SWEN 224 Formal Foundations of Programming WITH ANSWERS

SWEN 224 Formal Foundations of Programming WITH ANSWERS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Time Allowed: 3 Hours EXAMINATIONS 2011 END-OF-YEAR SWEN 224 Forml Foundtions of Progrmming

More information

i 1 i 2 i 3... i p o 1 o 2 AUTOMATON q 1, q 2,,q n ... o q Model of a automaton Characteristics of automaton:

i 1 i 2 i 3... i p o 1 o 2 AUTOMATON q 1, q 2,,q n ... o q Model of a automaton Characteristics of automaton: Definition of n Automton:-An Automton is defined s system tht preforms certin functions without humn intervention. it ccepts rw mteril nd energy s input nd converts them into the finl product under the

More information

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

More information

ARITHMETIC OPERATIONS. The real numbers have the following properties: a b c ab ac

ARITHMETIC OPERATIONS. The real numbers have the following properties: a b c ab ac REVIEW OF ALGEBRA Here we review the bsic rules nd procedures of lgebr tht you need to know in order to be successful in clculus. ARITHMETIC OPERATIONS The rel numbers hve the following properties: b b

More information

ɛ-closure, Kleene s Theorem,

ɛ-closure, Kleene s Theorem, DEGefW5wiGH2XgYMEzUKjEmtCDUsRQ4d 1 A nice pper relevnt to this course is titled The Glory of the Pst 2 NICTA Resercher, Adjunct t the Austrlin Ntionl University nd Griffith University ɛ-closure, Kleene

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 0 Forml Methods nd Models Dn Richrds, George Mson University, Fll 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 8 1. Prove q (q p) p q p () (4pts) with truth tle. p q p q p (q p) p q

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p

More information