Converting Grammar to Kuroda Normal Form



In the previous chapter, we presented a basic overview of the Kuroda Normal Form. Now we will see the steps for converting a Type-0 grammar into Kuroda Normal Form (KNF). This process is a systematic process where we modify the production rules of the grammar to fit one of the four specific forms allowed by KNF. As we know these forms are designed to simplify the grammar while retaining its ability to generate the same language.

In this chapter, we will see the steps to converting any Type-0 grammar into Kuroda Normal Form, and see examples for a better understanding.

Understanding the Target Forms

Before getting the steps involved in the conversion let us see the normal form for a little recap.

  • AB → CD − A pair of non-terminals is replaced by another pair of non-terminals.
  • A → BC − A single non-terminal is replaced by two non-terminals.
  • A → a − A non-terminal is replaced by a terminal symbol, generating an actual character in the language.
  • A → ε − A non-terminal is replaced by an empty string, effectively removing it from the generated string.

These forms provide the structure that every production rule in a Type-0 grammar must address to when converting to Kuroda Normal Form.

Transforming a Grammar to Kuroda Normal Form

Transforming a Type-0 grammar to Kuroda Normal Form has a series of steps to make all production rules are in the followed forms. The general approach to this transformation is as follows −

Initial Setup

Begin with a given Type-0 grammar G = (N, T, P, S), where N is the set of non-terminal symbols, T is the set of terminal symbols, P is the set of production rules, and S is the start symbol.

Replacing Terminal Symbols

For every production rule that involves a terminal symbol, replace the terminal with a corresponding non-terminal. This step says that the grammar can move closer to one of the allowed Kuroda forms.

For instance, if a production rule is,

A → a, introduce a new non-terminal a' such that A → a' and a' → a

Handling Productions with More or Fewer Symbols

If a production rule has more symbols on the left side than on the right, it needs to be adjusted to fit the Kuroda format.

For example, a rule like A1 ... Am → B1 ... Bn where m > n can be transformed by adding new non-terminals C to balance the equation. If m < n, the rule can be broken down into smaller steps to fit the form A → BC.

Simplifying the Complex Productions

Any production that does not directly fit the forms AB → CD, A → BC, A → a, or A → ε must be broken down.

For example, a production like A → B1 B2 ... Bn where n ≥ 3 can be split into a series of productions that conform to the Kuroda Normal Form.

Final Adjustments

The final step involves moving all the adjusted and newly formed production rules into the final grammar set H = (M, T, R, S) where R is the set of rules now in Kuroda Normal Form.

Example of Kuroda Normal Form

After getting the steps, consider a simple example of a Type-0 grammar and transform it into Kuroda Normal Form.

Original Grammar G

  • Non-terminals − N = {S, A, B}
  • Terminals − T = {a, b}

Productions

  • S → aAB
  • A → a
  • AB → BA
  • B → b

Transforming to Kuroda Normal Form

Let's replace the Terminal Symbols

  • For the production A → a, introduce a new non-terminal a' such that A → a' and a' → a.
  • For the production B → b, introduce b' such that B → b' and b' → b.

Adjusting the Productions − The production S → aAB is not in Kuroda form. Introduce a new non-terminal C and split the production as −

  • S → a'C
  • C → AB

The production AB → BA fits the AB → CD form, so it remains unchanged.

The Final Productions in Kuroda Normal Form will be like this −

  • S → a'C
  • C → AB
  • A → a'
  • B → b'
  • a' → a
  • b' → b
  • AB → BA

Conclusion

In this chapter, we highlighted the steps for converting a Type-0 grammar to Kuroda Normal Form. In these steps, there are a set of structured series of transformations for each production rule to make it in the four specified formats. Here we explained the steps along with examples for a clear understanding.

Advertisements