By the end of this chapter you'll be able to…

  • 1State what a finite automaton can and cannot remember
  • 2Apply the counting diagnostic to decide whether a language is regular
  • 3State the defining property of a deterministic finite automaton
  • 4Explain why a dead state is required when a transition is missing
  • 5Distinguish Moore and Mealy transducers from acceptors
  • 6State the acceptance condition for a nondeterministic automaton
  • 7Perform the subset construction and identify the accepting subsets
  • 8State the exponential bound and the family that makes it tight
  • 9Apply regular expression precedence and the star's inclusion of the empty string
  • 10Recall the standard regular expression identities and the non-identity
  • 11State Kleene's theorem and both constructive directions
  • 12Describe Thompson's construction and its linear size bound
  • 13Describe state elimination and why the order affects expression size
  • 14List the closure properties of regular languages
  • 15Explain why complementation requires a DFA
  • 16Build a product automaton for union and intersection
  • 17Minimise a DFA by removing unreachable states and table filling
  • 18State the termination condition for table filling
  • 19State the Myhill-Nerode theorem and its two consequences
  • 20Prove non-regularity by exhibiting infinitely many distinguishable strings
  • 21Explain why Myhill-Nerode can prove regularity while the pumping lemma cannot
💡
Why this chapter matters in GATE
Theory of Computation asks what machines can and cannot do, and it starts with the weakest useful machine: one with a fixed, finite amount of memory. A finite automaton remembers nothing except which state it is in, so the entire history of the input must be compressed into one of finitely many states before the next symbol arrives. That single restriction generates the whole theory: a language is regular precisely when the strings read so far can be sorted into finitely many classes that are interchangeable for every possible future. So the diagnostic question for any language is how many distinct situations must be told apart. If the answer is a fixed finite number, an automaton exists; if it grows with the input, none can. Counting matched brackets needs unboundedly many depths and is not regular; counting symbols modulo three needs exactly three and is. The second organising fact is that regular expressions and finite automata describe exactly the same languages, so a question can be attacked from whichever side is easier.

Before you start — revise these

🔗
Discrete Mathematics
Equivalence relations, partitions and the counting arguments behind the subset construction and Myhill-Nerode classes are developed there.
🔗
Sequential Circuits
A DFA is exactly a finite state machine, and the state-minimisation partitioning method is the same algorithm in a different notation.

Regular Expressions & Finite Automata

Theory of Computation asks what machines can and cannot do, and it starts with the weakest useful machine: one with a fixed, finite amount of memory.

A finite automaton remembers nothing except which state it is in. It has no counter, no stack, no tape — the entire history of the input must be compressed into one of finitely many states before the next symbol arrives.

That single restriction generates the whole theory. A language is regular precisely when the strings read so far can be sorted into finitely many classes such that any two strings in the same class are interchangeable for every possible future.

So the diagnostic question for any language is: how many distinct situations must be told apart? If the answer is a fixed finite number, a finite automaton exists and the language is regular. If the number grows with the input, no finite automaton can work.

Counting matched brackets requires distinguishing unboundedly many depths, so it is not regular. Counting the number of as modulo 3 requires distinguishing only three situations, so it is.

The second organising fact is that regular expressions and finite automata describe exactly the same languages. Kleene's theorem makes them interchangeable, so a question may be attacked from whichever side is easier.

1. Deterministic Finite Automata

A DFA is a five-tuple: states, alphabet, transition function, start state and accepting states.

The defining property is that the transition function is total and single-valued: for every state and every input symbol there is exactly one next state. No choices, no missing edges.

A string is accepted if reading it from the start state ends in an accepting state. The language of the automaton is the set of all accepted strings.

A DFA with a missing transition is not a DFA. The usual repair is a dead state — a non-accepting state with self-loops on every symbol — which absorbs anything that has already failed.

Because the machine is deterministic, tracing a string takes exactly one step per symbol, so membership testing is with a constant that does not depend on the automaton's size.

A Moore machine attaches an output to each state and a Mealy machine to each transition, which makes them transducers rather than acceptors, but the underlying state machinery is identical to a DFA's.

2. Nondeterministic Finite Automata

An NFA relaxes the transition function into a relation: a state may have several transitions on a symbol, or none.

A string is accepted if at least one computation path ends in an accepting state. Nondeterminism is not a coin flip; it is a guarantee that if any path succeeds, the machine accepts.

An -NFA additionally allows transitions that consume no input, which makes constructions much easier to draw.

The central theorem is that NFAs and DFAs recognise exactly the same languages. Nondeterminism buys convenience, never power.

The proof is the subset construction. Each DFA state is a set of NFA states — precisely the set the NFA could currently be in.

The DFA's start state is the -closure of the NFA's start state. The transition on a symbol takes the union of the NFA transitions from every state in the current set, then closes under .

An -state NFA can require up to DFA states, and that bound is tight: languages exist for which every equivalent DFA is exponentially larger.

The standard family is "the -th symbol from the end is a", which an NFA recognises with states by guessing when the tail begins, while any DFA must remember the last symbols and therefore needs states.

3. Regular Expressions

A regular expression is built from three operations over an alphabet.

OperationMeaning
Union, written with a plus or a barEither alternative
ConcatenationOne followed by the other
Kleene starZero or more repetitions

The star includes zero repetitions, so the empty string belongs to for every , including the empty language. This is the most frequently missed detail in expression questions.

Precedence runs star highest, then concatenation, then union, so means followed by any number of s, not .

Several identities are examined directly.

But , since the left side alternates the two while the right allows all of before any of .

Kleene's theorem states that a language is describable by a regular expression exactly when some finite automaton recognises it. The proof gives both directions constructively: Thompson's construction builds an -NFA from an expression, and state elimination extracts an expression from an automaton.

Thompson's construction is compositional, building a small -NFA fragment for each operator and gluing them together. Each fragment has exactly one start and one accepting state, which is what makes the gluing uniform.

The size grows linearly: an expression with symbols and operators yields an -NFA with at most states. That linearity is why regular-expression engines compile so cheaply.

State elimination runs the other way, repeatedly deleting a state and relabelling the edges that bypassed it with expressions that account for any loops on the removed state. When only a start and an accepting state remain, the label between them is the answer.

The order of elimination affects the size of the resulting expression enormously, though never its correctness, which is why extracted expressions are often far uglier than a hand-written equivalent.

4. Closure Properties

Regular languages are closed under every operation likely to be asked about.

OperationClosed?Construction
UnionYesProduct or NFA with two starts
IntersectionYesProduct automaton
ComplementYesSwap accepting and non-accepting in a DFA
ConcatenationYesLink accepting states to the second start
Kleene starYesLoop accepting states back
ReversalYesReverse all edges, swap roles
DifferenceYesIntersection with a complement

Complementation requires a DFA, not an NFA. Swapping accepting states in an NFA does not complement the language, because a string may have both an accepting and a rejecting path — so both the original and the "complement" would accept it.

The product construction handles union and intersection together. The state set is the Cartesian product, so an -state and an -state automaton give states, and only the accepting set differs: both components accepting for intersection, either component for union.

5. Minimisation

Every regular language has a unique minimal DFA, up to renaming of states.

The algorithm has two phases.

First, remove unreachable states — those no string can reach from the start. They affect nothing and are simply deleted.

Second, merge equivalent states. Two states are equivalent if no string distinguishes them, meaning for every string, both lead to accepting states or both to non-accepting ones.

The table-filling method computes this by refinement. Mark every pair with one accepting and one non-accepting state as distinguishable. Then repeatedly mark a pair if some symbol sends it to an already-marked pair. Stop when a full pass marks nothing new, and merge all unmarked pairs.

Stopping early is the standard error, because pairs that survive one round can be separated in the next.

Hopcroft's algorithm achieves the same result in by refining partitions rather than filling a table, which matters when the automaton is large. The answer is identical either way, since the minimal DFA is unique.

A useful sanity check after minimising is that the number of remaining states should match the number of Myhill-Nerode classes, if those can be counted independently.

6. The Myhill-Nerode Theorem

The theorem explains why the minimal DFA is unique and gives the sharpest tool for proving non-regularity.

Two strings and are indistinguishable with respect to a language if, for every string , either both and are in or neither is.

This is an equivalence relation, and the theorem says is regular exactly when it has finitely many equivalence classes. Moreover, the number of classes equals the number of states in the minimal DFA.

That gives a proof technique for non-regularity that is often cleaner than the pumping lemma: exhibit infinitely many pairwise distinguishable strings.

For the language of balanced brackets, the strings (, ((, ((( and so on are pairwise distinguishable, since appending closing brackets accepts exactly one of them. Infinitely many classes exist, so the language is not regular.

The theorem is an exact characterisation, so it can prove regularity as well as refute it — something the pumping lemma cannot do.

7. Worked Examples

Example 1. Construct a DFA over accepting strings where the number of s is divisible by 3.

The only thing that must be remembered is the count of s modulo 3, which takes three values.

States , , represent remainders 0, 1 and 2. The start state is , which is also the only accepting state, since the empty string has zero s.

On , each state advances: .

On , every state loops to itself, because does not change the count.

Three states suffice, and three are necessary. The strings , and are pairwise distinguishable — appending , and respectively accepts exactly one of them — so by Myhill-Nerode the minimal DFA has exactly 3 states.

Note how the count itself is never stored, only its remainder. That compression from an unbounded quantity to a bounded one is exactly what makes the language regular.

Example 2. Convert the NFA with states , start , accepting , and transitions , , into a DFA.

Apply the subset construction, starting from .

From on : the NFA can be in or , giving . On : only , giving .

From on : from we get , from there is no transition, so the union is . On : from we get , from we get , so the union is .

No new subsets appear, so the DFA has two reachable states: and .

Accepting states are those containing , so only accepts.

The DFA stays in until it sees an , then remains in forever. The language is therefore strings containing at least one .

Only 2 of the possible 4 subsets were reachable, which is typical: the exponential bound is worst case, not usual case.

Example 3. Show that a DFA for "the third symbol from the end is " needs at least 8 states over .

An NFA does this with 4 states, guessing nondeterministically when the last three symbols begin.

For the DFA lower bound, use Myhill-Nerode. Consider the eight strings of length 3 over .

Take any two distinct such strings and . They differ in some position from the left, say has and has there.

Append of length . Now the third-from-last symbol of is position of — provided we choose the length so that the differing position lands third from the end.

Concretely, if they differ in the first symbol, append nothing; the third from last of a 3-string is its first symbol, so exactly one is accepted. If they differ in the second, append one symbol. If in the third, append two.

In every case a distinguishing suffix exists, so all eight strings are pairwise inequivalent and the minimal DFA has at least 8 states.

Eight also suffice: the state remembers the last three symbols. So the minimum is exactly , against 4 for the NFA — the exponential gap in miniature.

Example 4. Minimise the DFA with states , start , accepting , and transitions: on 0 and on 1; on 0 and on 1; on 0 and on 1; on 0 and on 1; on both.

First check reachability. From we reach and ; from we reach ; from and we reach . All five states are reachable.

Now the table-filling method. Mark every pair with exactly one accepting state: , , , , , .

Unmarked so far: , , , .

Round 1. For : on 0 they go to and , giving the unmarked pair ; on 1 they go to and , giving the unmarked pair . Nothing forces a mark.

For : on 0 they go to and , giving , unmarked; on 1 they go to and , giving , which is marked. So mark .

For : on 1 they go to and , giving , marked. So mark .

For : on 0 both go to , giving , not a distinguishing pair; on 1 they go to and , giving itself. Nothing forces a mark.

Round 2. Re-examine : its successors are and , both still unmarked. No mark. Re-examine : same situation. No mark.

A full pass produced nothing new, so the algorithm stops.

Merge with , and with . The minimal DFA has three states: , and .

Example 5. Why does swapping accepting states fail to complement an NFA?

An NFA accepts a string if at least one computation path reaches an accepting state. It rejects only when every path fails.

Swapping the accepting set produces a machine that accepts when at least one path reaches a state that was previously non-accepting.

Those two conditions are not complementary. A string with two paths — one reaching an old accepting state and one reaching an old non-accepting state — is accepted by both machines.

Concretely, take an NFA over with start state and transitions , with accepting. The string is accepted, since the path to succeeds.

Swap the accepting set so that accepts and does not. The string is still accepted, via the path staying at .

Both machines accept , so the second is not the complement of the first.

The correct procedure is to convert to a DFA first, where each string has exactly one path, and then swap. That is why complementation is described as easy for DFAs and expensive for NFAs — the subset construction in between can cost exponential blow-up.

Example 6. Prove that is not regular using Myhill-Nerode.

Consider the infinite family of strings

Take any two distinct members and with .

Append the suffix .

Then is in , since the counts match. But is not in , since .

So the suffix distinguishes the two strings, and this works for every distinct pair.

The strings are therefore pairwise inequivalent, giving infinitely many Myhill-Nerode equivalence classes.

By the theorem, a language is regular exactly when it has finitely many classes. This language has infinitely many, so it is not regular.

The intuition matches: recognising the language requires remembering how many s were seen, which is unbounded, and a finite automaton has nowhere to keep that count.

Note that Myhill-Nerode gave a complete proof here in four lines, whereas the pumping lemma would require setting up a pumping length, choosing a witness string, and reasoning about every possible decomposition.

Summary

A finite automaton remembers only its current state, so a language is regular exactly when the strings read so far fall into finitely many interchangeable classes.

A DFA has exactly one transition per state and symbol; a missing transition means a dead state is required. Membership costs .

An NFA accepts if any path succeeds. NFAs and DFAs recognise the same languages, with the subset construction converting one to the other at a worst-case cost of states — a bound that is tight for the "-th symbol from the end" family.

Regular expressions use union, concatenation and star, with star including the empty string and precedence running star, then concatenation, then union.

Kleene's theorem makes expressions and automata interchangeable, with Thompson's construction one way and state elimination the other.

Regular languages are closed under union, intersection, complement, concatenation, star, reversal and difference. Complementation requires a DFA, because swapping accepting states in an NFA does not complement the language.

Minimisation removes unreachable states, then merges equivalent ones by table filling, stopping only after a full pass marks nothing new.

Myhill-Nerode characterises regularity exactly: finitely many indistinguishability classes, and their count equals the minimal DFA's state count. Exhibiting infinitely many pairwise distinguishable strings proves non-regularity, often more cleanly than the pumping lemma.

Key formulas & results

Everything to memorise for the exam hall, in one card. Screenshot this for revision.

The organising tool
A LANGUAGE IS REGULAR EXACTLY WHEN THE STRINGS READ SO FAR FALL INTO FINITELY MANY CLASSES THAT ARE INTERCHANGEABLE FOR EVERY POSSIBLE FUTURE.
ASK HOW MANY DISTINCT SITUATIONS MUST BE TOLD APART. A FIXED FINITE NUMBER MEANS REGULAR; A NUMBER GROWING WITH THE INPUT MEANS NOT.
DFA definition
A FIVE-TUPLE OF STATES, ALPHABET, TRANSITION FUNCTION, START STATE AND ACCEPTING STATES, WHERE THE TRANSITION FUNCTION IS TOTAL AND SINGLE-VALUED.
A MISSING TRANSITION MEANS IT IS NOT A DFA. THE REPAIR IS A DEAD STATE WITH SELF-LOOPS ON EVERY SYMBOL, ABSORBING ANYTHING THAT HAS ALREADY FAILED.
NFA acceptance
AN NFA ACCEPTS IF AT LEAST ONE COMPUTATION PATH ENDS IN AN ACCEPTING STATE.
NONDETERMINISM IS NOT A COIN FLIP BUT A GUARANTEE THAT IF ANY PATH SUCCEEDS, THE MACHINE ACCEPTS. IT BUYS CONVENIENCE, NEVER POWER.
The subset construction
EACH DFA STATE IS A SET OF NFA STATES — PRECISELY THE SET THE NFA COULD CURRENTLY BE IN. THE START IS THE EPSILON-CLOSURE OF THE NFA START.
THE TRANSITION ON A SYMBOL TAKES THE UNION OF NFA TRANSITIONS FROM EVERY STATE IN THE SET, THEN CLOSES UNDER EPSILON. ACCEPTING SUBSETS ARE THOSE CONTAINING AN NFA ACCEPTING STATE.
The exponential bound
AN n-STATE NFA CAN REQUIRE UP TO 2 TO THE n DFA STATES, AND THE BOUND IS TIGHT.
THE STANDARD FAMILY IS THE k-TH SYMBOL FROM THE END BEING a: AN NFA NEEDS k PLUS 1 STATES BY GUESSING, WHILE ANY DFA MUST REMEMBER THE LAST k SYMBOLS.
Regular expression operators
UNION, CONCATENATION AND KLEENE STAR, WITH PRECEDENCE RUNNING STAR HIGHEST, THEN CONCATENATION, THEN UNION.
THE STAR INCLUDES ZERO REPETITIONS, SO THE EMPTY STRING BELONGS TO r STAR FOR EVERY r. THIS IS THE MOST FREQUENTLY MISSED DETAIL IN EXPRESSION QUESTIONS.
Expression identities
(r STAR) STAR = r STAR. r STAR TIMES r STAR = r STAR. (r PLUS s) STAR = (r STAR s STAR) STAR.
BUT (rs) STAR IS NOT r STAR s STAR, SINCE THE LEFT SIDE ALTERNATES THE TWO WHILE THE RIGHT ALLOWS ALL OF r BEFORE ANY OF s.
Kleene's theorem
A LANGUAGE IS DESCRIBABLE BY A REGULAR EXPRESSION EXACTLY WHEN SOME FINITE AUTOMATON RECOGNISES IT.
BOTH DIRECTIONS ARE CONSTRUCTIVE: THOMPSON'S CONSTRUCTION BUILDS AN EPSILON-NFA FROM AN EXPRESSION, AND STATE ELIMINATION EXTRACTS AN EXPRESSION FROM AN AUTOMATON.
Thompson's construction
BUILD A SMALL EPSILON-NFA FRAGMENT PER OPERATOR, EACH WITH EXACTLY ONE START AND ONE ACCEPTING STATE, AND GLUE THEM TOGETHER.
AN EXPRESSION WITH n SYMBOLS AND OPERATORS YIELDS AT MOST 2n STATES, AND THAT LINEARITY IS WHY REGULAR-EXPRESSION ENGINES COMPILE SO CHEAPLY.
State elimination
REPEATEDLY DELETE A STATE AND RELABEL THE BYPASSING EDGES WITH EXPRESSIONS ACCOUNTING FOR ANY LOOPS ON THE REMOVED STATE.
THE ELIMINATION ORDER AFFECTS THE SIZE OF THE RESULTING EXPRESSION ENORMOUSLY THOUGH NEVER ITS CORRECTNESS, WHICH IS WHY EXTRACTED EXPRESSIONS ARE OFTEN UGLY.
Closure properties
REGULAR LANGUAGES ARE CLOSED UNDER UNION, INTERSECTION, COMPLEMENT, CONCATENATION, KLEENE STAR, REVERSAL AND DIFFERENCE.
DIFFERENCE IS INTERSECTION WITH A COMPLEMENT. REVERSAL REVERSES ALL EDGES AND SWAPS THE ROLES OF START AND ACCEPTING STATES.
Why complement needs a DFA
SWAPPING ACCEPTING STATES IN AN NFA DOES NOT COMPLEMENT THE LANGUAGE, BECAUSE A STRING MAY HAVE BOTH AN ACCEPTING AND A REJECTING PATH.
BOTH THE ORIGINAL AND THE SUPPOSED COMPLEMENT WOULD THEN ACCEPT IT. CONVERT TO A DFA FIRST, WHERE EACH STRING HAS EXACTLY ONE PATH.
The product construction
THE STATE SET IS THE CARTESIAN PRODUCT, SO AN m-STATE AND AN n-STATE AUTOMATON GIVE mn STATES.
ONLY THE ACCEPTING SET DIFFERS: BOTH COMPONENTS ACCEPTING FOR INTERSECTION, EITHER COMPONENT ACCEPTING FOR UNION.
Minimisation
FIRST REMOVE UNREACHABLE STATES, THEN MERGE EQUIVALENT ONES. TWO STATES ARE EQUIVALENT IF NO STRING DISTINGUISHES THEM.
TABLE FILLING MARKS PAIRS WITH ONE ACCEPTING AND ONE NON-ACCEPTING STATE, THEN MARKS ANY PAIR SENDING TO AN ALREADY-MARKED PAIR. STOP ONLY AFTER A FULL PASS MARKS NOTHING.
Minimisation uniqueness
EVERY REGULAR LANGUAGE HAS A UNIQUE MINIMAL DFA UP TO RENAMING OF STATES.
HOPCROFT'S ALGORITHM ACHIEVES THE SAME RESULT IN O(n log n) BY PARTITION REFINEMENT. THE ANSWER IS IDENTICAL EITHER WAY.
Myhill-Nerode indistinguishability
STRINGS x AND y ARE INDISTINGUISHABLE FOR L IF FOR EVERY STRING z, EITHER BOTH xz AND yz ARE IN L OR NEITHER IS.
THIS IS AN EQUIVALENCE RELATION, AND ITS CLASSES ARE EXACTLY WHAT A FINITE AUTOMATON'S STATES MUST DISTINGUISH.
The Myhill-Nerode theorem
L IS REGULAR EXACTLY WHEN IT HAS FINITELY MANY INDISTINGUISHABILITY CLASSES, AND THAT NUMBER EQUALS THE NUMBER OF STATES IN THE MINIMAL DFA.
IT IS AN EXACT CHARACTERISATION, SO IT CAN PROVE REGULARITY AS WELL AS REFUTE IT — SOMETHING THE PUMPING LEMMA CANNOT DO.
Proving non-regularity
EXHIBIT INFINITELY MANY PAIRWISE DISTINGUISHABLE STRINGS: FOR EVERY DISTINCT PAIR, GIVE A SUFFIX PLACING EXACTLY ONE OF THEM IN THE LANGUAGE.
FOR a TO THE n b TO THE n, THE STRINGS a TO THE i ARE PAIRWISE DISTINGUISHED BY THE SUFFIX b TO THE i, GIVING INFINITELY MANY CLASSES IN FOUR LINES.
⚠️

Traps GATE sets — and how to dodge them

These are the exact option-traps and misreads that cost marks under negative marking.

WATCH OUT
Complementing an NFA by swapping accepting states
A string with both an accepting and a rejecting path is accepted by both machines, so the result is not the complement. Convert to a DFA first, where every string has exactly one computation path.
WATCH OUT
Forgetting that the Kleene star includes the empty string
r star always contains the empty string, even when r is the empty language. Questions about which strings a given expression matches turn on this constantly.
WATCH OUT
Misreading regular expression precedence
Star binds tightest, then concatenation, then union. So ab star is a followed by any number of bs, not (ab) star, and a plus bc is a union bc rather than (a plus b)c.
WATCH OUT
Treating (rs) star as equal to r star s star
The left side alternates r and s in strict sequence; the right allows every r before any s. The string rsrs is in the first and not the second, which settles it.
WATCH OUT
Assuming the subset construction always produces exponentially many states
The bound is worst case. Most conversions reach far fewer subsets, because only reachable subsets are constructed and many are never generated at all.
WATCH OUT
Leaving a transition undefined in a DFA
The transition function must be total, so every state needs an outgoing edge on every symbol. Add a dead state with self-loops to absorb the failures rather than omitting edges.
WATCH OUT
Stopping table filling after one round
A pair whose successors are both unmarked survives that round but can be marked later once its successors are marked. The termination condition is a complete pass that marks nothing new.
WATCH OUT
Minimising without first removing unreachable states
Unreachable states can appear equivalent to nothing and inflate the count, or worse, merge with reachable states misleadingly. Reachability analysis must come first.
WATCH OUT
Using the pumping lemma where Myhill-Nerode is cleaner
Exhibiting infinitely many pairwise distinguishable strings is usually shorter and less error-prone than setting up a pumping length and reasoning over every decomposition.
WATCH OUT
Trying to prove regularity with the pumping lemma
The pumping lemma is a necessary condition only, so satisfying it proves nothing. Myhill-Nerode is an exact characterisation and can establish regularity in both directions.
WATCH OUT
Assuming the product automaton for intersection and union differ in structure
They share the same state set and transitions; only the accepting set changes. Both components must accept for intersection, either may accept for union.
WATCH OUT
Counting NFA states as a lower bound for the DFA
An NFA can be exponentially smaller. For the k-th-symbol-from-the-end language, the NFA needs k plus 1 states while the minimal DFA needs 2 to the k.

Exam-pattern practice

PYQ-style questions with full solutions. Work through them as a readiness check — mark yourself honestly and get your gap report at the end.

Readiness check

Are you exam-ready for Regular Expressions & Finite Automata?

9 problems from this chapter. Try each one, reveal the worked solution, mark yourself honestly — get your gap report at the end.

9 questions~6 min

5-minute revision

The whole chapter, distilled. Read this the night before the exam.

  • A finite automaton remembers only its current state.
  • Regular means finitely many interchangeable classes.
  • Ask how many situations must be told apart.
  • A DFA transition function is total and single-valued.
  • A missing transition needs a dead state.
  • Membership testing costs O(n).
  • Moore and Mealy machines are transducers, not acceptors.
  • An NFA accepts if any path succeeds.
  • NFAs and DFAs recognise the same languages.
  • The subset construction makes each DFA state a set of NFA states.
  • The blow-up bound of 2 to the n is tight.
  • The k-th-from-end family is the standard witness.
  • Star includes the empty string.
  • Precedence is star, then concatenation, then union.
  • (r star) star equals r star.
  • (rs) star does not equal r star s star.
  • Kleene's theorem equates expressions and automata.
  • Thompson's construction is linear in expression size.
  • State elimination order affects expression size only.
  • Regular languages are closed under all standard operations.
  • Complementation requires a DFA.
  • The product construction gives mn states.
  • Only the accepting set differs for union and intersection.
  • Minimisation removes unreachable states first.
  • Table filling marks accepting against non-accepting pairs.
  • Stop only after a full pass marks nothing.
  • The minimal DFA is unique up to renaming.
  • Hopcroft's algorithm minimises in n log n.
  • Myhill-Nerode counts indistinguishability classes.
  • Finitely many classes means regular.
  • The class count equals the minimal DFA state count.
  • Infinitely many distinguishable strings proves non-regularity.
  • Myhill-Nerode can prove regularity; the pumping lemma cannot.

GATE question blueprint

How this topic is asked, tier by tier — so you can prep to the pattern.

Typical weightage: Theory of Computation contributes roughly 7-9 of the 72 core-CS marks; regular languages supply 2-3 of those across 2-3 questions

Question styleMarks eachTypical countWhat it tests
DFA construction1~1Minimum state counts and what must be remembered
Regular expressions2~1Precedence, the empty string under star, and expression equivalence
Subset construction2~1Converting an NFA and counting reachable subsets
NFA to DFA blow-up2~1The tight exponential family and why a DFA cannot guess
Minimisation2~1Reachability, table filling and the termination condition
Closure properties1~1Which operations preserve regularity and why complement needs a DFA
Closure and constructions2~1Product construction state counts and accepting-set choice
Myhill-Nerode2~1Proving non-regularity by exhibiting distinguishable strings

Exam-hall strategy

Battle-tested tips from mentors and toppers for this topic under the sectional clock.

  1. Ask what must be remembered and whether it is bounded before anything else.
  2. For minimal-state questions, count Myhill-Nerode classes rather than drawing the automaton.
  3. Check the star's inclusion of the empty string in every expression question.
  4. Convert to a DFA before complementing.
  5. In table filling, continue until a full pass marks nothing.
  6. For non-regularity proofs, prefer Myhill-Nerode over the pumping lemma.
  7. Minimal state counts are commonly set as NAT, which carries no negative marking, so never leave one blank.
  8. For 1-mark and 2-mark MCQs, negative marking is -1/3 and -2/3, so guess only after eliminating an option.
  9. GATE gives a single freely-navigable 180-minute window, so flag a long subset construction and return to it.

Beyond the exam

Where this skill shows up in the job you're competing for — and in life.

Lexical analysis in a compiler

Token patterns are written as regular expressions and compiled to a DFA, which is why a lexer runs in time linear in the source length.

Input validation

Deciding whether a string matches a pattern is exactly DFA membership, and the linear cost is why regular expressions are safe for untrusted input when compiled deterministically.

Protocol state machines

A connection's legal message sequences form a regular language, and the state machine that enforces them is a DFA with a dead state for protocol violations.

Deciding what a pattern cannot express

Knowing that matched brackets are not regular is why parsing nested structures needs a grammar rather than a regular expression, however elaborate.

Where else this topic is tested

Prepare once, score in every exam that asks it.

GATE DALow overlap — theory of computation is not a component of that paper
UGC NET Computer ScienceHigh overlap — automata conversions, closure properties and minimisation are examined as direct recall and short construction
ISRO / BARC / DRDO computer science papersVery high overlap — minimal state counts, subset construction and regular expression equivalence are recurring MCQ topics

Questions aspirants ask

Pulled from the Q&A community and mentor sessions.

Ask what must be remembered to decide membership, and whether that quantity is bounded. A finite automaton has no memory beyond its current state, so if recognising the language requires tracking something that grows without bound — a count, a depth, a comparison between two unbounded quantities — no finite automaton can exist. If it requires tracking only something bounded, one does. Counting the number of as modulo three is bounded: three situations suffice, so the language is regular. Counting as and bs and comparing them is unbounded: the difference can be any integer, so it is not. Matching brackets is unbounded for the same reason. Two refinements make this reliable. First, bounded windows are fine: remembering the last three symbols requires eight states, which is finite however large the input, so the k-th-symbol-from-the-end language is regular for every fixed k. Second, an apparently unbounded quantity is sometimes bounded in disguise. The language of strings whose length is divisible by four seems to need the length, but only the length modulo four matters, so four states suffice. When the informal argument is unclear, Myhill-Nerode makes it precise: exhibit a family of strings that are pairwise distinguishable, and if the family is infinite, the language is not regular. The pumping lemma also proves non-regularity but cannot prove regularity, so Myhill-Nerode is the more complete instrument.

Because an NFA can have several computation paths on the same string, and acceptance depends on whether any of them succeeds. Complementation requires the opposite: the new machine must accept exactly when every path of the original fails. Swapping the accepting set produces a machine that accepts when at least one path reaches a state that was previously non-accepting, which is not the same condition. Concretely, take an NFA over the single-symbol alphabet with start state p and transitions on a going to both p and q, where q is accepting. The string a is accepted, because the path to q succeeds. Now swap, making p accepting and q not. The string a is still accepted, this time by the path that stays at p. Both machines accept a, so the second is not the complement of the first. The fix is to convert to a DFA first. A DFA has exactly one computation path per string, so it accepts if and only if that path ends in an accepting state, and swapping the accepting set inverts exactly that condition. Complementation is therefore trivial for a DFA and expensive for an NFA, since the subset construction in between can cost exponential blow-up. This asymmetry is worth remembering because it also explains why deterministic and nondeterministic machines behave differently for other classes: deterministic pushdown automata are closed under complement while nondeterministic ones are not, and the reason is exactly the same.

Almost always, and certainly whenever the language is easy to distinguish strings in. The pumping lemma states a necessary condition for regularity: every sufficiently long string can be split so that the middle part pumps. Proving non-regularity with it requires a game against an adversary — the adversary picks a pumping length, you pick a witness string, the adversary picks a decomposition satisfying the constraints, and you must find a pumping count that leaves the language. Getting the quantifier order wrong is the commonest error, and reasoning over every legal decomposition is tedious. Myhill-Nerode replaces all of that with a direct construction: exhibit an infinite family of strings and, for each pair, a suffix placing exactly one of them in the language. For a to the n b to the n, the family is the strings of as and the suffix for a pair a to the i and a to the j is b to the i, which takes four lines. For strings with equal as and bs, the same family and suffix work. For balanced brackets, the family is the strings of opening brackets. The decisive advantage is that Myhill-Nerode is an exact characterisation. Finitely many classes means regular; infinitely many means not. The pumping lemma is one-directional, so a language satisfying it may still be non-regular, and no amount of pumping analysis can ever establish regularity. Myhill-Nerode additionally tells you the exact size of the minimal DFA, which the pumping lemma cannot.

Worst case, and typically far from it. The subset construction builds one DFA state per reachable set of NFA states, and although 2 to the n subsets exist for an n-state NFA, only those actually generated by some input string are constructed. In most practical conversions the reachable subsets number a small multiple of n rather than an exponential in it. The worked example in this chapter converts a two-state NFA and reaches only two subsets out of four. That said, the bound is genuinely tight for a specific and important family: the strings whose k-th symbol from the end is a. An NFA recognises this with k plus 1 states by nondeterministically guessing where the tail begins, and the guess costs nothing because acceptance requires only one correct path. A DFA cannot guess. Reading left to right, it must retain the last k symbols at every point, because it does not know when the input will stop, and there are 2 to the k possible values. A Myhill-Nerode argument confirms that all 2 to the k are genuinely necessary, so no cleverer construction helps. The practical consequence is that regular-expression engines using a DFA build it lazily, generating subsets only as inputs require them, which keeps the common case cheap while still handling the pathological one. Engines that use the NFA directly avoid the blow-up entirely at the cost of simulating multiple paths, which is a time-versus-space trade rather than a correctness one.

Because distinguishability propagates backwards, and a pair that looks equivalent in one round can be separated in the next. The table-filling method starts by marking every pair with one accepting and one non-accepting state, since the empty string distinguishes those immediately. It then repeatedly marks any pair whose successors under some symbol form an already-marked pair, because if a symbol leads to distinguishable states then the original pair is distinguishable by that symbol followed by whatever distinguished the successors. The propagation can take several rounds. Suppose states p and q have successors r and s under symbol a, and r and s are themselves unmarked in round one. The pair p and q survives round one. If r and s are marked during round one because of their own successors, then p and q become markable in round two. A chain of such dependencies can be as long as the automaton is deep, so terminating after the first round can leave genuinely distinguishable states merged, producing a machine that accepts the wrong language. The correct termination condition is a complete pass over every unmarked pair that produces no new marks, at which point no further propagation is possible and every remaining unmarked pair is genuinely equivalent. Two other preconditions matter. Unreachable states must be removed first, or they can distort the merging. And the automaton must be a complete DFA, since a missing transition leaves the successor pair undefined and the algorithm has nothing to check.
Header Logo