CleverSphere

Chomsky hierarchy: classifying grammars

The Chomsky hierarchy orders grammars by the form of their rules. The stricter the rules, the higher the type.

Rules

  • Type 3: A → a or A → aB
  • Type 2: exactly one variable on the left
  • Type 1: the right side is never shorter than the left
  • Type 0: no restriction

Your turn

Three problems on this topic. The software checks your answer exactly.

  1. 1 · Chomsky hierarchy
  2. 2
  3. 3

What is the highest Chomsky type of this grammar?

S → aS ; S → b

Chomsky type

Worked example

What is the highest Chomsky type of this grammar?

S → aS ; S → b

Worked solution

  1. 1Type 3: one variable on the left, on the right a terminal plus at most one variable at the end.
  2. 2Type 2: exactly one variable on the left.
  3. 3Type 1: the right side is never shorter than the left.
  4. 4Here: Type 3 (regular)

Typical mistake: A left side like cB is no longer context-free, even if every other rule is.

Common questions

Which type do I give?

The highest type whose conditions all rules satisfy.

Related

More topics