Example #1
0
        internal override STbRule <TERM> Subst1(TERM path, IContextCore <TERM> solver, Dictionary <TERM, TERM> subst)
        {
            TERM condInst              = solver.Simplify(solver.ApplySubstitution(condition, subst));
            TERM path_and_condInst     = And(solver, path, condInst);
            TERM path_and_not_condInst = And(solver, path, solver.MkNot(condInst));

            if (!solver.IsSatisfiable(path_and_condInst))
            {
                return(falseCase.Subst1(path, solver, subst));
            }
            if (!solver.IsSatisfiable(path_and_not_condInst))
            {
                return(trueCase.Subst1(path, solver, subst));
            }
            else
            {
                var t = trueCase.Subst1(path_and_condInst, solver, subst);
                var f = falseCase.Subst1(path_and_not_condInst, solver, subst);
                if ((t is UndefRule <TERM>) && (f is UndefRule <TERM>))
                {
                    return(UndefRule <TERM> .Default);
                }
                return(new IteRule <TERM>(condInst, t, f));
            }
        }
Example #2
0
        internal override STbRule <TERM> Subst1(TERM path, IContextCore <TERM> solver, Dictionary <TERM, TERM> subst)
        {
            TERM defaultcond = solver.True;
            var  cases1      = new KeyValuePair <TERM, STbRule <TERM> > [cases.Length];

            for (int i = 0; i < cases.Length; i++)
            {
                var cond = solver.MkEq(input, cases[i].Key);
                defaultcond = And(solver, defaultcond, solver.MkNot(cond));
                cases1[i]   = new KeyValuePair <TERM, STbRule <TERM> >(cases[i].Key, cases[i].Value.Subst1(And(solver, path, cond), solver, subst));
            }
            var defaultcase1 = defaultcase.Subst1(And(solver, path, defaultcond), solver, subst);
            var rule         = new SwitchRule <TERM>(input, defaultcase1, cases1);

            return(rule);
        }