public override Regexp Normalize()
        {
            var v = left as REConcatenation;

            if (v != null)
            {
                return(new REConcatenation(v.left, new REConcatenation(v.right, right)).Normalize());
            }

            var v1 = right as REUnion;

            if (v1 != null)
            {
                return(new REUnion(new REConcatenation(left, v1.left), new REConcatenation(left, v1.right)));
            }

            var v2 = left as REUnion;

            if (v2 != null)
            {
                return(new REUnion(new REConcatenation(v2.left, right), new REConcatenation(v2.right, right)));
            }

            return(new REConcatenation(left.Normalize(), right.Normalize()));
        }
        private static Automaton <BDD> getDfa(Regexp regexp)
        {
            var re = regexp.Normalize();

            if (!memoDfa.Keys.Contains(re.ToString()))
            {
                memoDfa[re.ToString()] = re.getDFA(alph, solver);
            }

            return(memoDfa[re.ToString()]);
        }
        public override Regexp Normalize()
        {
            var r1 = r.Normalize();

            Regexp dj = null;

            foreach (var d in r1.GetDisjuncts())
            {
                Regexp sol = null;
                if (!(d is REStar) && !(d is REPlus) && !(d is REQMark))
                {
                    sol = d;
                }
                else
                {
                    if (d is REStar)
                    {
                        var v = d as REStar;
                        sol = v.r;
                    }
                    else
                    {
                        if (d is REPlus)
                        {
                            var v = d as REPlus;
                            sol = v.r;
                        }
                        else
                        {
                            var v = d as REQMark;
                            sol = v.r;
                        }
                    }
                }
                if (dj == null)
                {
                    dj = sol;
                }
                else
                {
                    dj = new REUnion(sol, dj);
                }
            }
            if (dj.GetDisjuncts().Count != r.GetDisjuncts().Count)
            {
                return(new REStar(dj).Normalize());
            }

            return(new REStar(dj));
        }