0 Up votes0 Down votes

6 views34 pagesMELJUN CORTES Automata Lecture Non-context-free Languages 2

Jun 12, 2015

© © All Rights Reserved

PDF, TXT or read online from Scribd

MELJUN CORTES Automata Lecture Non-context-free Languages 2

© All Rights Reserved

6 views

MELJUN CORTES Automata Lecture Non-context-free Languages 2

© All Rights Reserved

- Parsing
- Theory of computation Leland L. Beck -Systems PrograComming-PLelan Beckearson (1997)
- 3452-Theory of Automata (1)
- SCFG Smaller
- 1 (39)
- Assign 1
- Chomsky Hierarchy
- automata assigment
- AM_ch1
- PRINCIPLES COMPILER DESIGN DEC 2002
- Potongan Bab 2 TBO
- 06KleeneTheorem
- TCU 2019 Certificate Recognization SERVICE AWARD 5 Years
- TCU 2018 Certificate of Recognition Outstanding Faculty
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2018 2019
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2018 2019
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2017 2018
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2017 2018
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2016 2017
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2016 2017

You are on page 1of 34

NON-CONTEXT-FREE

LANGUAGES

Non-Context-Free Languages

Introduction

A regular language has either

a nondeterministic automaton

that recognizes it or a regular

expression that can generate

its strings.

A context-free language has

either a pushdown automaton

that recognizes it or a contextfree

grammar

that

can

generate its strings.

Non-Context-Free Languages

* Property of STI

Page 1 of 34

Questions:

1. Are there non-context-free

languages?

2. How can a language be

proven to be non-contextfree?

1} is non-context-free since

there is no PDA that can

recognize it.

non-context-free, it must be

shown that there is no PDA or

CFG for that language (difficult

to do).

Non-Context-Free Languages

* Property of STI

Page 2 of 34

lemma was used to prove that

a language is not regular.

The pumping lemma for

regular languages exploited a

property of regular languages

to prove the non-regularity of

languages.

Strings of regular languages

have the property that if they

are long enough, then they

have a substring that can be

repeated an arbitrary number

of times and the resulting

strings will still be in language.

that do not have this property

are considered not regular.

Non-Context-Free Languages

* Property of STI

Page 3 of 34

non-context-free, there must

be a pumping lemma for

context-free languages.

This pumping lemma should

also exploit a certain property

of context-free languages.

Languages whose strings do

not have this property are

considered non-context-free.

Non-Context-Free Languages

* Property of STI

Page 4 of 34

L:

S A1

A 0A1

string 0001111 is

S A1

0A11

00A111

000A1111

0001111

Non-Context-Free Languages

* Property of STI

Page 5 of 34

derivation for the string

0001111 is

S

Non-Context-Free Languages

* Property of STI

Page 6 of 34

being derived is long, some

variables were used more than

once.

regular languages, strings

whose length is greater than or

equal to the number of DFA

states (the pumping length)

have a substring that can be

repeated an arbitrary number

of times, and the resulting

strings will still be in the

language.

context-free languages, what

is then the pumping length?

Non-Context-Free Languages

* Property of STI

Page 7 of 34

parse tree, the non-leaf nodes

have a maximum number of

children equal to c (this implies

that the right-hand side of the

rules of the grammar has a

string whose length is c).

Assume also that in the

succeeding discussions c 2.

of the parse tree for the

derivation of a certain string w

is h.

maximum number of leaf

nodes equal to ch.

Non-Context-Free Languages

* Property of STI

Page 8 of 34

parse tree represent the

symbols of the string w being

derived, then this means that

w ch

a certain string w is

w cv + 1

where v is the number of

variables in the grammar.

This implies that the height of

the parse tree will be

hv+1

Non-Context-Free Languages

* Property of STI

Page 9 of 34

If h v + 1, then there is a

path from the root node to a

leaf node that is greater than

or equal to v + 1.

2 nodes. If the last node is a

terminal, then the remaining

nodes are variables.

Since the derivation used

more than v + 1 variables, then

at least one variable was

repeated (by the pigeonhole

principle).

Non-Context-Free Languages

* Property of STI

Page 10 of 34

S

...

u

...

...

z

...

y

Assume that this parse tree

represents

the

shortest

derivation for the string S.

Non-Context-Free Languages

* Property of STI

Page 11 of 34

repeated before the derivation

A x, then the parse tree

would look like:

S

...

u

...

v

...

...

...

y

...

y

uvvxyyz uv2xy2z

Non-Context-Free Languages

* Property of STI

Page 12 of 34

repeated several times, then

the string derived will look like

uvixyiz

and this string would still

belong to the language

represented by the grammar.

regular languages, the input

string w can then be written as

w = xyiz

where the middle substring y

can be pumped several times

and the resulting string will still

belong to the language

concerned.

Non-Context-Free Languages

* Property of STI

Page 13 of 34

context-free languages, the

input string w can then be

written as

w = uvixyiz

where the 2nd and 4th

substrings v and y can be

pumped several times and the

resulting string will still belong

to the language concerned.

Non-Context-Free Languages

* Property of STI

Page 14 of 34

regular languages, the pumping

length p refers to the number of

states of the DFA recognizing

the language.

Hence, w p for the pumping

lemma to be used.

In the pumping lemma for

context-free languages, the

pumping length p is equal to the

term cv + 1 where c is the length

of the longest right-hand side

string of any rule in the

grammar and v is the number of

variables of the grammar.

w being analyzed must be

greater than cv + 1.

Non-Context-Free Languages

* Property of STI

Page 15 of 34

If L is a context-free language,

then there is a number p (the

pumping length) where, if w

is any string in L whose length

is greater than or equal to p,

then w may be divided into five

parts, w = uvxyz, satisfying the

following conditions:

1. for each i 0, uvixyiz

L,

2. vy 1, and

3. vxy

Non-Context-Free Languages

p.

* Property of STI

Page 16 of 34

Major points:

1. The string w = uvixyiz

for each i 0.

This

condition

simply

states

that

strings

belonging to language L

that are longer than the

pumping length can be

divided into 5 parts u, v, x,

y, and z.

The 2nd and 4th parts can

be repeated several times

and the resulting string will

still belong to language L.

Non-Context-Free Languages

* Property of STI

Page 17 of 34

2.

that substrings v and y

cannot both be empty

strings.

If v = y = , then the

derivation

A

vAy

becomes A A. This is a

useless derivation and

therefore can be removed.

This, however, violates the

assumption that the parse

tree presented depicts the

shortest derivation for the

string S.

Therefore vy 1.

Non-Context-Free Languages

* Property of STI

Page 18 of 34

3.

vxy

Consider

again

following parse tree:

the

...

hv+1

u

...

...

z

...

y

of the tree h v + 1.

Non-Context-Free Languages

* Property of STI

Page 19 of 34

subtree (rooted at the

upper variable A) of the

given parse tree:

root of

the

subtree

A

...

...

hv+1

Non-Context-Free Languages

* Property of STI

Page 20 of 34

variable is repeated below

the root node of this

subtree.

It follows that this subtree

has a height:

hv+1

subtree then has a length:

Non-Context-Free Languages

vxy

cv + 1

vxy

* Property of STI

Page 21 of 34

regular languages, proving a

language is non-context-free

will use proof by contradiction:

1. First, assume that the

language L is context-free.

pumping lemma states that

all strings of L that are long

enough can be pumped.

3. Find a string w that is long

enough that cannot be

pumped.

4. If there is such a string,

then the pumping lemma

was contradicted. Hence,

language L is non-contextfree.

Non-Context-Free Languages

* Property of STI

Page 22 of 34

language L1 = {anbncn n 1}

is not context-free.

Let p be the pumping length of

L 1.

Let the string to be pumped be

w = a pb p c p.

Since w p, the string chosen

is long enough to be pumped.

Consider now the various

ways in which w can be

divided into the u, v, x, y, and z

substrings.

Non-Context-Free Languages

* Property of STI

Page 23 of 34

Pumping v and y would

create a string where there

are more as than bs and

cs. Hence, the resulting

string will not be in L1.

This violates condition 1 of

the pumping lemma.

Option 2: Let vxy be some

as followed by some bs.

Pumping v and y would

create a string where there

are more as and bs than

cs. Hence, the resulting

string will not be in L1.

This violates condition 1 of

the pumping lemma.

Non-Context-Free Languages

* Property of STI

Page 24 of 34

Pumping v and y would

create a string where there

are more bs than as and

cs. Hence, the resulting

string will not be in L1.

This violates condition 1 of

the pumping lemma.

Option 4: Let vxy be some

bs followed by some cs.

Pumping v and y would

create a string where there

are more bs and cs than

as. Hence, the resulting

string will not be in L1.

This violates condition 1 of

the pumping lemma.

Non-Context-Free Languages

* Property of STI

Page 25 of 34

Pumping v and y would

create a string where there

are more cs than as and

bs. Hence, the resulting

string will not be in L1.

This violates condition 1 of

the pumping lemma.

cannot be pumped, then this

contradicts

the

original

assumption that L1 is contextfree. Therefore, L1 is noncontext-free.

Non-Context-Free Languages

* Property of STI

Page 26 of 34

language L2 = {ww w

{0,

1}*} is not context-free.

Let p be the pumping length of

L 2.

Let the string to be pumped be

w = 0 p1 p 0 p1 p.

Since w p, the string chosen

is long enough to be pumped.

Consider now the various

ways in which w can be

divided into the u, v, x, y, and z

substrings.

Non-Context-Free Languages

* Property of STI

Page 27 of 34

from the first or second 0p of

the string.

Pumping v and y would

create a string where the

first half is not equal to the

second half. Hence, the

resulting string will not be

in L2.

This violates

condition 1 of the pumping

lemma.

from the first or second 1p of

the string.

Pumping v and y would

create a string where the

first half is not equal to the

second half. Hence, the

resulting string will not be

in L2.

Non-Context-Free Languages

* Property of STI

Page 28 of 34

followed by some 1s from the

first or second half of the

string.

Pumping v and y would

create a string where the

first half is not equal to the

second half. Hence, the

resulting string will not be

in L2.

This violates

condition 1 of the pumping

lemma.

Non-Context-Free Languages

* Property of STI

Page 29 of 34

followed

by

some

0s

somewhere in the middle

portion of the string.

create a string where the

first half is not equal to the

second half. Hence, the

resulting string will not be

in L2.

This violates

condition 1 of the pumping

lemma.

Since L2 has a string that

cannot be pumped, then this

contradicts

the

original

assumption that L2 is contextfree. Therefore, L2 is noncontext-free.

Non-Context-Free Languages

* Property of STI

Page 30 of 34

language L3 = {aibjck k j i

0} is not context-free.

Let p be the pumping length of

L 3.

Let the string to be pumped be

w = a pb p c p.

Since w p, the string chosen

is long enough to be pumped.

Consider now the various

ways in which w can be

divided into the u, v, x, y, and z

substrings.

Non-Context-Free Languages

* Property of STI

Page 31 of 34

Pumping v and y would

create a string where there

are more as than bs and

cs. Hence, the resulting

string will not be in L3.

This violates condition 1 of

the pumping lemma.

Option 2: Let vxy be some

as followed by some bs.

Pumping v and y would

create a string where there

are more as and bs than

cs. Hence, the resulting

string will not be in L3.

This violates condition 1 of

the pumping lemma.

Non-Context-Free Languages

* Property of STI

Page 32 of 34

Pumping v and y would

create a string where there

are more bs than cs.

Hence, the resulting string

will not be in L3. This

violates condition 1 of the

pumping lemma.

Option 4: Let vxy be some

bs followed by some cs.

Pumping down v and y

would create a string

where there are more as

than bs and cs. Hence,

the resulting string will not

be in L3.

This violates

condition 1 of the pumping

lemma.

Non-Context-Free Languages

* Property of STI

Page 33 of 34

Pumping down v and y

would create a string

where there are more as

and bs than cs. Hence,

the resulting string will not

be in L3.

This violates

condition 1 of the pumping

lemma.

Since L3 has a string that

cannot be pumped, then this

contradicts

the

original

assumption that L3 is contextfree. Therefore, L3 is noncontext-free.

Non-Context-Free Languages

* Property of STI

Page 34 of 34

- ParsingUploaded byTech_MX
- Theory of computation Leland L. Beck -Systems PrograComming-PLelan Beckearson (1997)Uploaded byJai
- 3452-Theory of Automata (1)Uploaded byFahad Shaikh
- SCFG SmallerUploaded byBill Majoros
- 1 (39)Uploaded bymajid Majid
- Assign 1Uploaded byWairegi Emma
- Chomsky HierarchyUploaded bypuneet
- automata assigmentUploaded byAbhay Singh
- AM_ch1Uploaded by김대원
- PRINCIPLES COMPILER DESIGN DEC 2002Uploaded byapi-3782519
- Potongan Bab 2 TBOUploaded byDeviWedayanti
- 06KleeneTheoremUploaded byAaine Siddiqui

- TCU 2019 Certificate Recognization SERVICE AWARD 5 YearsUploaded byMELJUN CORTES, MBA,MPA
- TCU 2018 Certificate of Recognition Outstanding FacultyUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2018 2019Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2018 2019Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2017 2018Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2017 2018Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2016 2017Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2016 2017Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2015 2016Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2015 2016Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2014 2015Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2014 2015Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU 2019 Certificate Recognization SERVICE AWARD 5 years of TCU OSASUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU 2018 Certificate of Recognition Outstanding Faculty of TCUUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC III BookkeepingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC II CSS Computer Systems ServicingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA TM 1 2016 Trainer's Methodology IUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA Data Encoder Eligibility 2Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA Data Encoder Eligibility 1Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC II PC OperationsUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC I Data EncoderUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC I TechnicianUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA 2009 Tm Am Trainers AMUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA 2009 CHS NC II 392 Hours Certificate of Training Computer Hardware ServicingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU OSAS 2019 Certificate Recognization SERVICE AWARD 5 YearsUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU 2018 Certificate of Recognition Outstanding Faculty - TEACHERUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM COGNOS Certified 2013Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM Training Certificate DATA WareHousingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM Training Certificate BIG DATAUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM Training Certificate Predictive AnalyticsUploaded byMELJUN CORTES, MBA,MPA

- notes.pdfUploaded byHafiz Mujadid Khalid
- Context Grammar QnAUploaded bySam Maosa
- Exam2Uploaded byhamz56787298
- Assignment2-SOLUTIONFINAL.docUploaded bySinclair Chinyoka
- mathematicalreasoning-120915110136-phpapp01.pdfUploaded byAmri Awalludin
- Cantor Schroeder BernsteinUploaded byKaram Aneja
- TOC(7th&8th)May2016Uploaded byNahid Bin Sharfuddin
- dorkUploaded byrizalkenzo
- Unit 6 2013Uploaded byalicenuoli
- Formal Languages and Chomsky Hierarchy[1]Uploaded bySaurabh Singh
- hw3sol1.20Uploaded byDaniell Beltran
- [Lifschitz] Foundations of Logic Programming, In Principles of Knowledge Representation, CSLI PublicationsUploaded bySergio Arturo
- Hypothetical Syllogism (Full version)Uploaded byroy_dubouzet
- English Math 2Uploaded byFadilah Yasin
- 2.5 Postulates and Paragraph ProofsUploaded byJared Lucas Turcuato
- compiler-design-lab-manual-for-r13.pdfUploaded bychippyrevu
- Theory of Computation Solved MCQ - Part 2 _ Computer Science Solved MCQsUploaded byAdithya Ta
- Boolean Algebra 2Uploaded bymars
- 06L8Uploaded bytheresa.painter
- Algebra and topology in lambda calculusUploaded byTa Thanh Dinh
- A00-2033Uploaded bypunjabian37
- Discrete Mathematics Using a Computer - 04 - Induction Notes and SolutionsUploaded bykanakkshetri
- Assignment 1 solutionUploaded bylegorogers
- strictimUploaded bytelos1
- HSS F236Uploaded byRaghav Chamadiya
- test through lesson 3Uploaded byapi-236387090
- QUESTION BANK FOR THEORY OF COMPUTATION REGULATION 2013Uploaded byPRIYA RAJI
- Compiler Lab ManualUploaded bySANDJITH
- Formal Languages and Automata TheoryUploaded byVenugopal Reddy
- Acd-cf 05 BatchUploaded bycvinay24

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.