Chomsky Hierarchy
Chomsky Hierarchy
The Chomsky Hierarchy is a classification of formal grammars that was introduced by Noam
Chomsky in the 1950s. It categorizes grammars based on their generative power and the
types of languages they can generate. The hierarchy consists of four types of grammars:
Type-0, Type-1, Type-2, and Type-3. Each type has distinct characteristics and is associated
with different classes of formal languages, ranging from the most general to the most
restrictive. This document will explain each type of grammar and highlight the differences
between them.
Type-0 Grammars
Type-1 Grammars
Type-2 Grammars
Type-3 Grammars
Type-0
Type-1
Recursively Enumerable
Context-Sensitive Languages
Languages
Linear Bounded Automata
Unrestricted Grammars
Chomsky
Hierarchy Type-2
Type-3
Context-Free Languages
Regular Languages
Pushdown Automata
Finite Automata
α→β
where α and β are strings of terminals and non-terminals, and α must contain at least
one non-terminal. Type-0 grammars can generate recursively enumerable languages,
which means that there exists a Turing machine that can recognize these languages.
However, they may not always halt, making them non-decidable.
Characteristics:
• No restrictions on production rules.
• Can generate any language that a Turing machine can recognize.
• Non-decidable languages.
αAβ → αγβ
where A is a non-terminal, and α, β, and γ are strings of terminals and non-terminals. The
key restriction is that the length of the string on the left-hand side must be less than or
equal to the length of the string on the right-hand side. Type-1 grammars can generate
context-sensitive languages, which can be recognized by linear-bounded automata.
Characteristics:
• Production rules must maintain or increase string length.
• Can generate context-sensitive languages.
• Recognized by linear-bounded automata.
Type-2 grammars, or context-free grammars, have even more restrictions on their production
rules. The rules are of the form:
A →β
Characteristics:
• Production rules consist of a single non-terminal on the left-hand side.
• Can generate context-free languages.
• Recognized by pushdown automata.
Type-3 grammars, or regular grammars, are the most restrictive class in the Chomsky
Hierarchy. The production rules can be of the form:
A → aB
A→a
where A and B are non-terminals and a is a terminal. Regular grammars can generate regular
languages, which can be recognized by finite automata. Regular languages are the simplest
class of languages and are commonly used in lexical analysis and pattern matching.
Characteristics:
• Production rules are highly restricted (right-linear or left-linear).
• Can generate regular languages.
• Recognized by finite automata.
Type-0 Type-1