Is it possible to come up with a linear grammar with unequal number of 0s and 1s?
Such as 0100, 01100, 111,1,0, 100101001…
I know there is a context-free grammar for this, but is there a linear grammar?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A grammar is regular if and only if it is either left regular or right regular. The left regular grammars are equivalent to the left linear grammars. The right regular grammars are equivalent to the right linear grammars. Therefore, if a regular grammar exists that generates the indicated language, then it is either right or left regular, and hence equivalent to either a left or right linear grammar.
edit1:
Note that there’s no regular grammar generating the indicated language LUNEQ. To see this, consider the fact that LEQ = { w : na(w) = nb(w)} is the complement of LUNEQ. Because the regular languages are closed under complementation and LEQ is not a regular language, LUNEQ is not a regular language.
edit2:
I believe the pumping lemma for linear languages can be used to show that the indicated language LUNEQ is not linear. Here is what I’ve come up with. I’m fairly confident it’s correct. My primary concern is that you were asked – presumably – for a linear language generating the indicated language; however, I came to the conclusion that there is no such grammar.
Assume LUNEQ is linear. By the pumping lemma for linear languages, there exists an n > 0 depending on LUNEQ such that for all z ∈ LUNEQ, z can be written uvwxy where:
Let n be the constant guaranteed be the pumping lemma. Consider the string
Since z ∈ LUNEQ, it can be decomposed into substrings uvwxy satisfying the constraints of the pumping lemma such that, for all i ≥ 0, the string
is a member of LUNEQ. Since 1 ≤ |vx| ≤ n, |vx| divides n!. Hence, (n!|vx|-1 + 1) is a natural number. Setting i to (n!|vx|-1 + 1) gives the string
Simplifying the pumped string gives us an equal number of a‘s and b‘s:
Since (2n + n!) is equivalent to the number of b‘s in the pumped string, z‘ ∉ LUNEQ. But this contradicts the assumption that LUNEQ is a linear language. Hence, LUNEQ is not a linear language.