I'm looking for an algorithm which produces the smallest DFA which matches any string from a given finite set of concrete strings, and nothing else. (Smallest as in fewest terminal symbols.)
Examples:
a,b->a|ba,ab->a(|b)ab,ac->a(b|c)aa,ab,ba,bb->(a|b)(a|b)x,xa,xb,xc,xac,xbc->x(|ab)(|c)
I tried a naive algorithm which does repeated prefix/suffix extraction, but that cannot handle the last case, and does not produce the minimal result.
I'm sure this is a common problem but I haven't been able to find the proper terminology for it. Apologies for improper terminology and the ad-hoc notation.