# Lecture 02

## Finite Automata

Recall: Goal. Determine which decision we can solve

#### Thesis 1: "Decision Problem" \(\Longleftrightarrow\) Languages

#### Thesis 2: "Solving a Language" \(\Longleftrightarrow\) Finite Automata

**Define**: A (deterministic) finite automaton is a 5-tuple (\(Q,\Sigma,\delta,q_0,F\))

- \(Q\): finite set of states
- \(\Sigma\): Alphabet
- \(\delta\): \(Q\times\Sigma\rightarrow Q\)
- \(q_0\): Initial state
- \(F\subseteq Q\): set of accepting states

**Define**: A finite automaton accepts \(w\in\Sigma^n\) (\(n\geq 0\)) iff there is a sequence of states \(r_0,...,r_n\) such that

- \(\forall i\in[n]=\{1,2,...,n\}\) \(r_i=\delta (r_{i-1},w_i)\)
- \(r_n\in F\)
- \(r_0=q_0\)

**Define** The empty string is denoted by \(\epsilon\)

Observation: \(L_{\epsilon}=\{\epsilon\}\), \(L_{\emptyset}=\emptyset\), \(L_{\epsilon}\neq L_{\emptyset}\)

#### Example

- \(L=\{w|\)last char of \(w\) is 1\(\}\)
- \(L=\{w|\)next-to-last char of \(w\) is 1 \(\}\)
- \(L=\{w|w\) has the same number of \(01\) and \(10\) substrings\(\}\)

**Define** A language \(L\) is regular iff it is recognized by some finite automaton

## Non-deterministic Finite Automata

**Define** A non-deterministic finite automaton is a 5-tuple (\(Q,\Sigma,\delta,q_0,F\))

- \(Q,\Sigma,q_0,F\) as before
- \(\delta\): \(Q\times\Sigma\rightarrow\mathcal{P}(Q)\) where \(\mathcal{P}(Q)\) is a set of subsets of \(Q\)

**Define** The NFA accepts \(w\in\Sigma^n\) iff \(\exists r_0,...,r_n\in Q\) such that

- \(r_0=q_0\)
- \(r_n\in F\)
- \(\forall i\in[n], r_i\in\delta(r_{i-1},w_i)\)

**Theorem** Every language that can be recognized by an NFA is regular

**Proof** Given an NFA \(N\) we can build a DFA \(M\) that recognizes the same languages

- \(Q'=\mathcal{P}\)
- \(q_0'=\{q_o\}\)
- \(F'=\{R\subseteq Q:R\cap F\neq\emptyset\}\)