Introduction
The Chomsky hierarchy organizes grammars and their languages into four classical types: regular (Type-3), context-free (Type-2), context-sensitive (Type-1), and unrestricted (Type-0). Matching machine models are finite automata, PDAs, linear bounded automata (LBAs), and Turing machines. The hierarchy is used for inclusion questions, example witnesses, and closure/decidability contrasts. This note summarises the map; it is not a deep dive into LBAs.
Three kinds of question arise here: which class a language belongs to (tightest class), which grammar type a rule set is, and which machine model matches which class. The finer ladder with DCFL and the decidable languages matters as much as the four classical types.
Prerequisites
- Turing Machines: Type-0 machine model.
- Earlier TOC notes on regular and context-free languages.
Core concepts
The four types
| Type | Grammar restriction | Machine | Languages |
|---|---|---|---|
| 3 | , (all right-linear) or all left-linear, | FA | Regular |
| 2 | , | PDA | Context-free |
| 1 | with ; equivalently non-contracting with ; allowed only if is on no right side | LBA | Context-sensitive |
| 0 | , contains a variable | TM | Recursively enumerable |
Mixing right-linear and left-linear rules in one grammar leaves Type 3: , generates . Such linear grammars (at most one variable on each right side) give a class strictly between REG and CFL.
Inclusions
and the finer ladder is
Every CSL is decidable, because an LBA on input has only finitely many configurations (), so a decider can search the configuration graph for an accepting configuration (or cut every run off after that many steps) and always halt. Watching a single run for a repeat is not enough, because an LBA is nondeterministic. The inclusion is strict by diagonalization over an enumeration of LBAs; no "natural" witness is needed for GATE.

Witnesses
- Regular but not finite: .
- CFL not regular: .
- CSL not CFL: .
- RE not recursive: (next note).
- DCFL not regular: . CFL not DCFL: , .
- Not RE: .
How it works
Right-linear grammars = regular
Productions or with generate regular languages; convert to/from NFAs by treating variables as states.
Unrestricted grammars = TMs
Type-0 productions ( nonempty) generate exactly the r.e. languages.
Algorithms and pseudocode
Membership:
- Regular: DFA run linear time.
- CFL: CYK cubic time.
- CSL: decidable (LBA space), expensive.
- RE: semidecidable (enumerate TM acceptors).
Mathematical explanation
Properness of inclusions
Each witness separates adjacent classes: has infinitely many Myhill-Nerode classes (the prefixes are pairwise distinguishable by ), fails the CFL pumping lemma, and is undecidable by diagonalization.
A context-sensitive grammar for
, , , , , . Every rule is non-contracting. Derivation of aabbcc: . The rule sorts the variables; and turn 's into 's only once they sit right after the 's or 's, so letters never get out of order. Because no rule shrinks a sentential form, membership of can be decided by searching only forms of length , which is the grammar view of "CSL REC".
Decidable versus r.e.
Recursive languages are those decided by total TMs; they properly contain the context-sensitive languages under standard textbook presentations used in GATE, and are properly contained in RE.
Worked examples
Example 1: place the language
| Language | Class (tight) |
|---|---|
| regular | |
| CFL, not regular | |
| CSL, not CFL | |
| RE, not recursive |
Example 2: grammar type check
right-linear (Type-3). Type-2. The rule rewrites as in the context , so it is Type-1. is contracting, so it is Type-0 only. is Type-2 although its language is regular: the type of a grammar is set by the rule shapes, the class of a language by the best grammar that exists for it.
Example 3: machine upgrade
FA cannot store for ; PDA can; PDA cannot store two independent counts for ; TM can.
Example 4: closure glance
Regular languages, DCFLs, CSLs and decidable languages are closed under complement; CFLs and RE languages are not. CSL closure under complement is the Immerman-Szelepcsenyi theorem. The full table across all classes is in Closure and Decision Properties of CFLs.
Example 5: exam diagram
Draw nested ovals labelled REG, CFL, CSL, RE and write each witness inside the ring of the smallest class that contains it: in the CFL ring outside REG, in the CSL ring outside CFL, in the RE ring.
Example 6: tightest class
| Language | Tightest class | Why |
|---|---|---|
| regular | finite | |
| DCFL | one counter, decided at end of input | |
| DCFL | counter with a sign | |
| CFL, not DCFL | the centre must be guessed | |
| , , , , | CSL, not CFL | each is decided in linear space |
| decidable; known CSL upper bound under the ordinary grammar encoding, not a tightest-class claim | marking generating variables | |
| , | RE, not co-RE | simulate; diagonalization |
| , | co-RE, not RE | complement of an RE, undecidable language |
| neither RE nor co-RE | and |
Traps: a subset of a regular language need not be regular (); a finite union of regular languages is regular, an infinite union need not be (); every finite language is regular, however complicated its definition.
Important properties and observations
- Hierarchy is about descriptive power, not asymptotic runtime.
- Ambiguity, determinism (DCFL) and decidability cut across the hierarchy with their own subclasses.
- An LBA is a nondeterministic TM whose head never leaves the input; whether deterministic LBAs are as powerful is an open problem.
- Type-0 grammars and TMs are equivalent: a TM can enumerate all derivations, and a grammar can simulate a TM run backwards.
Common misconceptions.
- "CSL means 'almost CFL'." CSLs properly contain CFLs; is the emblem.
- "RE means regular expression." In computability, RE means recursively enumerable.
- "All TM languages are decidable." Only the recursive ones.
- "Every CSL is a CFL with context." CSLs contain all CFLs, and also non-CFLs such as .
- "A grammar with a left-linear and a right-linear rule is still regular." Mixed linear grammars can generate .
GATE examination perspective
- NESTED DRAWING. Four classes with witnesses.
- VOCABULARY. RE vs regular expression vs recursive.
- MACHINE MATCHING. FA/PDA/LBA/TM.
- LIGHT CSL. Do not invent LBA transition tables unless asked.
- TIGHTEST CLASS. An option may name a true but loose class; pick the smallest one.
- GRAMMAR VERSUS LANGUAGE. A Type-2 grammar can generate a regular language.
- FINITE IS REGULAR. Any bound on makes the language finite.
Summary
Sources
- P. Linz, An Introduction to Formal Languages and Automata, 6th ed., Jones & Bartlett Learning, Section 11.1 (recursive and recursively enumerable languages), Section 11.2 (unrestricted grammars), Section 11.3 (context-sensitive grammars and languages; relation between recursive and context-sensitive languages), Section 11.4 (the Chomsky hierarchy), Section 10.5 (linear bounded automata).
- J. E. Hopcroft, R. Motwani, J. D. Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Pearson Addison-Wesley: Section 9.1 (a language that is not recursively enumerable), Section 9.2 (an undecidable problem that is RE).
- M. Sipser, Introduction to the Theory of Computation, 3rd ed., Cengage Learning: Section 4.2 (undecidability; a Turing-unrecognizable language).