/// If arg is another Functor3, then succeed (yield once) if this and arg have the /// same name and all functor args unify, otherwise fail (don't yield). /// If arg is a Variable, then call its unify to unify with this. /// Otherwise fail (don't yield). public IEnumerable <bool> unify(object arg) { arg = YP.getValue(arg); if (arg is Functor3) { Functor3 argFunctor = (Functor3)arg; if (_name.Equals(argFunctor._name)) { foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) { foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) { foreach (bool l3 in YP.unify(_arg3, argFunctor._arg3)) { yield return(false); } } } } } else if (arg is Variable) { foreach (bool l1 in ((Variable)arg).unify(this)) { yield return(false); } } }
public bool termEqual(object term) { term = YP.getValue(term); if (term is Functor3) { Functor3 termFunctor = (Functor3)term; return(_name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1) && YP.termEqual(_arg2, termFunctor._arg2) && YP.termEqual(_arg3, termFunctor._arg3)); } return(false); }
public bool lessThan(Functor3 functor) { // Do the equal check first since it is faster. if (!_name.Equals(functor._name)) { return(_name.lessThan(functor._name)); } if (!YP.termEqual(_arg1, functor._arg1)) { return(YP.termLessThan(_arg1, functor._arg1)); } if (!YP.termEqual(_arg2, functor._arg2)) { return(YP.termLessThan(_arg2, functor._arg2)); } return(YP.termLessThan(_arg3, functor._arg3)); }
public bool lessThan(Functor3 functor) { // Do the equal check first since it is faster. if (!_name.Equals(functor._name)) return _name.lessThan(functor._name); if (!YP.termEqual(_arg1, functor._arg1)) return YP.termLessThan(_arg1, functor._arg1); if (!YP.termEqual(_arg2, functor._arg2)) return YP.termLessThan(_arg2, functor._arg2); return YP.termLessThan(_arg3, functor._arg3); }