Lesson

Formula Sheet

Notation, definitions, constructions and procedures of the Automata and Formal Languages course in one place, in course order.

Last updated:


Using the sheet

A page for looking things up: notation, definitions, constructions and procedures, in the order of the course.
It teaches nothing new; each concept links to its glossary entry.
The sheet grows with the course: a unit appears here when its first lesson is published.

Strings and Formal Languages

Notation: letters and words

SymbolMeaning
Σ\Sigmathe alphabet: a finite, nonempty set of letters
ε\varepsilonthe empty word
∣w∣\lvert w\rvertthe length of ww⁠: the number of letters in it
Σ∗\Sigma^*the set of all words over Σ\Sigma⁠, including ε\varepsilon
Σ+\Sigma^+the set of all nonempty words over Σ\Sigma⁠, that is Σ∗−{ε}\Sigma^*-\{\varepsilon\}
u⋅vu\cdot v or uvuvthe concatenation: uu followed by vv
wnw^nww concatenated with itself nn times, with w0=εw^0=\varepsilon
wRw^Rthe reverse of ww⁠: its letters in the opposite order
#a(w)\#_a(w)the number of occurrences of the letter aa in ww

Words are defined by recursion on the last letter, where u∈Σ∗u\in\Sigma^* and a∈Σa\in\Sigma⁠:

Σ∗=I({ε}, {f:Σ∗×Σ→Σ∗∣f(w,a)=w⋅a})\Sigma^*=I\bigl(\{\varepsilon\},\ \{f:\Sigma^*\times\Sigma\to\Sigma^*\mid f(w,a)=w\cdot a\}\bigr) Σ+=I(Σ, {f:Σ∗×Σ→Σ∗∣f(w,a)=w⋅a})\Sigma^+=I\bigl(\Sigma,\ \{f:\Sigma^*\times\Sigma\to\Sigma^*\mid f(w,a)=w\cdot a\}\bigr)
#a(w)={0w=ε#a(u)+1w=u⋅a∧u∈Σ∗#a(u)w=u⋅c∧u∈Σ∗∧c∈Σ−{a}\#_a(w)= \begin{cases} 0 & w=\varepsilon\\ \#_a(u)+1 & w=u\cdot a\wedge u\in\Sigma^*\\ \#_a(u) & w=u\cdot c\wedge u\in\Sigma^*\wedge c\in\Sigma-\{a\} \end{cases}
wR={εw=εa⋅uRw=u⋅a∧u∈Σ∗∧a∈Σw^R= \begin{cases} \varepsilon & w=\varepsilon\\ a\cdot u^R & w=u\cdot a\wedge u\in\Sigma^*\wedge a\in\Sigma \end{cases}

The length of a word and the powers of a word, by the same kind of recursion:

∣w∣={0w=ε∣u∣+1w=u⋅a∧u∈Σ∗∧a∈Σwn={εn=0wn−1⋅wn∈N+\lvert w\rvert= \begin{cases} 0 & w=\varepsilon\\ \lvert u\rvert+1 & w=u\cdot a\wedge u\in\Sigma^*\wedge a\in\Sigma \end{cases} \qquad w^n= \begin{cases} \varepsilon & n=0\\ w^{n-1}\cdot w & n\in\mathbb{N}^+ \end{cases}

Useful rule: (uv)R=vRuR(uv)^R=v^Ru^R⁠.

Notation: languages

SymbolMeaning
L⊆Σ∗L\subseteq\Sigma^*a language over Σ\Sigma⁠: a set of words
∅\varnothingthe empty language, with no words (different from {ε}\{\varepsilon\}⁠)
LC=Σ∗−LL^C=\Sigma^*-Lthe complement of LL (depends on the alphabet)

Operations on languages

SymbolMeaning
L1⋅L2L_1\cdot L_2⁠, L1L2L_1L_2 or L1∘L2L_1\circ L_2{uv∣u∈L1∧v∈L2}\{uv\mid u\in L_1\wedge v\in L_2\}
LnL^nnn words of LL in a row, with L0={ε}L^0=\{\varepsilon\} and Ln=Ln−1⋅LL^n=L^{n-1}\cdot L
L∗L^*⋃n=0∞Ln\bigcup_{n=0}^{\infty}L^n⁠, the Kleene star: any number of words of LL in a row, including none
L+L^+⋃n=1∞Ln\bigcup_{n=1}^{\infty}L^n⁠: at least one word of LL
LRL^R{wR∣w∈L}={w∣wR∈L}\{w^R\mid w\in L\}=\{w\mid w^R\in L\}

Parts of the words of a language

SymbolMeaning
Pref(L)\mathrm{Pref}(L)the prefixes of words of LL
Suff(L)\mathrm{Suff}(L)the suffixes of words of LL
Sub(L)\mathrm{Sub}(L)the substrings of words of LL (contiguous pieces)
Pref(L)={x∈Σ∗∣ ∃y∈Σ∗∧xy∈L}Suff(L)={y∈Σ∗∣ ∃x∈Σ∗∧xy∈L}Sub(L)={y∈Σ∗∣ ∃x,z∈Σ∗∧xyz∈L}\begin{aligned} \mathrm{Pref}(L)&=\{x\in\Sigma^*\mid\,\exists y\in\Sigma^*\wedge xy\in L\}\\ \mathrm{Suff}(L)&=\{y\in\Sigma^*\mid\,\exists x\in\Sigma^*\wedge xy\in L\}\\ \mathrm{Sub}(L)&=\{y\in\Sigma^*\mid\,\exists x,z\in\Sigma^*\wedge xyz\in L\} \end{aligned}

Proving and refuting equality of languages

  • To prove L1=L2L_1=L_2⁠: show both inclusions, L1⊆L2L_1\subseteq L_2 and L2⊆L1L_2\subseteq L_1⁠, from the definitions of the operations (for an arbitrary word ww⁠, a chain of equivalences also works).
  • To refute L1=L2L_1=L_2⁠: give one word that belongs to one language and not to the other.

Deterministic Finite Automata and Regular Languages

Definition

A deterministic finite automaton (DFA) is an ordered quintuple A=(Q, Σ, δ, q0, F)A=(Q,\ \Sigma,\ \delta,\ q_0,\ F)⁠, where:

ComponentMeaning
QQa finite set of states
Σ\Sigmathe alphabet
δ:Q×Σ→Q\delta:Q\times\Sigma\to Qthe transition function: the next state after reading one letter
q0∈Qq_0\in Qthe start state
F⊆QF\subseteq Qthe accepting states

The transition function extended to words, δ∗:Q×Σ∗→Q\delta^*:Q\times\Sigma^*\to Q⁠, and the language of the automaton:

δ∗(q,w)={qw=εδ(δ∗(q,u),a)w=u⋅a∧u∈Σ∗∧a∈Σ\delta^*(q,w)= \begin{cases} q & w=\varepsilon\\ \delta\bigl(\delta^*(q,u),a\bigr) & w=u\cdot a\wedge u\in\Sigma^*\wedge a\in\Sigma \end{cases}
L(A)={ w∈Σ∗∣δ∗(q0,w)∈F }L(A)=\{\,w\in\Sigma^*\mid\delta^*(q_0,w)\in F\,\}

A language is regular if some DFA recognizes it.

Complement

For a complete DFA (a transition for every state and letter):

AC=(Q,Σ,δ,q0,Q−F),L(AC)=Σ∗−L(A)A^C=(Q,\Sigma,\delta,q_0,Q-F),\qquad L(A^C)=\Sigma^*-L(A)

Product automaton

For A=(QA,Σ,δA,q0,FA)A=(Q_A,\Sigma,\delta_A,q_0,F_A) and B=(QB,Σ,δB,p0,FB)B=(Q_B,\Sigma,\delta_B,p_0,F_B) over the same alphabet (otherwise extend both to the union of the alphabets), the product automaton has

Q=QA×QBδ((q,p),x)=(δA(q,x), δB(p,x))start state  (q0,p0)\begin{aligned} Q&=Q_A\times Q_B\\ \delta\bigl((q,p),x\bigr)&=\bigl(\delta_A(q,x),\ \delta_B(p,x)\bigr)\\ \text{start state }&\ (q_0,p_0) \end{aligned}

and a set of accepting states that depends on the language we want:

LanguageSet of accepting states FF of the product
L(A)∩L(B)L(A)\cap L(B)FA×FBF_A\times F_B
L(A)∪L(B)L(A)\cup L(B)(FA×QB)∪(QA×FB)(F_A\times Q_B)\cup(Q_A\times F_B)
L(A)−L(B)L(A)-L(B)FA×(QB−FB)F_A\times(Q_B-F_B)
L(A) △ L(B)L(A)\,\triangle\,L(B)(FA×(QB−FB))∪((QA−FA)×FB)\bigl(F_A\times(Q_B-F_B)\bigr)\cup\bigl((Q_A-F_A)\times F_B\bigr)

Minimization

Equivalent states and the quotient automaton:

p≡q  ⟺  ∀w∈Σ∗: (δ∗(p,w)∈F  ⟺  δ∗(q,w)∈F)δ′([q],x)=[δ(q,x)]\begin{aligned} p\equiv q &\iff \forall w\in\Sigma^*:\ \bigl(\delta^*(p,w)\in F\iff\delta^*(q,w)\in F\bigr)\\ \delta'\bigl([q],x\bigr)&=\bigl[\delta(q,x)\bigr] \end{aligned}

Table filling, after removing the unreachable states: round 0 marks every pair of an accepting and a non-accepting state; round kk marks a pair p,qp,q if for some letter xx the pair δ(p,x),δ(q,x)\delta(p,x),\delta(q,x) was marked in an earlier round; stop after a round that marks no pair.
An unmarked pair is a pair of equivalent states.

Myhill–Nerode

Indistinguishable words and the automaton of the classes:

x≡Ly  ⟺  ∀z∈Σ∗: (xz∈L  ⟺  yz∈L)sL=[ε],δL([x],c)=[xc],FL={[x]∣x∈L}\begin{aligned} x\equiv_L y &\iff \forall z\in\Sigma^*:\ \bigl(xz\in L\iff yz\in L\bigr)\\ s_L=[\varepsilon],\quad \delta_L\bigl([x],c\bigr)&=[xc],\quad F_L=\bigl\{[x] \mid x\in L\bigr\} \end{aligned}

Lower bound: if x1,…,xnx_1,\dots,x_n are pairwise distinguishable, every DFA for LL has at least nn states.
For a language that has a DFA, the number of classes is the number of states of the smallest DFA, which is unique up to renaming.

The Pumping Lemma

The lemma. If LL is regular, there is N∈N+N\in\mathbb{N}^+ (the pumping length) such that for every word w∈Lw\in L with ∣w∣≥N|w|\geq N there is a split w=xyzw=xyz with ∣y∣>0|y|>0⁠, ∣xy∣≤N|xy|\leq N and ∀i≥0 ⁣: xyiz∈L\forall i\geq 0\!:\ xy^iz\in L⁠.

Refuting regularity with the lemma:

  1. Assume, for contradiction, that LL is regular.
  2. Then there is an NN that satisfies the lemma for LL⁠.
  3. Choose a word w∈Lw\in L that depends on NN⁠, with ∣w∣≥N|w|\geq N⁠.
  4. Write generally every split w=xyzw=xyz with ∣y∣>0|y|>0 and ∣xy∣≤N|xy|\leq N⁠.
  5. Show that for every such split there is an i≥0i\geq 0 with xyiz∉Lxy^iz\notin L⁠.
  6. This contradicts the lemma, so LL is not regular.

The lemma is a necessary condition only: a language that satisfies it need not be regular.