How to use the intersection construction to form a DFA?

前端 未结 2 820
死守一世寂寞
死守一世寂寞 2020-12-07 16:41

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 d

相关标签:
2条回答
  • 2020-12-07 17:27

    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

    1. E is the input alphabet, a non-empty finite set of symbols
    2. Q is the set of states, non-empty and finite
    3. q0 is the start state, an element of Q
    4. A is the set of accepting or final states, a subset of Q
    5. 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'').

    1. Take E''' = E'' = E'
    2. Take Q''' = Q' x Q''
    3. Take q0''' = (q0', q0'')
    4. 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'').
    5. 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...

    1. E' = {a}
    2. Q' = {s0, s1}
    3. q0' = s0
    4. A' = {s0}
    5. f'(s0, a) = s1, f'(s1, a) = s0

    For M'', we have...

    1. E'' = {a}
    2. Q'' = {t0, t1, t2}
    3. q0'' = t0
    4. A'' = {t0}
    5. f''(t0, a) = t1, f''(t1, a) = t2, f''(t2, a) = t0

    For M''', we get...

    1. E''' = {a}
    2. Q''' = {(s0, t0), (s0, t1), (s0, t2), (s1, t0), (s1, t1), (s1, t2)}
    3. q0''' = (s0, t0)
    4. A''' = {(s0, t0)} for intersection, {(s0, t0), (s0, t1), (s0, t2), (s1, t0)} for union, {(s0, t1), (s0, t2)} for difference.
    5. 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.

    0 讨论(0)
  • 2020-12-07 17:38

    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 ...

    0 讨论(0)
提交回复
热议问题