Question

In: Computer Science

convert the following grammar to Chomsky Normal Form S -> D0S1 | 1 D -> F0D1...

convert the following grammar to Chomsky Normal Form

S -> D0S1 | 1
D -> F0D1 | 0 | e | FG
F -> SF | DD | S
G -> GK | DG

Solutions

Expert Solution

A context free grammar (CFG) is in Chomsky Normal Form (CNF) if all production rules satisfy one of the following conditions:

  • A ->a
  • B ->CD
  • S-> ε

GIVEN grammer :S -> D0S1 | 1

D -> F0D1 | 0 | e | FG

F -> SF | DD | S

G -> GK | DG

FIRSTLY we will check whether the grammer is in cnf form:- The given grammer is not in cnf form

1) Create new start variable:-

S0 -> S

S -> D0S1 | 1

D -> F0D1 | 0 | e | FG

F -> SF | DD | S

G -> GK | DG

2) Eliminate unit production F -> S, Also removal of unit production S->S and S0->S from grammar yields: :-

S0 -> D0S1 | 1

S -> D0S1 | 1

D -> F0D1 | 0 | e | FG

F -> SF | DD | D0S1 | 1 // NEW PRODUCTION

G -> GK | DG

3) Removing useless variables and productions:-

S0 -> D0S1|1

S -> D0S1 | 1 (1 is generated from S so, it is useful)

D -> F0D1 | 0 | e | FG (0 is generated from D so, it is useful)

F -> D0S1

G -> GK | DG

4) Delete all the REMOVING production  which is present in LHS as well as RHS:-

S0 -> D0S1|1

S -> D0S1 | 1  

D -> 0 |e

F -> D0S1

G -> GK | DG

5) THIS is the converted cnf

S0 -> D0S1|1

S -> D0S1 | 1  

D -> 0

J -> e

F -> D0S1

G -> GK | DG


Related Solutions

Convert this into Chomsky normal form, where each rule is in the form: A --> BC...
Convert this into Chomsky normal form, where each rule is in the form: A --> BC or A --> a A --> A + B | B B --> B x C | C C --> (A) | 5
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.
Convert the simple algebra below into Chomsky Normal Form (CNF), and then create a parse tree...
Convert the simple algebra below into Chomsky Normal Form (CNF), and then create a parse tree showing how the converted grammar could derive: x + y * z E → E + T | T T → T * F | F F → (E) | x | y | z
Assuming normal heptane and normal octane to form ideal solutions, do the following: d) Calculate the...
Assuming normal heptane and normal octane to form ideal solutions, do the following: d) Calculate the dew pressure of the solution at 40 ◦C. e) Calculate the bubble temperature at 1 bar. f) Calculate the dew temperature at 1 bar. g) Calculate the amount and composition of vapor and liquid when a solution with z1 = 0.45 is flashed to 40 ◦C, 0.065 bar. The saturation pressures of the two components are given by the Antoine equation: ln Pi sat...
Consider the following relation and convert to the normal form indicated. Make sure your Primary Key...
Consider the following relation and convert to the normal form indicated. Make sure your Primary Key and its attribute(s) is/are underlined for full credit. Also indicate foreign keys using (FK) if any. 0NF: ORDER[order_num, date, SSN, cust_name, phone, email, (SKU, item_name, price)] Notes:An order has only one customer, but a customer can place many orders. Each order can have multiple items.   1NF: 2NF: 3NF:
Add or subtract the following 2’s complement form signed numbers, then convert the entire problem to...
Add or subtract the following 2’s complement form signed numbers, then convert the entire problem to decimal and confirm: 110110 + 111000 001100 – 011100
Convert the logical statement ~(P || ~R) || (Q -> R) to conjunctive normal form. Please...
Convert the logical statement ~(P || ~R) || (Q -> R) to conjunctive normal form. Please explain the steps!!
Question 1. Put the following game into the normal form. That is, describe the set of...
Question 1. Put the following game into the normal form. That is, describe the set of players, the strategy sets for each player, the payoff functions, and draw the game in matrix form. What do you expect would happen in this game, and why?Two kids are playing a game of Chicken. In this game, they ride their bikes as fast as theycan at each other. The one to swerve or turn out of the way loses, he is a Chicken...
1. For each of the following statements find an equivalent statement in conjunctive normal form. a)...
1. For each of the following statements find an equivalent statement in conjunctive normal form. a) ¬(A ∨ B) b) ¬(A ∧ B) c) A ∨ (B ∧ C) 2. Is the following implication true or false? And if false, give an example that shows that it is false. ---> If S1 ∈ S2 and S2 ∈ S3, then S1 ∈ S3.
Can following BNF convert to CFG (Context Free Grammar) <Boolean_expr> → <Boolean_expr>||<Boolean_term>|<Boolean_term> <Boolean _term> → <Boolean...
Can following BNF convert to CFG (Context Free Grammar) <Boolean_expr> → <Boolean_expr>||<Boolean_term>|<Boolean_term> <Boolean _term> → <Boolean _term> && <Boolean _factor>| <Boolean _factor> <Boolean _factor> →ID | !<Boolean _factor>| (<Boolean _factor>) |<relation_expr> <relation_expr> → ID==ID | ID !=ID | ID < ID | ID≤ID | ID>ID | ID>=ID The above BNF is for Boolean Expression and Relational Expression.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT