Deterministic Finite Automata: COMP2600 - Formal Methods For Software Engineering
Deterministic Finite Automata: COMP2600 - Formal Methods For Software Engineering
Katya Lebedeva
(Σ, S, s0 , F, δ)
where
5. δ : S × Σ → S is a transition function
- S0 1
S2
0
1 6@ 1 0
@
R
S1
0
• alphabet - {0, 1}
• states - {S0 , S1 , S2 }
• initial state - S0 0 1
• final states - {S2 } S0 S1 S0
S1 S1 S2
• transition function S2 S1 S0
δ(S0 , 0) = S1 δ(S0 , 1) = S0
δ(S1 , 0) = S1 δ(S1 , 1) = S2
δ(S2 , 0) = S1 δ(S2 , 1) = S0
δ : S×Σ → S
δ∗ : S × Σ∗ → S
- S0 1
S2
0
1 6
R
@
@ 1 0
S1
0
In other words:
If
w = a1 a2 . . . an
and
δ(s, a1 ) = p1
δ(p1 , a2 ) = p2
...
δ(pn−1 , an ) = q
then
δ∗ (s, a1 a2 . . . an ) = q
Thus δ∗ is defined by breaking the input string into a single symbol followed
by a string. We exploit the fact that strings are defined inductively!
Proof:
Base case: α = ε
We say a DFA accepts a string if, starting from the start state, it terminates in
one of the final states. More precisely, let A = (S, Σ, δ, s0 , F) be a DFA and
w be a string in Σ∗ .
We say w is accepted by A if
δ∗ (s0 , w) ∈ F
L(A) = {w ∈ Σ∗ | δ∗ (s0 , w) ∈ F}
0011101 takes the machine from state S0 through the sequence of states S1 ,
S1 , S2 , S0 , S0 , S1 to the final state S2
What is the difference between strings that are accepted by A1 and that are
not?
Our claim: A1 accepts the language with only words finishing with 01.
S1 0
Observe that δ∗ (s, 01) = S2 holds for all s ∈ S.
Hence,
• w=ε
δ∗ (S0 , ε) = S0 and S0 is not equal to S2 . Hence, the antecedent is false
and the claim is true by the rules of propositional logic.
This is because DFA cannot remember how many ‘a’s it has seen.
Since this list is infinite and the number of states in A is finite, some of these
expressions must denote the same state.
What we have done here is pick two initial string fragments that the automaton will not
be able to distinguish in terms of what is allowed for the rest of the string
δ∗ (S0 , ai bi ) ∈ F
δ∗ (δ∗ (S0 , a j ), bi ) ∈ F
If we have more pigeons than pigeon-holes, then at least two pigeons must
be sharing a hole.
But be careful: there are infinite languages that can be recognised by DFAs,
as we have seen.
Two automata are said to be equivalent if they accept the same language.
a b a
?
? ?
b-
a S1 S2
a S1 Q b a,b
s
QQ ?
A2 : - S0 a 6 b A3 : - S0 S2
@ ? @ 3
bR
@ S3 - S4 b@
R S3 a
a
6
b 6
a 6
b
Two states S j and Sk of a DFA are equivalent if, for all input strings w
Note that δ∗ (S j , w) and δ∗ (Sk , w) may be different states - we only care that
both are in, or not in, F .
• The working data structure for the algorithm is a list of groups of states
• Each group contains states that appear to be equivalent, given the tests
we have done so far
• On each iteration, we test one of the groups with a symbol from the al-
phabet.
• Initialise: Divide the states into two groups: a group for non-final states
and a group for final states.
We assume that the states in the same group are equivalent, and we try
to distinguish them.
• Loop: Pick a group, {s1 , ...s j } and a symbol x. If states δ(si , x) for
i = 1, j are all in the same group, then the group {s1 , ...s j } is not (yet)
split. Otherwise split the group according to the result.
• Terminate when we cannot any more split any group by any letter of the
alphabet.
• S0 is S without Sk
• F 0 is F without Sk
0
S
j if δ(s, w) = Sk
• δ (s, w) =
δ(s, w) otherwise.
But S3 is inaccessible from the start state. That is why it can be deleted (along
with the transitions emerging from it).