Hello! Welcome back to our study of computability.
In our previous lesson, we established the fundamental distinction between recursive (decidable) languages and recursively enumerable (RE) languages. We learned that for a recursive language, a Turing Machine (TM) must halt on every input, providing a clear "yes" or "no." For an RE language, the TM is only guaranteed to halt and accept for strings in the language. We also saw that this distinction is captured by Post's Theorem: a language is recursive if and only if both and its complement are RE.
Today, we will build upon these definitions to explore their closure properties. This lesson addresses the learning outcome: Prove closure properties of recursive and RE languages under union and intersection. We will investigate whether combining languages from these classes, using operations like union and intersection, results in a language that is still in the same class. Understanding these properties is crucial for knowing how we can construct complex computable languages from simpler ones.
1. Closure Under Union
Let's start with the union operation. Given two languages, and , from the same class, is their union also in that class?
Recursive Languages are Closed Under Union
Let and be two recursive languages. By definition, there exist Turing Machines and that are deciders for them. This means and are guaranteed to halt on any input.
To prove closure, we need to construct a new TM, let's call it , that decides . The construction is straightforward:
Construction of for an input string w:
- Run the decider on input
w. - Since is a decider, it is guaranteed to halt.
- If accepts
w, thenwis in , so it must be in . accepts and halts. - If rejects
w, proceed to the next step.
- If accepts
- Run the decider on input
w. - Since is a decider, it is guaranteed to halt.
- If accepts
w, thenwis in , so it must be in . accepts and halts. - If rejects
w, thenwis in neither nor . rejects and halts.
- If accepts
This sequential execution works because we have the guarantee that both and will always terminate. Therefore, is a decider, and is a recursive language.

Recursively Enumerable Languages are Closed Under Union
Now, let's consider two RE languages, and , with corresponding recognizers and . Can we use the same sequential simulation?
The answer is no. Imagine we have a string w that is not in but is in . If we run on w first, might loop forever. Our machine would never get to run and discover that w is, in fact, in the union.
The solution is to simulate both machines "in parallel." From your background in building complex systems, you can think of this as a form of time-slicing or cooperative multitasking on a single-tape TM.
Construction of for an input string w:
- For :
a. Simulate one step of onw. If accepts, then accepts and halts.
b. Simulate one step of onw. If accepts, then accepts and halts.
Why does this work?
- If , then either or (or both) must accept
win a finite number of steps. Our interleaved simulation guarantees that we will eventually execute that accepting step, at which point halts and accepts. - If , then neither nor will accept. will continue to simulate them, potentially looping forever. This is acceptable behavior for a recognizer.
Thus, correctly recognizes , and the class of RE languages is closed under union.
To see these proofs explained with clear visuals, please watch the following segment.
Closure Properties of Decidable and Turing recognizable languages
This video from the Theory of Computation channel provides a step-by-step proof of closure under union for both decidable (recursive) and Turing-recognizable (RE) languages. It clearly explains the necessity of parallel simulation for RE languages.
Watch the segment from 01:18 to 09:19. Pay close attention to the argument for why sequential simulation fails for Turing-recognizable languages and how simultaneous simulation solves the problem.
2. Closure Under Intersection
Next, we examine the intersection operation. Given and , is in the same class?
Recursive Languages are Closed Under Intersection
Let and be recursive languages with deciders and . We can construct a decider for .
Construction of for an input string w:
- Run the decider on
w. - If rejects, then
wcannot be in the intersection. rejects and halts. - If accepts, proceed to the next step.
- Run the decider on
w. - If accepts, then
wis in both languages. accepts and halts. - If rejects, rejects and halts.
This works because both machines are guaranteed to halt. The resulting TM, , is a decider, proving closure.
An alternative, more abstract proof uses De Morgan's laws:
We know recursive languages are closed under complement (we'll revisit this in a moment) and we just proved they are closed under union. Since and are recursive, their union is recursive, and the complement of that union is also recursive.
Recursively Enumerable Languages are Closed Under Intersection
Let and be RE languages with recognizers and . Surprisingly, the simple sequential simulation that failed for union works for intersection.
Construction of for an input string w:
- Run the recognizer on
w. - If halts and accepts, then proceed to the next step. (If loops or rejects, will do the same, which is correct behavior since
wis not in and thus not in the intersection). - Run the recognizer on
w. - If halts and accepts, then accepts and halts. (If loops or rejects, does the same, which is correct since
wis not in ).
This sequential design correctly recognizes . If w is in the intersection, both and must accept in finite time, so will accept. If w is not in the intersection, will correctly not accept (it may reject or loop).
Test your understanding!
Why can we use a simple sequential simulation for the intersection of two RE languages, but we need a parallel simulation for their union?
Show answer
For intersection, a string w must be accepted by both recognizers. If the first recognizer R1 loops, it means w is not in L1, and therefore not in L1 ∩ L2. In this case, it is correct for the combined machine to also loop. We only need to proceed to R2 if R1 definitively accepts.
For union, a string w only needs to be accepted by one of the recognizers. If we run R1 first and it loops on a string w that is actually in L2, we would never get the chance to run R2 and find the correct "accept" answer. Parallel simulation ensures both machines get a chance to run.
The following video segment confirms our proofs for intersection.
Closure Properties of Decidable and Turing recognizable languages
This segment continues the discussion on closure properties, focusing on intersection. It confirms the sequential simulation works for both decidable and Turing-recognizable languages.
Watch from 20:41 to 24:27. Note how the argument for Turing-recognizable languages allows for sequential execution, in contrast to the union case.
3. The Decisive Role of Complementation
The learning outcome focuses on union and intersection, but we cannot ignore complement. It is the property that most clearly separates recursive and RE languages.
-
Recursive languages are closed under complement.
The proof is simple: take the deciderMfor a recursive languageL. Construct a new TMM'that is identical toMbut with its accept and reject states swapped. SinceMis guaranteed to halt on all inputs,M'is also guaranteed to halt on all inputs, and it will accept exactly the strings thatMrejects. Thus,M'decides . -
RE languages are NOT closed under complement.
This is a profound result that we can prove using Post's Theorem from our last lesson.
Proof by Contradiction:- Assume for contradiction that the class of RE languages is closed under complement.
- We know there exists a language that is RE but not recursive (our canonical example is ).
- If RE languages are closed under complement, then must also be RE.
- So now we have that both and are RE.
- But by Post's Theorem, if a language and its complement are both RE, the language must be recursive.
- This contradicts our initial statement that is not recursive.
- Therefore, our assumption in step 1 must be false. The class of RE languages is not closed under complement.
This result highlights the asymmetry of RE languages: they can confirm membership, but they can't always refute it.
Summary
Let's summarize our findings on the closure properties of these two important language classes.
| Operation | Recursive (Decidable) | Recursively Enumerable (Turing-Recognizable) |
|---|---|---|
| Union | Yes (Closed) | Yes (Closed) |
| Intersection | Yes (Closed) | Yes (Closed) |
| Complement | Yes (Closed) | No (Not Closed) |
Conclusion
In this lesson, we used constructive proofs to show that both recursive and recursively enumerable languages are closed under union and intersection. We saw how the guaranteed halting property of deciders simplifies these constructions, while the potential for looping in recognizers necessitates a more careful, parallel simulation for the union operation.
Key Takeaways:
- Recursive languages are closed under union, intersection, and complement. The constructions are straightforward because deciders always halt.
- RE languages are closed under union and intersection. The proof for union requires a parallel simulation to handle potential non-halting computations.
- The fact that RE languages are not closed under complement is a fundamental result that distinguishes them from recursive languages and reinforces Post's Theorem.
Preview of the Next Lesson:
We have now defined the most powerful languages recognized by machines—the recursively enumerable languages. The Chomsky Hierarchy, however, is defined by grammars. In the next lesson, we will bridge this gap by defining unrestricted grammars and proving their equivalence to Turing Machines. This will complete our picture of the hierarchy, linking each class of machine to a corresponding class of grammar.