Sub topic 16
GATE Problem Patterns and Strategies
Prerequisites and a general method
Assume you know alphabets, strings, regular expressions, DFAs, NFAs, subset construction, DFA minimization, closure properties, the pumping lemma, and Myhill–Nerode equivalence.
GATE questions usually test whether you can identify the right model before calculating. Use this process:
- Identify the language property being tested.
- Choose the smallest useful tool.
- Track states, transitions, or distinguishable prefixes carefully.
- Check edge cases such as the empty string, missing transitions, and overlapping cases.
- Test the result on short strings.
Counting states
For a DFA, every state represents information about the input prefix that may affect future acceptance. Count the information that must be remembered.
For example, a language that requires the number of a symbols to be congruent to 2 modulo 3 needs three states. The states record the current remainder: 0, 1, or 2.
If a language requires both a remainder modulo 3 and a remainder modulo 2, a product construction gives at most 6 states. The actual minimum may be smaller if some product states are unreachable or equivalent.
| Question pattern | Useful method | Common mistake |
|---|---|---|
| Count states for several modular conditions | Product construction | Assuming the product size is always minimal |
| Determine whether two DFAs are equivalent | Compare reachable product states | Comparing only their state counts |
| Convert an NFA to a DFA | Subset construction | Forgetting the empty subset |
| Test regularity | Closure, pumping lemma, or Myhill–Nerode | Trying the pumping lemma first every time |
Equivalence and regularity decisions
To compare two DFAs, construct a product whose states are pairs (p, q). Mark a pair as different when exactly one component is accepting. If a reachable different pair exists, the DFAs are not equivalent. If no such pair exists, they accept the same language.
For regularity questions, use closure properties when possible. If a language can be built from known regular languages using union, intersection, complement, concatenation, or Kleene star, it is regular.
Use the pumping lemma to prove non-regularity when a language has a counting dependency such as equal numbers of two symbols. Choose a string depending on the pumping length, then show that every permitted decomposition fails for some pumping value.
Use Myhill–Nerode when infinitely many prefixes require different future behavior. This often gives a shorter proof than the pumping lemma.
A small verification program
The following code compares two DFAs by exploring reachable pairs. Each DFA is represented by a transition dictionary.
from collections import deque
def equivalent(dfa1, dfa2):
start = (dfa1["start"], dfa2["start"])
queue = deque([start])
seen = {start}
while queue:
p, q = queue.popleft()
if (p in dfa1["accept"]) != (q in dfa2["accept"]):
return False
for symbol in dfa1["alphabet"]:
pair = (
dfa1["delta"][(p, symbol)],
dfa2["delta"][(q, symbol)],
)
if pair not in seen:
seen.add(pair)
queue.append(pair)
return TrueExercise
What is the best first tool for deciding whether two complete DFAs accept the same language?
Show answer
Explore the reachable product of their states and look for a pair where exactly one state is accepting.