Finite Automata
Deterministic Finite Automata (DFA)
A deterministic finite automaton (DFA, plural automata) is a finite state machine for the express purpose of determining whether a string (word) is in a language.
The set of words that the diagram describes the language
We can have more than 1 accepting state.
$$\Sigma = \{ a, b \}, L = \text{the set of all words with an odd number of a's}$$
$$\Sigma = \{ a, b \}, L = \{ \varepsilon \}$$
Formally
Example from the odd number of a's DFA:
: interpretation in Predicate Logic#Semantics (woo!)
The Error State (Dungeon State)
The error state (nicknamed the dungeon state) is a non-accepting state that does now allow you to leave.
You enter the error state when you try a combination which is not defined by
Drawing the implicit error state from the first example:
Extended Transition Function
where
Word Acceptance
A word
Given a word, to check if it is the language, run the word through the DFA. If you reach an accepting state, it is in the language. If you get stuck (dungeon state), it's not in the language.
Language Specification
A language specified by the DFA is a set of words accepted by it
Complement of a DFA
To take the complement of the language specified by a DFA, change all accepting states to non-accepting, and non-accepting states to accepting
Non-Deterministic Finite Automata (NFA)
A non-deterministic finite automaton (NFA) has multiple choices of transitions for an input symbol. We want to accept if any path leads to an accepting state.
We have two DFAs defining:
- The set of natural numbers written in decimal without leading zeros
- The set of natural numbers written in hexadecimal, prefixed with
0x
We want
Problem: if we have 0, how do we know which way to go?
Formally
A NFA is a 5-tuple
is a finite alphabet (input symbols) is a finite set of states is the start state is the set of accepting states : is the transition function ( means a set of states from )
which is the same as a DFA, except the transition function is different
Extended Transition Function:
which is the same as the extended transition function for a DFA, except we take the union of any of the "next states".
Word Acceptance
A word is accepted by an NFA if
ε-transitions
from state a, optionally transition to b without consuming input
This can make it easier for us to combine DFAs to make an NFA