CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 4 · Turing Machines

Lesson 4.3.3 · Item 72 of 91

Closure of REC and RE; L and L̅ both RE ⇒ L recursive

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

  1. Full containment chain?
    Stuck? Peek at 4.3.2 The Chomsky hierarchy and the containment chain
    • Regular ⊊ DCFL ⊊ CFL ⊊ CSL ⊊ REC ⊊ RE ⊊ all.
    • Types: 0 unrestricted/TM/RE; 1 CSG/LBA/CSL; 2 CFG/PDA/CFL; 3 regular grammar/FA/regular.
    • Witnesses: aⁿbⁿ, wwᴿ, aⁿbⁿcⁿ, (diagonal), A_TM.

    Read lesson 4.3.2

  2. What does dovetailing do?
    Stuck? Peek at 4.3.1 Recursive vs recursively enumerable; deciders and recognizers
    • Recognizer: accepts L, may loop outside. RE = recognizable = semi-decidable = enumerable.
    • Decider: halts always. Recursive = decidable.
    • REC ⊆ RE. Enumerator ⇔ recognizer (dovetailing). Shortlex enumeration ⇔ recursive.

    Read lesson 4.3.1

  3. Are CFLs closed under complement?
    Stuck? Peek at 3.4.1 Closure properties of CFLs and DCFLs
    • CFL closed: ∪, concat, *, reversal, h, h⁻¹, substitution, ∩R, −R. Not: ∩, complement, difference.
    • DCFL closed: complement, ∩R, ∪R, −R, h⁻¹. Not: ∪, ∩, concat, *, reversal, h.
    • Counterexample: aⁿbⁿcᵐ ∩ aᵐbⁿcⁿ = aⁿbⁿcⁿ. Non-CFL proof: L ∩ R non-CFL ⇒ L non-CFL.

    Read lesson 3.4.1

The Hook

You have a recognizer for “bug-free programs” and another for “buggy programs”. Neither alone may ever finish on some inputs. Run them side by side, one step each in turn: every program is either bug-free or buggy, so one of the two must eventually say yes. Together they form a decider. This little argument is one of the most used theorems in GATE’s decidability questions.

Predict First

To decide w ∈ L ∪ L′ with recognizers M and M′, why can’t you just run M to completion, then M′?

Core Concept

Prediction check

M might loop on w (when w ∉ L), and then M′ never starts even if w ∈ L′. Run them alternately, one step each — then if either accepts, you find out.

flowplay illustration
Alternate steps (parallel simulation).

Closure of recursive languages

REC is closed under union, intersection, complement (swap accept/reject of a decider), difference, concatenation, Kleene star (try all splits — finitely many), reversal, inverse homomorphism. Not closed under (arbitrary) homomorphism.

complement
decider: swap accept and reject
concatenation
try every split point — finitely many
homomorphism
can erase information: not closed
REC closure highlights.

Closure of RE languages

RE is closed under union (parallel), intersection (run both, accept if both accept), concatenation, Kleene star (nondeterministically guess splits / dovetail), reversal, homomorphism, inverse homomorphism. Not closed under complement or difference.

operationRECRE
union✓✓
intersection✓✓
complement✓✗
difference✓✗
concatenation✓✓
Kleene star✓✓
homomorphism✗✓
inverse homomorphism✓✓
reversal✓✓
Note the two mirror differences: complement (REC only) and homomorphism (RE only).

The complement theorem

Theorem. If L and L̅ are both RE, then L is recursive.

Proof: run a recognizer for L and one for L̅ alternately on w. Exactly one of w ∈ L, w ∈ L̅ holds, so one machine eventually accepts; answer accordingly. The combined machine always halts. ∎

recognizer for L
+
recognizer for L̅
→
run alternately
one must accept
decider for L
Two half-answers make a whole answer.

Four possible situations

For any language L, exactly one holds:

  1. L and L̅ both recursive.
  2. L is RE but not recursive ⇒ L̅ is not RE.
  3. L̅ is RE but not recursive ⇒ L is not RE.
  4. Neither L nor L̅ is RE.

Impossible: L and L̅ both RE but L not recursive.

L̅ recursiveL̅ RE, not RECL̅ not RE
L recursivepossible✗ impossible✗ impossible
L RE, not REC✗✗possible
L not RE✗possiblepossible
The four-cell grid GATE loves to probe.

Putting it together

  • REC keeps complement; RE keeps homomorphism; both keep ∪, ∩, concatenation, star.
  • Both L and L̅ RE ⇒ L recursive (run alternately).
  • An RE-but-not-REC language has a non-RE complement.

Visual

L RE  and  L̅ RE   ⇒   L REC   (and L̅ REC)
L RE, not REC      ⇒   L̅ not RE
REC: closed under complement, not homomorphism
RE : closed under homomorphism, not complement

Worked Examples

Easy

L is recursive. Is L̅ recursive?

Show the full solution

Yes — swap accept and reject.

Medium

L is RE and L̅ is RE. Is L recursive?

Show the full solution

Yes, by the complement theorem.

GATE-level

L₁ is RE but not recursive. Which are true? (i) L̅₁ is RE. (ii) L̅₁ is not recursive. (iii) L₁ ∪ L̅₁ is recursive. (iv) L₁ ∩ L₂ is RE for any RE L₂.

Show the full solution

(i) false (else L₁ recursive). (ii) true (complement of a recursive language is recursive). (iii) true: it is Σ*. (iv) true. Answer: (ii), (iii), (iv).

GATE Traps

  • RE is NOT closed under complement; REC is.
  • REC is NOT closed under homomorphism; RE is.
  • L RE and L̅ RE ⇒ L REC — the most tested theorem in this area.
  • If L is RE but not REC, then L̅ is not even RE.

Memory Hook

Two detectives, one for guilty and one for innocent: run them in turns and one will always report — together they are a judge.

Connect the Dots

One last idea before Phase 5: a Turing machine can be written down as a string — and a single machine can read that string and simulate any other machine. That universal machine is your computer, and it is the starting point for proving limits.

Self-Test

  1. MSQ

    RE languages are closed under:

    1. union
    2. intersection
    3. complement
    4. homomorphism
  2. MCQ

    If L and L̅ are both RE, then:

    1. L is regular
    2. L is recursive
    3. L is a CFL
    4. nothing follows
  3. MCQ

    L is RE but not recursive. L̅ is:

    1. recursive
    2. RE but not recursive
    3. not RE
    4. regular
  4. MSQ

    Recursive languages are closed under:

    1. complement
    2. Kleene star
    3. homomorphism
    4. intersection

Rule Card

  • REC closed: ∪ ∩ complement − concat * reversal h⁻¹; not h.
  • RE closed: ∪ ∩ concat * reversal h h⁻¹; not complement, not difference.
  • L, L̅ ∈ RE ⇒ L ∈ REC. L ∈ RE − REC ⇒ L̅ ∉ RE.

Concept Ledger

  • closure of recursive languages
  • closure of RE languages
  • complement theorem (L, L̅ RE ⇒ REC)
  • parallel (alternating) simulation

Answer Vault

Reveal answers when you’re ready

Warm-up answers

  1. Regular ⊂ DCFL ⊂ CFL ⊂ CSL ⊂ REC ⊂ RE.
  2. Interleaves runs so no single looping run blocks the others.
  3. No.

Self-test answers

  1. ABD — Not complement.
    • C: Would make every RE language recursive.
  2. B — Complement theorem.
    • A: No.
    • C: No.
    • D: It follows.
  3. C — Otherwise L would be recursive.
    • A: Then L would be recursive.
    • B: Then both RE ⇒ recursive.
    • D: No.
  4. ABD — Not homomorphism.
    • C: Not closed.

Flashcards

  1. If L and L̅ are RE, what is L?
    Reveal answerRecursive.
  2. Is RE closed under complement?
    Reveal answerNo.
  3. Is REC closed under homomorphism?
    Reveal answerNo (RE is).
  4. L is RE but not REC. L̅?
    Reveal answerNot RE.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.