Convert the following grammar into Chomsky Normal Form (CNF):
S → aS | A | bS
A → aA | bBa | aAa
B → bb | bBb
Note: you need to first simplify the grammar ( remove any λ - productions, unit productions, and useless productions), and then convert the simplified grammar to CNF.
Chomsky Normal Form format
S0 -> epsilon
NT -> NT NT
NT -> T
where NT = Non terminal and T = terminal
--------------------------------------
Add S0 to the grammar
S0 -> S
S -> aS | A | bS
A -> aA | aBa | aAa
B -> bb | bBb
Remove the epsilon productions: None
Remove the unit productions
S0 -> aS | aA | aBa | aAa | bS
S -> aS | aA | aBa | aAa | bS
A -> aA | aBa | aAa
B -> bb | bBb
Remove useless productions: S0 is redundant
S -> aS | aA | aBa | aAa | bS
A -> aA | aBa | aAa
B -> bb | bBb
Replace the Ts with NTs for non-unit
productions
S -> XS | XA | XBX | XAX | YS
A -> XA | XBX | XAX
B -> YY | YBY
X -> a
Y -> b
Final CNF Format
S -> XS | XA | CX | DX | YS
A -> XA | CX | DX
B -> YY | EY
X -> a
Y -> b
C -> XB
D -> XA
E -> YB
--------------------------------------
Hit the thumbs up if you are fine with the answer. Happy
Learning!
Convert the following grammar into Chomsky Normal Form (CNF): S → aS | A | bS...
In each of the following, find a Chomsky Normal Form (CNF) grammar equivalent to the given context-free grammar (CFG). 1. SaA Sab A+ ab | BA ASD BaS b 2. SAIC A → AaB AaC | B | a B Bb Cb (→ cclc 3. S → SabA; AAA bc | Bc; B → Aab | BS a
When is the grammar said to be in Chomsky Normal Form (CNF). Convert the given grammar to CNF by showing step by step. { S->VP VP->Verb VP-> Verb VP NP->N NP PP Verb->climb|lift|read N-> Tom | apple}
2. Convert the following grammar to Chomsky Normal Form (CNF). R is the start symbol and the lower case letters are terminals. The upper case letters are variables/non-terminals. R->XRXS S->a TbbTa T->XTXI X. € X->ab
Convert the following grammar G over Σ = {a, b} into Chomsky normal form. Note that G already satisfies the conditions on the start symbol S, λ-rules, useless symbols, and chain rules. Show your steps clearly. S → bT T → aAA | AbAT A → aT | bT | a
Conversions to CNF: Textbook problems: 7.1.1 - 7.1.4 (p. 275) 7.1.1) Find a grammar equivalent to the following, but with no useless symbols: S → AB | CA A → a B → BC | AB C → aB | b 7.1.2) Begin with the following grammar, then eliminate ε-productions, eliminate unit productions, eliminate useless symbols, then put the grammar into CNF. S → ASB | ε A → aAS | a B → SbS | A | bb 7.1.3)...
5. (10 points) Convert the following grammar G over Σ-{a, b} into Chomsky normal form. Note that G already satisfies the conditions on the start symbol S, A-rules, useless symbols, and chain rules. Show your steps clearly. 5. (10 points) Convert the following grammar G over Σ-{a, b} into Chomsky normal form. Note that G already satisfies the conditions on the start symbol S, A-rules, useless symbols, and chain rules. Show your steps clearly.
2. To find a Chomsky normal form for the following grammar (10 points) STR T - aTbab R RIA first note that we don't need to add a new production S' Sto the grammar because s does not appear on the right hand side of any productions in the grammar. Next, since we have a A-production in the grammar R - A, so we use the technique in question #6 to remove the production. Afterward the grammar becomes SLT TR...
1. (20 points) Given the following Grammar G, S->ASB A -> aAS | a | λ B -> SbS | A|bb (a) Identify and remove the λ-productions. (b) Identify and remove unit-productions from the result of (a). (c) Convert it to Chomsky Normal Form. 1. (20 points) Given the following Grammar G, S->ASB A -> AS | a 1a B -> Sbs | Albb (a) Identify and remove the -productions. (b) Identify and remove unit-productions from the result of (a)....
7.1.2 Below: Exercise 7.1.3: Repeat Exercise 7.1.2 for the following grammar: S040 1B1 BB a) Eliminate e-productions b) Eliminate any unit productions in the resulting grammar e) Eliminate any useless syunlbol in themesuling granmmar. d) Put the resulting grammar into Chomsky Normal Form Exercise 7.1.3: Repeat Exercise 7.1.2 for the following grammar: S040 1B1 BB a) Eliminate e-productions b) Eliminate any unit productions in the resulting grammar e) Eliminate any useless syunlbol in themesuling granmmar. d) Put the resulting grammar...
Given the following Grammar G, S->ASB A -> AAS | a B -> Sbs | A|bb (a) Identify and remove the A-productions. (b) Identify and remove unit-productions from the result of (a). (c) Convert it to Chomsky Normal Form.