LN4 - FL3 - Deterministic Finite Automata
LN4 - FL3 - Deterministic Finite Automata
- The finite automaton (FA) is a mathematical model of a system, with discrete inputs
and outputs.
- A finite automaton consists of a finite set of states, and a set of transitions from states
to states that occur in response to external “inputs” chosen from an alphabet .
- The purpose of a state is to remember the relevant portion of the system’s history.
Since there are only a finite number of states, the entire history generally cannot be
remembered. So, the system must be designed carefully.
- A state of the system summarizes the information concerning past inputs that is
needed to determine the behavior of the system on subsequent inputs.
- Example: On/Off switch, the control mechanism of an elevator etc.
- Deterministic vs Nondeterministic: The control is “deterministic”, meaning that the
automaton cannot be in more than one state at any one time or “nondeterministic”,
meaning that it may be in several states at once.
Formal Definition of DFA: A DFA is a quintuple (5-tuple), that is, a system which consists
of 5 elements. We write,
A = (Q, , , q0, F), where
- Q: finite nonempty set of states;
- (capital sigma): finite nonempty set of input symbols, input alphabet;
- (small delta): transition function that takes as arguments a state and an input
symbol and returns a state, : Q x → Q;
- q0: initial/start state, q0 Q;
- F: set of final or accepting states, F Q.
Example: Specify a DFA that accepts all and only the strings of 0’s and 1’s that have the
sequence 01 somewhere in the string.
So, L: {w | w is of the form x01y for some string x and y consisting of 0’s and 1’s only}
= {0, 1}, Say initial state q0.
CSE4129: Formal Languages and Compilers : Lecture 4
This automaton has to remember the important facts about what inputs it has seen so far. To
decide whether 01 is a substring of the input, the automaton needs to remember:
1. Has it already seen 01? If so, then it accepts every sequence of further inputs. (Say,
state q2)
2. Has it never seen 01, but its most recent input was 0, so if it now sees a 1, it will have
seen 01 and can accept everything it sees from here on? (Say, state q1)
3. Has it never seen 01, but its last input was either nonexistent (it just started) or it last
saw a 1? (Say, state q0)
Transition diagram:
1 0 0,1
0 1
q0 q1 q2
Transition Table:
0 1
q0 q1 q0
q1 q1 q2
*q2 q2 q2
Here,
Q = {q0, q1, q2},
= {0, 1},
= {((q0, 0), q1), ((q0, 1), q0), ((q1, 0), q1), ((q1, 1), q2), ((q2, 0), q2), ((q2, 1), q2)},
q0 and F = {q2}.