public override MSOFormula ToMSO(FreshGen fg, string V)
        {
            switch (op)
            {
            case PDLBinarySetOperator.Intersection:
            {
                int c = fg.get();

                string X1 = "_X1_" + c.ToString();
                string X2 = "_X2_" + c.ToString();
                string x  = "_x_" + c.ToString();

                return(new MSOForallFO(x, new MSOIff(new MSOBelong(x, V), new MSOAnd(set1.Contains(fg, x), set2.Contains(fg, x)))));
            }

            case PDLBinarySetOperator.Union:
            {
                int c = fg.get();

                string X1 = "_X1_" + c.ToString();
                string X2 = "_X2_" + c.ToString();
                string x  = "_x_" + c.ToString();

                return(new MSOForallFO(x, new MSOIff(new MSOBelong(x, V), new MSOOr(set1.Contains(fg, x), set2.Contains(fg, x)))));
            }

            default: throw new PDLException("undefined operator");
            }
        }
        public override MSOFormula Contains(FreshGen fg, string v)
        {
            switch (op)
            {
            case PDLComparisonOperator.Ge:
            {
                int    c = fg.get();
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOLess(y, v))));
            }

            case PDLComparisonOperator.Geq:
            {
                int    c = fg.get();
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOLessEq(y, v))));
            }

            case PDLComparisonOperator.Le:
            {
                int    c = fg.get();
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOLess(v, y))));
            }

            case PDLComparisonOperator.Leq:
            {
                int    c = fg.get();
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOLessEq(v, y))));
            }

            default: throw new PDLException("not defined on this operator");
            }
        }
        public override void ToTreeString(FreshGen fg, StringBuilder sb, int index, Dictionary <string, Pair <PDL, string> > nodes)
        {
            nodes.Add(this.GetNodeName() + ":" + index, new Pair <PDL, string>(this, ""));
            int x1 = fg.get();

            nodes.Add(FOvar + ":" + x1, new Pair <PDL, string>(this, "FOvar"));
            sb.Append(string.Format("{0}:{2}-{1}:{3};", this.GetNodeName(), FOvar, index, x1));
            int x2 = fg.get();

            sb.Append(string.Format("{0}:{2}-{1}:{3};", this.GetNodeName(), pred.GetNodeName(), index, x2));
            pred.ToTreeString(fg, sb, x2, nodes);
        }
        public override MSOFormula ToMSO(FreshGen fg, string V)
        {
            int    c = fg.get();
            string x = "_x_" + c.ToString();
            string y = "_y_" + c.ToString();
            string X = "_X_" + c.ToString();


            int        i = str.Length - 1;
            string     z_i, z_im;
            MSOFormula phi = null;

            phi = new MSOLabel("z0", str[0]);

            while (i > 0)
            {
                z_i  = "z" + i.ToString();
                z_im = "z" + (i - 1).ToString();
                phi  = new MSOExistsFO(z_i, new MSOAnd(new MSOSucc(z_im, z_i),
                                                       new MSOAnd(new MSOLabel(z_i, str[i]), phi)));
                i--;
            }

            return(new MSOForallFO("z0", new MSOIff(new MSOBelong("z0", V), phi)));
        }
        public override void ToTreeString(FreshGen fg, StringBuilder sb, int index, Dictionary <string, Pair <PDL, string> > nodes)
        {
            nodes.Add(this.GetNodeName() + ":" + index, new Pair <PDL, string>(this, ""));
            int x = fg.get();

            sb.Append(string.Format("{0}:{2}-{1}:{3};", this.GetNodeName(), pos.GetNodeName(), index, x));
            pos.ToTreeString(fg, sb, x, nodes);
        }
        public override MSOFormula ToMSO(FreshGen fg, string V)
        {
            switch (op)
            {
            case PDLComparisonOperator.Ge:
            {
                int    c = fg.get();
                string x = "_x";
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOForallFO(x,
                                                                                       new MSOIff(new MSOLess(y, x), new MSOBelong(x, V))))));
            }

            case PDLComparisonOperator.Geq:
            {
                int    c = fg.get();
                string x = "_x";
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOForallFO(x,
                                                                                       new MSOIff(new MSOLessEq(y, x), new MSOBelong(x, V))))));
            }

            case PDLComparisonOperator.Le:
            {
                int    c = fg.get();
                string x = "_x";
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOForallFO(x,
                                                                                       new MSOIff(new MSOLess(x, y), new MSOBelong(x, V))))));
            }

            case PDLComparisonOperator.Leq:
            {
                int    c = fg.get();
                string x = "_x";
                string y = "_y_" + c.ToString();
                return(new MSOExistsFO(y, new MSOAnd(pos.ToMSO(fg, y), new MSOForallFO(x,
                                                                                       new MSOIff(new MSOLessEq(x, y), new MSOBelong(x, V))))));
            }

            default: throw new PDLException("not defined on this operator");
            }
        }
        public override MSOFormula ToMSO(FreshGen fg, string v)
        {
            switch (op)
            {
            case PDLPosUnaryConstructor.Pred:
            {
                int    c  = fg.get();
                string x1 = "_x1_" + c.ToString();
                return(new MSOExistsFO(x1, new MSOAnd(pos.ToMSO(fg, x1), new MSOSucc(v, x1))));
            }

            case PDLPosUnaryConstructor.Succ:
            {
                int    c = fg.get();
                string x = "_x_" + c.ToString();
                return(new MSOExistsFO(x, new MSOAnd(pos.ToMSO(fg, x), new MSOSucc(x, v))));
            }

            default: throw new PDLException("undefined operator");
            }
        }