# Chapter 1: Regular Languages

• 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 q0? (the start state)
• What is F? (the set of accept states)
• Note: A nondeterministic finite automaton (NFA) is a 5-tuple (Q, Σ, δ, q0, 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, Σ, δ, q0, F) accepts string w = w1...wn where each wi ∈ Σε if a sequence of states r0...rn exists with

• r0 = q0
• ri+1 ∈ δ(ri, wi+1)
• rn ∈ F

### Active Learning

Theorem: Every NFA has an equivalent DFA.

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

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