CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 4 · Turing Machines

Lesson 4.2 · Item 69 of 91

TM variants, linear bounded automata and context-sensitive languages

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

On this page

Recall warm-up

  1. Running time of the cross-off TM for aⁿbⁿcⁿ?
    Stuck? Peek at 4.1.2 Designing Turing machines
    • Cross-off: mark X/Y/Z per pass, walk back; O(n²) for aⁿbⁿcⁿ.
    • Copy: carry one symbol in the state, append, return.
    • Unary +: replace separator, erase one 1. Binary +1: trailing 1s → 0, first 0/□ → 1.
    • TM computes f: halts with f(w) on the tape.

    Read lesson 4.1.2

  2. NFA with n states → DFA states at most?
    Stuck? Peek at 1.2.3 Subset construction and the 2ⁿ blow-up
    • Subset construction: start {q₀} (or ECLOSE(q₀)); δ(S,a) = ⋃ δ(q,a) (then ECLOSE); accept iff S ∩ F ≠ ∅; ∅ = dead state.
    • ≤ 2ⁿ states; count only reachable sets.
    • ε-removal: δ'(q,a) = ECLOSE(δ(ECLOSE(q), a)); F' = {q : ECLOSE(q) ∩ F ≠ ∅}.
    • k-th from end is 1: NFA k+1, DFA 2ᵏ. k-th from start: DFA k+2.
    • DFA ≡ NFA ≡ ε-NFA in power.

    Read lesson 1.2.3

  3. Is an NPDA more powerful than a DPDA?
    Stuck? Peek at 3.3.3 Designing PDAs; DPDA vs NPDA; DCFL ⊂ CFL
    • Recipe: stack stores what is unbounded; states store the phase; Z₀ detects empty; accept via ε, Z₀.
    • DPDA: ≤ 1 move per (q, a|ε, X), and no ε-move competing with input moves.
    • Regular ⊊ DCFL ⊊ CFL. wwᴿ, aⁿbⁿ ∪ aⁿb²ⁿ, aⁱbʲcᵏ (i=j or j=k): CFL not DCFL.
    • DCFL ⇒ unambiguous grammar; not conversely.

    Read lesson 3.3.3

The Hook

Real computers have many memory banks, random access, parallel threads. Would a Turing machine with more tapes, or the power to guess, compute more? Remarkably, no: every reasonable upgrade can be simulated by a plain one-tape TM, only slower. This robustness is why “Turing machine” is the definition of computable. The one change that does matter is removing space: a tape no longer than the input gives a strictly weaker machine.

Predict First

For finite automata, guessing added no power; for stack machines it did. What do you expect for Turing machines?

Core Concept

Prediction check

No extra power. A deterministic TM can explore every branch of a nondeterministic TM breadth-first (to avoid getting lost in a looping branch). It may take exponentially longer, but it accepts the same strings.

C₀C₁C₃…C₄accC₂C₅∞
A nondeterministic computation tree. The simulator explores it level by level, so an infinite branch (C₅) cannot hide the accepting leaf.

Equivalent variants

  • Multi-tape TM: k tapes and heads. Simulated on one tape by interleaving tracks and marking head positions; t steps become O(t²).
  • Nondeterministic TM: breadth-first simulation; same languages.
  • Two-way infinite tape: fold it in half onto a one-way tape with two tracks.
  • Multi-head, multi-track, 2-D tape, stay-put moves: all equivalent.
  • PDA with two stacks: equivalent to a TM (left stack = tape left of the head, right stack = the rest). Two counters also suffice.
variantsame languages as a TM?simulation cost
multi-tapeyesO(t²)
nondeterministicyesexponential (BFS of the tree)
two-way infinite tapeyesO(t)
PDA with 2 stacksyesO(t)
PDA with 1 stackno — CFLs only—
tape bounded by input (LBA)no — CSLs only—
Every unbounded upgrade is equivalent; bounding memory loses power.

Two stacks = a tape

Cut the tape at the head: everything to the left is one stack (top = cell next to the head), the head cell and everything to the right is the other stack. Moving the head is popping one stack and pushing the other. So adding a single second stack jumps straight from CFLs to everything a TM can do.

left stack
b a (top = b)
head
c
right stack
c d e (top = c)
Tape “a b [c] d e” as two stacks. Move right: pop c from the right stack, push it on the left.

Linear bounded automata

A linear bounded automaton (LBA) is a nondeterministic TM whose head never leaves the cells holding the input (between end markers ⊢ and ⊣).

It can still mark and re-read the input, so aⁿbⁿcⁿ, ww and {aᵖ : p prime} are LBA languages. With finitely many states and cells, its number of configurations on input length n is bounded (|Q| · n · |Γ|ⁿ), so a halting check is possible: every LBA language has an always-halting decision procedure.

⊢aabbcc⊣the only cells the LBA may use
An LBA works only inside the input, between the end markers.

Context-sensitive grammars and languages

Context-sensitive grammar (CSG): every rule α → β has |α| ≤ |β| (non-contracting), with S → ε allowed if S never appears on a right side. Rules can depend on context: aAb → aBb.

CSG languages = LBA languages = the context-sensitive languages (CSL). Example grammar for aⁿbⁿcⁿ (n ≥ 1): S → aSBC | aBC, CB → BC, aB → ab, bB → bb, bC → bc, cC → cc.

Facts: CFL ⊂ CSL (strict: aⁿbⁿcⁿ); every CSL is decided by an always-halting TM; CSLs are closed under ∪, ∩, complement, concatenation, star.

flowplay illustration
A context-sensitive derivation of aabbcc. Rules never shrink the string.

Putting it together

  • Every unbounded-memory variant of the TM has the same power.
  • Two stacks already equal a tape.
  • Bounding the tape to the input gives LBAs and the context-sensitive languages, strictly between CFL and TM languages.

Visual

memory upgrades and their power
 DFA (no memory)            → regular
 PDA (1 stack)              → CFL
 LBA (tape = input length)  → CSL
 TM  (unbounded tape)       → RE        ← 2 stacks, k tapes, nondeterminism: all land here

Worked Examples

Easy

A 3-tape TM runs for t steps. About how long does the one-tape simulation take?

Show the full solution

O(t²).

Medium

Is a PDA with two stacks more powerful than a PDA with one?

Show the full solution

Yes: one stack gives the CFLs; two stacks simulate a TM.

GATE-level

Which are true? (i) Nondeterministic TMs accept more languages than deterministic TMs. (ii) Every CSL is accepted by some LBA. (iii) aⁿbⁿcⁿ is context-sensitive. (iv) An LBA may move its head anywhere on an infinite tape.

Show the full solution

(i) false. (ii) true. (iii) true. (iv) false — it is confined to the input. Answer: (ii) and (iii).

GATE Traps

  • NTM = DTM in power (unlike NPDA vs DPDA). Only speed differs.
  • Two stacks = TM; one stack = PDA.
  • LBA = nondeterministic TM confined to the input; it accepts exactly the CSLs.
  • CSG rules are non-contracting: |α| ≤ |β|.

Memory Hook

Upgrades that add unbounded memory change nothing beyond the TM; taking memory away (bounding the tape) is what loses power.

Connect the Dots

All machines with unbounded tapes have the same power. But some TMs halt on every input and some don’t — that difference splits the TM languages into two classes, next.

Self-Test

  1. MSQ

    Which are equivalent in power to a standard TM?

    1. multi-tape TM
    2. nondeterministic TM
    3. PDA with two stacks
    4. PDA with one stack
  2. MCQ

    An LBA is:

    1. a DFA with a stack
    2. a TM with tape bounded by the input length
    3. a TM with two tapes
    4. a PDA with a bound on stack height
  3. MCQ

    Which rule is allowed in a context-sensitive grammar?

    1. AB → a
    2. aA → aBb
    3. AbC → b
    4. S → ε (S on a right side)
  4. NAT

    A one-tape simulation of a multi-tape TM running t = 100 steps takes on the order of how many steps (t²)?

    Write your answer before opening the key.

Rule Card

  • Multi-tape (O(t²)), nondeterministic (BFS, exponential), two-way tape, 2-stack PDA, 2 counters: all = TM.
  • LBA: nondeterministic TM within the input ⇔ CSG (|α| ≤ |β|) ⇔ CSL.
  • CFL ⊊ CSL (aⁿbⁿcⁿ). Every CSL is decided by an always-halting TM.

Concept Ledger

  • multi-tape TM
  • nondeterministic TM
  • two-way infinite tape
  • two-stack PDA
  • linear bounded automaton (LBA)
  • context-sensitive grammar (CSG)
  • context-sensitive language (CSL)

Answer Vault

Reveal answers when you’re ready

Warm-up answers

  1. O(n²).
  2. 2ⁿ.
  3. Yes (wwᴿ).

Self-test answers

  1. ABC — Unbounded, flexible memory.
    • D: Only CFLs.
  2. B — Definition.
    • A: That is a PDA.
    • C: Equivalent to TM.
    • D: That is essentially finite.
  3. B — |α| ≤ |β|.
    • A: Contracting.
    • C: Contracting.
    • D: Not allowed when S appears on a right side.
  4. 10000 — t².

Flashcards

  1. Does nondeterminism add power to TMs?
    Reveal answerNo — only speed differs.
  2. Power of a PDA with two stacks?
    Reveal answerSame as a TM.
  3. What does an LBA accept?
    Reveal answerExactly the context-sensitive languages.
  4. CSG rule restriction?
    Reveal answer|α| ≤ |β| (non-contracting).

Ready for the next idea?

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