2,495 views
19 votes
19 votes

Let $L$ be the language over the alphabet $\{1, 2, 3, (, )\}$ generated by the following grammar (with start symbol $S$, and non-terminals $\{A, B, C\}$):

$ S \rightarrow A \: B \: C \\ A \rightarrow ( \\ B \rightarrow 1 \: B \mid 2 \: B \mid 3 \: B \\ B \rightarrow 1 \mid 2 \mid 3 \\ C \rightarrow )$

Then, which of the following is TRUE?

  1. $L$ is finite
  2. $L$ is not recursively enumerable
  3. $L$ is regular
  4. $L$ contains only strings of even length
  5. $L$ is context-free but not regular

2 Answers

Best answer
22 votes
22 votes
Language accepted by that grammar is:
$( (1+2+3)^+)$
Hence, regular!

Correct Answer: $C$
edited by
6 votes
6 votes
In the question above they are asking about the language accepted by the grammar not about the grammar,

we can rewrite the grammar as,

S -> ( B )

B-> 1B | 2B | 3B

B-> 1 | 2 | 3

you can generate any combination of 1,2,3 by the above grammar prefixed by '(' and suffixed by ')'. For this language, Finite automata can also be constructed.

let q0 be the initial state and q3 be the final state with transition function below->

(->q0, '(' ) = q1

(q1, 1) = q2

(q1, 2) = q2

(q1, 3) = q2

(q2, 1) = q2

(q2, 2) = q2

(q2, 3) = q2

(q2, ')' ) = q3*

The language for which Finite automata can be constructed is regular. Hence, the language generated by this grammar is regular.
Answer:

Related questions

12 votes
12 votes
6 answers
2
go_editor asked Dec 23, 2016
2,311 views
Which of the following regular expressions correctly accepts the set of all $0/1$-strings with an even (possibly zero) number of $1$s?$(10^*10^*)^*$$(0^*10^*1)^*$$0^*1(10...