function M = bool2fsa_dd1(B,alf0) % converts a boolean expression for a dot-depth one language % to a DFSA % the following boolean expressions are legal: % 1. [u0,u1,...,un] with ui in \Sigma^*, corresponding to the % "generalized shuffle ideal" % 2. (a + b) union, where a,b are boolean expressions % 3. (a ^ b) intersection, where a,b are boolean expressions % 4. (a - b) negation, where a,b are boolean expressions % as always, @ stands for the empty word ops = '()+-^[]'; % the operators alf = ['@' ',' alf0]; if ~setcontains(union(alf,ops),B) error('Unknown characters used in expression'); end % abusing the power of matlab: B = ['(' B ')']; alfplus = setplus(alf0); STRS = text2cell_adv(B,alf,''); OPRS = text2cell_adv(B,ops,''); REG = OPRS{1}; for j=1:length(STRS) str = STRS{j}; WRDS = text2cell_adv(str,'',','); if isempty(WRDS) R = alfplus; else R = WRDS{1}; for s=2:length(WRDS) R = [R alfplus WRDS{s}]; end end REG = [REG R OPRS{j+1}]; end REG = strrep(REG,'@',''); REG = strrep(REG,'[',''); REG = strrep(REG,']',''); M = gregexp2dfsa_fast(REG,alf0); return