# Chapter 1: Regular Languages

## For Your Enjoyment

- Algorithms can be nondeterministic. Check out the nondeterministic
algorithm for primality testing in this
Wikipedia article.

## Chapter 1.2, Nondeterminism

### Lecture Problem

- Design a nondeterministic finite automaton that accepts any binary
string that contains either 00 or 11.
- What is Q? (a finite set of states)
- What is Σ? (a finite set called the alphabet)
- What is δ? (Q × Σ
_{ε} —> P(Q) is the transition function)
- What is q
_{0}? (the start state)
- What is F? (the set of accept states)
- Note: A nondeterministic finite automaton (NFA) is a 5-tuple (Q, Σ, δ, q
_{0}, F).

### Active Learning Problem

Construct a three-state NFA that accepts any binary number
that consists of any number of 0s or any number of 1s.

### Definition

Machine M = (Q, Σ, δ, q_{0}, F)
**accepts** string w = w_{1}...w_{n}
where each w_{i} ∈ Σ_{ε}
if a sequence of states
r_{0}...r_{n} exists with

- r
_{0} = q_{0}
- r
_{i+1} ∈ δ(r_{i}, w_{i+1})
- r
_{n} ∈ F

### Active Learning

Theorem: Every NFA has an equivalent DFA.

Proof Sketch (assuming no ε transitions):
Let NFA N = (Q, Σ, δ, q_{0}, F).
Construct DFA M = (Q', Σ, δ', q_{0}', F').

Exercise: Convert the three-state NFA above to a DFA
using the construction given in the proof.