CS 275 Automata and Formal Language Theory
|
|
- Junior Lawson
- 5 years ago
- Views:
Transcription
1 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) Dept. of Computer Science, Swnse University csetzer/lectures/ utomtformllnguge/12/index.html pril 14, 2013 CS 275 Chpter II.5. 1/ 52
2 Slight Reorgnistion of Sect. 5 nd 6 Section 5 nd 6 will e slightly reorgnised. The new pln is s follows: Context-free lnguges: II.5. Properties of Context Free Grmmrs. Includes the Pumping Lemm for context-free grmmrs. II.6. Push Down utomt. Includes equivlence theorem. CS 275 Chpter II.5. 2/ 52
3 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) II.5.2. Norml Forms for Context-Free Grmmrs (14.2) II.5.3. The Pumping Lemm for CFG (14.4) II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem CS 275 Chpter II.5. 3/ 52
4 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) II.5.2. Norml Forms for Context-Free Grmmrs (14.2) II.5.3. The Pumping Lemm for CFG (14.4) II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem CS 275 Sect. II / 52
5 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Derivtion Trees or Prse Trees Context free Grmmrs (revited s CFG in the following) llow to pply to non-terminl t position without needing the context. Therefore we cn expnd the non-terminls independently of ech other. This llows us to define derivtion trees (lso clled prse trees). CS 275 Sect. II / 52
6 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Consider the grmmr grmmr G terminls nonterminls strt symol productions, S S S S S CS 275 Sect. II / 52
7 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Derivtion We derive in it: S S S CS 275 Sect. II / 52
8 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Derivtion Tree S S S S S S CS 275 Sect. II / 52
9 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Form of the Derivtion Tree Nodes re lelled with elements of N T {ɛ}. node with lel hs sutree X 1 X 2... X n only if is non-terminl nd there is production where X i T N. X 1 X 2 X n ll leves of the tree together red from left to right form the string derived, nmely. This is clled the frontier of the derivtion tree. We will s well consider derivtion trees not ending in string of terminls, so the frontier is n element of (T N). CS 275 Sect. II / 52
10 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Definition Derivtion Tree Definition Let G = (T, N, S, P) e CFG. derivtion tree or prse tree for G is finite tree with nodes lelled y elements of N T {ɛ}, s.t. node hs children with lels X 1,..., X n only if N nd there is production X 1 X 2 X n If the node of one of the children of is ɛ, then this node is the only child of this tree. The frontier of the tree is the set of leves red from left to right in sequence, which is n element (T N). The root of the tree is the node t the to of the derivtion tree. CS 275 Sect. II / 52
11 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Left-Most nd Right-Most Derivtions From derivtion tree we cn otin derivtion in vrious orders. Consider the grmmr grmmr G terminls nonterminls strt symol productions, S,, B S S B,, B B, B CS 275 Sect. II / 52
12 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Derivtion Tree S B B CS 275 Sect. II / 52
13 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Different Derivtions of We cn derive in different wys: S B B B B left most derivtion S B B right most derivtion S B B B B S B B B S B B B B S B B B CS 275 Sect. II / 52
14 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Left-Most Derivtion Definition Let G = (T, N, S, P) e CFG. single-step derivtion w w is left-most if rule ws pplied to the left-most non-terminl in w, i.e. w = st for some N, s T (consisting only of terminls), t (S T ), nd there exist production v s.t. w = svt. CS 275 Sect. II / 52
15 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Left-Most Derivtion Definition Let G = (T, N, S, P) e CFG. single-step derivtion w w is right-most if rule ws pplied to the right-most non-terminl in w, i.e. w = st for some N, s (S T ), t T (consisting only of terminls), there exist production v s.t. w = svt. CS 275 Sect. II / 52
16 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Left/Right-Most Derivtion Sequence Definition Let G = (T, N, S, P) e CFG 1. derivtion sequence w 0 w 1 w 2 w n is left-most, if ech derivtion step w i w i+1 is left-most. 2. Right-most derivtion sequences re defined nlogously. CS 275 Sect. II / 52
17 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Theorem II (Derivtion Trees nd Lnguge Genertion) Theorem Let G = (T, N, S, P) e CFG, T, w, w (T N), Then the following re equivlent (1) There exist derivtion tree with root lelled y nd frontier w. (2) w. In cse w T, the derivtion sequence w w cn oth e chosen s left-most nd s right-most derivtion sequence CS 275 Sect. II / 52
18 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Proof of Theorem II proof of this theorem cn e found in the dditionl mteril. We illustrte this theorem y n exmple. We will first present left-most derivtion. Then we will present right most derivtion. CS 275 Sect. II / 52
19 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Left-Most Derivtion (Step 1) S S B B CS 275 Sect. II / 52
20 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Left-Most Derivtion (Step 2) S B S B B CS 275 Sect. II / 52
21 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Left-Most Derivtion (Step 3) S B B S B B Derivtion tree for is trivil. CS 275 Sect. II / 52
22 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Left-Most Derivtion (Step 4) S B B B S B B CS 275 Sect. II / 52
23 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Left-Most Derivtion (Step 5) S B B B B S B B CS 275 Sect. II / 52
24 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Left-Most Derivtion (Step 6) S B B B B S B B Finl derivtion. CS 275 Sect. II / 52
25 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Right-Most Derivtion (Step 1) S S B B CS 275 Sect. II / 52
26 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Right-Most Derivtion (Step 2) S B S B B CS 275 Sect. II / 52
27 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Right-Most Derivtion (Step 3) S B B S B B CS 275 Sect. II / 52
28 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Right-Most Derivtion (Step 4) S B B S B B CS 275 Sect. II / 52
29 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Right-Most Derivtion (Step 5) S B B S B B CS 275 Sect. II / 52
30 I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) Exmple Right-Most Derivtion (Step 6) S B B S B B CS 275 Sect. II / 52
31 II.5.2. Norml Forms for Context-Free Grmmrs (14.2) I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) II.5.2. Norml Forms for Context-Free Grmmrs (14.2) II.5.3. The Pumping Lemm for CFG (14.4) II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem CS 275 Sect. II / 52
32 II.5.2. Norml Forms for Context-Free Grmmrs (14.2) Mteril for this Section Moved to dditionl Mteril The mteril for this section hs een moved to dditionl Mteril CS 275 Sect. II / 52
33 II.5.3. The Pumping Lemm for CFG (14.4) I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) II.5.2. Norml Forms for Context-Free Grmmrs (14.2) II.5.3. The Pumping Lemm for CFG (14.4) II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem CS 275 Sect. II / 52
34 II.5.3. The Pumping Lemm for CFG (14.4) Ide of the Pumping Lemm for CFG The Pumping Lemm for Regulr Lnguges is sed on the fct tht if string derived y finite stte utomton is sufficiently ig, we pss to t lest one stte twice. We could equivlently hve used the fct tht in left- or right-liner grmmr, if string derived is sufficiently ig, we pss through one non-terminl t lest twice. For CFG, we need tht if string derived is sufficiently ig, one we pss through one non-terminl t lest twice. However, if this occurrence is in two disjoint sutrees of the derivtion trees, there is no reltion etween them. Wht we need tht there is pth in the sutree which psses through one non-terminl t lest twice. CS 275 Sect. II / 52
35 II.5.3. The Pumping Lemm for CFG (14.4) Picture S D D i D j u v w x y CS 275 Sect. II / 52
36 II.5.3. The Pumping Lemm for CFG (14.4) Ide of the Pumping Lemm for CFG If in CFG with m non-terminls there is no repetition of non-terminl in ny pth, then ny derivtion tree cn hve height t most m + 1. Since t ny node of derivtion tree there re only finitely mny rules to pply to, one cn esily see tht there re only finitely mny derivtion trees in CFG with height t most m + 1. Let n e the mximum height of ny string derived with height t most m + 1. Let n := n + 1. ny string with height n must hve pth in which t lest one non-terminl occurs twice. We cn hve this derivtion to within the lst n + 1 steps, nd therefore otin, tht the string derived from the first of the two occurrences of hs length t most n. CS 275 Sect. II / 52
37 II.5.3. The Pumping Lemm for CFG (14.4) Ide of the Pumping Lemm for CFG So for ny CFG G we cn find constnt n s.t. in ny derivtion tree of word w L(G) s.t. w n, we cn decompose w s uvwxy find nonterminl, nd derivtions S uy (written lue on the next slide), vx (written green on the next slide), w (written red on the next slide) The suderivtion vx plys the role of the loop we hd in the pumping lemm for regulr lnguges. Furthermore the middle prt vwx cn e chosen to e of length n, nd vx ɛ. The following pictures don t come out well on the lck nd white hndouts. Plese look t them on the online version. CS 275 Sect. II / 52
38 II.5.3. The Pumping Lemm for CFG (14.4) Picture S D D i D j u v w x y CS 275 Sect. II / 52
39 II.5.3. The Pumping Lemm for CFG (14.4) Ide of the Pumping Lemm for CFG Now we cn repet the suderivtion vx severl times nd otin S uy uvxy uvvxxy uv i x i y uv i vx i y nd therefore we otin tht for ll i 0 we hve uv i vx i y L(G) CS 275 Sect. II / 52
40 II.5.3. The Pumping Lemm for CFG (14.4) Pumping it up to uv 3 vx 3 y S u v x y v x v w x CS 275 Sect. II / 52
41 II.5.3. The Pumping Lemm for CFG (14.4) Pumping it down to uv 0 vx 0 yy S w u y CS 275 Sect. II / 52
42 II.5.3. The Pumping Lemm for CFG (14.4) Pumping Lemm for CFG Theorem Let L e context free lnguge.. Then there exists constnt n s.t. for ll strings z of L s.t. z n there exist u, v, w, x, y s.t. z = uvwxy, vwx n, i.e. the middle portion is not too long, vx 1, i.e. v or x re not ɛ, i 0.uv i wx i y L. CS 275 Sect. II / 52
43 II.5.3. The Pumping Lemm for CFG (14.4) Proof of the Pumping Lemm for CFG forml proof cn e found in the dditionl Mteril CS 275 Sect. II / 52
44 II.5.3. The Pumping Lemm for CFG (14.4) Exmple 1 Lemm The lnguge L = { i i c i i 0} is not context free. CS 275 Sect. II / 52
45 II.5.3. The Pumping Lemm for CFG (14.4) Proof (Exmple 1) ssume L is context free. Let n e the constnt from the pumping lemm. Let z := n n c n L. By the pumping lemm, z = uvwxy s.t. vwx n nd i 0.uv i wx i y L. If v contins s nd s or s nd c s, uv 2 wx 2 y is not n element of (i.e. the lnguge defined y this regulr expression), since there is n fter or fter c. Therefore v is prt of n, n or c n, similrly for x. But now uv 2 wx 2 y = n+i n+j c n+k where t most 2 of (i, j, k) cn e 0, nd t lest one is 0. But then n+i n+j c n+k L. CS 275 Sect. II / 52
46 II.5.3. The Pumping Lemm for CFG (14.4) Exmple 2 Lemm The lnguge L = { n m n m n, m 0} is not context free. CS 275 Sect. II / 52
47 II.5.3. The Pumping Lemm for CFG (14.4) Proof (Exmple 2) ssume L is context free. Let n e the constnt from the pumping lemm. Let z := n n n n L. By the pumping lemm, z = uvwxy s.t. vwx n nd i 0.uv i wx i y L. If v contins oth s nd s uv 2 wx 2 y is not n element of, since there re more thn 3 switches etween s nd s. Therefore v is prt of one of the suwords n, n, similrly for x. But now uv 2 wx 2 y = n+i n+j n+k n+l where t most 2 of (i, j, k, l) cn e 0, if there re two they re consecutive, t lest one is 0. But then n+i n+j n+k n+l L. CS 275 Sect. II / 52
48 II.5.3. The Pumping Lemm for CFG (14.4) Exmple 3 Lemm The lnguge L = {ww w {, } } is not context free. CS 275 Sect. II / 52
49 II.5.3. The Pumping Lemm for CFG (14.4) Proof (Exmple 3) We use the fct (we hven t shown this) tht the intersection of context free nd regulr grmmr is context free. If L were context free, so were L := L ( ). But L is just the lnguge of Exmple 2, which is not context free. CS 275 Sect. II / 52
50 II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem I.5.1. Derivtion Trees for Context-Free Grmmrs (14.1) II.5.2. Norml Forms for Context-Free Grmmrs (14.2) II.5.3. The Pumping Lemm for CFG (14.4) II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem CS 275 Sect. II / 52
51 II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem Repetition of words is not context free Exmple 3 of II.5.3 showed tht is not context free. L := {ww w {, } } This exmple generlised to the fct tht under wek conditions lnguge which requires the repetition of word which cn e chosen ritrry, is not context free. progrm lnguge which expresses tht vrile needs to e declred efore it is used is essentilly of this form. CS 275 Sect. II / 52
52 II.5.4. Limittions of Context Free Grmmrs Floyd s Theorem II.5.4. Floyd s Theorem Floyd s Theorem expresses tht under wek ssumptions progrmming lnguges, which requires tht vriles need to e declred efore used, cnnot e defined y context free grmmr. Therefore most progrmming lnguges cnnot e defined y context free grmmr. However, one cn define in most cses context free grmmr defining the syntx of lnguge. Then one needs progrm, which fterwrds checks semntic properties of the progrm, such s tht vrile needs to e declred efore eing used. More detils cn e found in the dditionl Mteril. CS 275 Sect. II / 52
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 informationCS 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 informationClosure 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 information1.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 informationGrammar. 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 informationFirst 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 informationI. 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 informationContext-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 informationParse 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 information1.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 informationFirst 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 informationFormal 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 informationAssignment 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 informationFor 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 informationLecture 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 information5. (±±) Λ = 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 informationHarvard 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 informationAutomata 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 informationHomework 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 informationChapter 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 informationTutorial 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 informationFABER Formal Languages, Automata and Models of Computation
DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte
More information1 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 informationLecture 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 informationSWEN 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 informationFinite 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 informationThe 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 informationHomework 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 informationTheory 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 informationChapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)
C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,
More informationLecture 09: Myhill-Nerode Theorem
CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives
More information1B40 Practical Skills
B40 Prcticl Skills Comining uncertinties from severl quntities error propgtion We usully encounter situtions where the result of n experiment is given in terms of two (or more) quntities. We then need
More informationTalen 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 informationCoalgebra, 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 informationTheory 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 informationCS 314 Principles of Programming Languages
C 314 Principles of Progrmming Lnguges Lecture 6: LL(1) Prsing Zheng (Eddy) Zhng Rutgers University Ferury 5, 2018 Clss Informtion Homework 2 due tomorrow. Homework 3 will e posted erly next week. 2 Top
More informationCS 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 informationExercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.
1 Exercises Chpter 1 Exercise 1.1. Let Σ e n lphet. Prove wv = w + v for ll strings w nd v. Prove # (wv) = # (w)+# (v) for every symol Σ nd every string w,v Σ. Exercise 1.2. Let w 1,w 2,...,w k e k strings,
More informationOverview 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 informationMinimal 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 informationCMPSCI 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 informationCS 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 informationCS375: Logic and Theory of Computing
CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks
More informationConvert 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 informationHomework Solution - Set 5 Due: Friday 10/03/08
CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution - et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte non-finl.
More informationCS 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 informationRegular 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 informationLet'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 informationCSC 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 informationCS 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 informationRegular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15
Regulr Lnguge Nonregulr Lnguges The Pumping Lemm Models of Comput=on Chpter 10 Recll, tht ny lnguge tht cn e descried y regulr expression is clled regulr lnguge In this lecture we will prove tht not ll
More informationPART 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 informationCS 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 informationDesigning 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 informationCS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata
CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or
More informationFormal 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 informationChapter 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 information3 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 informationCS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted
More informationConverting Regular Expressions to Discrete Finite Automata: A Tutorial
Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert
More informationCHAPTER 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 informationCS 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 informationI. 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 informationScanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:
Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes
More information1 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ɛ-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 informationIntermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4
Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one
More information1. 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 informationCSCI 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 informationThe Regulated and Riemann Integrals
Chpter 1 The Regulted nd Riemnn Integrls 1.1 Introduction We will consider severl different pproches to defining the definite integrl f(x) dx of function f(x). These definitions will ll ssign the sme vlue
More informationFinite 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 informationCHAPTER 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 informationFarey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University
U.U.D.M. Project Report 07:4 Frey Frctions Rickrd Fernström Exmensrete i mtemtik, 5 hp Hledre: Andres Strömergsson Exmintor: Jörgen Östensson Juni 07 Deprtment of Mthemtics Uppsl University Frey Frctions
More informationCS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6
CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized
More informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS
The University of ottinghm SCHOOL OF COMPUTR SCIC A LVL 2 MODUL, SPRIG SMSTR 2015 2016 MACHIS AD THIR LAGUAGS ASWRS Time llowed TWO hours Cndidtes my omplete the front over of their nswer ook nd sign their
More informationFinite-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 informationKleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15
Models of Comput:on Lecture #8 Chpter 7 con:nued Any lnguge tht e defined y regulr expression, finite utomton, or trnsi:on grph cn e defined y ll three methods We prove this y showing tht ny lnguge defined
More informationFinite 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 informationRevision Sheet. (a) Give a regular expression for each of the following languages:
Theoreticl Computer Science (Bridging Course) Dr. G. D. Tipldi F. Bonirdi Winter Semester 2014/2015 Revision Sheet University of Freiurg Deprtment of Computer Science Question 1 (Finite Automt, 8 + 6 points)
More informationI1 = 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 informationSpeech Recognition Lecture 2: Finite Automata and Finite-State Transducers
Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.
More informationFree groups, Lecture 2, part 1
Free groups, Lecture 2, prt 1 Olg Khrlmpovich NYC, Sep. 2 1 / 22 Theorem Every sugroup H F of free group F is free. Given finite numer of genertors of H we cn compute its sis. 2 / 22 Schreir s grph The
More informationLecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations.
Lecture 3 3 Solving liner equtions In this lecture we will discuss lgorithms for solving systems of liner equtions Multiplictive identity Let us restrict ourselves to considering squre mtrices since one
More informationCompiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz
University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite
More informationAUTOMATA 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 informationTable of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...
Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive
More informationFinite 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 informationLecture 9: LTL and Büchi Automata
Lecture 9: LTL nd Büchi Automt 1 LTL Property Ptterns Quite often the requirements of system follow some simple ptterns. Sometimes we wnt to specify tht property should only hold in certin context, clled
More informationAutomata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.
Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent
More informationTHEOTY OF COMPUTATION
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
More informationNon-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 informationFundamentals 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 informationSymbolic enumeration methods for unlabelled structures
Go & Šjn, Comintoril Enumertion Notes 4 Symolic enumertion methods for unlelled structures Definition A comintoril clss is finite or denumerle set on which size function is defined, stisfying the following
More informationThoery of Automata CS402
Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...
More informationNondeterminism 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 informationLexical Analysis Finite Automate
Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition
More informationp-adic Egyptian Fractions
p-adic Egyptin Frctions Contents 1 Introduction 1 2 Trditionl Egyptin Frctions nd Greedy Algorithm 2 3 Set-up 3 4 p-greedy Algorithm 5 5 p-egyptin Trditionl 10 6 Conclusion 1 Introduction An Egyptin frction
More informationNFAs 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 informationCS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7
CS103 Hndout 32 Fll 2016 Novemer 11, 2016 Prolem Set 7 Wht cn you do with regulr expressions? Wht re the limits of regulr lnguges? On this prolem set, you'll find out! As lwys, plese feel free to drop
More informationFormal Languages and Automata Theory. D. Goswami and K. V. Krishna
Forml Lnguges nd Automt Theory D. Goswmi nd K. V. Krishn Novemer 5, 2010 Contents 1 Mthemticl Preliminries 3 2 Forml Lnguges 4 2.1 Strings............................... 5 2.2 Lnguges.............................
More information