Chapter 1

Strings and language operations

First identify the universe, the empty objects and the quantifiers. Many apparent counting constraints disappear when an existentially chosen substring is allowed to be empty.

1.1 Strings and counting

An alphabet Σ\Sigma is a finite, nonempty set of symbols. A string ww is a finite sequence of symbols; ∣w∣|w| is its length, wRw^R its reversal and na(w)n_a(w) its number of occurrences of symbol aa. The empty string has length zero. Σn\Sigma^n contains all strings of length nn; Σ∗\Sigma^* contains all finite strings, including ϵ\epsilon.

1.2 Language algebra

Past papers · CS 2014–2026 (23 papers): 2 questions, 3 marks

A language LL is a subset of Σ∗\Sigma^*. Concatenation chooses its two strings independently: AB={xy:x∈A,y∈B}AB=\{xy:x\in A,y\in B\}. In particular, {an:n≥0}{bn:n≥0}=a∗b∗\{a^n:n\ge0\}\{b^n:n\ge0\}=a^*b^*; the two bound indices do not impose equality.

For a language LL, Prefix⁡(L)={x:∃y,xy∈L}\operatorname{Prefix}(L)=\{x:\exists y,xy\in L\}; suffix and substring use analogous existential contexts. A homomorphism hh assigns a string to each symbol and extends by h(uv)=h(u)h(v)h(uv)=h(u)h(v), h(ϵ)=ϵh(\epsilon)=\epsilon. It may erase symbols. Its inverse image is h−1(L)={w:h(w)∈L}h^{-1}(L)=\{w:h(w)\in L\}.

1.3 Quantifiers and hidden simplifications

Past papers · CS 2014–2026 (23 papers): 3 questions, 6 marks

In {wxwR:w,x∈Σ∗}\{wxw^R:w,x\in\Sigma^*\}, choosing w=ϵw=\epsilon gives every string. If both ww and xx must be nonempty, the language is exactly the strings of length at least three whose first and last symbols agree: a one-symbol ww suffices. Over {a,b}\{a,b\} its expression is aΣ+a+bΣ+ba\Sigma^+a+b\Sigma^+b.

Repeated copies differ from reversed copies. With nonempty u,vu,v, {uvu:u∈{a,b}+,v∈{a,b}+}\{uvu:u\in\{a,b\}^+,v\in\{a,b\}^+\} is not regular. Intersecting with a+ba+ba^+ba^+b gives {ambanb:n>m≥1}\{a^mba^nb:n>m\ge1\}, which requires an unbounded comparison. If uu is restricted to a+a^+, however, one symbol u=au=a suffices and the language is aΣ+aa\Sigma^+a.

Last-minute recall

  • Specify the alphabet before taking complement.
  • L0L^0 is always {ϵ}\{\epsilon\}.
  • Concatenation chooses independent strings unless the definition explicitly couples them.
  • Count words, not accepting paths or regex parses.
  • Try the smallest permitted existential choices first.
  • Distinguish copies wwww from mirrors wwRww^R.

Revise offline: the whole Theory of Computation handbook as one PDF

40 pages · 1.7 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections