0

Hi so consider the language $L= \{(0^i)(1^j)\mid i=k*j \text{ for some positive }k\}$ Could I not rewrite this as $\{((0^k)^j)(b^j)\mid k>1\}$. Seeing it in this form makes me think of a form $a^n b^n$ which we know is context free so therefore it should be context free. Is my logic wrong and if not what would be the best way to show it's context free.

babou
  • 19,445
  • 40
  • 76
  • Your title is a bit strange. Can you make it more direct of explicit. – babou Apr 21 '15 at 15:10
  • I edited the title now, sorry didn't know how to word it. Do you have any idea on this? – learning_user7 Apr 21 '15 at 15:13
  • 1
    If you think that this is context free, come up with a context-free grammar generating it or with a push-down automaton accepting it. If you think that this is not context free, try to prove it, say using the pumping lemma. – Yuval Filmus Apr 21 '15 at 15:15
  • Your intuition is right. One is a homomorphic image of the other. Look at closure properties of CF Languages, and the reference page: http://cs.stackexchange.com/questions/18524/how-to-prove-that-a-language-is-context-free/ – babou Apr 21 '15 at 15:23
  • Are you saying it should be context free then? And could prove it using homomorphism – learning_user7 Apr 21 '15 at 15:42
  • Yes, that is what I mean. - - - - - - - I did not see your comment as you forgot to prefix it with @babou, so the system did not notify me. – babou Apr 21 '15 at 16:43
  • @babou could you show me how I would do it, yuval flimis showed me in a way to try pumping lemma – learning_user7 Apr 21 '15 at 20:35
  • Well, just to make sure we agree: the $k$ in the definition keeps a constant value: you say "for some $k$" not "for any $k$". If that is the case, the CF grammar is simply $S\to 0^kS1|\epsilon$. I do not see what problem there can be, as suggested by Yuval Filmus, even though he is usually correct. So, what is it for $k$? Is it a constant? – babou Apr 21 '15 at 22:02
  • Sorry, I was misinterpreting the question. It is unlikely to be CF, but I have no time now. – babou Apr 22 '15 at 15:26

1 Answers1

1

The best way to show that a language is context-free is to use one of the equivalent definitions of context-free languages. The two most popular ones are:

  • A language is context-free if it is generated by a context-free grammar.
  • A language is context-free if it is accepted by a (non-deterministic) push-down automaton.

The language $\{ a^n b^n : n \geq 0 \}$ is generated by the grammar $S \to aSb | \epsilon$. Let's try to use the same idea for your language: $S \to 0^k S 1 | \epsilon$ (we can implement $0^k$ using context-free rules). The problem is that we can't guarantee that the same $k$ is used in all productions. This leads me to conjecture that the language is not context-free.

How do we show that a language is not context-free? The most popular way is to use the pumping lemma or one of its variants, though this method doesn't always work. Perhaps you should give it a try.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
  • Right I know what methods to use but trying to represent it as a grammar seems problematic like you said, I just wanted to make sure which road to take as yeah I'll just use the pumping-lemma for this. Thanks! – learning_user7 Apr 21 '15 at 15:21
  • 2
    In real life you don't always know which road to take. You have to try both options. – Yuval Filmus Apr 21 '15 at 15:22
  • Would it be ok to choose my pumping string to be (a^p)^p(b^p) – learning_user7 Apr 21 '15 at 16:17
  • If the proof works out, its ok. If it doesn't, it's not ok. Only one way to find out. – Yuval Filmus Apr 21 '15 at 16:28
  • I believe it works out unless I messed up my partitions mainly in the cases where if the string is broken into u,v,w,x, and y vwx contains all a's than if we pump the string in the form u(v^0)w(x^0)y there should be more b's than a's which can't happen in L – learning_user7 Apr 21 '15 at 16:35
  • As far as I can see, this language is CF, and $S\to 0^kS1|\epsilon$. is a grammar for it. I do not see what your remarks regarding $0^k$ and guaranteeing the same $k$ can mean. Or I am badly misreading something. cc @learning_user7 – babou Apr 22 '15 at 09:58
  • @babou I'm afraid your are badly misreading something. The value of $k$ can depend on the word, but it has to be the same for the entire word. – Yuval Filmus Apr 22 '15 at 14:05
  • OK ...!? Can you give me an example of a word that is not acceptable because $k$ is not "the same for the entire word". I do not even see what you mean. I should maybe point out that I read the definition as meaningg that $k$ should be the same for all words, since it says "for some $k$" rather than "for any $k$". I would interpret the latter as requiring to consider all possible values of $k$. The question is poorly quantified ... and I have no idea whether my understanding of English is betraying me. – babou Apr 22 '15 at 14:21
  • The language consists of words $0^i1^j$ where $j$ divides $i$. – Yuval Filmus Apr 22 '15 at 14:23
  • Thanks ... I was misreading the question, and looking at the wrong language. It seemed very easy ... but then, I have seen even easier. :( – babou Apr 22 '15 at 15:24