The document describes finite automata. A finite automaton consists of a finite number of internal states and a transition function that determines the next state based on the current state and input. It takes an input string over a given alphabet and produces an output of "accept" or "reject". A deterministic finite automaton (DFA) is formally defined as a 5-tuple consisting of a set of states, an input alphabet, a transition function, an initial state, and a set of final states. The transition function of a DFA is represented by a transition graph with states as vertices and transitions as edges between states.
2. Finite Automaton
Input
A string over a given alphabet
written on an input file
String
Output
A control unit consisting of a
finite number of internal states
Finite String
Automaton
The internal state at the next time step is
determined by the transition function
2
4. Finite Accepter
Input String of
Internal states
Initial state
q0 “Accept”
q1 q5
or
q2 q4 final state “Reject”
q3
4
5. Formalities
Deterministic Finite Accepter (DFA) (p.38)
M Q, , , q0 , F
Q : set of internal states
: input alphabet
:Q×Q transition function
q0 : initial state
F : set of final states
5
6. Finite Accepter
Leftmost position
Input String abba
a b b a ×
: a particular status of the
Initial configuration input file and internal state
Internal states
q0 “Accept”
q1 q5
initial state
or
q2 q4 “Reject”
q3
6
7. At q0 now check for
current symbol-
Transition function
a b b a × q0 , a q1 Next
state
current state
current input symbol
move to the next state
Internal states
q0 “Accept”
q1 q5
or
q2 q4 “Reject”
q3
7
8. At q1 now check for
current symbol-
Transition function
q1 , b q2
a b b a ×
Next
state
current state
current input symbol
move to the next state
Internal states
q0 “Accept”
q1 q5
or
q2 q4 “Reject”
q3
8
9. At q2 now check for
current symbol-
Transition function
q2 , b q3
a b b a ×
Internal states
q0 “Accept”
q1 q5
or
q2 q4 “Reject”
q3
9
10. At q3 now check for
current symbol-
Transition function
q3 , a q4
a b ba ×
Internal states
q0 “Accept”
q1 q5
or
q2 q4 “Reject”
q3
10
11. At q4 now check for
current symbol-
a b ba × No symbol left and it
stops at final state
Internal states
q0 “Accept”
q1 q5
or
q2 q4 “Reject”
q3
The string abba is accepted
by the machine.
11
12. Transition Graph GM
Transition functions are the most
important part for a finite accepter.
We use a transition graph to represent
a finite accepter such that
Node state, and
Edge with label transition function
(current symbol)
12
13. Transition Graph for
q2 , b q3 Next
state
current state
current input symbol
q2 b q3
Initial state q0
Final state qf
13
14. Transition Graph
abba – a,b
Finite Accepter
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
initial final
state state
transition
state q2 , b q3 “accept”
It is important to have a clear and intuitive picture to work with DFA.
Transition graph: vertices > states, edges > transitions 14
15. Initial Configuration
Input String
a b b a
a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
15
16. Reading the Input
One at a time
from left to right
a b b a
a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
16
17. a b b a
a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
17
18. a b b a
a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
18
19. a b b a
a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
19
20. Input finished
a b b a
a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
Output: “accept”
20
28. End of input! a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
Output:“reject”
28
29. a,b
GM
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
A Trap State
It is important to have a clear and intuitive picture to work with DFA.
Transition graph: vertices > states, edges > transitions 29
30. A Deterministic Finite Accepter or DFA is
defined as M Q, , , q0 , F
(Def. 2.1 p.38)
a,b
GM
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
What are Q, , , q0, F?
It is important to have a clear and intuitive picture to work with DFA.
Transition graph: vertices > states, edges > transitions 30
31. Input Alphabet
a, b
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
31
32. Set of States Q
Q q0 , q1, q2 , q3 , q4 , q5
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
32
34. Set of Final States F
F q4
a,b
q5
a a,b
b a b
q0 a q1 b q2 b q3 a q4
34
35. Transition Function
:Q Q
a,b
GM
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
By Transition Graph
35
36. M Q, , , q0 , F a,b
q5
GM
b a a,b
a b
q0 a q1 b q2 b q3 a q4
What does “deterministic” mean?
is a total function
Other than using transition graph GM to represent a
transition function, there are two common ways to
represent a transition function.
It is important to have a clear and intuitive picture to work with DFA.
Transition graph: vertices > states, edges > transitions 36
37. Transition Function
q0 , a q1 q0 , b q5 q4 , a q5 q4 , b q5
q1 , a q5 q1 , b q2 q5 , a q5 q5 , b q5
q2 , a q5 q2 , b q3
q3 , a q4 q3 , b q5
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
37
38. Transition Function
a b
q0 q1 q5
q1 q5 q2
q2 q5 q3
q3 q4 q5 a,b
q4 q5 q5
q5 q5 q5 q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
38
39. Extended Transition Function *
including
* : Q * Q
Transition
function :Q Q
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
39
40. * : Q * Q
* q0 , ab q2
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
40
41. * q0 , abba q4
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
41
42. * q0 , abbbaa q5
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
42
43. Extended Transition Function
* : Q * Q
Recursive Definition
* ( q, ) q,
* (q, wa) ( * (q, w), a)
for all q Q, w*, a
43
44. Recursive * q, q
Definition
* q, wa ( * (q, w), a)
q wa q
q w q1 a q
If * q, wa q
then a state, say q1, * q, wa ( * (q, w), a)
such that * q, wa (q1 , a)
and
* q, w q1 44
45. * q0 , ab * q , q
* (q0 , a ),b * q, w ( * (q, w), )
* 0 , a ,b
q ,
q0 ,a b
,
q1 , b q2
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
45
46. There is a walk in GM
from q to q with label w 1 2 ... k
q w q
In the DFA M, there is * q, w q
with w 1 2 ... k
1 2 k
q q
46
47. There is a walk in GM
from q to q with label w 1 2 ... k
q w q
In the DFA M, there is * q, w q
with w 1 2 ... k
1 2 k
q q
47
48. There is a walk in GM
from q to q with label w 1 2 ... k
q w q
Theorem 2.1
In the DFA M, there is * q, w q
with w 1 2 ... k
1 2 k
q q
48
49. There is a walk from q0 to q5
with label abbbaa
If and only if * q0 , abbbaa q5
a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
49
50. Languages Accepted by DFAs
Take DFA M Q, , , q0 , F
Definition: (p.40)
The language L M contains all input
strings accepted by
M
LM = { strings that drive M to a final
state}
= { w * : *(q0, w) F }
50
51. Example
M a,b
q5
b a a,b
a b
q0 a q1 b q2 b q3 a q4
accept
LM abba back to complement Ex. p.51
51
52. Another Example
M a,b
q5
b a a a,b
b
q0 a q1 b q2 b q3 a q4
accept accept accept
LM , ab, abba
52
53. Formally, for a DFA M Q, , , q0 , F
Since M is DFA, every w*, * q0 , w q
corresponding to a unique walk in the
transition graph of M.
If q F w L(M )
q0 w q
If q F
w L(M )
q0 w q
53
54. Observation
Language rejected by M:
LM w * : * q0 , w F
q0 w q
q F
What is the complement of language on example
(p.48)? Example on p.48
54
56. LM = { all strings with prefix ab }
a,b
q0 a q1 b q2
b a accept
q3 a,b
56
57. LM = { all strings without substring 001}
1 0 0,1
1
0 1
0 00 001
0 What if consider DFA for {strings with 001}?
57
58. Regular Languages
A language L is regular if there is a
DFA M such that L LM
All regular languages form a language
family
58
59. Examples of regular languages:
abba , ab, abba
{a b : n 0}
n
{ all strings with prefix ab }
{ all strings without substring 001 }
There exist automata that accept these
Languages (see previous slides).
59
60. Is the complement ofabba also regular?
How can you show that the complement of
a regular language is regular? (referring to
Hw# 3, 4 on p.47)
60
61. Another Example
The language L awa : w a, b*
is regular
a
b
since we can find a
DFA M such that b
a
L LM q0 q2 q3
b a
q4
L*=L {}
a,b
61
62. Another Example
The language L awa : w a, b*
is regular. How about L2 ?
Can you show L* is a regular language?
Try Hw # 20, 21, 22
62
63. Is L?
If there is a DFA M for L, can you
tell if L?
If L is regular, then how about L-{}?
How can you construct a DFA for L-{} from
the DFA of L?
How can you construct a DFA for L{} from
the DFA of L?
Try hw #17 & 18 p.48
63
64. Homework 2.1 p.47
Try: 1 ~7, 9, 11~25
Hand in: 2bd, 4, 6, 7e, 9bf, 18
For hw18, state the general method then
use the example to illustrate the method
where L {a,b}*
L= {w: w= or w contains a substring “ab”}
64