verifier of addition… not-regular, but is it context-free? [closed]

天大地大妈咪最大 提交于 2019-12-12 01:16:05

问题


How can I show that the following language is (not) context-free? The argument that it's not regular goes as follows.

I suspect this language to be context-free... The reason why I think this, is because L = {an bm c{n+m} | n,m >= 0} is context-free. A proof for this can be found at

http://cg.scs.carleton.ca/~michiel/TheoryOfComputation/TheoryOfComputation.pdf (p102 in pdf; p94 in text)

The proof is kind of long and it can probably be proven much shorter by making use of the equivalence with PDAs (i.e. pushing first some symbol n "+" m times on the stack, and consequently taking it off again n+m times.) Either way, this example makes me believe that my original language must also be context-free. Yet, I don't really see how I can argue for this.


回答1:


No, your assumption is not correct!

The language L = { x = y + z | where x, y, z are binary integers and x is the sum of y and z} is not Context Free Languages(CFL).

I try to explain.

First of all, consider following examples strings s in language L.

110 = 100 + 10   
1110 = 1100 + 10  
:
111000 = 110000 + 1000    

In my explanation LHS is X in question and RHS is Y + Z.

What is pumping Lemma for CFL?
If a language L is context-free, then there exists some integer p ≥ 1 such that any string s in L with |s| ≥ p. (where p is a "pumping length" can be written as

s = uvxyz
with substrings u, v, x, y and z, such that
1. |vxy| ≤ p,
2. |vy| ≥ 1, and
3. uv nxy nz is in L for every natural number n.  

This definition | ≥ 1, and 3. uv nxy nz is in L for every natural number n.

Notice: Middle part of s , vxy not greater then pumping length p. (condition 1)

[SOLUTION]:

Let us choose a string s in L that satisfy condition |s| ≥ p

our s is 1m0q = 1m-10q + 10q , where q > p , m-1 > p

Now total length of s is 2m + 2q -1 that is greater then p and of-course for some combination of natural numbers this inequality is possible (I am not including length of + and = to keep explanation simple )

Now our s is in language and sufficiently large according to pumping lemma for CFG.

Now break it:

u vxy z = 1m0q = 1m-10q + 10q

Try to find v and y to pump and generate new string in language L, But keep in mind v and y should not be too much far than p (according to condition 1).

You don't have any choice for v and y such that you can generate new strings in language!

(Step-1): Because if you chose to increase 1 then you can't pump both side RHS and LHS of = because last 1 on LHS is at q (>p) to first 1 of RHS. hence not possible to generate new strings in language.

(Step-2): Suppose you like to pump 0 again its not possible to increase 0 on LHS and RHS together because last 0 on LHS in m-1 (>p) distend to first 0 on RHS.

(Step-3): You can't pump a combination of 111...000... both side. , try this you will get string out of language L.

Try other options too within the rules of Pumping Lemma. you would not find correct choice for v and y.

[ANSWER]

So he have a string s in L that is sufficiently large and using that we can't generate new strings in language. its contradict to Pumping Lemma for CFL hence given L is not a CFL.



来源:https://stackoverflow.com/questions/13904309/verifier-of-addition-not-regular-but-is-it-context-free

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!