Chomsky Hierarchy

 


According to Noam Chomsky, there are four types of grammar-
  1. Type 0 or Unrestricted Grammrs
  2. Type 1 or Context Sensitive Grammars
  3. Type 2 or Context Free Grammars
  4. Type 3 or Regular Grammar

Unrestricted Grammar ( or Type 0 grammar)
 A grammar G = (V, T, P, S)  is called unrestricted if all the productions are of the form,
α→β
where α is in (VUT)+ ( i.e., it can be a string of terminals or non-terminals with at least one non-terminal ) and β is in (VUT)* (a string of terminals and non-terminals ).
Any language generated by an unrestricted grammar is recursively enumerable that are recognized by Turing Machine.
For example,
SAaB
AS
BcacB

Context Sensitive Grammars ( or Type 1 grammars )
    A grammar G = (V, T, P, S ) is said to be context sensitive if all productions are of the form, 
α→β
where α, β ∈ (VUT)and |α| ≤ |β|
( Except for S∈ and start symbol S does not appear on the right hand side of any production )
This type of grammar generate context sensitive language that are recognized by Linear Bounded Automata.
For example,
SAB
ABabc
Bb

Context Free Grammars ( or Type 2 grammars )
    A grammar G = (V, T, P, S) is said to be context free if all productions are of the form,
α→β
where α ∈ V and β ∈ (VUT)* .
This type of grammar generate context free language that are recognized by Non Deterministic Push Down Automata.
For example,
SAB
Ax
By

Regular Grammar ( or Type 3 grammar )
    A grammar G = (V, T, P, S) is said to be context free if all productions are of the form,
α→β
where α ∈ V and β ∈ VT* + T* or β ∈ T* V + T* ( i.e., grammar must have a single terminal on left hand side and on right hand side must have a single non-terminal followed by a terminal ( 0 or more ) or terminal ( 0 or more ) followed by a single non-terminal.
If variable(V of β) is on left then its left linear grammar and if variable is on right then its right linear grammar.
Type 3 generates regular languages that is recognized by Finite Automata.
For example,
SaS | bS |