コード例 #1
0
        public static object Reify_Object(DyLogicObject logicObj, Dictionary <object, object> s)
        {
            var obj = Reify(logicObj.Properties, s) as Dictionary <object, object>;

            if (LogicSharp.equal_test(obj, logicObj.Properties))
            {
                return(logicObj);
            }
            else
            {
                //Initialize a new dynamic object
                var newObj = new DyLogicObject();
                if (obj != null)
                {
                    foreach (var pair in obj)
                    {
                        newObj.Properties.Add(pair.Key, pair.Value);
                    }
                }
                return(newObj);
            }
        }
コード例 #2
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));
        }