Chomsky Hierarchy
Extended Chomsky hierarchy
• According to Chomsky hierarchy, grammars are divided of 4 types:
• Type 0 known as unrestricted grammar.
• Type 1 known as context sensitive grammar.
• Type 2 known as context free grammar.
• Type 3 Regular Grammar.
• Type 0 ( Unrestricted Grammar )
• In Type 0
Type-0 grammars include all formal grammars.
• Type-0 grammars generate recursively enumerable languages.
• The productions have no restrictions.
• They generate the languages that are recognized by a Turing machine.
• The productions can be in the form of α → β where α is a string of
terminals and nonterminals with at least one non-terminal and α cannot
be null. β is a string of terminals and non-terminals.
• For example,
Sab –> ba
A –> S.
• Here, Variables are S, A and Terminals a, b.
Type - 1 Grammar
• Context-sensitive grammars
• Type-1 grammars generate context-sensitive languages.
The productions must be in the form
• αAβ→αγβ
• where A ∈ N (Non-terminal)
• and α, β, γ ∈ (T ∪ N)*
• The languages generated by these grammars are recognized by a linear bounded
automaton.
• AB → AbBc
• A → bcA
•B→b
Type - 2 Grammar
• Context-free grammar
• Type-2 grammars generate context-free languages.
• The productions must be in the form A → γ
• where A ∈ N (Non terminal)
• and γ ∈ (T ∪ N)*
• These languages generated by these grammars are be recognized by a non-
deterministic pushdown automaton.
S→Xa
X→a
X → aX
X → abc
X→ε
Type - 3 Grammar
• Regular grammar
• Type-3 grammars generate regular languages.
• Type-3 grammars must have a single non-terminal on the left-hand side and a
right-hand side consisting of a single terminal or single terminal followed by a
single non-terminal.
• The productions must be in the form X → a or X → aY
• where X, Y ∈ N (Non terminal) and a ∈ T (Terminal)
• The rule S → ε is allowed if S does not appear on the right side of any rule.
• X→ε
• X → a | aY
•Y→b
Grammar Type Grammar Accepted Language Accepted Automaton
Recursively enumerable
Type 0 Unrestricted grammar/free Turing Machine
language
Type 1 Context-sensitive grammar Context-sensitive language Linear-bounded automaton
Type 2 Context-free grammar Context-free language Pushdown automaton
Type 3 Regular grammar Regular language Finite state automaton