How to Determine a Language from a Recursive Definition
At a glance
- 1. Find the base cases
List the strings that belong to the language before any recursive rule is applied.
- 2. Apply each rule
Use every recursive operation repeatedly, including in combinations, to generate further strings.
- 3. Use the least set
Unless the definition says otherwise, include only strings obtainable from the base cases by finitely many applications.
- 4. Check the missing clauses
The alphabet alone does not specify which strings are generated; the base cases and recursive rules are required.
The alphabet tells you which symbols may appear in strings, but it does not say which strings belong to . To determine the language, you need the recursive definition’s base cases and recursive rules. Since those clauses are not included here, the set cannot be identified uniquely.
The method is to start with the specified strings, repeatedly apply the rules, and include exactly the strings that can be obtained in finitely many applications. The examples below show why the missing clauses matter and how to work with a complete definition.
What a recursive definition must specify
A recursive definition of a language usually gives:
- Base cases: one or more strings declared to be in the language.
- Recursive rules: instructions for constructing new strings from strings already in the language.
- An exclusion convention: usually, that no strings belong except those obtained from the base cases by applying the rules finitely many times.
The third part may be stated as “ is the smallest set satisfying these conditions.” This rules out adding unrelated strings that happen to satisfy a broad description. In many textbook definitions, “smallest” is understood even if it is not repeated explicitly.
Example: strings with equally many a’s and b’s in order
Consider this complete recursive definition:
- Base case: , where is the empty string.
- Rule: if , then .
- No other strings belong to .
Starting from the base case gives
For example, the derivation of is
The resulting language is . Every application of the rule adds one at the beginning and one at the end, so the strings have the stated form. Conversely, applying the rule times produces for every nonnegative integer . The “no other strings” clause excludes strings such as or .
Why the alphabet is not enough
Even with the same alphabet, different recursive rules define different languages. For example:
- If the base case is and the rule is “if , then ,” the result is . The symbol is allowed by the alphabet but never appears in a generated string.
- If the base case is and the rule is “if , then ,” the result is .
Thus, knowing only that strings are over does not tell you whether the language contains , , , the empty string, or any other particular string.
How to test a string
For a complete definition, test membership by tracing the string back through the recursive rules to a base case. In the second example above, is in because removing its outer and leaves , and removing those leaves . By contrast, cannot be reduced to the base case using that rule, so it is not in .
This backward check is useful for small examples, but a convincing membership proof should explain why the reductions follow the rules. To describe the entire language, also show both directions: every generated string has the proposed form, and every string of that form can be generated.
Common mistakes
- Treating the alphabet as the language. The alphabet lists available symbols; a language is a set of strings over those symbols.
- Forgetting the empty string. If is a base case, it belongs to the language even though it contains no letters.
- Applying a rule only once. Recursive rules can usually be applied repeatedly, and sometimes in different orders.
- Adding strings that merely look plausible. A string belongs only if the base cases and rules can generate it.
- Ignoring the smallest-set convention. Without it, conditions that say what must be included may allow additional, unintended strings.
To determine the particular intended by a problem, the omitted base cases and recursive clauses must be supplied. Once they are available, list short derivations, infer a pattern, and then prove that the pattern describes exactly the generated strings.
References
- Introduction to the Theory of Computation, Michael Sipser
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.