Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the language A = {0^n 1^n 0^n} context free?

I was just putting some thought into different languages (as I'm reviewing for final exams coming up) and I can not think of a valid pushdown automata to handle the language A = {0^n 1^n 0^n | n >= 0}. This is not a context-free language, am I correct?

like image 837
Tony Avatar asked Apr 11 '10 19:04

Tony


People also ask

Is a language context-free?

Every regular language is context free. | m, l, k, n >= 1 } is context free, as it is regular too. Given an expression such that it is possible to obtain a center or mid point in the strings, so we can carry out comparison of left and right sub-parts using stack.

What is a context-free language?

Definition of context-free : of, relating to, or being a grammar or language based on rules that describe a change in a string without reference to elements not in the string also : being such a rule.

Which programming language is context free?

Since regular languages are a subset of context-free languages, all programs of bounded size are context-free.

Is WWR a context-free language?

For the following context-free grammar G1 = < V1 , , S , P1 > generates L1 : V1 = { S } , = { a , b } and P1 = { S -> aSb , S -> ab }. Example 2: L2 = { wwr| w {a, b }+ } is a context-free language , where w is a non-empty string and wr denotes the reversal of string w, that is, w is spelled backward to obtain wr .


2 Answers

I believe you are. It looks quite similar to the language L = { a^i b^i c^i | i > 0 } which the Wikipedia article on the pumping lemma uses as an example of how to prove that a language is not context-free.

like image 94
SamB Avatar answered Nov 12 '22 19:11

SamB


Think of just the {0^n 1^n} part for a second. Replace 0 with ( and 1 with ) and you've got the language of simple nested parentheses, which is a dead give-away that a language is not regular.

Adding the final 0^n makes it context-sensitive (i.e. not context-free). Keep in mind that a CFG can be decided by a finite-state computer with a single stack as its only data structure. Seeing a 0 will cause a character to be pushed onto the stack, and seeing a 1 will pop from the stack. This guarantees that there are as many 0's as 1's, but there's no way to then match more 0's.

like image 37
baddox Avatar answered Nov 12 '22 20:11

baddox