Deterministic Finite Automata
Deterministic Finite Automata
Denition: A deterministic nite automaton (DFA) consists of 1. a nite set of states (often denoted Q) 2. a nite set of symbols (alphabet) 3. a transition function that takes as argument a state and a symbol and returns a state (often denoted ) 4. a start state often denoted q0 5. a set of nal or accepting states (often denoted F ) We have q0 Q and F Q
The indicates the start state: here q0 The indicates the nal state(s) (here only one nal state q1 ) This denes the following transition diagram
1 0 0
q0
q2
q1
0,1
Example: password
When does the automaton accepts a word?? It reads the word and accepts it if it stops in an accepting state q0
=t t
q1
=e
q2
q3
q4
=h
q5 Only the word then is accepted Here Q = {q0 , q1 , q2 , q3 , q4 } is the set of all characters F = {q4 }
=n
A Transition table
B
0
0,1
0 A B C D C C C D
1 B B D D
Minimalisation
The same language may be represented by dierent DFA
1 0 1 0 1
A and
B
0
0,1
1 0 0 1
0,1
10
Minimalisation
Later in the course we shall show that there is only one machine with the minimum number of states (up to renaming of states) Furthermore, there is a (clever) algorithm which can nd this minimal automaton given an automaton for a language
11
Example
Mn the cyclic automaton with n states on = {1} such that L(Mn ) = {1l | n divides l}
12
13
14
15
16
E -> (Q -> Q)
17
18
19
A proof by induction
A very important result, quite intuitive, is the following. Theorem: for any state q and any word x and y we have q.(xy) = (q.x).y Proof by induction on x. We prove that: for all q we have q.(xy) = (q.x).y (notice that y is xed) Basis: x = then q.(xy) = q.y = (q.x).y
20
21
22
f (n + 1) = g(n), g(n + 1) = f (n), h(n + 1) = 1 h(n) We have f (n) = h(n) We can prove this automatically using DFA
23
24
Show that f (n + 3) = f (n) by using Q = {0, 1} {0, 1} {0, 1} and the transition function (a, b, c) (b, c, b + c bc) with the initial state (0, 1, 1)
25
Product of automata
How do we represent interaction between machines? This is via the product operation There are dierent kind of products We may then have combinatorial explosion: the product of n automata with 2 states has 2n states!
26
The product of
p1 p0
p1
A
p0
p1
and
p0
C
p1
p0
is
p1
A, C
p1
p0
B, C
p1 p1
A, D
p0
B, D
p0
If we start from A, C and after the word w we are in the state A,D we know that w contains an even number of p0 s and odd number of p1 s
27
ik
uk
28
i1 , r2
r1 , r2
u 1 , r2
i1 , u2
r1 , u 2
u1 , u2
29
30
31
32
Product of automata
It can be quite dicult to build automata directly for the intersection of two regular languages Example: build a DFA for the language that contains the subword ab twice and an even number of as
33
34
Complement
If A = (Q, , , q0 , F ) we dene the complement A of A as the automaton A = (Q, , , q0 , Q F ) Theorem: If A is a DFA, then L(A) = L(A) Remark: We have A A = A A
35
Languages
Given an alphabet A language is simply a subset of Common languages, programming languages, can be seen as sets of words Denition: A language L is regular i there exists a DFA A, on the same alphabet such that L = L(A) Theorem: If L1 , L2 are regular then so are L1 L2 , L1 L2 , L1
36
q0
q1
q2
0 0
q3
q0
0 1
q1
which is the accessible part of the DFA The remaining states are not accessible from the start state and can be removed
37
38
39
40
41
oA
=onB,oA
p1 onB p2
42
q0 onB q2
onA
q1
We can take the product of the two automata to express the two conditions as one automaton, which may represent the control system
43