I'm doing a homework assignment for my theory of computation class and am a bit confused how to combine 2 DFAs. The book says it uses the "intersection construction" to do so, but I'm not sure what that is. Here are 2 examples:
2 Answers
The idea is pretty straightforward, although I can see where the confusion comes in. I will give a text/symbolic description of the process for making the intersection (union, difference) machines via the Cartesian Product Machine construction (same thing as you are talking about).
A DFA is a 5-tuple (E, Q, q0, A, f) where
- E is the input alphabet, a non-empty finite set of symbols
- Q is the set of states, non-empty and finite
- q0 is the start state, an element of Q
- A is the set of accepting or final states, a subset of Q
- f is the transition function, taking pairs from Q x E to Q
Say we have two machines M' = (E', Q', q0', A', f') and M'' = (E'', Q'', q0'', A'', f''). To make the discussion easier, we assume E' = E''. We will now construct M''' so that L(M''') = L(M') intersect (or union or difference) L(M'').
- Take E''' = E'' = E'
- Take Q''' = Q' x Q''
- Take q0''' = (q0', q0'')
- Take A''' = (x, y) where x in A' and y in A'' (for union, x in A' or y in A''; for difference, x in A' but not y in A'').
- Take f'''((x, y), e) = (f'(x, e), f''(y, e)).
There you go! Let's now consider two machines: one which accepts a^2n, and one which accepts a^3n (the intersection should be a machine accepting a^6n... right?).
For M', we have...
- E' = {a}
- Q' = {s0, s1}
- q0' = s0
- A' = {s0}
- f'(s0, a) = s1, f'(s1, a) = s0
For M'', we have...
- E'' = {a}
- Q'' = {t0, t1, t2}
- q0'' = t0
- A'' = {t0}
- f''(t0, a) = t1, f''(t1, a) = t2, f''(t2, a) = t0
For M''', we get...
- E''' = {a}
- Q''' = {(s0, t0), (s0, t1), (s0, t2), (s1, t0), (s1, t1), (s1, t2)}
- q0''' = (s0, t0)
- A''' = {(s0, t0)} for intersection, {(s0, t0), (s0, t1), (s0, t2), (s1, t0)} for union, {(s0, t1), (s0, t2)} for difference.
- f'''((s0, t0), a) = (s1, t1), f'''((s1, t1), a) = (s0, t2), f'''((s0, t2), a) = (s1, t0), f'''((s1, t0), a) = (s0, t1), f'''((s0, t1), a) = (s1, t2), f'''((s1, t2), a) = (s0, t0).
And there you go! Please let me know if this needs clarification.

- 27,682
- 3
- 38
- 73
-
@JanusTroelsen Yes, that was the intent. – Patrick87 May 31 '13 at 15:25
-
What makes t_0 and s_0 in both DFA's for the purposes of intersection? They both go to a s_1,t_1? – RaenirSalazar Feb 17 '16 at 03:40
-
1Side note: I believe that the DFA for example b is incorrect. The requirements ask for exactly 3 a's for one of the two sub-strings and the corresponding DFA accounts for exactly 2 a's. Just be careful as this affects the answers for both the corresponding DFA as well as the combined DFA. – Leila H Jan 10 '17 at 02:44
These are:
{s∈{a,b,c}∗:every a in s is immediately followed by a b}
{s∈{a,b,c}∗:every a in s is immediately followed by a b}
and
{s∈{a,b,c}∗: every c in s is immediately preceded by a b}
In front and another automaton, you can join states "0" and "2".
and you need to retain that ...
There is a precise way for performing automatons for the crossing of languages. Let AA and BB be the input automatons. The cases of new automaton will be all pairs of states of AA and BB, that is SA∩B=SA×SBSA∩B=SA×SB, the initial state will be iA∩B=⟨iA,iB⟩iA∩B=⟨iA,iB⟩, where iAiA and iBiB are the initial states of AA and BB, and FA∩B=FA×FBFA∩B=FA×FB where FXFX denotes the set of accepting states of XX. Finally, the transition function δA∩BδA∩B is defined as follows for any letter α∈Σα∈Σ and states p1,p2∈SAp1,p2∈SA, q1,q2∈SBq1,q2∈SB:
⟨p1,q1⟩−→−−A∩B α ⟨p2,q2⟩ iff p1−→A α p2andq1−→B α q2 ⟨p1,q1⟩→A∩B α ⟨p2,q2⟩ iff p1→A α p2andq1→B α q2 Please note, that such automaton usually is not minimal (e.g. the intersection might be just an empty language). Also, it might be useful (but it is not necessary) to make input automatons minimal since the output is quadratic in size. // Reference: math.stackexchange.com Happy Coding ...

- 1,245
- 17
- 27