0

Say you are given the following CFG $G$: $$ S \to S_1 \mid S_2 \\ S_1 \to AbAS_1c \mid \epsilon \\ S_2 \to BaBS_2c \mid \epsilon \\ A \to Aa \mid \epsilon \\ B \to Bb \mid \epsilon $$

What is $L(G)$?

So far I've derived the following regular expressions:

$ S \rightarrow (a^*ba^*)^*c \mid (b^*ab^*)^*c$

So far I've come up with this $L(G)$:

$L(G) = \{ (a^nba^n)^qc \mid (b^nab^n)^*q : n,q \geq 0 \}$

When you approach the second $S_1$ do you include the $c$ ( As in, finish $S_1c$ and the go recursive)?

marcusvb
  • 13
  • 4
  • 2
    Please ask only one question per question. I count about five questions in your question, which is about four too many. Please read http://cs.stackexchange.com/q/11315/755 and http://cs.stackexchange.com/q/50456/755, see what you can learn from them, try applying them to your situation, then edit your post to ask a single question and show us what you tried and where you got stuck and what progress you made. – D.W. Jun 28 '16 at 21:02
  • 2
    If you are confused about multiple things, I recommend you ask one question now about the logically "first" thing you're confused about and wait a few days for answers. One of two things will happen. You might get an answer that answers the question you asked, and enables you to finish off everything else on your own. Or, you might still be confused about the other issues after reading the answers; at that point, you can ask another question about the next thing you're confused about. – D.W. Jun 28 '16 at 21:03
  • 1
  • "What is L(G)?" -- that question is incomplete. In what form should we answer? 2) Why do you set up with a regular expression? Is the generated language regular?
  • – Raphael Jul 01 '16 at 12:21
  • 1
    The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! – Raphael Jul 01 '16 at 12:22