function NFSA = d2nfsa(DFSA) % convets a DFSA to equivalent NFSA (trivial) % 1. a NFSA is defined by % 2. an alphabet ALF % 3. a set of states Q % 4. a set of the start states Q0 % 5. a set of accepting states F \subste {1,2,3,...,Q} % 6. a function delta : (q,s) \mapsto Q' % where Q' subset Q, s\in ALF_in; q'\in Q global ALF NFSA.ALF = ['@' DFSA.ALF]; % the character @ stands for the epsilon-char NFSA.Q = DFSA.Q; NFSA.q0 = [DFSA.q0]; NFSA.F = DFSA.F; NFSA = init_ndelta(NFSA); for q1=DFSA.Q for s=DFSA.ALF q2 = dfsa_delta(DFSA,q1,s); NFSA = set_ndelta(NFSA,[q1],[s],{[q2]}); end end if 0 DS = deadstates_fsa(NFSA); for q=NFSA.Q for s=NFSA.ALF R = nfsa_delta(NFSA,q,s); R = setdiff(R,DS); NFSA = set_ndelta(NFSA,[q],[s],{R}); end end NFSA.Q = setdiff(NFSA.Q,DS); NFSA = compact_names(NFSA); end return