Esempio n. 1
0
        public static bool Unify(object u, object v, Dictionary <object, object> s)
        {
            if (s == null)
            {
                s = new Dictionary <object, object>();
            }

            object tempU = LogicSharp.transitive_get(u, s);
            object tempV = LogicSharp.transitive_get(v, s);

            if (LogicSharp.equal_test(tempU, tempV))
            {
                return(true);
            }

            if (Var.IsVar(tempU) && Var.IsVar(tempV))
            {
                return(tempU.Equals(tempV));
            }

            if (Var.IsVar(tempU))
            {
                LogicSharp.Assoc(s, tempU, tempV);
                return(true);
            }

            if (Var.IsVar(tempV))
            {
                LogicSharp.Assoc(s, tempV, tempU);
                return(true);
            }

            dynamic a = tempU;
            dynamic b = tempV;

            return(UnifyImpl(a, b, s));
        }