/*        public EqualityFormula substituteEq(Substitution s)
 *      {
 *          return new EqualityFormula(t1.substitute(s), t2.substitute(s));
 *      }*/
        public EqualityFormula substituteEq(Substitution s)
        {
            var newArgs = new List <ITerm>();

            if (TermTuple.substitute(s, args, newArgs))
            {
                return(new EqualityFormula(newArgs[0], newArgs[1]));
            }
            else
            {
                return(this);
            }
//            foreach (var a in args)
//                newArgs.Add(a.substitute(s));
        }
示例#2
0
        public PredicateApplication substitutePA(Substitution s)
        {
            var newArgs = new List <ITerm>();

            if (TermTuple.substitute(s, args, newArgs))
            {
                return(new PredicateApplication(predicate, newArgs));
            }
            else
            {
                return(this);
            }
//            foreach (var a in args)
//                newArgs.Add(a.substitute(s));
        }
示例#3
0
        public ITerm substitute(Substitution s)
        {
            if (!freeVariables.Intersect(s.domain).Any())
            {
                return(this);
            }
            var nts = new List <ITerm>();

            if (TermTuple.substitute(s, args, nts))
            {
                return(new FunctionApplicationFormula(function, nts));
            }
            else
            {
                return(this);
            }
        }
        protected OperatorApplication(IOperator op, IEnumerable <ITerm> arguments)
        {
            this.op       = op;
            args          = new TermTuple(arguments);
            subTerms      = args;
            freeVariables = new HashSet <LVar>(from a in args from fv in a.freeVariables select fv);

            orderedFreeVariables = new List <LVar>();
            foreach (var a in args)
            {
                foreach (var fv in a.orderedFreeVariables)
                {
                    if (!orderedFreeVariables.Contains(fv))
                    {
                        orderedFreeVariables.Add(fv);
                    }
                }
            }
            functions = new HashSet <Function>(from a in args from f in a.functions select f);
            varMap    = new Dictionary <LVar, string>();
            foreach (var fv in orderedFreeVariables)
            {
                varMap[fv] = "v_" + varMap.Count.ToString();
            }

            stringCache  = op.ToString(args);
            stringCacheN = op.ToStringN(args, new Dictionary <LVar, string>());//, varMap);
            stringCacheB = op.ToString(args, varMap);

            height = 0;
//            weight = 0;
            foreach (var a in args)
            {
                if (height < a.height)
                {
                    height = a.height;
                }
//                weight += a.weight;
            }
            height++;
//            weight++;
        }