Deterministic Finite Automata Module
Deterministic Finite Automata Module
● Prerequisite knowledge:
Automata
Regular Languages
Set Theory
JFLAP Tutorial
The following figure illustrates a DFA using the JFLAP state diagram notation (see DFA_a.jff).
This DFA recognizes the regular language over the alphabet {a, b} consisting of only the string “a”. That
is, it accepts the string “a” and rejects all other strings.
The transition function given by state diagram above is also described by the following table:
a b
q0 q1 q2
q1 q2 q2
q2 q2 q2
In the transition function of a DFA, every state has exactly one transition associated with each symbol of
the alphabet. Because the DFA determines the unique next state for each next input symbol, this is a
deterministic finite automaton.
Example (see: DFA_cxc.jff)
Consider the regular language L over the alphabet { a, b, c } comprised of all strings that begin and end
with c. Let’s construct a DFA M to recognize that language.
Some strings in the language include: c, cc, ccc, cac, cabc, cabcbabc
1. Since the empty string is not in the language, we know that the initial state must not be an accept state.
2. Since all strings that begin with a or b are not in the language, we can create a “trap” state to catch all
such strings.
Create a new state, q1, as the destination of a or b from q0 and which traps all subsequent
substrings.
3. The string c is in the language, so we must create an accept state as the destination of transition c from
q0.
Create a new state, q2, as the destination of transition c from q0 and which is an accept
state.
4. Since the string may begin or end with an arbitrary length substring of consecutive c symbols, the DFA
can stay in the q2 accept state.
Add state q3 with a transition of a or b from q2. Add transitions to remain in q3 for a or b.
Add transition from q3 back to q2 for c.
3. Enumerate at least six strings over alphabet {a, b} not in the language
{ w | w is a string of a and b symbols in which a never follows b }.
Answer: ba, bab, aba, abba, bbba, bbab
(see: DFA_akbk.jff)
5. Check your DFA to ensure that it accepts and rejects the strings you previously identified.
Answer:
References
Kun, Jeremy, Determinism and Finite Automata – A Primer
http://jeremykun.com/2011/07/02/determinism-and-finite-automata-a-primer/
[2 July 2011; Accessed on 16 June 2014]
Wikipedia, Deterministic Finite Automaton
https://en.wikipedia.org/wiki/Deterministic_finite-state_machine
[13 June 2014; Accessed on 17 June 2014]