Question

In: Computer Science

Simplify the grammar G. Does L(G) contain ε ? S -> A B C | B...

Simplify the grammar G. Does L(G) contain ε ?

S -> A B C | B a B

A -> a A | B a C | a a a

B -> b B b | a | D

C -> C A | A C

D -> ε

Solutions

Expert Solution

Solution:

Given grammar G,

S -> ABC | BaB

A -> aA | BaC | aaa

B -> bBb | a | D

C -> CA | AC

D ->

The answer will be "No"

Explanation:

Simplification of grammar G:

Step 1:

=>Remove useless symbols

=>Production rule C -> CA | AC , as AC and CA never terminates so never generate any string hence symbol C is useless hence remove all productions where symbol C appears. A is also useless as it is not reachable from start symbol S.

S -> BaB

B -> bBb | a | D

D ->

Step 2:

=>Remove null productions.

=>Production D -> is a null production so remove D ->

S -> a | BaB | aB | Ba

B -> bBb | a

Step 3:

=>Remove unit productions, as here there is no unit production of type X -> Y where X is single non terminal and Y is also single terminal.

S -> a | BaB | aB | Ba

B -> bBb | a

=>So the simplified grammar is:

S -> a | BaB | aB | Ba

B -> bBb | a

Finding language of grammar G:

=>Smallest strings generated by the given grammar G = a using S -> a

=>Strings of length 2 generated by the grammar G = aa using S -> aB or S -> Ba, B -> a

and so on.

=>L(G) means the language generated by given grammar G.

=>L(G) is set of all the strings generated by the given grammar G, L(G) = {a, aa, aaa,.....}

=>We can see that the smallest string generated by the grammar G is "a" and there is no way to generate the string of length 0 means .

=>On the basis of above statements we can say that L(G) does not contain .

I have explained each and every part with the help of statements attached to it.

We were unable to transcribe this image

We were unable to transcribe this image

We were unable to transcribe this image

We were unable to transcribe this image

We were unable to transcribe this image

We were unable to transcribe this image


Related Solutions

For a grammar G with the productions where G = ( {S, A, B}, {a, b},...
For a grammar G with the productions where G = ( {S, A, B}, {a, b}, S, P ) with productions                                              S --> AB | bbbB,              A --> b | Ab,       B --> a.. 1.Show that the grammar G is ambiguous. 2.Give language L that is generated by G, L = L(G), in a formal expression (including a regular expression). 3.Can you construct an unambiguous grammar that is equivalent to G? Otherwise, show that G is inherently ambiguous.
What is the reaction A(g) + B(g) + C(g)------------> D(g) Experiment Initial [A] (mol/L) Initial [B]...
What is the reaction A(g) + B(g) + C(g)------------> D(g) Experiment Initial [A] (mol/L) Initial [B] (mol/L) Initial [C] (mol/L) Initial rate (M/s) 1 0.0500 0.0500 0.0100 6.25*^(-3) 2 0.1000 0.0500 0.0100 1.25*^(-2) 3 0.1000 0.1000 0.0100 5*10^(-2) 4 0.0500 0.0500 0.0200 6.25*10^(-3) 1) What is the order with respect to each reactant? 2) Write the rate law 3) Calculate K (using the data from experiment 1)
Given a grammar G, G = (Ν, Σ, Π, S), where Ν = { ... }...
Given a grammar G, G = (Ν, Σ, Π, S), where Ν = { ... } Σ = { ... } Π = { ... } S is ... For a string ... write (a) A leftmost derivation (b) A rightmost derivation
Let L = {x = a r b s c t | r + s =...
Let L = {x = a r b s c t | r + s = t, r, s, t ≥ 0}. Give the simplest proof you can that L is not regular using the pumping lemma.
3. Simplify the following expressions using the properties of boolean algebra : 3A)    S(A,B,C) = A'B'C...
3. Simplify the following expressions using the properties of boolean algebra : 3A)    S(A,B,C) = A'B'C + A'BC + AB'C + ABC 3B) F(A,B,C) = A'B'C' + A'B'C + AB'C' + AB'C + ABC' + ABC
Consider the following (unbalanced) chemical reaction: Fe2O3(s) + C(s) → Fe(l) + CO2(g)Fe2O3(s) + C(s) →...
Consider the following (unbalanced) chemical reaction: Fe2O3(s) + C(s) → Fe(l) + CO2(g)Fe2O3(s) + C(s) → Fe(l) + CO2(g) a How many grams of carbon are needed to react with 811.21 grams of Fe22O33? b How many grams of iron can be produced from 390.955 g of carbon? c you make 487.857 grams of CO22, how many grams of Fe are produced?
1. Consider the regular grammar G given below: S → aS|aA|bB|λ A → aA|bS B →...
1. Consider the regular grammar G given below: S → aS|aA|bB|λ A → aA|bS B → bB|aS (a) Give a derivation for the strings aabbba and baaba (b) Give an infinite language L such that L is not a subset of L(G) (c) Give a regular expression that describes the language L(G).
Give a context-free grammar for {w ∈ {b, c}∗| #c(w) = #b(w)}.
Give a context-free grammar for {w ∈ {b, c}∗| #c(w) = #b(w)}.
Let G = (AN , AT , S, P) be a context-free grammar in Chomsky normal...
Let G = (AN , AT , S, P) be a context-free grammar in Chomsky normal form. Prove that if there exists a word w ∈ L(G) generated by a derivation that uses more than |P| + |AT | steps, then L(G) is infinite.
#1 We are given the grammar rules A ➝ F B E B ➝ A C...
#1 We are given the grammar rules A ➝ F B E B ➝ A C These rules are only some of the rules of a larger grammar G, but we are not given the remaining rules of G. We are told that A is the start symbol of G and that the following holds: {ε, c, d} ⊆ FIRST(C) {ε, e} ⊆ FIRST(E) {ε, f, g} ⊆ FIRST(F) Recall that end of file is denoted EOF. The symbol ⊆...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT