Sie sind auf Seite 1von 3

Informatique Théorique Spring 2011

Handout 2: The Product Construction for Finite Automata

2.1 Example. Check if the input contains an odd number of 1’s. We remember in state a that the
processed portion of the input contains an even number of 1’s, and in state b that the processed portion
of the input contains an odd number of 1’s. State diagram:

 w 0
A
K
1 1

B k
0

2.2 Example. Check if the input contains the substring 000. We remember in state r that we have not
yet seen 000 and we need to see 3 more 0’s to accept; in state s, that we have not yet seen 000 and we
need to see 2 more 0’s to accept; in state t, that we have not yet seen 000 and we need to see 1 more 0
to accept; in state u, that we have seen 000. State diagram:

1 0,1

 
/ R 0 / S 0 / T 0 / U
`g
1

2.3 Intersection and union of finite automata. Since a language is a set of words, we can take
the intersection and the union of two languages L1 and L2 . It would be useful if we can construct finite
automata for L1 ∩ L2 and L1 ∪ L2 from finite automata for L1 and L2 , no matter what L1 and L2 are.
For instance, this would give us a systematic way of constructing from the automata of Examples 2.1
and 2.2 an automaton that checks “if the input contains an odd number of 1’s and the substring 000,”
as well as an automaton that checks “if the input contains an odd number of 1’s or the substring 000.”
We cannot first run the automaton for L1 over the input, then back up and run the automaton for L2
over the same input, because a finite automaton cannot “back up.” However, we can run both automata
“in parallel,” by remembering the states of both automata while reading the input. This is achieved by
the product construction.
Let M1 = (Q1 , Σ, δ1 , q01 , F1 ) and M2 = (Q2 , Σ, δ2 , q02 , F2 ) be two finite automata with the same input
alphabet. We define a finite automaton M∩ such that L(M∩ ) = L(M1 ) ∩ L(M2 ) and a finite automaton
M∪ such that L(M∪ ) = L(M1 ) ∪ L(M2 ) as follows:
M∩ = (Q, Σ, δ, q0 , F∩ ),
M∪ = (Q, Σ, δ, q0 , F∪ ),
where
Q = Q1 × Q2 ,
δ((q1 , q2 ), a) = (δ1 (q1 , a), δ2 (q2 , a)),
q0 = (q01 , q02 ),
(q1 , q2 ) ∈ F∩ iff q1 ∈ F1 and q2 ∈ F2 ,
(q1 , q2 ) ∈ F∪ iff q1 ∈ F1 or q2 ∈ F2 .

1
c T.A. Henzinger, G. Théoduloz
Each state in Q is a pair consisting of a state from Q1 and a state from Q2 . In state (q1 , q2 ) on input a,
the automata M∩ and M∪ proceed by executing M1 from q1 , and in parallel, executing M2 from q2 . If
M1 has n1 states and M2 has n2 states, then M∩ and M∪ each have n1 · n2 states.

2.4 Example. Check if the input contains an odd number of 1’s and the substring 000. State diagram:


/ 0 / 0 / 0 /
_g
A,R A,S A,T A,U
K 1 K
1
1 1 1 1
1

w 1
B,R / B,S / B,T / B,U
0 0 0
W
0

2.5 Example. Check if the input contains an odd number of 1’s or the substring 000. State diagram:


/ 0 / 0 / 0 /
_g
A,R A,S A,T A,U
K 1 K
1
1 1 1 1
1

w 1
B,R / B,S / B,T / B,U
0 0 0
W
0

2.6 Merge of finite automata. For two languages L1 and L2 , we write L1 ||L2 for the set of words
that result from merging a word in L1 with a word in L2 . For instance:
{a,ab}||{01} = {a01,0a1,01a,ab01,a0b1,0ab1,a01b,0a1b,01ab}

Let M1 = (Q1 , Σ, δ1 , q01 , F1 ) and M2 = (Q2 , Σ, δ2 , q02 , F2 ) be two finite automata with the same input
alphabet. We define a finite automaton M|| such that L(M|| ) = L(M1 )||L(M2 ) as follows:
M|| = (Q, Σ, δ|| , q0 , F∩ )
where

Q = Q1 × Q2 ,
δ|| ((q1 , q2 ), a) = {(δ1 (q1 , a), q2 ), (q1 , δ2 (q2 , a))},
q0 = (q01 , q02 ),
(q1 , q2 ) ∈ F∩ iff q1 ∈ F1 and q2 ∈ F2 .
In state (q1 , q2 ) on input a, the automaton M|| has two choices: it can either execute M1 from q1 ,
leaving q2 unchanged, or it can execute M2 from q2 , leaving q1 unchanged. Such a choice is called
nondeterminism. State diagram for merging to the two automata from Examples 2.1 and 2.2:

2
c T.A. Henzinger, G. Théoduloz
1

0,1 0 0 0,1

 w 1   
/ A,R / A,S / A,T / A,U
K 0
K 0
K 0
K

1 1 1 1 1 1 1 1


B,R
0 / B,S
0 / B,T
0 / B,U
K ]g W W W
1
0,1 0 0 0,1

3
c T.A. Henzinger, G. Théoduloz

Das könnte Ihnen auch gefallen