Beispiel #1
0
        private static int Apply(Op op, int u1, int u2)
        {
            int u;

            if (G.ContainsKey(u1, u2, op))
            {
                return(G[u1, u2, op]);
            }

            if (IsTerminal(u1) && IsTerminal(u2))
            {
                return(Lookup[(int)(byte)op, u1 *2 + u2]);
            }
            else
            {
                switch (Var(u1).CompareTo(Var(u2)))
                {
                case 0:         //equals
                    u = Mk(Var(u1), Apply(op, Low(u1), Low(u2)), Apply(op, High(u1), High(u2)));
                    break;

                case -1:        //less than
                    u = Mk(Var(u1), Apply(op, Low(u1), u2), Apply(op, High(u1), u2));
                    break;

                default:        //greater than
                    u = Mk(Var(u2), Apply(op, u1, Low(u2)), Apply(op, u1, High(u2)));
                    break;
                }
            }

            G.Add(u1, u2, op, u);
            return(u);
        }
Beispiel #2
0
        private static int AppEx(Op op, int u1, int u2, ref BddPairList varList)
        {
            int u;

            if (GAppEx.ContainsKey(u1, u2, op))
            {
                return(GAppEx[u1, u2, op]);
            }

            if (IsTerminal(u1) && IsTerminal(u2))
            {
                return(Lookup[(int)(byte)op, u1 * 2 + u2]);
            }
            else
            {
                switch (Var(u1).CompareTo(Var(u2)))
                {
                case 0:         //equals
                    u = Mk(Var(u1), AppEx(op, Low(u1), Low(u2), ref varList), AppEx(op, High(u1), High(u2), ref varList));
                    break;

                case -1:        //less than
                    u = Mk(Var(u1), AppEx(op, Low(u1), u2, ref varList), AppEx(op, High(u1), u2, ref varList));
                    break;

                default:        //greater than
                    u = Mk(Var(u2), AppEx(op, u1, Low(u2), ref varList), AppEx(op, u1, High(u2), ref varList));
                    break;
                }
            }
            if (varList.QuantificationContainsKey(Var(u)))
            {
                u = Apply(Op.DIS, Low(u), High(u));
            }
            GAppEx.Add(u1, u2, op, u);
            return(u);
        }