CD5080 AUBER RECAPITULATION. Context-Free Languages. Models of Computation, Languages and Automata. S asb. S bsb

Similar documents
Formal Languages The Pumping Lemma for CFLs

Applications of Regular Closure

Namely, for regular languages L1. Concatenation. Regular Languages. Star operation L 1. Complement. For regular language L the complement L is regular

Review of CFGs and Parsing I Context-free Languages and Grammars. Winter 2014 Costas Busch - RPI 1

Positive Properties of Context-Free languages

Project 3: Using Identities to Rewrite Expressions

Content. Languages, Alphabets and Strings. Operations on Strings. a ab abba baba. aaabbbaaba b 5. Languages. A language is a set of strings

Course Material. CS Lecture 1 Deterministic Finite Automata. Grading and Policies. Workload. Website:

Data Compression Techniques (Spring 2012) Model Solutions for Exercise 4

ENGR 3861 Digital Logic Boolean Algebra. Fall 2007

Riemann Integral Oct 31, such that

Discrete Mathematics I Tutorial 12

Section 3.6: Rational Exponents

Introduction to Matrix Algebra

M098 Carson Elementary and Intermediate Algebra 3e Section 10.2

Name: Period: Date: 2.1 Rules of Exponents

Modified Farey Trees and Pythagorean Triples

Chapter 7 Infinite Series

Week 13 Notes: 1) Riemann Sum. Aim: Compute Area Under a Graph. Suppose we want to find out the area of a graph, like the one on the right:

CH 20 SOLVING FORMULAS

CH 19 SOLVING FORMULAS

Infinite Series Sequences: terms nth term Listing Terms of a Sequence 2 n recursively defined n+1 Pattern Recognition for Sequences Ex:

SINCLAIR COMMUNITY COLLEGE DAYTON, OHIO DEPARTMENT SYLLABUS FOR COURSE IN MAT ALGEBRA II (3 CREDIT HOURS)

SUTCLIFFE S NOTES: CALCULUS 2 SWOKOWSKI S CHAPTER 11

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Summer MA Lesson 4 Section P.3. such that =, denoted by =, is the principal square root

Taylor Polynomials. The Tangent Line. (a, f (a)) and has the same slope as the curve y = f (x) at that point. It is the best

ALGEBRA II CHAPTER 7 NOTES. Name

Hypergeometric Functions and Lucas Numbers

Numerical Methods. Lecture 5. Numerical integration. dr hab. inż. Katarzyna Zakrzewska, prof. AGH. Numerical Methods lecture 5 1

A Level Mathematics Transition Work. Summer 2018

Section 6.3: Geometric Sequences

In an algebraic expression of the form (1), like terms are terms with the same power of the variables (in this case

MATH 104: INTRODUCTORY ANALYSIS SPRING 2009/10 PROBLEM SET 8 SOLUTIONS. and x i = a + i. i + n(n + 1)(2n + 1) + 2a. (b a)3 6n 2

RULES FOR MANIPULATING SURDS b. This is the addition law of surds with the same radicals. (ii)

Section 11.5 Notes Page Partial Fraction Decomposition. . You will get: +. Therefore we come to the following: x x

Laws of Integral Indices

Math 153: Lecture Notes For Chapter 1

MATRIX ALGEBRA, Systems Linear Equations

MATH 104: INTRODUCTORY ANALYSIS SPRING 2008/09 PROBLEM SET 10 SOLUTIONS. f m. and. f m = 0. and x i = a + i. a + i. a + n 2. n(n + 1) = a(b a) +

Normal Forms for Context-free Grammars

APPLICATION OF DIFFERENCE EQUATIONS TO CERTAIN TRIDIAGONAL MATRICES

Section IV.6: The Master Method and Applications

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Lecture 17

The total number of permutations of S is n!. We denote the set of all permutations of S by

Vectors. Vectors in Plane ( 2

a f(x)dx is divergent.

Convergence rates of approximate sums of Riemann integrals

Société de Calcul Mathématique SA Mathematical Modelling Company, Corp.

Unit 1. Extending the Number System. 2 Jordan School District

Thomas J. Osler Mathematics Department Rowan University Glassboro NJ Introduction

1.3 Continuous Functions and Riemann Sums

PRACTICE FINAL SOLUTIONS

1. (25 points) Use the limit definition of the definite integral and the sum formulas to compute. [1 x + x2

SM2H. Unit 2 Polynomials, Exponents, Radicals & Complex Numbers Notes. 3.1 Number Theory

General properties of definite integrals

0 otherwise. sin( nx)sin( kx) 0 otherwise. cos( nx) sin( kx) dx 0 for all integers n, k.

First Midterm Examination

Accuplacer Elementary Algebra Study Guide

Error-free compression

Chapter 2. LOGARITHMS

10.5 Power Series. In this section, we are going to start talking about power series. A power series is a series of the form

EXPONENTS AND LOGARITHMS

ELEG 3143 Probability & Stochastic Process Ch. 5 Elements of Statistics

NON-DETERMINISTIC FSA

Lesson 5: Does the Order Matter?

LAWS OF INDICES M.K. HOME TUITION. Mathematics Revision Guides Level: GCSE Higher Tier

( ) 2 3 ( ) I. Order of operations II. Scientific Notation. Simplify. Write answers in scientific notation. III.

Limit of a function:

Convergence rates of approximate sums of Riemann integrals

CH 45 INTRO TO FRACTIONS

a) Read over steps (1)- (4) below and sketch the path of the cycle on a P V plot on the graph below. Label all appropriate points.

( ) dx ; f ( x ) is height and Δx is

Crushed Notes on MATH132: Calculus

Topic 4 Fourier Series. Today

STK4011 and STK9011 Autumn 2016

Fig. 1. I a. V ag I c. I n. V cg. Z n Z Y. I b. V bg

Intermediate Arithmetic

Linford 1. Kyle Linford. Math 211. Honors Project. Theorems to Analyze: Theorem 2.4 The Limit of a Function Involving a Radical (A4)

First Midterm Examination

, we would have a series, designated as + j 1

Steady State Solution of the Kuramoto-Sivashinsky PDE J. C. Sprott

MA123, Chapter 9: Computing some integrals (pp )

The limit comparison test

AP Calculus AB AP Review

is an ordered list of numbers. Each number in a sequence is a term of a sequence. n-1 term

MTH 146 Class 16 Notes

=> PARALLEL INTERCONNECTION. Basic Properties LTI Systems. The Commutative Property. Convolution. The Commutative Property. The Distributive Property

,... are the terms of the sequence. If the domain consists of the first n positive integers only, the sequence is a finite sequence.

{ } { S n } is monotonically decreasing if Sn

* power rule: * fraction raised to negative exponent: * expanded power rule:

Addendum. Addendum. Vector Review. Department of Computer Science and Engineering 1-1

Finite State Automata and Determinisation

 n. A Very Interesting Example + + = d. + x3. + 5x4. math 131 power series, part ii 7. One of the first power series we examined was. 2!

GRAPHING LINEAR EQUATIONS. Linear Equations. x l ( 3,1 ) _x-axis. Origin ( 0, 0 ) Slope = change in y change in x. Equation for l 1.

Interpreters and compilers. Operational Semantics 3. Problem 1: Compile Aexp to a stack-based VM. Our target VM, 1. interpreter. compiler.

Approximate Integration

UNIT 4 EXTENDING THE NUMBER SYSTEM Lesson 1: Working with the Number System Instruction

Definition Integral. over[ ab, ] the sum of the form. 2. Definite Integral

Sect Simplifying Radical Expressions. We can use our properties of exponents to establish two properties of radicals: and

Transcription:

CD5080 AUBR RCAPIULAION Models of Coputtio, Lguges d Autot Leture 1 Cotext-ree Lguges, CL Pushdow Autot, PDA Pupig Le for CL eleted CL Proles Cotext-ree Lguges Mälrdle Uiversity 00 1 3 Cotext-ree Lguges xple Cotext-ree Grrs Pushdow Autot stk Cotext-ree Grrs A otext-free grr G A derivtio utoto 4 5 6 A otext-free grr G Aother derivtio L G = { : 0} l l xple A otext-free grr G A derivtio 7 8 9

A otext-free grr G Aother derivtio R L G = { ww : w {, }*} xple A otext-free grr G A derivtio 10 11 1 A otext-free grr A derivtio Defiitio: Cotext-ree Grrs Grr G = V,,, P 13 L G = { w : w = w,d v prefix v} l l 14 v Vriles eril syols trt vriles Produtios of the for: A x x is strig of vriles d terils 15 Defiitio: Cotext-ree Lguge L A lguge is otext-free if d oly if there is grr G 1.. 3. 4. 5. AB A A A B B B Derivtio Order 1.. 3. 4. 5. AB Derivtio Order A A A B B B with L = LG 16 Leftost derivtio 1 3 AB AB B B 4 5 17 Rightost derivtio 1 4 5 AB AB AA 3 18

AB A B B Leftost derivtio A AB BB AB BB B AB A B B Rightost derivtio A AB A B A B Derivtio rees 19 0 1 AB A A B B AB A A B B AB A A AB B B AB AB A B AB AB AB A B A B A A B 3 4 AB A A B B AB AB AB B AB A A B B AB AB AB B Derivtio ree AB A A B B AB AB AB B Derivtio ree A B A B A B A B 5 6 A B A B yield = 7

8 Aiguity 9 leftost derivtio derivtio * deotes ultiplitio 30 derivtio leftost derivtio 31 wo derivtio trees 3 he grr is iguous! trig hs two derivtio trees 33 strig hs two leftost derivtios * he grr is iguous: 34 Defiitio A otext-free grr is iguous if soe strig hs two or ore derivtio trees two or ore leftost/rightost derivtios G w LG 35 Why do we re out iguity? = 36 Why do we re out iguity?

37 Why do we re out iguity? 4 6 4 8 6 = 8 = 38 6 = Corret result: 4 6 39 Aiguity is d for progrig lguges We wt to reove iguity! 40 We fix the iguous grr y itroduig pretheses to idite groupig, preedee No-iguous grr expressio; ter; ftor 41 4 Uiue derivtio tree 43 he grr is o-iguous G very strig hs uiue derivtio tree. w LG 44 Iheret Aiguity oe otext free lguges hve oly iguous grrs! xple: } { } { L = 1 1 A A A B B B 1 45 he strig hs two derivtio trees 1 1

Pushdow Autot PDAs 46 Pushdow Autoto - PDA Iput trig tk ttes 47 he tk A PDA write syols o stk d red the lter o. PUH writig syol POP redig syol All ess to the stk oly o the top! tk top is writte leftost i the strig, e.g. yxz A stk is vlule s it hold uliited out of ifortio. he stk llows pushdow utot to reogize soe o-regulr lguges. y x z 48 he ttes, / 1, / 1 Iput syol Pop syol Push syol iput h h h h iput h h h h, / 1 stk top Reple stk e h $ top Push e h $ e h $ e h $ 49 50 51 A ltertive is to strt d fiish with epty stk., / 1 iput h h h h 1, / iput h h h h xple 3.7 llig: A PDA for siple ested prethesis strigs ε Iput tk stk e h $ top Pop e h $ stk e h $ top No Chge e h $ strt, ε /, / ε s, / ε ed 5 53 54

xple 3.7 Iput ε xple 3.7 Iput ε xple 3.7 Iput ε, ε /, / ε tk, ε /, / ε tk, ε /, / ε tk strt s, / ε ed strt s, / ε ed strt s, / ε ed 55 56 57 xple 3.7 Iput ε xple 3.7 Iput ε xple 3.7 Iput ε, ε /, / ε tk, ε /, / ε tk, ε /, / ε tk strt s, / ε ed strt s, / ε ed strt s, / ε ed 58 59 60 xple 3.7 Iput ε tk, ε /, / ε NPDAs 1, / No-Deteriis, / 1 strt s, / ε ed, / 3 trsitio 61 6 63

A strig is epted if: All the iput is osued he lst stte is fil stte tk i the iitil oditio either: epty whe we strted with epty stk, or: otto syol rehed 64 xple NPDA L = { : 0} is the lguge epted y the NPDA:, /, / Σ = {, }, /, /,$ / $ 0 1 3 65 xple NPDA NPDA M, /, / 0 L M = { ww, /, /, / R } Σ = {, } ve-legth plidroes,$ / $ 1 66 Iput syol Pushig trigs Pop syol, / w 1 Push strig 67 xple: iput stk e h top, / df 1 Push 8 d f h e 88 pushed strig NPDA M Aother NPDA exple,$ / 0$, 0 / 00,1/ L M = { w: = },$ /1$,1/11, 0 /, $ / $ 1 Σ = {, } $ $ 68 69 rsitio futio:, / w orl Defiitios for NPDAs, / w 1 rsitio futio: δ 1,, = {, w} 1, / w 3 ew stte δ 1,, = {, w, 3, w} urret stte urret stk top ew stk top urret iput syol 70 71 7

orl Defiitio of NPDA No-Deteriisti Pushdow Autoto orl Defiitio A uspeified trsitio futio is to the ull set d represets A ded ofigurtio for the NPDA. ttes Iput lphet M = Q, Σ, Γ, δ, z, tk lphet rsitio futio il sttes tk strt syol Lguge of NPDA M L M = { w : 0, w, s f,, s' } Iitil stte il stte 73 74 75 Proof - tep 1: NPDAs Aept Cotext-ree Lguges heore Cotext-ree Lguges Grrs Lguges Aepted y NPDAs Cotext-ree Lguges Grrs Covert y otext-free grr to NPDA with L G = L M Lguges Aepted y NPDAs G M 76 77 78 Proof - tep : Cotext-ree Lguges Grrs Lguges Aepted y NPDAs Covert y NPDA to otext-free grr with: G M L G = L M Covertig Cotext-ree Grrs to NPDAs A exple grr: Wht is the euivlet NPDA? 79 80 81

Grr NPDA, /, /, /, /, /, / he NPDA siultes leftost derivtios of the grr LGrr = LNPDA I geerl Give y grr G We ostrut NPDA M, /,$ / $ 0 1 With L G = L M 8 83 84 Costrutig NPDA fro grr op-dow prser or y produtio A w, A/ w M or y teril, / G Grr G geertes strig if d oly if w NPDA M epts w L G = L M herefore: or y otext-free lguge there is NPDA tht epts the se lguge, /,$ / $ 0 1 85 86 87 Covertig NPDAs to Cotext-ree Grrs or y NPDA M we will ostrut otext-free grr G with L M = L G he grr siultes the hie A derivtio i Grr terils labcl l l G vriles Iput proessed tk otets i NPDA M 88 89 90

oe iplifitios irst we odify the NPDA so tht It hs sigle fil stte f It epties the stk whe it epts the iput Origil NPDA pty tk f 91 eod we odify the NPDA trsitios. All trsitios will hve for: i i, B / or, B / CD j j whih es tht eh ove ireses/dereses stk y sigle syol. 9 hose siplifitios do ot ffet geerlity of our rguet. It e show tht for y NPDA there exists euivlet oe hvig ove two properties i.e. the euivlet NPDA with sigle fil stte whih epties its stk whe it epts the iput, d whih for eh ove ireses/dereses stk y sigle syol. 93 or eh trsitio: i, B / j or eh trsitio: i, B / CD j tk otto syol o trt Vrile $ f we dd produtio: ib j we dd produtio: ibk jcl l Dk trt stte igle il stte for ll sttes k, l 94 95 96 Lguge Hierrhy { : 0} No-regulr lguges Cotext-ree Lguges R { } { ww } Deteriisti PDAs DPDAs Regulr Lguges 97 98 99

Allowed DPDAs, w 1 Not llowed, w 1 Allowed, w 1 trsitios, w 1, w 1 1 1 1, w 3, w 3, w 3 100 101 oethig ust e thed fro the stk 10 Not llowed, w 1 1 NPDAs Hve More Power th DPDAs Positive Properties of Cotext-ree Lguges, w 3 103 104 105 L1 is otext free L is otext free Uio Cotext-free lguges re losed uder Uio L1 L is otext-free I geerl: or otext-free lguges with otext-free grrs d strt vriles he grr of the uio hs ew strt vrile L 1, L G 1, G 1, L1 L 1 d dditiol produtio Cotext-free lguges re losed uder Cotetio L1 is otext free L is otext free Cotetio L 1 L is otext-free 106 107 108

I geerl: or otext-free lguges with otext-free grrs d strt vriles 1, L 1, L G 1, G L 1 L he grr of the otetio hs ew strt vrile d dditiol produtio 1 tr Opertio Cotext-free lguges re losed uder str-opertio L is otext free * L is otext free I geerl: or otext-free lguge with otext-free grr d strt vrile L G he grr of the str opertio hs ew strt vrile 1 d dditiol produtio L* 1 1 109 110 111 Negtive Properties of Cotext-ree Lguges Cotext-free lguges re ot losed uder itersetio L1 is otext free L is otext free Itersetio L1 L ot eessrily otext-free Copleet Cotext-free lguges re ot losed uder opleet L is otext free L ot eessrily otext-free 11 113 114 Itersetio of CL d RL Regulr Closure he itersetio of otext-free lguge d regulr lguge is otext-free lguge L1 otext free L regulr L1 L otext-free he Pupig Le for Cotext-ree Lguges 115 116 117

he Pupig Le for CL or ifiite otext-free lguge L there exists iteger suh tht for y strig we write w L, w w = uvxyz vxy vy with legths d 1 i i d uv xy z L, for ll i 0 118 Applitios of he Pupig Le for CL 119 Restritio-free lguges { : 0} Cotext-free lguges { : 0} 10 heore Proof he lguge L = { : 0} is ot otext free Use the Pupig Le for otext-free lguges L = { : 0} Assue for otrditio tht is otext-free ie L is otext-free d ifiite we pply the pupig le L Pupig Le gives uer suh tht: Pik y strig w L with legth We pik: L = { : 0} w = w 11 1 13 L = { : 0} w = We write: w = uvxyz vxy vy 1 with legths d L = { : 0} Pupig Le sys: i w = w = uvxyz i vxy vy 1 uv xy z L for ll i 0 L = { : 0} w = w = uvxyz We exie ll the possile lotios of strig i vxy w vxy vy 1 14 15 16

L = { : 0} Cse 1: vxy is withi......... u vxy w = w = uvxyz vxy vy 1 z 17 C.W GO HROUGH ALL CA L = { : 0} w = w = uvxyz Cse 5: iilr lysis to se 4......... u vxy vy 1 vxy z 18 here re o other ses to osider vxy vxy sie, strig ot overlp, d t the se tie 19 I ll ses we otied otrditio herefore: he origil ssuptio tht L = { : 0} is otext-free ust e wrog {! : 0} { : 0} { : 0} { ww : w {, }} Urestrited grr lguges Cotext-free lguges { : 0} { ww R : w {, }*} eleted xples of C Lguge Proles Colusio: L is ot otext-free Regulr Lguges ** ND O PROO 130 131 13 xple id CG for the followig lguge id CG for the followig lguge id CG for the followig lguge L = { : k = } Let G e the grr with produtios: B B B Cli: LG = L k 133 L = { : k = } Proof: Cosider the followig derivtio: k * B * B where the first * pplies ties, the seod B B ties ie ll words i LG ust follow this ptter i their derivtios, it is ler tht LG L B B B 134 L = { : k = } Cosider w L, w = for soe, 0 he derivtio k * B * B lerly produes w for y,. L LG L LG G is CG for L ND O PROO B B B 135

xple id PDA d CG for the followig lguge L = {, / 3 : N} 3, / L = { 3 CG : 3 : N}, / 3, / xple id PDA d CG for the followig lguge PDA L = { x {, } : = }, /, / i 3, / f Is the utoto deteriisti? Yes. It ts i uiue wy i eh stte. 136 i 3, / f 137, /, /, /, / 138 L = { x {, } : = } CG :, /, /, /, /, /, / 139 xple Prove tht the lguge L is otext-free L = { : is ot ultiple of Cosider the followig two lguges: L 1 ={w : w is de fro s d s d the legth of w is ultiple of 10} L = { : 0} 5} 140 L 1 ={w : w is de fro s d s d the legth of w is ultiple of te} L = { : 0} Let L 1 deote the opleet of L 1. We hve tht L = L 1 L. L 1 is regulr lguge, sie we esily uild fiite utoto with 10 sttes tht epts y strig i this lguge. L 1 is regulr too, sie regulr lguges re losed uder opleet. 141 xple he lguge L is otext-free. he grr is: herefore, the lguge L = L 1 L is lso otext-free, sie otext-free lguges re losed uder regulr itersetio Regulr Closure. ND O PROO 14 id PDA d CG for the followig lguge L = { x : N, x {, }, x } CG Produtio ex. A A A A A A AA AA A A 143 L = { x : N, x {, }, x } PDA i, / f, / A A, A/ A A, /, / 144

xple id PDA d CG for the followig lguge L = { x {, }: >, the strtig d the fiishig syolsre differet} PDA L = { x {, }: >, the strtig d the fiishig syolsre differet}, /, /, /, /, /, /, /, /, /, /,,,, / /, / / /, /, /, /, /,,,, / / / / CG, diret ostrutio trigs strt d fiish with differet syols A A trigs oti t lest oe ore th A A AA AA AA, /, /, / 145 we ust hve AA here s oly oe A just les 146