![]() |
![]() |
|
TODO: - first example: missing-letter-language (but NO epsilon-transitions) [leave it on board to come back to!] - second example: a?aab* - put up the parallel definitions with color-difference: DFSM,NDFSM [leave δ on board]; config, ⊢, computation, accepts. - then add in epsilon-transitions: go back to missing-letter-language, then def'n - NOTE: unix `fork` is like the parallel evaluation! ---- examples of *building* a NDFSM: handy for pattern-matching: - All strings which contain 'ababb' in them. First, as a DFSM. Now, as a NDFSM. - strings containing "ababb" *or* containing "abaa". - [skip for now; it requires DFSM = NDFSM anyway] Show: regular languages closed under union Let L1, L2 be reg.langs; we show L1 ∪ L2 is regular. - without loss of generality, L1,L2 have same alphabet - because L1,L2 regular, there exist DFMs M1,M2 which accept them. - We construct M' such that L(M') = L(M1 ∪ M2): K' = Σ (already presumed same) s = Δ' = ... (here's the sticky part!) ... A' = - emulating NDFSM: - threads -- each move in parallel on reading an input-char - backtracking - keep track of all possible states you might be in, after each input-char eps: KM → P(KM). We define eps(q), where q is some state in M, to be the set of states of M that are reachable from q by following zero or more -transitions. Formally: eps(q) = {p K : (q, w) |-M* (p, w)}. Alternatively, eps(q) is the closure of {q} under the relation {(p, r) : there is a transition (p, , r) }. The following algorithm computes eps: eps(q: state) = 1. result = {q}. 2. While there exists some p result and some r result and some transition (p, , r) do: Insert r into result. 3. Return result. This algorithm is guaranteed to halt because, each time through the loop, it adds an element to result. It must halt when there are no elements left to add. Since there are only a finite n Book 5.4.4: equivalence of DFSM, NDFSM (!) Two directions. - one trivial - other: Given a NDFSM M=<>, we construct a DFSM M'=<...> where: K' = Σ' = s' = δ' = A' = Proof of correctness of construct: - Lemma: a NDFSM w/ eps can turned into one w/o eps Given a NDFSM M: for every a transition <p,ε,q> ∈ Δ, then for every <eps(q),c,r> ∈ Δ, then add the direct edge <p,c,r>. [ian: rephrase the above a bit?] Proof left to the reader [formalizing it needs to be more precise about eps(q) being transitive-closure of eps-transits-from-q]. (this is also in Appendix B (p. 627 = 643-15), slightly different presentation) Put on board: Reminder: M -- the NONeterministic machine; M' -- the deterministic one we built - 420: review subset-construction example; Note the key element of construction of M': δ(P,c) = union_p∈P {r : Δ(p,c,r)} review subset-constr-equiv proof: - PROOF: Show L(M) = L(M') - L(M) ⊆ L(M') if <p,w> |-* <q,ε> in the NDFSM M, then <P,w> |-* <Q,ε> where P is any state including p, and Q is *some* state involving Q (Note: if q is accepting in M, then Q is accepting in M') induction on |w| straightforward: - base case trivial: p=q,w=ε: - induct step: Let w = cx, where |x|=k. By def'n of w∈L(M), we know there's *some* sequence <p,cx> |- <r,x> |-* <q,ε> (where q accepts in M) [Note: that first step consumes a char becase no more eps-transits by our lemma above]. By construction, <P,cx> |- <R,x> where r∈R. By inductive hyphothesis (since <r,x> |-* <q,ε>) we know that: <R,x> |-* <Q,ε> (since R is "any state including r"). Since q was an accepting state in M, then (by construction) Q accepts in M', so we have <P,w> |- <Q,ε>, meaning w∈L(M'). - L(M') ⊆ L(M) That is: if <P,w> |-* <Q,ε> in M', then for all p in P: <p,w> |-* <q,ε> in the NDFSM M, for some q in Q, ** This step is a bit trickier. Induct on |w|: - base case still easy; - induct step: Let w = cx, where |x|=k. We know: <P,cx> |- <R,x> |-* <Q,ε> where R is: all states M could reach from any p on c: R = union_p∈P {r : Δ(p,c,r)} We want to show that <p,w> |-* <q,ε> in M (for *some* q∈Q) By induct hyp, for every r∈R there's some q such that: <r,x> |-* <q,ε> in M By def'n of δ, we know [ R = union_p∈P {r : (p,c,r)∈Δ}.] <P,cx> |- <R,x> means that for every p in P: <p,cx> |- <r,x> (for some r in R) and for that r <r,x> |-* <q,ε> for some q in Q But then <p,cx> |- <r,x> |-* <q,ε>,which is what we want to show! [Note: book's appendix B "lemma",p.627 makes me unsure: it talks of eps(q) for any q in M, but is eps(q) even a state we constructed in M'? I guess we do define *all* those states; some might be unreachable but that doesn't hurt their proof.]
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |