function M = bool2fsa_pt(B,alf0) % converts a boolean expression for a piecewise testable language % to a DFSA % the following boolean expressions are legal: % 1. (w) with w in \Sigma^*, corresponding to the shuffle ideal of w % 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 % now allowing the new "not" operator B = procshuffnot(B); alf = ['@' alf0]; B = strrep(B,' ',''); if ~setcontains(union(alf,ops),B) error('Unknown characters used in expression'); end % abusing the power of matlab: B = ['(' B ')']; alfstar = setstar(alf0); STRS = text2cell_adv(B,alf,''); OPRS = text2cell_adv(B,ops,''); REG = OPRS{1}; for j=1:length(STRS) str = STRS{j}; R = alfstar; if ~strcmp(str,'@') for s=str R = [R s alfstar]; end end REG = [REG R OPRS{j+1}]; end M = gregexp2dfsa_fast(REG,alf0); return